ship-safe 6.1.1 → 6.2.0
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 +735 -641
- package/cli/agents/api-fuzzer.js +345 -345
- package/cli/agents/auth-bypass-agent.js +348 -348
- package/cli/agents/base-agent.js +272 -272
- package/cli/agents/cicd-scanner.js +236 -201
- package/cli/agents/config-auditor.js +521 -521
- package/cli/agents/deep-analyzer.js +6 -2
- package/cli/agents/git-history-scanner.js +170 -170
- package/cli/agents/html-reporter.js +568 -568
- package/cli/agents/index.js +84 -84
- package/cli/agents/injection-tester.js +500 -500
- package/cli/agents/llm-redteam.js +251 -251
- package/cli/agents/mobile-scanner.js +231 -231
- package/cli/agents/orchestrator.js +322 -322
- package/cli/agents/pii-compliance-agent.js +301 -301
- package/cli/agents/scoring-engine.js +248 -248
- package/cli/agents/supabase-rls-agent.js +154 -154
- package/cli/agents/supply-chain-agent.js +650 -507
- package/cli/bin/ship-safe.js +452 -426
- package/cli/commands/agent.js +608 -608
- package/cli/commands/audit.js +986 -980
- package/cli/commands/baseline.js +193 -193
- package/cli/commands/ci.js +342 -342
- package/cli/commands/deps.js +516 -516
- package/cli/commands/doctor.js +159 -159
- package/cli/commands/fix.js +218 -218
- package/cli/commands/hooks.js +268 -0
- package/cli/commands/init.js +407 -407
- package/cli/commands/mcp.js +304 -304
- package/cli/commands/red-team.js +7 -1
- package/cli/commands/remediate.js +798 -798
- package/cli/commands/rotate.js +571 -571
- package/cli/commands/scan.js +569 -569
- package/cli/commands/score.js +449 -449
- package/cli/commands/watch.js +281 -281
- package/cli/hooks/patterns.js +313 -0
- package/cli/hooks/post-tool-use.js +140 -0
- package/cli/hooks/pre-tool-use.js +186 -0
- package/cli/index.js +73 -69
- package/cli/providers/llm-provider.js +397 -287
- package/cli/utils/autofix-rules.js +74 -74
- package/cli/utils/cache-manager.js +311 -311
- package/cli/utils/output.js +230 -230
- package/cli/utils/patterns.js +1121 -1121
- package/cli/utils/pdf-generator.js +94 -94
- package/package.json +69 -69
- package/configs/supabase/rls-templates.sql +0 -242
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auto-Fix Rules
|
|
3
|
-
* ================
|
|
4
|
-
*
|
|
5
|
-
* Pure functions that transform a source line to fix a security issue.
|
|
6
|
-
* Each rule maps to a finding rule name from the agents.
|
|
7
|
-
*
|
|
8
|
-
* Used by `ship-safe remediate --all` to auto-fix agent-detected issues
|
|
9
|
-
* beyond just secrets.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
export const AUTOFIX_RULES = [
|
|
13
|
-
{
|
|
14
|
-
rule: 'TLS_REJECT_UNAUTHORIZED',
|
|
15
|
-
match: /rejectUnauthorized\s*:\s*false/g,
|
|
16
|
-
replace: (line) => line.replace(/rejectUnauthorized\s*:\s*false/, 'rejectUnauthorized: true // TODO: configure proper CA bundle'),
|
|
17
|
-
description: 'Enable TLS certificate verification',
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
rule: 'DOCKER_LATEST_TAG',
|
|
21
|
-
match: /FROM\s+(\S+):latest/gi,
|
|
22
|
-
replace: (line) => {
|
|
23
|
-
return line.replace(/FROM\s+(\S+):latest/i, (_, image) => {
|
|
24
|
-
const pinned = { node: 'node:20-alpine', python: 'python:3.12-slim', nginx: 'nginx:1.25-alpine', ruby: 'ruby:3.3-slim' };
|
|
25
|
-
return `FROM ${pinned[image] || image + ':latest'} # TODO: pin to specific version`;
|
|
26
|
-
});
|
|
27
|
-
},
|
|
28
|
-
description: 'Pin Docker base image to a specific version',
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
rule: 'DEBUG_MODE_PRODUCTION',
|
|
32
|
-
match: /(?:DEBUG|debug)\s*[:=]\s*(?:true|True|1|['"]true['"])/g,
|
|
33
|
-
replace: (line) => line
|
|
34
|
-
.replace(/DEBUG\s*=\s*True/, 'DEBUG = False')
|
|
35
|
-
.replace(/DEBUG\s*=\s*true/, 'DEBUG = false')
|
|
36
|
-
.replace(/debug\s*:\s*true/, 'debug: false')
|
|
37
|
-
.replace(/debug\s*=\s*['"]true['"]/, "debug = 'false'"),
|
|
38
|
-
description: 'Disable debug mode for production',
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
rule: 'XSS_DANGEROUS_INNER_HTML',
|
|
42
|
-
match: /dangerouslySetInnerHTML\s*=\s*\{\s*\{\s*__html\s*:\s*([^}]+)\}\s*\}/g, // ship-safe-ignore: autofix pattern
|
|
43
|
-
replace: (line) => {
|
|
44
|
-
return line.replace(
|
|
45
|
-
/dangerouslySetInnerHTML\s*=\s*\{\s*\{\s*__html\s*:\s*([^}]+)\}\s*\}/,
|
|
46
|
-
(_, value) => `dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(${value.trim()}) }}` // ship-safe-ignore: replacement template
|
|
47
|
-
);
|
|
48
|
-
},
|
|
49
|
-
description: 'Wrap dangerouslySetInnerHTML value in DOMPurify.sanitize()',
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
rule: 'CMD_INJECTION_SHELL_TRUE',
|
|
53
|
-
match: /shell\s*:\s*true/g,
|
|
54
|
-
replace: (line) => line.replace(/shell\s*:\s*true/, 'shell: false // TODO: ensure command works without shell'),
|
|
55
|
-
description: 'Disable shell execution in spawn/exec',
|
|
56
|
-
},
|
|
57
|
-
];
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Check if a finding's rule has an autofix available.
|
|
61
|
-
*/
|
|
62
|
-
export function hasAutofix(rule) {
|
|
63
|
-
return AUTOFIX_RULES.some(r => r.rule === rule);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Apply an autofix rule to a line.
|
|
68
|
-
* Returns the fixed line, or the original if no rule matches.
|
|
69
|
-
*/
|
|
70
|
-
export function applyAutofix(rule, line) {
|
|
71
|
-
const fixRule = AUTOFIX_RULES.find(r => r.rule === rule);
|
|
72
|
-
if (!fixRule) return line;
|
|
73
|
-
return fixRule.replace(line);
|
|
74
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Auto-Fix Rules
|
|
3
|
+
* ================
|
|
4
|
+
*
|
|
5
|
+
* Pure functions that transform a source line to fix a security issue.
|
|
6
|
+
* Each rule maps to a finding rule name from the agents.
|
|
7
|
+
*
|
|
8
|
+
* Used by `ship-safe remediate --all` to auto-fix agent-detected issues
|
|
9
|
+
* beyond just secrets.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const AUTOFIX_RULES = [
|
|
13
|
+
{
|
|
14
|
+
rule: 'TLS_REJECT_UNAUTHORIZED',
|
|
15
|
+
match: /rejectUnauthorized\s*:\s*false/g,
|
|
16
|
+
replace: (line) => line.replace(/rejectUnauthorized\s*:\s*false/, 'rejectUnauthorized: true // TODO: configure proper CA bundle'),
|
|
17
|
+
description: 'Enable TLS certificate verification',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
rule: 'DOCKER_LATEST_TAG',
|
|
21
|
+
match: /FROM\s+(\S+):latest/gi,
|
|
22
|
+
replace: (line) => {
|
|
23
|
+
return line.replace(/FROM\s+(\S+):latest/i, (_, image) => {
|
|
24
|
+
const pinned = { node: 'node:20-alpine', python: 'python:3.12-slim', nginx: 'nginx:1.25-alpine', ruby: 'ruby:3.3-slim' };
|
|
25
|
+
return `FROM ${pinned[image] || image + ':latest'} # TODO: pin to specific version`;
|
|
26
|
+
});
|
|
27
|
+
},
|
|
28
|
+
description: 'Pin Docker base image to a specific version',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
rule: 'DEBUG_MODE_PRODUCTION',
|
|
32
|
+
match: /(?:DEBUG|debug)\s*[:=]\s*(?:true|True|1|['"]true['"])/g,
|
|
33
|
+
replace: (line) => line
|
|
34
|
+
.replace(/DEBUG\s*=\s*True/, 'DEBUG = False')
|
|
35
|
+
.replace(/DEBUG\s*=\s*true/, 'DEBUG = false')
|
|
36
|
+
.replace(/debug\s*:\s*true/, 'debug: false')
|
|
37
|
+
.replace(/debug\s*=\s*['"]true['"]/, "debug = 'false'"),
|
|
38
|
+
description: 'Disable debug mode for production',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
rule: 'XSS_DANGEROUS_INNER_HTML',
|
|
42
|
+
match: /dangerouslySetInnerHTML\s*=\s*\{\s*\{\s*__html\s*:\s*([^}]+)\}\s*\}/g, // ship-safe-ignore: autofix pattern
|
|
43
|
+
replace: (line) => {
|
|
44
|
+
return line.replace(
|
|
45
|
+
/dangerouslySetInnerHTML\s*=\s*\{\s*\{\s*__html\s*:\s*([^}]+)\}\s*\}/,
|
|
46
|
+
(_, value) => `dangerouslySetInnerHTML={{ __html: DOMPurify.sanitize(${value.trim()}) }}` // ship-safe-ignore: replacement template
|
|
47
|
+
);
|
|
48
|
+
},
|
|
49
|
+
description: 'Wrap dangerouslySetInnerHTML value in DOMPurify.sanitize()',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
rule: 'CMD_INJECTION_SHELL_TRUE',
|
|
53
|
+
match: /shell\s*:\s*true/g,
|
|
54
|
+
replace: (line) => line.replace(/shell\s*:\s*true/, 'shell: false // TODO: ensure command works without shell'),
|
|
55
|
+
description: 'Disable shell execution in spawn/exec',
|
|
56
|
+
},
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Check if a finding's rule has an autofix available.
|
|
61
|
+
*/
|
|
62
|
+
export function hasAutofix(rule) {
|
|
63
|
+
return AUTOFIX_RULES.some(r => r.rule === rule);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Apply an autofix rule to a line.
|
|
68
|
+
* Returns the fixed line, or the original if no rule matches.
|
|
69
|
+
*/
|
|
70
|
+
export function applyAutofix(rule, line) {
|
|
71
|
+
const fixRule = AUTOFIX_RULES.find(r => r.rule === rule);
|
|
72
|
+
if (!fixRule) return line;
|
|
73
|
+
return fixRule.replace(line);
|
|
74
|
+
}
|