korext 0.9.11 → 0.9.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/korext.js +20 -4
- package/package.json +1 -1
package/bin/korext.js
CHANGED
|
@@ -296,13 +296,22 @@ async function fetchAndCacheRules() {
|
|
|
296
296
|
* Mirrors korext-core/src/engine/localEngine.ts analyzeLocally().
|
|
297
297
|
*/
|
|
298
298
|
function analyzeLocally(code, packId, definitions) {
|
|
299
|
-
|
|
300
|
-
|
|
299
|
+
// Normalize packId to array to support multi-pack (e.g. ["web", "pci-dss-v1"])
|
|
300
|
+
const packIdList = Array.isArray(packId) ? packId : [packId];
|
|
301
|
+
// Merge rules from all requested packs via Set
|
|
302
|
+
const mergedRuleIds = new Set();
|
|
303
|
+
for (const pid of packIdList) {
|
|
304
|
+
const pack = definitions.packs[pid];
|
|
305
|
+
if (pack && pack.rules) {
|
|
306
|
+
for (const rid of pack.rules) mergedRuleIds.add(rid);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
if (mergedRuleIds.size === 0) return [];
|
|
301
310
|
|
|
302
311
|
const violations = [];
|
|
303
312
|
const lines = code.split('\n');
|
|
304
313
|
|
|
305
|
-
for (const ruleId of
|
|
314
|
+
for (const ruleId of mergedRuleIds) {
|
|
306
315
|
const rule = definitions.rules[ruleId];
|
|
307
316
|
if (!rule) continue;
|
|
308
317
|
if (rule.checkMode === 'server-only') continue;
|
|
@@ -1030,7 +1039,14 @@ program
|
|
|
1030
1039
|
console.log(chalk.yellow('\n⚡ Offline mode: using local rule engine (regex-based analysis)'));
|
|
1031
1040
|
console.log(chalk.dim(` Cached rules: v${localDefinitions.version} · ${localDefinitions.ruleCount} rules · ${localDefinitions.packCount} packs`));
|
|
1032
1041
|
// Show rule coverage breakdown
|
|
1033
|
-
|
|
1042
|
+
// Merge rules from all packs for coverage display
|
|
1043
|
+
const coveragePackList = Array.isArray(pack) ? pack : [pack];
|
|
1044
|
+
const allPackRuleIds = new Set();
|
|
1045
|
+
for (const pid of coveragePackList) {
|
|
1046
|
+
const pr = localDefinitions.packs?.[pid]?.rules || [];
|
|
1047
|
+
for (const rid of pr) allPackRuleIds.add(rid);
|
|
1048
|
+
}
|
|
1049
|
+
const packRules = [...allPackRuleIds];
|
|
1034
1050
|
const availableCount = packRules.filter(r => localDefinitions.rules?.[r]).length;
|
|
1035
1051
|
const serverOnlyCount = packRules.length - availableCount;
|
|
1036
1052
|
console.log(chalk.dim(` Offline mode: ${availableCount} of ${packRules.length} rules available. ${serverOnlyCount} rules require server analysis.`));
|