ktg-plugin-marketplace/plugins/llm-security-copilot/tests/hooks/probe-secrets.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

30 lines
1,007 B
JavaScript

// Temporary probe — delete after debugging
import { execFile } from 'node:child_process';
const SCRIPT = '/Users/ktg/.claude/plugins/marketplaces/plugin-marketplace/plugins/llm-security/hooks/scripts/pre-edit-secrets.mjs';
// Fake AWS key
const awsKeyId = 'AKIA' + 'IOSFODNN7EXAMPLE';
async function test(filePath) {
return new Promise(resolve => {
const child = execFile('node', [SCRIPT], {timeout:5000}, (err, stdout, stderr) => {
resolve({ code: child.exitCode, filePath, stderr: stderr.split('\n')[0] });
});
const payload = { tool_name: 'Write', tool_input: { file_path: filePath, content: `key = "${awsKeyId}"` } };
child.stdin.end(JSON.stringify(payload));
});
}
const paths = [
'knowledge/aws-docs.md',
'/project/knowledge/aws-docs.md',
'tests/config.test.mjs',
'tests/config.test.js',
'config.example',
'src/config.example.js',
];
for (const p of paths) {
const r = await test(p);
console.log('exit=' + r.code, JSON.stringify(p), r.stderr || '');
}