safelaunch 1.0.37 → 1.0.40
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/bin/safelaunch.js +7 -0
- package/package.json +1 -1
- package/src/scan.js +7 -11
package/bin/safelaunch.js
CHANGED
|
@@ -59,6 +59,7 @@ for (const a of args) {
|
|
|
59
59
|
}
|
|
60
60
|
const hookMode = flags["--hook"] === true;
|
|
61
61
|
const silent = flags["--silent"] === true;
|
|
62
|
+
const jsonMode = flags["--json"] === true;
|
|
62
63
|
|
|
63
64
|
// ─── Dispatch ─────────────────────────────────────────────────────────────────
|
|
64
65
|
(async () => {
|
|
@@ -89,6 +90,12 @@ const silent = flags["--silent"] === true;
|
|
|
89
90
|
|
|
90
91
|
// ── scan ────────────────────────────────────────────────────────────────
|
|
91
92
|
case "scan": {
|
|
93
|
+
if (jsonMode) {
|
|
94
|
+
const result = await runScan({ hookMode: false, quiet: true, cwd: process.cwd() });
|
|
95
|
+
const all = [...result.blockers, ...result.warnings, ...result.infos];
|
|
96
|
+
process.stdout.write(JSON.stringify({ blockers: result.blockers, warnings: result.warnings, infos: result.infos, all, elapsed: result.elapsed }, null, 2));
|
|
97
|
+
process.exit(0);
|
|
98
|
+
}
|
|
92
99
|
if (!hookMode && !silent) {
|
|
93
100
|
process.stdout.write(gray(`safelaunch v${version} — scanning...\n\n`));
|
|
94
101
|
}
|
package/package.json
CHANGED
package/src/scan.js
CHANGED
|
@@ -128,12 +128,7 @@ const IMPACTS = {
|
|
|
128
128
|
impact: "Known vulnerabilities exist that could be exploited. These should be fixed before deploying.",
|
|
129
129
|
fix: "Run npm audit fix or check npm audit for manual fixes.",
|
|
130
130
|
}),
|
|
131
|
-
|
|
132
|
-
title: `${count} high-severity vulnerability${count > 1 ? "ies" : "y"} in dependencies`,
|
|
133
|
-
impact: "Known vulnerabilities exist that could be exploited. These should be fixed before deploying.",
|
|
134
|
-
fix: "Run npm audit fix or check npm audit for manual fixes.",
|
|
135
|
-
}),
|
|
136
|
-
AUDIT_CRITICAL: (count) => ({
|
|
131
|
+
AUDIT_CRITICAL: (count) => ({
|
|
137
132
|
title: `${count} critical vulnerability${count > 1 ? "ies" : "y"} in dependencies`,
|
|
138
133
|
impact: "Known exploits exist for these packages. Shipping them puts your users and infrastructure at risk.",
|
|
139
134
|
fix: "Run npm audit fix or check npm audit for manual fixes.",
|
|
@@ -177,8 +172,9 @@ function loadManifest(cwd) {
|
|
|
177
172
|
|
|
178
173
|
function checkMissingEnvVars(cwd, envVars, manifest) {
|
|
179
174
|
const issues = [];
|
|
180
|
-
if (!manifest || !manifest.
|
|
181
|
-
for (const name of manifest.
|
|
175
|
+
if (!manifest || !manifest.envs) return issues;
|
|
176
|
+
for (const [name, meta] of Object.entries(manifest.envs)) {
|
|
177
|
+
if (!meta.required) continue;
|
|
182
178
|
if (!(name in envVars) && !process.env[name]) {
|
|
183
179
|
issues.push({ severity: "block", ...IMPACTS.MISSING_ENV_VAR(name) });
|
|
184
180
|
}
|
|
@@ -252,7 +248,7 @@ function checkTypeScript(cwd) {
|
|
|
252
248
|
const issues = [];
|
|
253
249
|
if (!fileExists(path.join(cwd, "tsconfig.json"))) return issues;
|
|
254
250
|
try {
|
|
255
|
-
execSync("npx tsc --noEmit", { cwd, encoding: "utf8", stdio: ["pipe","pipe","pipe"] });
|
|
251
|
+
execSync("npx tsc --noEmit", { cwd, encoding: "utf8", stdio: ["pipe","pipe","pipe"], timeout: 30000 });
|
|
256
252
|
} catch {
|
|
257
253
|
issues.push({ severity: "block", ...IMPACTS.TS_ERRORS() });
|
|
258
254
|
}
|
|
@@ -287,7 +283,7 @@ function checkNpmAudit(cwd) {
|
|
|
287
283
|
const issues = [];
|
|
288
284
|
if (!fileExists(path.join(cwd, "package.json"))) return issues;
|
|
289
285
|
try {
|
|
290
|
-
execSync("npm audit --json", { cwd, encoding: "utf8", stdio: ["pipe","pipe","pipe"] });
|
|
286
|
+
execSync("npm audit --json", { cwd, encoding: "utf8", stdio: ["pipe","pipe","pipe"], timeout: 15000 });
|
|
291
287
|
} catch (e) {
|
|
292
288
|
try {
|
|
293
289
|
const data = JSON.parse(e.stdout || "");
|
|
@@ -563,7 +559,7 @@ function checkDebugFlags(cwd) {
|
|
|
563
559
|
issues.push({ severity: "warn", ...IMPACTS.DEBUG_FLAG_ENABLED(key.trim()) });
|
|
564
560
|
}
|
|
565
561
|
if (k === 'NODE_ENV' && v === 'development') {
|
|
566
|
-
issues.push({ severity: "warn",
|
|
562
|
+
issues.push({ severity: "warn", title: `NODE_ENV is set to development`, impact: 'Running in development mode in production exposes stack traces and disables optimizations.', fix: 'Set NODE_ENV=production in your production environment.' });
|
|
567
563
|
}
|
|
568
564
|
}
|
|
569
565
|
return issues;
|