ktg-plugin-marketplace/plugins/llm-security-copilot/scanners/supply-chain-recheck-cli.mjs
Kjell Tore Guttormsen f418a8fe08 feat(llm-security-copilot): port llm-security v5.1.0 to GitHub Copilot CLI
Full port of llm-security plugin for internal use on Windows with GitHub
Copilot CLI. Protocol translation layer (copilot-hook-runner.mjs)
normalizes Copilot camelCase I/O to Claude Code snake_case format — all
original hook scripts run unmodified.

- 8 hooks with protocol translation (stdin/stdout/exit code)
- 18 SKILL.md skills (Agent Skills Open Standard)
- 6 .agent.md agent definitions
- 20 scanners + 14 scanner lib modules (unchanged)
- 14 knowledge files (unchanged)
- 39 test files including copilot-port-verify.mjs (17 tests)
- Windows-ready: node:path, os.tmpdir(), process.execPath, no bash

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-09 21:56:10 +02:00

37 lines
1.1 KiB
JavaScript

#!/usr/bin/env node
// CLI wrapper for supply-chain-recheck scanner
// Usage: node supply-chain-recheck-cli.mjs <target-path>
// Outputs JSON to stdout. Exit codes: 0=ok, 1=warning, 2=block, 3=error
import { resolve } from 'node:path';
import { existsSync } from 'node:fs';
import { resetCounter } from './lib/output.mjs';
import { scan } from './supply-chain-recheck.mjs';
import { riskScore, verdict } from './lib/severity.mjs';
const target = process.argv[2];
if (!target) {
console.error('Usage: node supply-chain-recheck-cli.mjs <target-path>');
process.exit(3);
}
const targetPath = resolve(target);
if (!existsSync(targetPath)) {
console.error(`Target path does not exist: ${targetPath}`);
process.exit(3);
}
resetCounter();
const result = await scan(targetPath, { files: [] });
// Add aggregate info matching orchestrator format
const counts = result.counts;
const score = riskScore(counts);
const verd = verdict(counts);
result.aggregate = { risk_score: score, verdict: verd };
process.stdout.write(JSON.stringify(result, null, 2) + '\n');
if (verd === 'BLOCK') process.exit(2);
if (verd === 'WARNING') process.exit(1);
process.exit(0);