periderm-cli 0.1.26 → 0.1.28
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/dist/scanner/checks.js +10 -0
- package/dist/scanner/repo-checks.js +23 -10
- package/package.json +1 -1
package/dist/scanner/checks.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* we can detect via regex + AST without a full type-checker.
|
|
7
7
|
*/
|
|
8
8
|
import traverseDefault from "@babel/traverse";
|
|
9
|
+
import { reportCliError } from "../error-report.js";
|
|
9
10
|
// @babel/traverse ships CJS; pick the default export defensively.
|
|
10
11
|
const traverse = traverseDefault.default
|
|
11
12
|
?? traverseDefault;
|
|
@@ -726,6 +727,15 @@ export function runChecks(source, file, ast) {
|
|
|
726
727
|
out.push(...c(source, file, ast));
|
|
727
728
|
}
|
|
728
729
|
catch (e) {
|
|
730
|
+
const err = e instanceof Error ? e : new Error(String(e));
|
|
731
|
+
// Report the crash silently in the background
|
|
732
|
+
reportCliError({
|
|
733
|
+
source: "cli-scan",
|
|
734
|
+
message: `Scanner rule crashed on ${file}`,
|
|
735
|
+
stack: err.stack,
|
|
736
|
+
where: c.name || "anonymous check",
|
|
737
|
+
extra: { file, rawError: String(e) }
|
|
738
|
+
}).catch(() => { });
|
|
729
739
|
out.push(mkFinding({ id: "internal-error", category: "Runtime Stability", severity: "high", file, line: 1, message: `Scanner crashed: ${e}`, why: "Internal exception in scanner rule.", fix: "Report this issue.", aiPrompt: "Fix the crash in the scanner rule." }));
|
|
730
740
|
}
|
|
731
741
|
}
|
|
@@ -40,16 +40,29 @@ export async function runRepoChecks(root, _files) {
|
|
|
40
40
|
}
|
|
41
41
|
// .env.example
|
|
42
42
|
if (!(await has(".env.example"))) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
let usesEnvVars = false;
|
|
44
|
+
for (const abs of _files) {
|
|
45
|
+
const rel = path.relative(root, abs);
|
|
46
|
+
if (!/\.(tsx|jsx|ts|js|mjs|cjs|svelte|vue|astro)$/.test(rel))
|
|
47
|
+
continue;
|
|
48
|
+
const chunk = await readMaybe(abs);
|
|
49
|
+
if (chunk && /(process\.env|import\.meta\.env)/.test(chunk)) {
|
|
50
|
+
usesEnvVars = true;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (usesEnvVars) {
|
|
55
|
+
out.push({
|
|
56
|
+
id: "missing-env-example",
|
|
57
|
+
category: "Deployment & Testing Readiness",
|
|
58
|
+
severity: "medium",
|
|
59
|
+
file: ".env.example", line: 1,
|
|
60
|
+
message: ".env.example is missing.",
|
|
61
|
+
why: "Anyone cloning the repo has to guess which env vars are required.",
|
|
62
|
+
fix: "Create a .env.example listing every env var with a placeholder value (no secrets).",
|
|
63
|
+
aiPrompt: "Scan the codebase for process.env.* and import.meta.env.* reads and produce a .env.example file listing every variable found with placeholder values.",
|
|
64
|
+
});
|
|
65
|
+
}
|
|
53
66
|
}
|
|
54
67
|
// public dir favicon
|
|
55
68
|
const pkgRaw = await readMaybe(path.join(root, "package.json"));
|