korext 0.9.5 → 0.9.6
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 +13 -5
- package/package.json +1 -1
package/bin/korext.js
CHANGED
|
@@ -254,13 +254,16 @@ program
|
|
|
254
254
|
program
|
|
255
255
|
.command('enforce [dir]')
|
|
256
256
|
.description('Statically analyze files in a directory against Korext policies')
|
|
257
|
-
.option('-p, --pack <
|
|
257
|
+
.option('-p, --pack <packIds>', 'Policy Pack ID(s) to enforce (comma-separated, e.g. web,pci-dss-v1)', 'web')
|
|
258
258
|
.option('-f, --format <format>', 'Output format (text, json, sarif)', 'text')
|
|
259
259
|
.option('--offline', 'Force local-only analysis using cached rule definitions (no server calls)', false)
|
|
260
260
|
.option('--sync-rules', 'Fetch and cache latest rule definitions before running analysis', false)
|
|
261
261
|
.action(async (dirArg, options) => {
|
|
262
262
|
const dir = dirArg || '.';
|
|
263
|
-
const
|
|
263
|
+
const packInput = options.pack;
|
|
264
|
+
// Multi-pack: split on comma, trim whitespace
|
|
265
|
+
const packIds = packInput.split(',').map(p => p.trim()).filter(Boolean);
|
|
266
|
+
const pack = packIds.length === 1 ? packIds[0] : packIds;
|
|
264
267
|
const format = options.format.toLowerCase();
|
|
265
268
|
const isText = format === 'text';
|
|
266
269
|
|
|
@@ -321,7 +324,8 @@ program
|
|
|
321
324
|
|
|
322
325
|
const report = {
|
|
323
326
|
version,
|
|
324
|
-
packId: pack,
|
|
327
|
+
packId: Array.isArray(pack) ? pack[0] : pack,
|
|
328
|
+
packIds,
|
|
325
329
|
directory: dir,
|
|
326
330
|
summary: { totalFiles: 0, scannedFiles: 0, skippedFiles: 0, errorFiles: 0, critical: 0, high: 0, medium: 0, low: 0, totalViolations: 0 },
|
|
327
331
|
results: []
|
|
@@ -343,7 +347,7 @@ program
|
|
|
343
347
|
process.exit(0);
|
|
344
348
|
}
|
|
345
349
|
|
|
346
|
-
if (isText) console.log(`Found ${files.length} files. Starting analysis with pack: ${chalk.cyan(
|
|
350
|
+
if (isText) console.log(`Found ${files.length} files. Starting analysis with pack${packIds.length > 1 ? 's' : ''}: ${chalk.cyan(packIds.join(', '))}...\n`);
|
|
347
351
|
|
|
348
352
|
let usedLocalEngine = false;
|
|
349
353
|
|
|
@@ -377,6 +381,8 @@ program
|
|
|
377
381
|
} else {
|
|
378
382
|
// Online mode: try server, fall back to local on failure
|
|
379
383
|
try {
|
|
384
|
+
const controller = new AbortController();
|
|
385
|
+
const timeoutId = setTimeout(() => controller.abort(), 10000);
|
|
380
386
|
const res = await fetch(`${API_URL}/api/ide/analyze`, {
|
|
381
387
|
method: 'POST',
|
|
382
388
|
headers: {
|
|
@@ -390,8 +396,10 @@ program
|
|
|
390
396
|
packId: pack,
|
|
391
397
|
requestSignature: false,
|
|
392
398
|
asyncExplanations: false
|
|
393
|
-
})
|
|
399
|
+
}),
|
|
400
|
+
signal: controller.signal
|
|
394
401
|
});
|
|
402
|
+
clearTimeout(timeoutId);
|
|
395
403
|
|
|
396
404
|
if (!res.ok) {
|
|
397
405
|
throw new Error(`HTTP ${res.status}`);
|