hackmyagent 0.9.5 → 0.9.6

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.
@@ -444,7 +444,9 @@ class HardeningScanner {
444
444
  catch { }
445
445
  try {
446
446
  await fs.access(path.join(targetDir, '.claude'));
447
- platforms.push('claude-code');
447
+ if (!platforms.includes('claude-code')) {
448
+ platforms.push('claude-code');
449
+ }
448
450
  }
449
451
  catch { }
450
452
  // OpenClaw detection
@@ -1750,15 +1752,24 @@ dist/
1750
1752
  });
1751
1753
  // DEP-004: Check for npm scripts security
1752
1754
  let hasDangerousScripts = false;
1753
- const dangerousScriptPatterns = ['curl | sh', 'wget | bash', 'eval(', '$(curl'];
1755
+ const dangerousScriptRegexes = [
1756
+ /curl\b.*\|\s*sh/i, // curl ... | sh (with anything between)
1757
+ /curl\b.*\|\s*bash/i, // curl ... | bash
1758
+ /wget\b.*\|\s*sh/i, // wget ... | sh
1759
+ /wget\b.*\|\s*bash/i, // wget ... | bash
1760
+ /\beval\s*\(/, // eval(
1761
+ /\$\(curl\b/, // $(curl
1762
+ /\$\(wget\b/, // $(wget
1763
+ ];
1764
+ const pkgJsonPath = path.join(targetDir, 'package.json');
1754
1765
  try {
1755
- const pkgJson = await fs.readFile(path.join(targetDir, 'package.json'), 'utf-8');
1766
+ const pkgJson = await fs.readFile(pkgJsonPath, 'utf-8');
1756
1767
  const pkg = JSON.parse(pkgJson);
1757
1768
  if (pkg.scripts) {
1758
1769
  for (const [, script] of Object.entries(pkg.scripts)) {
1759
1770
  if (typeof script === 'string') {
1760
- for (const pattern of dangerousScriptPatterns) {
1761
- if (script.includes(pattern)) {
1771
+ for (const pattern of dangerousScriptRegexes) {
1772
+ if (pattern.test(script)) {
1762
1773
  hasDangerousScripts = true;
1763
1774
  break;
1764
1775
  }
@@ -1775,6 +1786,7 @@ dist/
1775
1786
  category: 'dependencies',
1776
1787
  severity: 'critical',
1777
1788
  passed: !hasDangerousScripts,
1789
+ file: hasDangerousScripts ? 'package.json' : undefined,
1778
1790
  message: hasDangerousScripts
1779
1791
  ? 'Dangerous patterns in npm scripts (curl|sh, eval) - review carefully'
1780
1792
  : 'npm scripts appear safe',
@@ -1885,15 +1897,29 @@ dist/
1885
1897
  async checkProcessSecurity(targetDir, autoFix) {
1886
1898
  const findings = [];
1887
1899
  // PROC-001: Check for Dockerfile security
1900
+ // Search common Dockerfile locations
1888
1901
  let hasSecureDockerfile = true;
1889
- try {
1890
- const dockerfile = await fs.readFile(path.join(targetDir, 'Dockerfile'), 'utf-8');
1891
- if (dockerfile.includes('USER root') || !dockerfile.includes('USER ')) {
1892
- hasSecureDockerfile = false;
1902
+ let dockerfilePath;
1903
+ const dockerfileCandidates = [
1904
+ 'Dockerfile',
1905
+ 'Dockerfile.prod',
1906
+ 'Dockerfile.production',
1907
+ 'Dockerfile.dev',
1908
+ 'docker/Dockerfile',
1909
+ ];
1910
+ for (const candidate of dockerfileCandidates) {
1911
+ const candidatePath = path.join(targetDir, candidate);
1912
+ try {
1913
+ const dockerfile = await fs.readFile(candidatePath, 'utf-8');
1914
+ dockerfilePath = candidatePath;
1915
+ if (dockerfile.includes('USER root') || !dockerfile.includes('USER ')) {
1916
+ hasSecureDockerfile = false;
1917
+ }
1918
+ break; // Use the first Dockerfile found
1919
+ }
1920
+ catch {
1921
+ // File not found, try next candidate
1893
1922
  }
1894
- }
1895
- catch {
1896
- // No Dockerfile, that's fine
1897
1923
  }
1898
1924
  findings.push({
1899
1925
  checkId: 'PROC-001',
@@ -1902,6 +1928,7 @@ dist/
1902
1928
  category: 'process',
1903
1929
  severity: 'high',
1904
1930
  passed: hasSecureDockerfile,
1931
+ file: !hasSecureDockerfile && dockerfilePath ? path.relative(targetDir, dockerfilePath) : undefined,
1905
1932
  message: hasSecureDockerfile
1906
1933
  ? 'Container runs as non-root user or no Dockerfile present'
1907
1934
  : 'Dockerfile runs as root - add USER directive for non-root user',
@@ -5177,7 +5204,7 @@ dist/
5177
5204
  message: `Skill matches known malicious pattern: "${matchedPattern}"`,
5178
5205
  file: relativePath,
5179
5206
  fixable: false,
5180
- fix: 'Remove this skill immediately - it matches known malware from the ClawHavoc campaign',
5207
+ fix: 'Remove this skill -- it matches known malware from the ClawHavoc campaign',
5181
5208
  });
5182
5209
  }
5183
5210
  // SUPPLY-004: Version Drift Detection
@@ -5209,7 +5236,7 @@ dist/
5209
5236
  message: `Known C2 IP address found: ${ip}`,
5210
5237
  file: relativePath,
5211
5238
  fixable: false,
5212
- fix: 'Remove this skill immediately - contains known malware C2 infrastructure',
5239
+ fix: 'Remove this skill -- contains known malware C2 infrastructure',
5213
5240
  });
5214
5241
  break;
5215
5242
  }
@@ -5227,7 +5254,7 @@ dist/
5227
5254
  message: `Known malware filename referenced: "${filename}"`,
5228
5255
  file: relativePath,
5229
5256
  fixable: false,
5230
- fix: 'Remove this skill immediately - references known malware payload',
5257
+ fix: 'Remove this skill -- references known malware payload',
5231
5258
  });
5232
5259
  break;
5233
5260
  }