ship-safe 6.1.1 → 6.3.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 +748 -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 +85 -84
- package/cli/agents/injection-tester.js +500 -500
- package/cli/agents/legal-risk-agent.js +302 -0
- 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 +464 -426
- package/cli/commands/agent.js +608 -608
- package/cli/commands/audit.js +1006 -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/legal.js +158 -0
- 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
package/cli/utils/output.js
CHANGED
|
@@ -1,230 +1,230 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Output Utilities
|
|
3
|
-
* ================
|
|
4
|
-
*
|
|
5
|
-
* Consistent, pretty terminal output for the CLI.
|
|
6
|
-
* Uses chalk for colors and provides helper functions
|
|
7
|
-
* for common output patterns.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import chalk from 'chalk';
|
|
11
|
-
|
|
12
|
-
// =============================================================================
|
|
13
|
-
// SEVERITY COLORS
|
|
14
|
-
// =============================================================================
|
|
15
|
-
|
|
16
|
-
export const severityColors = {
|
|
17
|
-
critical: chalk.bgRed.white.bold,
|
|
18
|
-
high: chalk.red.bold,
|
|
19
|
-
medium: chalk.yellow,
|
|
20
|
-
low: chalk.blue
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const severityIcons = {
|
|
24
|
-
critical: '\u2620\ufe0f ', // skull
|
|
25
|
-
high: '\u26a0\ufe0f ', // warning
|
|
26
|
-
medium: '\u26a1', // lightning
|
|
27
|
-
low: '\u2139\ufe0f ' // info
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
// =============================================================================
|
|
31
|
-
// OUTPUT HELPERS
|
|
32
|
-
// =============================================================================
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Print a section header
|
|
36
|
-
*/
|
|
37
|
-
export function header(text) {
|
|
38
|
-
console.log();
|
|
39
|
-
console.log(chalk.cyan.bold('='.repeat(60)));
|
|
40
|
-
console.log(chalk.cyan.bold(` ${text}`));
|
|
41
|
-
console.log(chalk.cyan.bold('='.repeat(60)));
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Print a subheader
|
|
46
|
-
*/
|
|
47
|
-
export function subheader(text) {
|
|
48
|
-
console.log();
|
|
49
|
-
console.log(chalk.white.bold(text));
|
|
50
|
-
console.log(chalk.gray('-'.repeat(text.length)));
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Print a success message
|
|
55
|
-
*/
|
|
56
|
-
export function success(text) {
|
|
57
|
-
console.log(chalk.green('\u2714 ') + text);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Print a warning message
|
|
62
|
-
*/
|
|
63
|
-
export function warning(text) {
|
|
64
|
-
console.log(chalk.yellow('\u26a0 ') + text);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Print an error message
|
|
69
|
-
*/
|
|
70
|
-
export function error(text) {
|
|
71
|
-
console.log(chalk.red('\u2718 ') + text);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Print an info message
|
|
76
|
-
*/
|
|
77
|
-
export function info(text) {
|
|
78
|
-
console.log(chalk.blue('\u2139 ') + text);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const confidenceColors = {
|
|
82
|
-
high: chalk.red,
|
|
83
|
-
medium: chalk.yellow,
|
|
84
|
-
low: chalk.gray,
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Print a finding (secret detected)
|
|
89
|
-
*/
|
|
90
|
-
export function finding(file, line, patternName, severity, matched, description, confidence) {
|
|
91
|
-
const color = severityColors[severity] || chalk.white;
|
|
92
|
-
const icon = severityIcons[severity] || '';
|
|
93
|
-
const confColor = confidenceColors[confidence] || chalk.gray;
|
|
94
|
-
const confLabel = confidence ? ` ${chalk.gray('Confidence:')} ${confColor(confidence)}` : '';
|
|
95
|
-
|
|
96
|
-
console.log();
|
|
97
|
-
console.log(chalk.white.bold(`${file}:${line}`));
|
|
98
|
-
console.log(` ${icon}${color(`[${severity.toUpperCase()}]`)} ${chalk.white(patternName)}`);
|
|
99
|
-
console.log(` ${chalk.gray('Found:')} ${chalk.yellow(maskSecret(matched))}`);
|
|
100
|
-
if (confLabel) console.log(confLabel);
|
|
101
|
-
console.log(` ${chalk.gray('Why:')} ${description}`);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Print a vulnerability finding (code issue — show matched code, not masked)
|
|
106
|
-
*/
|
|
107
|
-
export function vulnerabilityFinding(file, line, patternName, severity, matched, description) {
|
|
108
|
-
const color = severityColors[severity] || chalk.white;
|
|
109
|
-
const icon = severityIcons[severity] || '';
|
|
110
|
-
const snippet = matched.length > 80 ? matched.slice(0, 80) + '…' : matched;
|
|
111
|
-
|
|
112
|
-
console.log();
|
|
113
|
-
console.log(chalk.white.bold(`${file}:${line}`));
|
|
114
|
-
console.log(` ${icon}${color(`[${severity.toUpperCase()}]`)} ${chalk.white(patternName)}`);
|
|
115
|
-
console.log(` ${chalk.gray('Code:')} ${chalk.cyan(snippet)}`);
|
|
116
|
-
console.log(` ${chalk.gray('Why:')} ${description}`);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Mask the middle of a secret for safe display
|
|
121
|
-
*/
|
|
122
|
-
export function maskSecret(secret) {
|
|
123
|
-
if (secret.length <= 6) {
|
|
124
|
-
return '***';
|
|
125
|
-
}
|
|
126
|
-
if (secret.length <= 12) {
|
|
127
|
-
return secret.substring(0, 3) + '***';
|
|
128
|
-
}
|
|
129
|
-
return secret.substring(0, 4) + '***' + secret.substring(secret.length - 4);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Print a summary box
|
|
134
|
-
*
|
|
135
|
-
* stats can include:
|
|
136
|
-
* total, critical, high, medium, filesScanned
|
|
137
|
-
* secretsTotal (optional), vulnsTotal (optional)
|
|
138
|
-
*/
|
|
139
|
-
export function summary(stats) {
|
|
140
|
-
console.log();
|
|
141
|
-
console.log(chalk.cyan('='.repeat(60)));
|
|
142
|
-
|
|
143
|
-
if (stats.total === 0) {
|
|
144
|
-
console.log(chalk.green.bold(' \u2714 No issues detected!'));
|
|
145
|
-
} else {
|
|
146
|
-
const secretsTotal = stats.secretsTotal ?? stats.total;
|
|
147
|
-
const vulnsTotal = stats.vulnsTotal ?? 0;
|
|
148
|
-
|
|
149
|
-
if (secretsTotal > 0) {
|
|
150
|
-
console.log(chalk.red.bold(` \u26a0 Found ${secretsTotal} secret(s)`));
|
|
151
|
-
}
|
|
152
|
-
if (vulnsTotal > 0) {
|
|
153
|
-
console.log(chalk.yellow.bold(` \u26a0 Found ${vulnsTotal} code vulnerability/vulnerabilities`));
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
if (stats.critical > 0) {
|
|
157
|
-
console.log(chalk.red(` \u2022 Critical: ${stats.critical}`));
|
|
158
|
-
}
|
|
159
|
-
if (stats.high > 0) {
|
|
160
|
-
console.log(chalk.red(` \u2022 High: ${stats.high}`));
|
|
161
|
-
}
|
|
162
|
-
if (stats.medium > 0) {
|
|
163
|
-
console.log(chalk.yellow(` \u2022 Medium: ${stats.medium}`));
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
console.log(chalk.gray(` Files scanned: ${stats.filesScanned}`));
|
|
168
|
-
console.log(chalk.cyan('='.repeat(60)));
|
|
169
|
-
console.log(chalk.gray(` Cloud dashboard & team scanning: `) + chalk.cyan('https://shipsafecli.com'));
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Print recommended actions after finding code vulnerabilities
|
|
174
|
-
*/
|
|
175
|
-
export function vulnRecommendations() {
|
|
176
|
-
console.log();
|
|
177
|
-
console.log(chalk.yellow.bold('Code Vulnerability Actions:'));
|
|
178
|
-
console.log();
|
|
179
|
-
console.log(chalk.white('1.') + ' Fix the flagged code patterns (see "Why" descriptions above)');
|
|
180
|
-
console.log(chalk.white('2.') + ' Use # ship-safe-ignore on lines that are safe (e.g. internal tools, controlled input)');
|
|
181
|
-
console.log(chalk.white('3.') + ' Run npx ship-safe checklist for a full launch-day security review');
|
|
182
|
-
console.log();
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Print recommended actions after finding secrets
|
|
187
|
-
*/
|
|
188
|
-
export function recommendations() {
|
|
189
|
-
console.log();
|
|
190
|
-
console.log(chalk.cyan.bold('Recommended Actions:'));
|
|
191
|
-
console.log();
|
|
192
|
-
console.log(chalk.white('1.') + ' Move secrets to environment variables (.env file)');
|
|
193
|
-
console.log(chalk.white('2.') + ' Add .env to your .gitignore');
|
|
194
|
-
console.log(chalk.white('3.') + chalk.yellow(' If already committed:'));
|
|
195
|
-
console.log(chalk.gray(' \u2022 Rotate the compromised credentials immediately'));
|
|
196
|
-
console.log(chalk.gray(' \u2022 Use git-filter-repo or BFG Repo-Cleaner to remove from history'));
|
|
197
|
-
console.log(chalk.gray(' \u2022 Remember: deleting doesn\'t remove git history!'));
|
|
198
|
-
console.log();
|
|
199
|
-
console.log(chalk.white('4.') + ' Set up pre-commit hooks to catch this automatically:');
|
|
200
|
-
console.log(chalk.gray(' npm install --save-dev husky'));
|
|
201
|
-
console.log(chalk.gray(' npx husky add .husky/pre-commit "npx ship-safe scan ."'));
|
|
202
|
-
console.log();
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Print a checklist item
|
|
207
|
-
*/
|
|
208
|
-
export function checklistItem(number, title, checked = null) {
|
|
209
|
-
const checkbox = checked === null
|
|
210
|
-
? chalk.gray('[ ]')
|
|
211
|
-
: checked
|
|
212
|
-
? chalk.green('[\u2714]')
|
|
213
|
-
: chalk.red('[\u2718]');
|
|
214
|
-
|
|
215
|
-
console.log(`${checkbox} ${chalk.white.bold(`${number}.`)} ${title}`);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Print progress (for verbose mode)
|
|
220
|
-
*/
|
|
221
|
-
export function progress(text) {
|
|
222
|
-
process.stdout.write(chalk.gray(`\r${text}`));
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Clear the current line
|
|
227
|
-
*/
|
|
228
|
-
export function clearLine() {
|
|
229
|
-
process.stdout.write('\r' + ' '.repeat(80) + '\r');
|
|
230
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Output Utilities
|
|
3
|
+
* ================
|
|
4
|
+
*
|
|
5
|
+
* Consistent, pretty terminal output for the CLI.
|
|
6
|
+
* Uses chalk for colors and provides helper functions
|
|
7
|
+
* for common output patterns.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import chalk from 'chalk';
|
|
11
|
+
|
|
12
|
+
// =============================================================================
|
|
13
|
+
// SEVERITY COLORS
|
|
14
|
+
// =============================================================================
|
|
15
|
+
|
|
16
|
+
export const severityColors = {
|
|
17
|
+
critical: chalk.bgRed.white.bold,
|
|
18
|
+
high: chalk.red.bold,
|
|
19
|
+
medium: chalk.yellow,
|
|
20
|
+
low: chalk.blue
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const severityIcons = {
|
|
24
|
+
critical: '\u2620\ufe0f ', // skull
|
|
25
|
+
high: '\u26a0\ufe0f ', // warning
|
|
26
|
+
medium: '\u26a1', // lightning
|
|
27
|
+
low: '\u2139\ufe0f ' // info
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// =============================================================================
|
|
31
|
+
// OUTPUT HELPERS
|
|
32
|
+
// =============================================================================
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Print a section header
|
|
36
|
+
*/
|
|
37
|
+
export function header(text) {
|
|
38
|
+
console.log();
|
|
39
|
+
console.log(chalk.cyan.bold('='.repeat(60)));
|
|
40
|
+
console.log(chalk.cyan.bold(` ${text}`));
|
|
41
|
+
console.log(chalk.cyan.bold('='.repeat(60)));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Print a subheader
|
|
46
|
+
*/
|
|
47
|
+
export function subheader(text) {
|
|
48
|
+
console.log();
|
|
49
|
+
console.log(chalk.white.bold(text));
|
|
50
|
+
console.log(chalk.gray('-'.repeat(text.length)));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Print a success message
|
|
55
|
+
*/
|
|
56
|
+
export function success(text) {
|
|
57
|
+
console.log(chalk.green('\u2714 ') + text);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Print a warning message
|
|
62
|
+
*/
|
|
63
|
+
export function warning(text) {
|
|
64
|
+
console.log(chalk.yellow('\u26a0 ') + text);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Print an error message
|
|
69
|
+
*/
|
|
70
|
+
export function error(text) {
|
|
71
|
+
console.log(chalk.red('\u2718 ') + text);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Print an info message
|
|
76
|
+
*/
|
|
77
|
+
export function info(text) {
|
|
78
|
+
console.log(chalk.blue('\u2139 ') + text);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const confidenceColors = {
|
|
82
|
+
high: chalk.red,
|
|
83
|
+
medium: chalk.yellow,
|
|
84
|
+
low: chalk.gray,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Print a finding (secret detected)
|
|
89
|
+
*/
|
|
90
|
+
export function finding(file, line, patternName, severity, matched, description, confidence) {
|
|
91
|
+
const color = severityColors[severity] || chalk.white;
|
|
92
|
+
const icon = severityIcons[severity] || '';
|
|
93
|
+
const confColor = confidenceColors[confidence] || chalk.gray;
|
|
94
|
+
const confLabel = confidence ? ` ${chalk.gray('Confidence:')} ${confColor(confidence)}` : '';
|
|
95
|
+
|
|
96
|
+
console.log();
|
|
97
|
+
console.log(chalk.white.bold(`${file}:${line}`));
|
|
98
|
+
console.log(` ${icon}${color(`[${severity.toUpperCase()}]`)} ${chalk.white(patternName)}`);
|
|
99
|
+
console.log(` ${chalk.gray('Found:')} ${chalk.yellow(maskSecret(matched))}`);
|
|
100
|
+
if (confLabel) console.log(confLabel);
|
|
101
|
+
console.log(` ${chalk.gray('Why:')} ${description}`);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Print a vulnerability finding (code issue — show matched code, not masked)
|
|
106
|
+
*/
|
|
107
|
+
export function vulnerabilityFinding(file, line, patternName, severity, matched, description) {
|
|
108
|
+
const color = severityColors[severity] || chalk.white;
|
|
109
|
+
const icon = severityIcons[severity] || '';
|
|
110
|
+
const snippet = matched.length > 80 ? matched.slice(0, 80) + '…' : matched;
|
|
111
|
+
|
|
112
|
+
console.log();
|
|
113
|
+
console.log(chalk.white.bold(`${file}:${line}`));
|
|
114
|
+
console.log(` ${icon}${color(`[${severity.toUpperCase()}]`)} ${chalk.white(patternName)}`);
|
|
115
|
+
console.log(` ${chalk.gray('Code:')} ${chalk.cyan(snippet)}`);
|
|
116
|
+
console.log(` ${chalk.gray('Why:')} ${description}`);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Mask the middle of a secret for safe display
|
|
121
|
+
*/
|
|
122
|
+
export function maskSecret(secret) {
|
|
123
|
+
if (secret.length <= 6) {
|
|
124
|
+
return '***';
|
|
125
|
+
}
|
|
126
|
+
if (secret.length <= 12) {
|
|
127
|
+
return secret.substring(0, 3) + '***';
|
|
128
|
+
}
|
|
129
|
+
return secret.substring(0, 4) + '***' + secret.substring(secret.length - 4);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Print a summary box
|
|
134
|
+
*
|
|
135
|
+
* stats can include:
|
|
136
|
+
* total, critical, high, medium, filesScanned
|
|
137
|
+
* secretsTotal (optional), vulnsTotal (optional)
|
|
138
|
+
*/
|
|
139
|
+
export function summary(stats) {
|
|
140
|
+
console.log();
|
|
141
|
+
console.log(chalk.cyan('='.repeat(60)));
|
|
142
|
+
|
|
143
|
+
if (stats.total === 0) {
|
|
144
|
+
console.log(chalk.green.bold(' \u2714 No issues detected!'));
|
|
145
|
+
} else {
|
|
146
|
+
const secretsTotal = stats.secretsTotal ?? stats.total;
|
|
147
|
+
const vulnsTotal = stats.vulnsTotal ?? 0;
|
|
148
|
+
|
|
149
|
+
if (secretsTotal > 0) {
|
|
150
|
+
console.log(chalk.red.bold(` \u26a0 Found ${secretsTotal} secret(s)`));
|
|
151
|
+
}
|
|
152
|
+
if (vulnsTotal > 0) {
|
|
153
|
+
console.log(chalk.yellow.bold(` \u26a0 Found ${vulnsTotal} code vulnerability/vulnerabilities`));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (stats.critical > 0) {
|
|
157
|
+
console.log(chalk.red(` \u2022 Critical: ${stats.critical}`));
|
|
158
|
+
}
|
|
159
|
+
if (stats.high > 0) {
|
|
160
|
+
console.log(chalk.red(` \u2022 High: ${stats.high}`));
|
|
161
|
+
}
|
|
162
|
+
if (stats.medium > 0) {
|
|
163
|
+
console.log(chalk.yellow(` \u2022 Medium: ${stats.medium}`));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
console.log(chalk.gray(` Files scanned: ${stats.filesScanned}`));
|
|
168
|
+
console.log(chalk.cyan('='.repeat(60)));
|
|
169
|
+
console.log(chalk.gray(` Cloud dashboard & team scanning: `) + chalk.cyan('https://shipsafecli.com'));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Print recommended actions after finding code vulnerabilities
|
|
174
|
+
*/
|
|
175
|
+
export function vulnRecommendations() {
|
|
176
|
+
console.log();
|
|
177
|
+
console.log(chalk.yellow.bold('Code Vulnerability Actions:'));
|
|
178
|
+
console.log();
|
|
179
|
+
console.log(chalk.white('1.') + ' Fix the flagged code patterns (see "Why" descriptions above)');
|
|
180
|
+
console.log(chalk.white('2.') + ' Use # ship-safe-ignore on lines that are safe (e.g. internal tools, controlled input)');
|
|
181
|
+
console.log(chalk.white('3.') + ' Run npx ship-safe checklist for a full launch-day security review');
|
|
182
|
+
console.log();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Print recommended actions after finding secrets
|
|
187
|
+
*/
|
|
188
|
+
export function recommendations() {
|
|
189
|
+
console.log();
|
|
190
|
+
console.log(chalk.cyan.bold('Recommended Actions:'));
|
|
191
|
+
console.log();
|
|
192
|
+
console.log(chalk.white('1.') + ' Move secrets to environment variables (.env file)');
|
|
193
|
+
console.log(chalk.white('2.') + ' Add .env to your .gitignore');
|
|
194
|
+
console.log(chalk.white('3.') + chalk.yellow(' If already committed:'));
|
|
195
|
+
console.log(chalk.gray(' \u2022 Rotate the compromised credentials immediately'));
|
|
196
|
+
console.log(chalk.gray(' \u2022 Use git-filter-repo or BFG Repo-Cleaner to remove from history'));
|
|
197
|
+
console.log(chalk.gray(' \u2022 Remember: deleting doesn\'t remove git history!'));
|
|
198
|
+
console.log();
|
|
199
|
+
console.log(chalk.white('4.') + ' Set up pre-commit hooks to catch this automatically:');
|
|
200
|
+
console.log(chalk.gray(' npm install --save-dev husky'));
|
|
201
|
+
console.log(chalk.gray(' npx husky add .husky/pre-commit "npx ship-safe scan ."'));
|
|
202
|
+
console.log();
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Print a checklist item
|
|
207
|
+
*/
|
|
208
|
+
export function checklistItem(number, title, checked = null) {
|
|
209
|
+
const checkbox = checked === null
|
|
210
|
+
? chalk.gray('[ ]')
|
|
211
|
+
: checked
|
|
212
|
+
? chalk.green('[\u2714]')
|
|
213
|
+
: chalk.red('[\u2718]');
|
|
214
|
+
|
|
215
|
+
console.log(`${checkbox} ${chalk.white.bold(`${number}.`)} ${title}`);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Print progress (for verbose mode)
|
|
220
|
+
*/
|
|
221
|
+
export function progress(text) {
|
|
222
|
+
process.stdout.write(chalk.gray(`\r${text}`));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Clear the current line
|
|
227
|
+
*/
|
|
228
|
+
export function clearLine() {
|
|
229
|
+
process.stdout.write('\r' + ' '.repeat(80) + '\r');
|
|
230
|
+
}
|