hackmyagent 0.9.6 → 0.9.8
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/dist/cli.js +25 -8
- package/dist/cli.js.map +1 -1
- package/dist/hardening/scanner.d.ts +3 -0
- package/dist/hardening/scanner.d.ts.map +1 -1
- package/dist/hardening/scanner.js +16 -12
- package/dist/hardening/scanner.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/registry/client.d.ts.map +1 -1
- package/dist/registry/client.js +25 -2
- package/dist/registry/client.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -64,6 +64,21 @@ function writeJsonStdout(data) {
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
+
// Resolve the CLI command name based on how we were invoked.
|
|
68
|
+
// When run via `opena2a scan secure`, use `opena2a scan` prefix.
|
|
69
|
+
// When run directly as `hackmyagent`, use that.
|
|
70
|
+
// The HMA_CLI_PREFIX env var lets parent CLIs override explicitly.
|
|
71
|
+
function resolveCliPrefix() {
|
|
72
|
+
if (process.env.HMA_CLI_PREFIX)
|
|
73
|
+
return process.env.HMA_CLI_PREFIX;
|
|
74
|
+
const argv1 = process.argv[1] || '';
|
|
75
|
+
const basename = require('path').basename(argv1).replace(/\.[jt]s$/, '');
|
|
76
|
+
if (basename === 'opena2a' || basename.startsWith('opena2a-')) {
|
|
77
|
+
return 'opena2a scan';
|
|
78
|
+
}
|
|
79
|
+
return 'hackmyagent';
|
|
80
|
+
}
|
|
81
|
+
const CLI_PREFIX = resolveCliPrefix();
|
|
67
82
|
// Check for NO_COLOR env or non-TTY to disable colors by default
|
|
68
83
|
const noColorEnv = process.env.NO_COLOR !== undefined || process.stdout.isTTY === false;
|
|
69
84
|
// Color codes - will be cleared if --no-color is passed
|
|
@@ -1478,10 +1493,10 @@ function printBenchmarkReport(result, verbose) {
|
|
|
1478
1493
|
}
|
|
1479
1494
|
// Show appropriate next step based on current level
|
|
1480
1495
|
if (result.level === 'L1') {
|
|
1481
|
-
console.log(`\nRun '
|
|
1496
|
+
console.log(`\nRun '${CLI_PREFIX} secure -b oasb-1 -l L2' for stricter checks.`);
|
|
1482
1497
|
}
|
|
1483
1498
|
else if (result.level === 'L2') {
|
|
1484
|
-
console.log(`\nRun '
|
|
1499
|
+
console.log(`\nRun '${CLI_PREFIX} secure -b oasb-1 -l L3' for hardened requirements.`);
|
|
1485
1500
|
}
|
|
1486
1501
|
else {
|
|
1487
1502
|
console.log(`\nThis is the highest maturity level (L3 - Hardened).`);
|
|
@@ -1633,7 +1648,7 @@ Examples:
|
|
|
1633
1648
|
if (!process.env.ANTHROPIC_API_KEY) {
|
|
1634
1649
|
console.log(`Layer 3: Semantic analysis — skipped (no ANTHROPIC_API_KEY)`);
|
|
1635
1650
|
console.log(` Tip: Add HackMyAgent as an MCP server for free LLM analysis:`);
|
|
1636
|
-
console.log(` npx
|
|
1651
|
+
console.log(` npx ${CLI_PREFIX} init-mcp\n`);
|
|
1637
1652
|
}
|
|
1638
1653
|
}
|
|
1639
1654
|
const scanner = new index_1.HardeningScanner();
|
|
@@ -1643,6 +1658,7 @@ Examples:
|
|
|
1643
1658
|
dryRun: options.dryRun ?? false,
|
|
1644
1659
|
ignore: ignoreList,
|
|
1645
1660
|
deep: isDeep,
|
|
1661
|
+
cliName: CLI_PREFIX,
|
|
1646
1662
|
onProgress,
|
|
1647
1663
|
});
|
|
1648
1664
|
// OASB-2 composite mode: infrastructure (50%) + governance (50%)
|
|
@@ -1883,7 +1899,7 @@ Examples:
|
|
|
1883
1899
|
console.log();
|
|
1884
1900
|
if (result.backupPath) {
|
|
1885
1901
|
console.log(`Backup: ${result.backupPath}`);
|
|
1886
|
-
console.log(`Undo:
|
|
1902
|
+
console.log(`Undo: ${CLI_PREFIX} rollback ${directory}\n`);
|
|
1887
1903
|
}
|
|
1888
1904
|
}
|
|
1889
1905
|
// Registry reporting: only when explicitly requested via --version-id (CI) or --registry-report
|
|
@@ -2023,7 +2039,7 @@ function assessRiskLevel(findings) {
|
|
|
2023
2039
|
return {
|
|
2024
2040
|
level: 'None',
|
|
2025
2041
|
color: colors.dim,
|
|
2026
|
-
description:
|
|
2042
|
+
description: `No OpenClaw configuration detected. Run \`${CLI_PREFIX} secure\` for a full scan.`,
|
|
2027
2043
|
};
|
|
2028
2044
|
}
|
|
2029
2045
|
return {
|
|
@@ -2084,6 +2100,7 @@ Examples:
|
|
|
2084
2100
|
autoFix: options.fix ?? false,
|
|
2085
2101
|
dryRun: options.dryRun ?? false,
|
|
2086
2102
|
ignore: [],
|
|
2103
|
+
cliName: CLI_PREFIX,
|
|
2087
2104
|
});
|
|
2088
2105
|
// Filter to OpenClaw-specific findings
|
|
2089
2106
|
const allOpenClawFindings = filterOpenClawFindings(result.findings);
|
|
@@ -2146,7 +2163,7 @@ Examples:
|
|
|
2146
2163
|
console.log();
|
|
2147
2164
|
if (result.backupPath) {
|
|
2148
2165
|
console.log(`${colors.yellow}Backup created:${RESET()} ${result.backupPath}`);
|
|
2149
|
-
console.log(`${colors.yellow}To rollback:${RESET()}
|
|
2166
|
+
console.log(`${colors.yellow}To rollback:${RESET()} ${CLI_PREFIX} rollback ${targetDir}`);
|
|
2150
2167
|
console.log();
|
|
2151
2168
|
console.log(`${colors.cyan}Note:${RESET()} If you replaced tokens with env vars, set OPENCLAW_AUTH_TOKEN`);
|
|
2152
2169
|
console.log(` in your environment before starting OpenClaw.\n`);
|
|
@@ -2161,7 +2178,7 @@ Examples:
|
|
|
2161
2178
|
console.log();
|
|
2162
2179
|
}
|
|
2163
2180
|
console.log(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`);
|
|
2164
|
-
console.log(`Run '
|
|
2181
|
+
console.log(`Run '${CLI_PREFIX} secure' for a full security scan.\n`);
|
|
2165
2182
|
// Exit with non-zero if critical/high issues remain
|
|
2166
2183
|
const criticalOrHigh = issues.filter((f) => f.severity === 'critical' || f.severity === 'high');
|
|
2167
2184
|
if (criticalOrHigh.length > 0) {
|
|
@@ -3619,7 +3636,7 @@ Examples:
|
|
|
3619
3636
|
console.log(`${colors.green}[+] No security issues found. Agent looks good.${RESET()}\n`);
|
|
3620
3637
|
}
|
|
3621
3638
|
console.log(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`);
|
|
3622
|
-
console.log(`Run '
|
|
3639
|
+
console.log(`Run '${CLI_PREFIX} secure' for a full hardening scan.\n`);
|
|
3623
3640
|
// Warn if scan is incomplete due to plugin errors
|
|
3624
3641
|
if (pluginErrors > 0) {
|
|
3625
3642
|
console.log(`\n${colors.brightRed}[!!] Note: ${pluginErrors} plugin(s) failed -- scan results are incomplete${RESET()}`);
|