hackmyagent 0.11.13 → 0.11.15
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/README.md +26 -3
- package/dist/attack-engine/feedback-loop.d.ts +36 -0
- package/dist/attack-engine/feedback-loop.d.ts.map +1 -0
- package/dist/attack-engine/feedback-loop.js +261 -0
- package/dist/attack-engine/feedback-loop.js.map +1 -0
- package/dist/attack-engine/index.d.ts +13 -0
- package/dist/attack-engine/index.d.ts.map +1 -0
- package/dist/attack-engine/index.js +21 -0
- package/dist/attack-engine/index.js.map +1 -0
- package/dist/attack-engine/payload-generator.d.ts +21 -0
- package/dist/attack-engine/payload-generator.d.ts.map +1 -0
- package/dist/attack-engine/payload-generator.js +210 -0
- package/dist/attack-engine/payload-generator.js.map +1 -0
- package/dist/attack-engine/target-reader.d.ts +15 -0
- package/dist/attack-engine/target-reader.d.ts.map +1 -0
- package/dist/attack-engine/target-reader.js +152 -0
- package/dist/attack-engine/target-reader.js.map +1 -0
- package/dist/attack-engine/training-pipeline.d.ts +57 -0
- package/dist/attack-engine/training-pipeline.d.ts.map +1 -0
- package/dist/attack-engine/training-pipeline.js +146 -0
- package/dist/attack-engine/training-pipeline.js.map +1 -0
- package/dist/attack-engine/types.d.ts +133 -0
- package/dist/attack-engine/types.d.ts.map +1 -0
- package/dist/attack-engine/types.js +22 -0
- package/dist/attack-engine/types.js.map +1 -0
- package/dist/cli.js +248 -15
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/dist/nanomind-core/analyzers/capability-analyzer.d.ts +40 -0
- package/dist/nanomind-core/analyzers/capability-analyzer.d.ts.map +1 -0
- package/dist/nanomind-core/analyzers/capability-analyzer.js +310 -0
- package/dist/nanomind-core/analyzers/capability-analyzer.js.map +1 -0
- package/dist/nanomind-core/analyzers/code-analyzer.d.ts +21 -0
- package/dist/nanomind-core/analyzers/code-analyzer.d.ts.map +1 -0
- package/dist/nanomind-core/analyzers/code-analyzer.js +350 -0
- package/dist/nanomind-core/analyzers/code-analyzer.js.map +1 -0
- package/dist/nanomind-core/analyzers/credential-analyzer.d.ts +20 -0
- package/dist/nanomind-core/analyzers/credential-analyzer.d.ts.map +1 -0
- package/dist/nanomind-core/analyzers/credential-analyzer.js +317 -0
- package/dist/nanomind-core/analyzers/credential-analyzer.js.map +1 -0
- package/dist/nanomind-core/analyzers/governance-analyzer.d.ts +22 -0
- package/dist/nanomind-core/analyzers/governance-analyzer.d.ts.map +1 -0
- package/dist/nanomind-core/analyzers/governance-analyzer.js +393 -0
- package/dist/nanomind-core/analyzers/governance-analyzer.js.map +1 -0
- package/dist/nanomind-core/analyzers/prompt-analyzer.d.ts +22 -0
- package/dist/nanomind-core/analyzers/prompt-analyzer.d.ts.map +1 -0
- package/dist/nanomind-core/analyzers/prompt-analyzer.js +486 -0
- package/dist/nanomind-core/analyzers/prompt-analyzer.js.map +1 -0
- package/dist/nanomind-core/analyzers/scope-analyzer.d.ts +20 -0
- package/dist/nanomind-core/analyzers/scope-analyzer.d.ts.map +1 -0
- package/dist/nanomind-core/analyzers/scope-analyzer.js +326 -0
- package/dist/nanomind-core/analyzers/scope-analyzer.js.map +1 -0
- package/dist/nanomind-core/compiler/semantic-compiler.d.ts +41 -0
- package/dist/nanomind-core/compiler/semantic-compiler.d.ts.map +1 -0
- package/dist/nanomind-core/compiler/semantic-compiler.js +490 -0
- package/dist/nanomind-core/compiler/semantic-compiler.js.map +1 -0
- package/dist/nanomind-core/index.d.ts +30 -0
- package/dist/nanomind-core/index.d.ts.map +1 -0
- package/dist/nanomind-core/index.js +45 -0
- package/dist/nanomind-core/index.js.map +1 -0
- package/dist/nanomind-core/ingestion/artifact-parser.d.ts +48 -0
- package/dist/nanomind-core/ingestion/artifact-parser.d.ts.map +1 -0
- package/dist/nanomind-core/ingestion/artifact-parser.js +203 -0
- package/dist/nanomind-core/ingestion/artifact-parser.js.map +1 -0
- package/dist/nanomind-core/ingestion/input-sanitizer.d.ts +49 -0
- package/dist/nanomind-core/ingestion/input-sanitizer.d.ts.map +1 -0
- package/dist/nanomind-core/ingestion/input-sanitizer.js +80 -0
- package/dist/nanomind-core/ingestion/input-sanitizer.js.map +1 -0
- package/dist/nanomind-core/scanner-bridge.d.ts +49 -0
- package/dist/nanomind-core/scanner-bridge.d.ts.map +1 -0
- package/dist/nanomind-core/scanner-bridge.js +317 -0
- package/dist/nanomind-core/scanner-bridge.js.map +1 -0
- package/dist/nanomind-core/security/defense-in-depth.d.ts +99 -0
- package/dist/nanomind-core/security/defense-in-depth.d.ts.map +1 -0
- package/dist/nanomind-core/security/defense-in-depth.js +206 -0
- package/dist/nanomind-core/security/defense-in-depth.js.map +1 -0
- package/dist/nanomind-core/security/integrity-verifier.d.ts +132 -0
- package/dist/nanomind-core/security/integrity-verifier.d.ts.map +1 -0
- package/dist/nanomind-core/security/integrity-verifier.js +437 -0
- package/dist/nanomind-core/security/integrity-verifier.js.map +1 -0
- package/dist/nanomind-core/types.d.ts +125 -0
- package/dist/nanomind-core/types.d.ts.map +1 -0
- package/dist/nanomind-core/types.js +22 -0
- package/dist/nanomind-core/types.js.map +1 -0
- package/dist/output/asff.d.ts.map +1 -1
- package/dist/output/asff.js +2 -1
- package/dist/output/asff.js.map +1 -1
- package/dist/semantic/index.d.ts +4 -0
- package/dist/semantic/index.d.ts.map +1 -1
- package/dist/semantic/index.js +13 -1
- package/dist/semantic/index.js.map +1 -1
- package/dist/semantic/nanomind-analyzer.d.ts +77 -0
- package/dist/semantic/nanomind-analyzer.d.ts.map +1 -0
- package/dist/semantic/nanomind-analyzer.js +165 -0
- package/dist/semantic/nanomind-analyzer.js.map +1 -0
- package/dist/semantic/nanomind-enhancer.d.ts +50 -0
- package/dist/semantic/nanomind-enhancer.d.ts.map +1 -0
- package/dist/semantic/nanomind-enhancer.js +203 -0
- package/dist/semantic/nanomind-enhancer.js.map +1 -0
- package/dist/simulation/engine.d.ts +69 -0
- package/dist/simulation/engine.d.ts.map +1 -0
- package/dist/simulation/engine.js +297 -0
- package/dist/simulation/engine.js.map +1 -0
- package/dist/simulation/index.d.ts +15 -0
- package/dist/simulation/index.d.ts.map +1 -0
- package/dist/simulation/index.js +31 -0
- package/dist/simulation/index.js.map +1 -0
- package/dist/simulation/llm-executor.d.ts +58 -0
- package/dist/simulation/llm-executor.d.ts.map +1 -0
- package/dist/simulation/llm-executor.js +297 -0
- package/dist/simulation/llm-executor.js.map +1 -0
- package/dist/simulation/mock-tools.d.ts +35 -0
- package/dist/simulation/mock-tools.d.ts.map +1 -0
- package/dist/simulation/mock-tools.js +181 -0
- package/dist/simulation/mock-tools.js.map +1 -0
- package/dist/simulation/probes.d.ts +17 -0
- package/dist/simulation/probes.d.ts.map +1 -0
- package/dist/simulation/probes.js +295 -0
- package/dist/simulation/probes.js.map +1 -0
- package/dist/simulation/types.d.ts +79 -0
- package/dist/simulation/types.d.ts.map +1 -0
- package/dist/simulation/types.js +25 -0
- package/dist/simulation/types.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HMA Adaptive Attack Engine Types
|
|
3
|
+
*
|
|
4
|
+
* NanoMind-powered red team agent that generates target-specific
|
|
5
|
+
* attack payloads, observes responses, adapts, and iterates.
|
|
6
|
+
*/
|
|
7
|
+
export interface SemanticTargetProfile {
|
|
8
|
+
/** Artifact type being targeted */
|
|
9
|
+
artifactType: 'skill' | 'soul' | 'mcp_tool' | 'mcp_server' | 'system_prompt' | 'a2a_card';
|
|
10
|
+
/** What the target claims to do */
|
|
11
|
+
declaredPurpose: string;
|
|
12
|
+
/** Tools and resources the target can access */
|
|
13
|
+
capabilities: string[];
|
|
14
|
+
/** How the target phrases its limitations */
|
|
15
|
+
constraints: string[];
|
|
16
|
+
/** How governance is enforced */
|
|
17
|
+
governanceMechanism: string;
|
|
18
|
+
/** Data types the target regularly touches */
|
|
19
|
+
dataAccessPatterns: string[];
|
|
20
|
+
/** Specific vulnerability surface identified by NanoMind */
|
|
21
|
+
vulnerabilitySurface: VulnerabilitySurfaceEntry[];
|
|
22
|
+
}
|
|
23
|
+
export interface VulnerabilitySurfaceEntry {
|
|
24
|
+
/** Which aspect of the target is vulnerable */
|
|
25
|
+
surface: string;
|
|
26
|
+
/** How the vulnerability could be exploited */
|
|
27
|
+
exploitApproach: string;
|
|
28
|
+
/** Which attack category this maps to */
|
|
29
|
+
attackCategory: AttackCategory;
|
|
30
|
+
/** Estimated likelihood of success (0-1) */
|
|
31
|
+
estimatedSuccess: number;
|
|
32
|
+
}
|
|
33
|
+
export type AttackCategory = 'prompt_injection' | 'data_exfiltration' | 'privilege_escalation' | 'social_engineering' | 'instruction_override' | 'memory_poisoning' | 'soul_bypass' | 'indirect_injection' | 'capability_abuse' | 'persistence' | 'semantic_mismatch';
|
|
34
|
+
export interface AdaptivePayload {
|
|
35
|
+
id: string;
|
|
36
|
+
category: AttackCategory;
|
|
37
|
+
/** The actual attack input to inject */
|
|
38
|
+
input: string;
|
|
39
|
+
/** Why this payload was generated for this specific target */
|
|
40
|
+
rationale: string;
|
|
41
|
+
/** Which vulnerability surface entry this targets */
|
|
42
|
+
targetsSurface: string;
|
|
43
|
+
/** Iteration number (1 = first attempt) */
|
|
44
|
+
iteration: number;
|
|
45
|
+
/** If iteration > 1, what defense was detected and how this variant adapts */
|
|
46
|
+
adaptsTo?: string;
|
|
47
|
+
}
|
|
48
|
+
export type AttackOutcome = 'SUCCESS' | 'PARTIAL' | 'FAIL';
|
|
49
|
+
export interface AttackResult {
|
|
50
|
+
payloadId: string;
|
|
51
|
+
category: AttackCategory;
|
|
52
|
+
outcome: AttackOutcome;
|
|
53
|
+
/** What the target actually did in response */
|
|
54
|
+
observedBehavior: string;
|
|
55
|
+
/** Defense mechanism detected (if FAIL) */
|
|
56
|
+
defenseMechanism?: string;
|
|
57
|
+
/** How strong the defense is (0-1) */
|
|
58
|
+
defenseStrength?: number;
|
|
59
|
+
/** Tool calls observed during the attack */
|
|
60
|
+
toolCalls: Array<{
|
|
61
|
+
tool: string;
|
|
62
|
+
args: Record<string, unknown>;
|
|
63
|
+
}>;
|
|
64
|
+
/** Confidence in the outcome classification */
|
|
65
|
+
confidence: number;
|
|
66
|
+
}
|
|
67
|
+
export interface DefenseMap {
|
|
68
|
+
/** All defenses discovered during the attack session */
|
|
69
|
+
defenses: DefenseEntry[];
|
|
70
|
+
/** Overall resilience score (0-1, 1 = all attacks blocked) */
|
|
71
|
+
resilienceScore: number;
|
|
72
|
+
/** Categories where defenses held */
|
|
73
|
+
strongCategories: AttackCategory[];
|
|
74
|
+
/** Categories where defenses failed */
|
|
75
|
+
weakCategories: AttackCategory[];
|
|
76
|
+
}
|
|
77
|
+
export interface DefenseEntry {
|
|
78
|
+
mechanism: string;
|
|
79
|
+
category: AttackCategory;
|
|
80
|
+
strength: number;
|
|
81
|
+
bypassAttempts: number;
|
|
82
|
+
bypassSuccesses: number;
|
|
83
|
+
/** What the target did to enforce this defense */
|
|
84
|
+
enforcement: string;
|
|
85
|
+
}
|
|
86
|
+
export interface AttackSessionResult {
|
|
87
|
+
/** Target profile that was attacked */
|
|
88
|
+
target: SemanticTargetProfile;
|
|
89
|
+
/** All attack results across all iterations */
|
|
90
|
+
results: AttackResult[];
|
|
91
|
+
/** Total payloads generated */
|
|
92
|
+
totalPayloads: number;
|
|
93
|
+
/** Total successful attacks */
|
|
94
|
+
successCount: number;
|
|
95
|
+
/** Total partial successes */
|
|
96
|
+
partialCount: number;
|
|
97
|
+
/** Defense map discovered */
|
|
98
|
+
defenseMap: DefenseMap;
|
|
99
|
+
/** Duration of the full attack session */
|
|
100
|
+
durationMs: number;
|
|
101
|
+
/** Vulnerabilities found with specific remediation */
|
|
102
|
+
vulnerabilities: VulnerabilityFinding[];
|
|
103
|
+
}
|
|
104
|
+
export interface VulnerabilityFinding {
|
|
105
|
+
category: AttackCategory;
|
|
106
|
+
severity: 'critical' | 'high' | 'medium' | 'low';
|
|
107
|
+
title: string;
|
|
108
|
+
description: string;
|
|
109
|
+
/** The exact attack input that triggered it */
|
|
110
|
+
triggerInput: string;
|
|
111
|
+
/** What defense was bypassed */
|
|
112
|
+
defenseBypass: string;
|
|
113
|
+
/** Specific fix (not generic) */
|
|
114
|
+
remediation: string;
|
|
115
|
+
/** Confidence based on reproduction count */
|
|
116
|
+
confidence: number;
|
|
117
|
+
/** How many attack iterations confirmed this */
|
|
118
|
+
reproductions: number;
|
|
119
|
+
}
|
|
120
|
+
export interface AttackEngineConfig {
|
|
121
|
+
/** Max iterations per attack category (default: 5) */
|
|
122
|
+
maxIterations: number;
|
|
123
|
+
/** Max total payloads per session (default: 50) */
|
|
124
|
+
maxPayloads: number;
|
|
125
|
+
/** Timeout per individual attack in ms (default: 5000) */
|
|
126
|
+
attackTimeoutMs: number;
|
|
127
|
+
/** Which attack categories to run (default: all 11) */
|
|
128
|
+
categories: AttackCategory[];
|
|
129
|
+
/** LLM provider for payload generation */
|
|
130
|
+
llmProvider: 'nanomind-daemon' | 'anthropic' | 'ollama';
|
|
131
|
+
}
|
|
132
|
+
export declare const DEFAULT_ATTACK_CONFIG: AttackEngineConfig;
|
|
133
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/attack-engine/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,MAAM,WAAW,qBAAqB;IACpC,mCAAmC;IACnC,YAAY,EAAE,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,YAAY,GAAG,eAAe,GAAG,UAAU,CAAC;IAC1F,mCAAmC;IACnC,eAAe,EAAE,MAAM,CAAC;IACxB,gDAAgD;IAChD,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,6CAA6C;IAC7C,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,iCAAiC;IACjC,mBAAmB,EAAE,MAAM,CAAC;I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YAAY,EAAE,MAAM,CAAC;IACrB,gCAAgC;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,6CAA6C;IAC7C,UAAU,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,aAAa,EAAE,MAAM,CAAC;CACvB;AAMD,MAAM,WAAW,kBAAkB;IACjC,sDAAsD;IACtD,aAAa,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,WAAW,EAAE,MAAM,CAAC;IACpB,0DAA0D;IAC1D,eAAe,EAAE,MAAM,CAAC;IACxB,uDAAuD;IACvD,UAAU,EAAE,cAAc,EAAE,CAAC;IAC7B,0CAA0C;IAC1C,WAAW,EAAE,iBAAiB,GAAG,WAAW,GAAG,QAAQ,CAAC;CACzD;AAED,eAAO,MAAM,qBAAqB,EAAE,kBAWnC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* HMA Adaptive Attack Engine Types
|
|
4
|
+
*
|
|
5
|
+
* NanoMind-powered red team agent that generates target-specific
|
|
6
|
+
* attack payloads, observes responses, adapts, and iterates.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.DEFAULT_ATTACK_CONFIG = void 0;
|
|
10
|
+
exports.DEFAULT_ATTACK_CONFIG = {
|
|
11
|
+
maxIterations: 5,
|
|
12
|
+
maxPayloads: 50,
|
|
13
|
+
attackTimeoutMs: 5000,
|
|
14
|
+
categories: [
|
|
15
|
+
'prompt_injection', 'data_exfiltration', 'privilege_escalation',
|
|
16
|
+
'social_engineering', 'instruction_override', 'memory_poisoning',
|
|
17
|
+
'soul_bypass', 'indirect_injection', 'capability_abuse',
|
|
18
|
+
'persistence', 'semantic_mismatch',
|
|
19
|
+
],
|
|
20
|
+
llmProvider: 'nanomind-daemon',
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/attack-engine/types.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AA8KU,QAAA,qBAAqB,GAAuB;IACvD,aAAa,EAAE,CAAC;IAChB,WAAW,EAAE,EAAE;IACf,eAAe,EAAE,IAAI;IACrB,UAAU,EAAE;QACV,kBAAkB,EAAE,mBAAmB,EAAE,sBAAsB;QAC/D,oBAAoB,EAAE,sBAAsB,EAAE,kBAAkB;QAChE,aAAa,EAAE,oBAAoB,EAAE,kBAAkB;QACvD,aAAa,EAAE,mBAAmB;KACnC;IACD,WAAW,EAAE,iBAAiB;CAC/B,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -1743,8 +1743,9 @@ Examples:
|
|
|
1743
1743
|
.option('-b, --benchmark <name>', 'Run benchmark compliance check (e.g., oasb-1)')
|
|
1744
1744
|
.option('-l, --level <level>', 'Benchmark level: L1 (Essential), L2 (Standard), L3 (Hardened)', 'L1')
|
|
1745
1745
|
.option('-c, --category <name>', 'Filter to specific benchmark category')
|
|
1746
|
-
.option('--deep', '
|
|
1747
|
-
.option('--
|
|
1746
|
+
.option('--deep', 'Maximum analysis: static + NanoMind + behavioral simulation + adaptive attacks (~30s per artifact)')
|
|
1747
|
+
.option('--static-only', 'Disable NanoMind and simulation (static checks only, fast, deterministic)')
|
|
1748
|
+
.option('--scan-depth <depth>', 'CAAT scan depth: quick (config+creds only), standard (default), deep (+ simulation)', 'standard')
|
|
1748
1749
|
.option('--ci-publish', 'Submit scan results to registry CI endpoint (requires CI_SCAN_HMAC_SECRET env)')
|
|
1749
1750
|
.option('--publish', 'Push scan results to the OpenA2A Registry')
|
|
1750
1751
|
.option('--registry-report', 'Post results to OpenA2A Registry')
|
|
@@ -1817,17 +1818,41 @@ Examples:
|
|
|
1817
1818
|
console.error(`Error: Invalid scan depth '${options.scanDepth}'. Use: ${validDepths.join(', ')}`);
|
|
1818
1819
|
process.exit(1);
|
|
1819
1820
|
}
|
|
1820
|
-
//
|
|
1821
|
+
// Analysis mode: smart defaults, minimal flags
|
|
1822
|
+
// Default: static + NanoMind (if daemon available)
|
|
1823
|
+
// --deep: everything (static + NanoMind + simulation + adaptive attacks)
|
|
1824
|
+
// --static-only: just static checks (CI/deterministic)
|
|
1825
|
+
// --ci: implies --static-only
|
|
1826
|
+
const isStaticOnly = options.staticOnly ?? false;
|
|
1821
1827
|
const isDeep = options.deep ?? (scanDepth === 'deep');
|
|
1822
|
-
|
|
1828
|
+
// Auto-detect NanoMind daemon
|
|
1829
|
+
let nanomindAvailable = false;
|
|
1830
|
+
if (!isStaticOnly && !options.ci) {
|
|
1831
|
+
try {
|
|
1832
|
+
const { isDaemonAvailable } = await Promise.resolve().then(() => __importStar(require('./semantic/nanomind-analyzer.js')));
|
|
1833
|
+
nanomindAvailable = await isDaemonAvailable();
|
|
1834
|
+
}
|
|
1835
|
+
catch { /* daemon not installed */ }
|
|
1836
|
+
}
|
|
1837
|
+
const onProgress = format === 'text'
|
|
1823
1838
|
? (msg) => process.stdout.write(msg)
|
|
1824
1839
|
: undefined;
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
console.log(` npx ${CLI_PREFIX} init-mcp\n`);
|
|
1840
|
+
// Show analysis mode to user
|
|
1841
|
+
if (format === 'text') {
|
|
1842
|
+
if (isStaticOnly || options.ci) {
|
|
1843
|
+
// Static only -- no extra output
|
|
1830
1844
|
}
|
|
1845
|
+
else if (nanomindAvailable && isDeep) {
|
|
1846
|
+
console.log(`Analysis: static + NanoMind + behavioral simulation + adaptive attacks\n`);
|
|
1847
|
+
}
|
|
1848
|
+
else if (nanomindAvailable) {
|
|
1849
|
+
console.log(`Analysis: static + NanoMind (enhanced accuracy)\n`);
|
|
1850
|
+
}
|
|
1851
|
+
else if (isDeep) {
|
|
1852
|
+
console.log(`Analysis: static + behavioral simulation\n`);
|
|
1853
|
+
console.log(` Tip: Install NanoMind for even better results: nanomind-daemon start\n`);
|
|
1854
|
+
}
|
|
1855
|
+
// Default static-only: no message needed, it's the baseline
|
|
1831
1856
|
}
|
|
1832
1857
|
if (scanDepth === 'quick' && format === 'text') {
|
|
1833
1858
|
console.log(`Scan depth: quick (config checks + credential detection only)\n`);
|
|
@@ -1845,6 +1870,81 @@ Examples:
|
|
|
1845
1870
|
onProgress,
|
|
1846
1871
|
});
|
|
1847
1872
|
const scanDurationMs = Date.now() - scanStartMs;
|
|
1873
|
+
// NanoMind Semantic Compiler: AST-based analysis runs alongside static checks
|
|
1874
|
+
// Defense-in-depth: static findings can NEVER be suppressed, only upgraded
|
|
1875
|
+
if (!isStaticOnly && !options.ci) {
|
|
1876
|
+
try {
|
|
1877
|
+
const { runNanoMindScan } = await Promise.resolve().then(() => __importStar(require('./nanomind-core/scanner-bridge.js')));
|
|
1878
|
+
const existingFindings = result.allFindings || result.findings || [];
|
|
1879
|
+
const nmResult = await runNanoMindScan(targetDir, existingFindings);
|
|
1880
|
+
if (format === 'text' && nmResult.astFindings.length > 0) {
|
|
1881
|
+
const newFindings = nmResult.astFindings.filter(f => !f.passed);
|
|
1882
|
+
if (newFindings.length > 0) {
|
|
1883
|
+
process.stdout.write(`\nNanoMind: ${nmResult.compiledArtifacts} artifact(s) compiled, ${newFindings.length} semantic finding(s) added\n`);
|
|
1884
|
+
}
|
|
1885
|
+
if (nmResult.integrityStatus !== 'CLEAN') {
|
|
1886
|
+
process.stdout.write(` Integrity: ${nmResult.integrityStatus}\n`);
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
// Merge: AST findings ADD to static (never remove)
|
|
1890
|
+
if (result.allFindings) {
|
|
1891
|
+
result.allFindings = nmResult.mergedFindings;
|
|
1892
|
+
}
|
|
1893
|
+
if (result.findings) {
|
|
1894
|
+
result.findings = nmResult.mergedFindings.filter((f) => !f.passed);
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
catch {
|
|
1898
|
+
// NanoMind unavailable -- static results are still valid
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
// Behavioral simulation: auto-runs on --deep, or when NanoMind detects ambiguity
|
|
1902
|
+
if (isDeep && format === 'text') {
|
|
1903
|
+
try {
|
|
1904
|
+
const { SimulationEngine, parseSkillProfile } = await Promise.resolve().then(() => __importStar(require('./simulation/index.js')));
|
|
1905
|
+
const { readFileSync, readdirSync, statSync } = await Promise.resolve().then(() => __importStar(require('node:fs')));
|
|
1906
|
+
const { join } = await Promise.resolve().then(() => __importStar(require('node:path')));
|
|
1907
|
+
// Find skill files in target directory
|
|
1908
|
+
const skillFiles = [];
|
|
1909
|
+
const findSkills = (dir) => {
|
|
1910
|
+
try {
|
|
1911
|
+
for (const entry of readdirSync(dir)) {
|
|
1912
|
+
const fullPath = join(dir, entry);
|
|
1913
|
+
const stat = statSync(fullPath);
|
|
1914
|
+
if (stat.isDirectory() && !entry.startsWith('.') && entry !== 'node_modules') {
|
|
1915
|
+
findSkills(fullPath);
|
|
1916
|
+
}
|
|
1917
|
+
else if (entry.endsWith('.md') || entry.endsWith('.yaml') || entry.endsWith('.yml')) {
|
|
1918
|
+
skillFiles.push(fullPath);
|
|
1919
|
+
}
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
catch { /* skip inaccessible dirs */ }
|
|
1923
|
+
};
|
|
1924
|
+
findSkills(targetDir);
|
|
1925
|
+
if (skillFiles.length === 0) {
|
|
1926
|
+
process.stdout.write(`\n[Simulation] No skill/SOUL/MCP artifacts found. Simulation skipped.\n\n`);
|
|
1927
|
+
}
|
|
1928
|
+
else {
|
|
1929
|
+
process.stdout.write(`\n[Simulation] Running behavioral simulation on ${skillFiles.length} artifact(s)...\n`);
|
|
1930
|
+
const sim = new SimulationEngine({ useLLM: nanomindAvailable });
|
|
1931
|
+
for (const file of skillFiles.slice(0, 10)) { // Cap at 10 files
|
|
1932
|
+
const content = readFileSync(file, 'utf-8');
|
|
1933
|
+
const profile = parseSkillProfile(content, file.split('/').pop() ?? 'unknown');
|
|
1934
|
+
const simResult = await sim.runLayer3(profile);
|
|
1935
|
+
const icon = simResult.verdict === 'CLEAN' ? 'PASS' : simResult.verdict === 'SUSPICIOUS' ? 'WARN' : 'FAIL';
|
|
1936
|
+
process.stdout.write(` [${icon}] ${file.split('/').pop()} — ${simResult.verdict} (${(simResult.confidence * 100).toFixed(0)}% confidence, ${simResult.failedProbes.length}/${simResult.probeCount} probes failed)\n`);
|
|
1937
|
+
// Auto-export training data
|
|
1938
|
+
const { exportSimulationTraining } = await Promise.resolve().then(() => __importStar(require('./attack-engine/training-pipeline.js')));
|
|
1939
|
+
exportSimulationTraining(content, simResult);
|
|
1940
|
+
}
|
|
1941
|
+
process.stdout.write(`[Simulation] Complete.\n\n`);
|
|
1942
|
+
} // end skillFiles.length > 0
|
|
1943
|
+
}
|
|
1944
|
+
catch (err) {
|
|
1945
|
+
process.stdout.write(`[Simulation] Skipped: ${err instanceof Error ? err.message : 'unknown error'}\n\n`);
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1848
1948
|
// OASB-2 composite mode: infrastructure (50%) + governance (50%)
|
|
1849
1949
|
if (isOasb2) {
|
|
1850
1950
|
const infraResult = generateBenchmarkReport(result.allFindings || result.findings, level, options.category);
|
|
@@ -4412,7 +4512,8 @@ Examples:
|
|
|
4412
4512
|
.option('--tier <tier>', 'Override agent tier detection (BASIC, TOOL-USING, AGENTIC, MULTI-AGENT)')
|
|
4413
4513
|
.option('--profile <profile>', 'Override agent profile (conversational, code-assistant, tool-agent, autonomous, orchestrator, custom)')
|
|
4414
4514
|
.option('--fail-below <score>', 'Exit 1 if score below threshold (0-100)')
|
|
4415
|
-
.option('--deep', '
|
|
4515
|
+
.option('--deep', 'Maximum analysis: NanoMind + SOUL governance simulation (~15s)')
|
|
4516
|
+
.option('--static-only', 'Disable NanoMind (static governance checks only)')
|
|
4416
4517
|
.option('--publish', 'Push scan results to the OpenA2A Registry')
|
|
4417
4518
|
.option('--registry-url <url>', 'Registry URL (default: REGISTRY_URL env)', validateRegistryUrl(process.env.REGISTRY_URL || 'https://api.oa2a.org'))
|
|
4418
4519
|
.option('--contribute', 'Share anonymized scan findings with OpenA2A Registry (overrides config)')
|
|
@@ -5047,9 +5148,141 @@ program
|
|
|
5047
5148
|
writeJsonStdout({ totalChecks: Object.keys(metadata).length, checks: metadata });
|
|
5048
5149
|
});
|
|
5049
5150
|
// Show help and exit 0 when no arguments provided
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5151
|
+
// explain command: NanoMind-powered finding explanation
|
|
5152
|
+
program
|
|
5153
|
+
.command('explain')
|
|
5154
|
+
.argument('<findingId>', 'Finding ID to explain (e.g., SKILL-SEMANTIC-007 or CRED-001)')
|
|
5155
|
+
.description('Explain a security finding in plain English using NanoMind')
|
|
5156
|
+
.action(async (findingId) => {
|
|
5157
|
+
console.log(`Explaining finding: ${findingId}\n`);
|
|
5158
|
+
// Try NanoMind daemon first for dynamic explanation
|
|
5159
|
+
const { isDaemonAvailable, explainFinding } = await Promise.resolve().then(() => __importStar(require('./semantic/nanomind-analyzer.js')));
|
|
5160
|
+
const available = await isDaemonAvailable();
|
|
5161
|
+
if (available) {
|
|
5162
|
+
const explanation = await explainFinding(JSON.stringify({ findingId }));
|
|
5163
|
+
if (explanation) {
|
|
5164
|
+
console.log(explanation);
|
|
5165
|
+
return;
|
|
5166
|
+
}
|
|
5167
|
+
}
|
|
5168
|
+
// Fallback: static explanation from check metadata
|
|
5169
|
+
const checkId = findingId.toUpperCase();
|
|
5170
|
+
const staticExplanations = {
|
|
5171
|
+
'CRED-001': 'Hardcoded credential detected. API keys, tokens, or passwords are embedded directly in source code. Replace with environment variable references ($VAR_NAME) and rotate the exposed credential immediately.',
|
|
5172
|
+
'CRED-002': 'OpenAI API key pattern detected (sk-...). Move to environment variable OPENAI_API_KEY.',
|
|
5173
|
+
'CRED-003': 'Anthropic API key pattern detected (sk-ant-...). Move to environment variable ANTHROPIC_API_KEY.',
|
|
5174
|
+
'CRED-004': 'AWS credential pattern detected. Use AWS SDK credential chain or environment variables.',
|
|
5175
|
+
'MCP-001': 'MCP server running without TLS. Agent-to-server communication is unencrypted.',
|
|
5176
|
+
'SKILL-005': 'External endpoint in skill capability declaration. Verify the endpoint is trusted.',
|
|
5177
|
+
};
|
|
5178
|
+
const explanation = staticExplanations[checkId];
|
|
5179
|
+
if (explanation) {
|
|
5180
|
+
console.log(`${checkId}: ${explanation}`);
|
|
5181
|
+
}
|
|
5182
|
+
else {
|
|
5183
|
+
console.log(`No explanation available for ${findingId}.`);
|
|
5184
|
+
if (!available) {
|
|
5185
|
+
console.log(`\nFor dynamic explanations, install NanoMind: npm install -g @nanomind/cli && nanomind-daemon start`);
|
|
5186
|
+
}
|
|
5187
|
+
}
|
|
5188
|
+
});
|
|
5189
|
+
// red-team command: NanoMind-powered adaptive attack engine
|
|
5190
|
+
program
|
|
5191
|
+
.command('red-team')
|
|
5192
|
+
.argument('<target>', 'Path to artifact to red-team (skill, SOUL.md, MCP config, system prompt)')
|
|
5193
|
+
.description('Run adaptive attack session against an artifact. NanoMind generates target-specific attacks, observes responses, adapts, and maps defenses.')
|
|
5194
|
+
.option('--iterations <n>', 'Max attack iterations per category', '5')
|
|
5195
|
+
.option('--json', 'Output results as JSON')
|
|
5196
|
+
.action(async (target, options) => {
|
|
5197
|
+
const { readFileSync } = await Promise.resolve().then(() => __importStar(require('node:fs')));
|
|
5198
|
+
const { runAttackSession, exportTrainingData } = await Promise.resolve().then(() => __importStar(require('./attack-engine/feedback-loop.js')));
|
|
5199
|
+
const { exportAttackTraining } = await Promise.resolve().then(() => __importStar(require('./attack-engine/training-pipeline.js')));
|
|
5200
|
+
let content;
|
|
5201
|
+
try {
|
|
5202
|
+
content = readFileSync(target, 'utf-8');
|
|
5203
|
+
}
|
|
5204
|
+
catch {
|
|
5205
|
+
console.error(`Cannot read file: ${target}`);
|
|
5206
|
+
process.exit(1);
|
|
5207
|
+
}
|
|
5208
|
+
const artifactType = target.toLowerCase().includes('soul') ? 'soul'
|
|
5209
|
+
: target.toLowerCase().includes('mcp') ? 'mcp_tool'
|
|
5210
|
+
: 'skill';
|
|
5211
|
+
const name = target.split('/').pop() ?? 'unknown';
|
|
5212
|
+
if (!options.json) {
|
|
5213
|
+
console.log(`\nAdaptive Attack Engine`);
|
|
5214
|
+
console.log(`Target: ${name} (${artifactType})`);
|
|
5215
|
+
console.log(`Max iterations: ${options.iterations ?? 5} per category\n`);
|
|
5216
|
+
}
|
|
5217
|
+
const result = await runAttackSession(content, artifactType, name, {
|
|
5218
|
+
maxIterations: parseInt(options.iterations ?? '5', 10),
|
|
5219
|
+
});
|
|
5220
|
+
if (options.json) {
|
|
5221
|
+
console.log(JSON.stringify(result, null, 2));
|
|
5222
|
+
}
|
|
5223
|
+
else {
|
|
5224
|
+
console.log(`Results:`);
|
|
5225
|
+
console.log(` Payloads generated: ${result.totalPayloads}`);
|
|
5226
|
+
console.log(` Successful attacks: ${result.successCount}`);
|
|
5227
|
+
console.log(` Partial successes: ${result.partialCount}`);
|
|
5228
|
+
console.log(` Resilience score: ${(result.defenseMap.resilienceScore * 100).toFixed(0)}%`);
|
|
5229
|
+
console.log(` Duration: ${result.durationMs}ms\n`);
|
|
5230
|
+
if (result.vulnerabilities.length > 0) {
|
|
5231
|
+
console.log(`Vulnerabilities Found:`);
|
|
5232
|
+
for (const vuln of result.vulnerabilities) {
|
|
5233
|
+
console.log(` [${vuln.severity.toUpperCase()}] ${vuln.title}`);
|
|
5234
|
+
console.log(` ${vuln.description}`);
|
|
5235
|
+
console.log(` Fix: ${vuln.remediation}\n`);
|
|
5236
|
+
}
|
|
5237
|
+
}
|
|
5238
|
+
else {
|
|
5239
|
+
console.log(`No vulnerabilities found. All defenses held.\n`);
|
|
5240
|
+
}
|
|
5241
|
+
if (result.defenseMap.strongCategories.length > 0) {
|
|
5242
|
+
console.log(`Strong defenses: ${result.defenseMap.strongCategories.join(', ')}`);
|
|
5243
|
+
}
|
|
5244
|
+
if (result.defenseMap.weakCategories.length > 0) {
|
|
5245
|
+
console.log(`Weak defenses: ${result.defenseMap.weakCategories.join(', ')}`);
|
|
5246
|
+
}
|
|
5247
|
+
}
|
|
5248
|
+
// Auto-export training data
|
|
5249
|
+
const trainingCount = exportAttackTraining(result);
|
|
5250
|
+
if (!options.json && trainingCount > 0) {
|
|
5251
|
+
console.log(`\n${trainingCount} training samples exported to NanoMind corpus.`);
|
|
5252
|
+
}
|
|
5253
|
+
});
|
|
5254
|
+
// Self-securing: verify own integrity before running any command
|
|
5255
|
+
// A security tool that doesn't verify itself is worse than no security tool
|
|
5256
|
+
(async () => {
|
|
5257
|
+
try {
|
|
5258
|
+
const { verifyAll } = await Promise.resolve().then(() => __importStar(require('./nanomind-core/security/integrity-verifier.js')));
|
|
5259
|
+
const integrity = await verifyAll();
|
|
5260
|
+
if (integrity.status === 'QUARANTINE') {
|
|
5261
|
+
// Binary tampered -- refuse to run
|
|
5262
|
+
process.stderr.write('\nINTEGRITY CHECK FAILED: HackMyAgent binary may have been tampered with.\n' +
|
|
5263
|
+
'This could indicate a supply chain attack.\n\n' +
|
|
5264
|
+
'Actions:\n' +
|
|
5265
|
+
' 1. Reinstall: npm install -g hackmyagent\n' +
|
|
5266
|
+
' 2. Verify: npm audit signatures\n' +
|
|
5267
|
+
' 3. Report: https://github.com/opena2a-org/hackmyagent/security\n\n');
|
|
5268
|
+
for (const check of integrity.checks.filter(c => !c.passed)) {
|
|
5269
|
+
process.stderr.write(` Failed: ${check.name} -- ${check.reason}\n`);
|
|
5270
|
+
}
|
|
5271
|
+
process.exit(3); // Exit code 3 = integrity failure
|
|
5272
|
+
}
|
|
5273
|
+
if (integrity.status === 'DEGRADE') {
|
|
5274
|
+
// Model or rules tampered -- warn but continue with fallback
|
|
5275
|
+
process.stderr.write('\nIntegrity warning: some components could not be verified.\n' +
|
|
5276
|
+
'Continuing with baseline analysis (reduced accuracy).\n\n');
|
|
5277
|
+
}
|
|
5278
|
+
}
|
|
5279
|
+
catch {
|
|
5280
|
+
// Integrity check itself failed -- continue (don't block on missing manifest in dev)
|
|
5281
|
+
}
|
|
5282
|
+
if (process.argv.length <= 2) {
|
|
5283
|
+
program.outputHelp();
|
|
5284
|
+
process.exit(0);
|
|
5285
|
+
}
|
|
5286
|
+
program.parse();
|
|
5287
|
+
})();
|
|
5055
5288
|
//# sourceMappingURL=cli.js.map
|