hackmyagent 0.12.1 → 0.12.3
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 +21 -2
- package/dist/.integrity-manifest.json +1 -1
- package/dist/attack/types.d.ts +2 -0
- package/dist/attack/types.d.ts.map +1 -1
- package/dist/attack/types.js.map +1 -1
- package/dist/cli.js +235 -16
- package/dist/cli.js.map +1 -1
- package/dist/hardening/scanner.d.ts.map +1 -1
- package/dist/hardening/scanner.js +24 -5
- package/dist/hardening/scanner.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/nanomind-core/compiler/semantic-compiler.js +78 -5
- package/dist/nanomind-core/compiler/semantic-compiler.js.map +1 -1
- package/dist/nanomind-core/inference/tme-classifier.js +1 -1
- package/dist/nanomind-core/inference/tme-classifier.js.map +1 -1
- package/dist/wild/browser.d.ts +44 -0
- package/dist/wild/browser.d.ts.map +1 -0
- package/dist/wild/browser.js +222 -0
- package/dist/wild/browser.js.map +1 -0
- package/dist/wild/index.d.ts +20 -0
- package/dist/wild/index.d.ts.map +1 -0
- package/dist/wild/index.js +173 -0
- package/dist/wild/index.js.map +1 -0
- package/dist/wild/scorer.d.ts +29 -0
- package/dist/wild/scorer.d.ts.map +1 -0
- package/dist/wild/scorer.js +101 -0
- package/dist/wild/scorer.js.map +1 -0
- package/dist/wild/types.d.ts +95 -0
- package/dist/wild/types.d.ts.map +1 -0
- package/dist/wild/types.js +8 -0
- package/dist/wild/types.js.map +1 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../../src/hardening/scanner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,KAAK,EAAE,UAAU,EAA0C,MAAM,kBAAkB,CAAC;AAwG3F,0CAA0C;AAC1C,MAAM,MAAM,SAAS,GA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G;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,+DAA+D;YACjD,YAAY;CA+B3B"}
|
|
@@ -811,7 +811,10 @@ class HardeningScanner {
|
|
|
811
811
|
pattern.lastIndex = 0;
|
|
812
812
|
if (pattern.test(lines[i]) && !lines[i].includes('${' + envVar + '}')) {
|
|
813
813
|
keysFoundInFile.push({ name, line: i + 1 });
|
|
814
|
-
|
|
814
|
+
// Fix: replace credential with env var reference (but NOT in .env files
|
|
815
|
+
// where the actual value is supposed to live)
|
|
816
|
+
const isEnvFile = filename.startsWith('.env');
|
|
817
|
+
if (autoFix && !isEnvFile) {
|
|
815
818
|
pattern.lastIndex = 0;
|
|
816
819
|
lines[i] = lines[i].replace(pattern, '${' + envVar + '}');
|
|
817
820
|
fileModified = true;
|
|
@@ -828,20 +831,25 @@ class HardeningScanner {
|
|
|
828
831
|
content = lines.join('\n');
|
|
829
832
|
await fs.writeFile(filePath, content);
|
|
830
833
|
}
|
|
834
|
+
const isEnvFile = filename.startsWith('.env');
|
|
831
835
|
findings.push({
|
|
832
836
|
checkId: 'CRED-001',
|
|
833
837
|
name: 'Exposed Credential',
|
|
834
838
|
description: `${keyNames.join(', ')} found in plaintext`,
|
|
835
839
|
category: 'credentials',
|
|
836
840
|
severity: 'critical',
|
|
837
|
-
passed: fileModified,
|
|
841
|
+
passed: fileModified,
|
|
838
842
|
message: keyNames.join(', '),
|
|
839
843
|
file: filename,
|
|
840
844
|
line: firstLine,
|
|
841
|
-
fixable:
|
|
845
|
+
fixable: !isEnvFile, // .env files can't be auto-fixed (that's where values belong)
|
|
842
846
|
fixed: fileModified,
|
|
843
|
-
fix:
|
|
844
|
-
|
|
847
|
+
fix: isEnvFile
|
|
848
|
+
? 'Add .env to .gitignore to prevent committing secrets'
|
|
849
|
+
: `${this.cliName} secure --fix`,
|
|
850
|
+
guidance: isEnvFile
|
|
851
|
+
? 'Credentials in .env are expected but the file must be in .gitignore. Run `hackmyagent secure --fix` to create a .gitignore.'
|
|
852
|
+
: 'Replaces hardcoded credentials with ${ENV_VAR} references. Store actual values in your .env file, which should be in .gitignore.',
|
|
845
853
|
});
|
|
846
854
|
}
|
|
847
855
|
}
|
|
@@ -5453,6 +5461,17 @@ dist/
|
|
|
5453
5461
|
for (const pattern of PROMPT_INJECTION_PATTERNS) {
|
|
5454
5462
|
const match = content.match(pattern);
|
|
5455
5463
|
if (match) {
|
|
5464
|
+
// Exclude matches inside defensive/governance context
|
|
5465
|
+
// SOUL.md templates quote attack phrases to teach defense against them
|
|
5466
|
+
const matchIdx = content.indexOf(match[0]);
|
|
5467
|
+
const surroundingStart = Math.max(0, matchIdx - 200);
|
|
5468
|
+
const surroundingEnd = Math.min(content.length, matchIdx + match[0].length + 100);
|
|
5469
|
+
const surrounding = content.slice(surroundingStart, surroundingEnd).toLowerCase();
|
|
5470
|
+
const isDefensive = /must never|forbidden|should not|must not|never comply|resist|reject|refuse|do not|defense|hardening|such as|attempt|detect/i.test(surrounding);
|
|
5471
|
+
// Also check if the document is a governance doc (3+ constraint phrases)
|
|
5472
|
+
const constraintCount = (content.match(/must never|must not|must always|should not|forbidden|prohibited|restricted to|shall not/gi) || []).length;
|
|
5473
|
+
if (isDefensive || constraintCount >= 3)
|
|
5474
|
+
continue;
|
|
5456
5475
|
findings.push({
|
|
5457
5476
|
checkId: 'CONFIG-002',
|
|
5458
5477
|
name: 'SOUL.md Injection Vectors',
|