hackmyagent 0.17.6 → 0.17.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/.integrity-manifest.json +1 -1
- package/dist/cli.js +221 -17
- package/dist/cli.js.map +1 -1
- package/dist/hardening/scanner.d.ts +7 -0
- package/dist/hardening/scanner.d.ts.map +1 -1
- package/dist/hardening/scanner.js +17 -2
- package/dist/hardening/scanner.js.map +1 -1
- package/dist/nanomind-core/inference/analm-infer-llamacpp.py +113 -0
- package/dist/nanomind-core/inference/security-analyst.d.ts +1 -1
- package/dist/nanomind-core/inference/security-analyst.d.ts.map +1 -1
- package/dist/nanomind-core/inference/security-analyst.js +108 -21
- package/dist/nanomind-core/inference/security-analyst.js.map +1 -1
- package/dist/nanomind-core/orchestrate.js +19 -5
- package/dist/nanomind-core/orchestrate.js.map +1 -1
- package/package.json +2 -2
|
@@ -33,6 +33,13 @@ export interface ScanOptions {
|
|
|
33
33
|
* This is the canonical scoring formula — all score paths must use it.
|
|
34
34
|
*
|
|
35
35
|
* Accepts findings with at minimum: { passed?, fixed?, severity, category, checkId }.
|
|
36
|
+
*
|
|
37
|
+
* Per-check capping: only the first MAX_FINDINGS_PER_CHECK instances of each
|
|
38
|
+
* unique checkId contribute to the weighted sum at full weight. Additional
|
|
39
|
+
* instances contribute at a steeply diminished rate (10%). This prevents a
|
|
40
|
+
* single pattern-match check (e.g. AST-CRED-001) from dominating the score
|
|
41
|
+
* when it fires across dozens of files in a large repository. All findings
|
|
42
|
+
* are still reported — only the score contribution is capped.
|
|
36
43
|
*/
|
|
37
44
|
export declare function calculateSecurityScore(findings: Array<{
|
|
38
45
|
passed?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../../src/hardening/scanner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAY,WAAW,EAAE,M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IAiE9B;;;;OAIG;YACW,yBAAyB;IA+YvC;;;;;OAKG;YACW,qBAAqB;IAqnBnC;;;;OAIG;YACW,gBAAgB;IA2G9B;;;;OAIG;YACW,mBAAmB;IAmKjC;;;;OAIG;YACW,gBAAgB;IAkF9B;;;OAGG;YACW,iBAAiB;IA+C/B;;;;OAIG;YACW,yBAAyB;IA6FvC;;;OAGG;YACW,kBAAkB;IA8ChC;;;OAGG;YACW,mBAAmB;IA4CjC;;;OAGG;YACW,6BAA6B;IAiD3C;;;OAGG;YACW,oBAAoB;IA4ClC;;;OAGG;YACW,WAAW;IA4DzB;;;OAGG;YACW,aAAa;IAgD3B;;;OAGG;YACW,oBAAoB;IA6ClC;;;OAGG;YACW,YAAY;IAmD1B;;;OAGG;YACW,qBAAqB;IA+DnC;;;;OAIG;YACW,oBAAoB;IAyHlC;;;OAGG;YACW,iBAAiB;IA+F/B;;;OAGG;YACW,4BAA4B;IAqD1C;;;OAGG;YACW,8BAA8B;IAgE5C;;;;OAIG;YACW,qBAAqB;IAgBnC,+DAA+D;YACjD,YAAY;CA+B3B"}
|
|
@@ -247,20 +247,35 @@ const SEVERITY_WEIGHTS = {
|
|
|
247
247
|
* This is the canonical scoring formula — all score paths must use it.
|
|
248
248
|
*
|
|
249
249
|
* Accepts findings with at minimum: { passed?, fixed?, severity, category, checkId }.
|
|
250
|
+
*
|
|
251
|
+
* Per-check capping: only the first MAX_FINDINGS_PER_CHECK instances of each
|
|
252
|
+
* unique checkId contribute to the weighted sum at full weight. Additional
|
|
253
|
+
* instances contribute at a steeply diminished rate (10%). This prevents a
|
|
254
|
+
* single pattern-match check (e.g. AST-CRED-001) from dominating the score
|
|
255
|
+
* when it fires across dozens of files in a large repository. All findings
|
|
256
|
+
* are still reported — only the score contribution is capped.
|
|
250
257
|
*/
|
|
251
258
|
function calculateSecurityScore(findings) {
|
|
252
259
|
const GOVERNANCE_CATEGORIES = new Set(['governance', 'Governance', 'injection-hardening', 'trust-hierarchy']);
|
|
253
260
|
const GOVERNANCE_PREFIXES = ['AST-GOV', 'AST-GOVERN', 'AST-PROMPT', 'AST-HEARTBEAT'];
|
|
254
261
|
const GOVERNANCE_WEIGHT = 0.4;
|
|
255
262
|
const DECAY_CONSTANT = 150;
|
|
263
|
+
const MAX_FINDINGS_PER_CHECK = 3;
|
|
264
|
+
const OVERFLOW_WEIGHT = 0.1; // 10% weight for findings beyond the cap
|
|
265
|
+
// Count occurrences per checkId to apply diminishing returns
|
|
266
|
+
const checkIdCounts = new Map();
|
|
256
267
|
let weightedSum = 0;
|
|
257
268
|
for (const finding of findings) {
|
|
258
269
|
if (!finding.passed && !finding.fixed) {
|
|
270
|
+
const checkId = finding.checkId || '_unknown_';
|
|
271
|
+
const count = (checkIdCounts.get(checkId) || 0) + 1;
|
|
272
|
+
checkIdCounts.set(checkId, count);
|
|
259
273
|
const isGovernance = GOVERNANCE_CATEGORIES.has(finding.category || '') ||
|
|
260
274
|
GOVERNANCE_PREFIXES.some(p => (finding.checkId || '').startsWith(p));
|
|
261
|
-
const
|
|
275
|
+
const governanceMultiplier = isGovernance ? GOVERNANCE_WEIGHT : 1;
|
|
276
|
+
const capMultiplier = count <= MAX_FINDINGS_PER_CHECK ? 1 : OVERFLOW_WEIGHT;
|
|
262
277
|
const sevWeight = SEVERITY_WEIGHTS[finding.severity] ?? 0;
|
|
263
|
-
weightedSum += sevWeight *
|
|
278
|
+
weightedSum += sevWeight * governanceMultiplier * capMultiplier;
|
|
264
279
|
}
|
|
265
280
|
}
|
|
266
281
|
const score = weightedSum === 0
|