periderm-cli 0.1.56 → 0.1.59
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 +0 -1
- package/dist/index.js +34 -40
- package/dist/report/ai-instructions.js +1 -2
- package/dist/scanner/checks.js +93 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,7 +17,6 @@ Or use the install script from your Periderm dashboard docs (`curl -fsSL https:/
|
|
|
17
17
|
```bash
|
|
18
18
|
periderm login # authenticate once
|
|
19
19
|
periderm scan # scan + upload to your dashboard
|
|
20
|
-
periderm scan --local-only # local report only, no upload
|
|
21
20
|
periderm watch # rerun on file change
|
|
22
21
|
periderm whoami # show current token + plan
|
|
23
22
|
```
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ const program = new Command();
|
|
|
31
31
|
program
|
|
32
32
|
.name("periderm")
|
|
33
33
|
.description("A pre-launch checklist.")
|
|
34
|
-
.version("0.1.
|
|
34
|
+
.version("0.1.57");
|
|
35
35
|
// Easter egg: `periderm bless` — hidden, undocumented
|
|
36
36
|
program
|
|
37
37
|
.command("bless", { hidden: true })
|
|
@@ -58,7 +58,6 @@ program
|
|
|
58
58
|
program
|
|
59
59
|
.command("scan")
|
|
60
60
|
.description("Scan the current directory and write a markdown report.")
|
|
61
|
-
.option("--local-only", "Scan locally without uploading to your Periderm dashboard")
|
|
62
61
|
.option("--cwd <dir>", "Directory to scan", process.cwd())
|
|
63
62
|
.action(async (opts) => {
|
|
64
63
|
const root = path.resolve(opts.cwd);
|
|
@@ -157,45 +156,41 @@ program
|
|
|
157
156
|
await fs.writeFile(path.join(outDir, "ai-instructions.md"), getAiInstructions(readConfig().apiUrl), "utf8");
|
|
158
157
|
// Ignore all files in the .periderm folder to prevent leaking vulnerabilities
|
|
159
158
|
await fs.writeFile(path.join(outDir, ".gitignore"), "*\n", "utf8");
|
|
160
|
-
if (!
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
159
|
+
if (!cfg.token) {
|
|
160
|
+
console.info(chalk.yellow("no token configured — run `periderm login` first to sync to dashboard."));
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
const uploadSpinner = ora({ text: UPLOAD_MESSAGES[0], color: "cyan" }).start();
|
|
164
|
+
const uploadStarted = Date.now();
|
|
165
|
+
const stopUploadRotate = startRotatingMessages(uploadSpinner, UPLOAD_MESSAGES);
|
|
166
|
+
const res = await uploadScan(cfg.token, result);
|
|
167
|
+
await finishRotatingMessages(stopUploadRotate, uploadStarted);
|
|
168
|
+
if (res.error) {
|
|
169
|
+
uploadSpinner.fail(`upload failed: ${res.error}`);
|
|
170
|
+
if (res.error.includes("401") || res.error.includes("Invalid token") || res.error.includes("expired")) {
|
|
171
|
+
writeConfig({ ...cfg, token: undefined });
|
|
172
|
+
console.info(chalk.yellow("\nYour session expired or your token is invalid. Please run `periderm login` to authenticate again."));
|
|
173
|
+
}
|
|
174
|
+
// Throw so it gets caught by the crash reporter and sent to Formspree
|
|
175
|
+
throw new Error(`Upload failed: ${res.error}\nContext: Uploading scan for project ${result.projectName}`);
|
|
164
176
|
}
|
|
165
177
|
else {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
uploadSpinner.fail(`upload failed: ${res.error}`);
|
|
173
|
-
if (res.error.includes("401") || res.error.includes("Invalid token") || res.error.includes("expired")) {
|
|
174
|
-
writeConfig({ ...cfg, token: undefined });
|
|
175
|
-
console.info(chalk.yellow("\nYour session expired or your token is invalid. Please run `periderm login` to authenticate again."));
|
|
176
|
-
}
|
|
177
|
-
// Throw so it gets caught by the crash reporter and sent to Formspree
|
|
178
|
-
throw new Error(`Upload failed: ${res.error}\nContext: Uploading scan for project ${result.projectName}`);
|
|
178
|
+
uploadSpinner.succeed(`Uploaded! View it at: ${chalk.underline.cyan(`${cfg.apiUrl}/dashboard/scans/${res.id ?? ""}`)}`);
|
|
179
|
+
let formatQuota = "Unlimited";
|
|
180
|
+
let remainingNum = Infinity;
|
|
181
|
+
if (v.plan !== "unlimited" && v.scans_remaining !== undefined) {
|
|
182
|
+
remainingNum = Math.max(0, v.scans_remaining - 1);
|
|
183
|
+
formatQuota = `${remainingNum} scans`;
|
|
179
184
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
console.info(
|
|
189
|
-
console.info(chalk.bold.white("Quota : ") + chalk.yellow(formatQuota));
|
|
190
|
-
console.info("");
|
|
191
|
-
console.info(chalk.bold.white("[Next Steps]"));
|
|
192
|
-
console.info(chalk.white(" 1. Run AI Review ") + chalk.hex("#FF4D00")("$ periderm review --deep"));
|
|
193
|
-
console.info(chalk.white(" 2. Local only ") + chalk.hex("#FF4D00")("$ periderm scan --local-only"));
|
|
194
|
-
console.info(chalk.white(" 3. Log out ") + chalk.hex("#FF4D00")("$ periderm logout"));
|
|
195
|
-
console.info("");
|
|
196
|
-
if (remainingNum <= 3 && v.plan !== "unlimited") {
|
|
197
|
-
console.info(chalk.yellow(`⚠ Almost exhausted! Renew or upgrade at `) + chalk.underline.cyan(`${cfg.apiUrl}/dashboard/billing`));
|
|
198
|
-
}
|
|
185
|
+
console.info("");
|
|
186
|
+
console.info(chalk.bold.white("Quota : ") + chalk.yellow(formatQuota));
|
|
187
|
+
console.info("");
|
|
188
|
+
console.info(chalk.bold.white("[Next Steps]"));
|
|
189
|
+
console.info(chalk.white(" 1. Run AI Review ") + chalk.hex("#FF4D00")("$ periderm review --deep"));
|
|
190
|
+
console.info(chalk.white(" 2. Log out ") + chalk.hex("#FF4D00")("$ periderm logout"));
|
|
191
|
+
console.info("");
|
|
192
|
+
if (remainingNum <= 3 && v.plan !== "unlimited") {
|
|
193
|
+
console.info(chalk.yellow(`⚠ Almost exhausted! Renew or upgrade at `) + chalk.underline.cyan(`${cfg.apiUrl}/dashboard/billing`));
|
|
199
194
|
}
|
|
200
195
|
}
|
|
201
196
|
}
|
|
@@ -374,8 +369,7 @@ program
|
|
|
374
369
|
console.info("");
|
|
375
370
|
console.info(chalk.bold.white("[Next Steps]"));
|
|
376
371
|
console.info(chalk.white(" 1. Scan + upload ") + chalk.hex("#FF4D00")("$ periderm scan"));
|
|
377
|
-
console.info(chalk.white(" 2.
|
|
378
|
-
console.info(chalk.white(" 3. Log out ") + chalk.hex("#FF4D00")("$ periderm logout"));
|
|
372
|
+
console.info(chalk.white(" 2. Log out ") + chalk.hex("#FF4D00")("$ periderm logout"));
|
|
379
373
|
console.info("");
|
|
380
374
|
console.info(chalk.white("Need help? Visit ") + chalk.underline.cyan(`${apiUrl}/docs`) + chalk.white("\n"));
|
|
381
375
|
server.close();
|
|
@@ -57,7 +57,7 @@ You get a terminal verdict plus report files at:
|
|
|
57
57
|
- \`.periderm/last-report.md\`
|
|
58
58
|
- \`.periderm/last-report.json\`
|
|
59
59
|
|
|
60
|
-
Scans upload to your dashboard by default.
|
|
60
|
+
Scans upload to your dashboard by default.
|
|
61
61
|
|
|
62
62
|
### Project context (admin dashboards & monorepos)
|
|
63
63
|
Periderm detects project structure — not just folder names — to skip legal, SEO, and accessibility checks on internal admin surfaces. Override with \`.periderm/context.json\`:
|
|
@@ -79,7 +79,6 @@ When viewing scan reports, findings are broken down by severity:
|
|
|
79
79
|
|
|
80
80
|
### CLI commands
|
|
81
81
|
- \`periderm scan\`: Scan current directory, upload results, and write reports. Requires login.
|
|
82
|
-
- \`periderm scan --local-only\`: Scan locally without uploading to the dashboard.
|
|
83
82
|
- \`periderm review --deep\`: (Scale/Unlimited plan only) AI agent review for edge cases static checks miss. Appends to your last report.
|
|
84
83
|
- \`periderm login\`: Link the CLI to your Periderm account via browser.
|
|
85
84
|
- \`periderm logout\`: Clear the locally stored CLI token.
|
package/dist/scanner/checks.js
CHANGED
|
@@ -982,6 +982,97 @@ const heavyLibImport = (source, file) => {
|
|
|
982
982
|
return out;
|
|
983
983
|
};
|
|
984
984
|
// ───────────────────────────────────────────────────────────────────────
|
|
985
|
+
// 29. Missing Error Property Typing Issue
|
|
986
|
+
// ───────────────────────────────────────────────────────────────────────
|
|
987
|
+
const missingErrorTyping = (source, file, ast) => {
|
|
988
|
+
const out = [];
|
|
989
|
+
if (!ast)
|
|
990
|
+
return out;
|
|
991
|
+
traverse(ast, {
|
|
992
|
+
CatchClause(p) {
|
|
993
|
+
if (!p.node.param || p.node.param.type !== "Identifier")
|
|
994
|
+
return;
|
|
995
|
+
const errorName = p.node.param.name;
|
|
996
|
+
const catchBodySrc = source.slice(p.node.body.start ?? 0, p.node.body.end ?? 0);
|
|
997
|
+
const propAccessRegex = new RegExp(`\\b${errorName}\\.(message|code|name|stack)\\b`);
|
|
998
|
+
if (propAccessRegex.test(catchBodySrc)) {
|
|
999
|
+
// Check if there is a type narrowing guard
|
|
1000
|
+
const hasGuard = new RegExp(`instanceof\\s+Error|typeof\\s+${errorName}\\s*===?\\s*['"]object['"]|${errorName}\\s+is\\s+|as\\s+Error`).test(catchBodySrc) || new RegExp(`\\b${errorName}\\s+instanceof\\b`).test(catchBodySrc) || /Error\s*\(/.test(catchBodySrc) || new RegExp(`isError\\s*\\(\\s*${errorName}\\s*\\)`).test(catchBodySrc);
|
|
1001
|
+
if (!hasGuard) {
|
|
1002
|
+
out.push(mkFinding({
|
|
1003
|
+
id: "missing-error-typing",
|
|
1004
|
+
category: "Data Integrity",
|
|
1005
|
+
severity: "medium",
|
|
1006
|
+
file, line: p.node.loc?.start.line ?? 1,
|
|
1007
|
+
message: `Error property accessed without type narrowing.`,
|
|
1008
|
+
why: "In TypeScript, caught errors are of type `unknown` or `any`. Accessing properties like `.message` directly can crash if the thrown value is a string or null.",
|
|
1009
|
+
fix: "Check if the error is an instance of Error (e.g. `if (e instanceof Error)`) before accessing its properties, or safely cast it.",
|
|
1010
|
+
aiPrompt: `In ${file} near line ${p.node.loc?.start.line ?? 1}, the catch block accesses properties on the caught error without type narrowing. Wrap the property access in an \`if (${errorName} instanceof Error)\` check.`,
|
|
1011
|
+
}));
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
});
|
|
1016
|
+
return out;
|
|
1017
|
+
};
|
|
1018
|
+
// ───────────────────────────────────────────────────────────────────────
|
|
1019
|
+
// 30. Unused Variables/Imports
|
|
1020
|
+
// ───────────────────────────────────────────────────────────────────────
|
|
1021
|
+
const unusedVariablesImports = (source, file, ast) => {
|
|
1022
|
+
const out = [];
|
|
1023
|
+
if (!ast || !/\.(tsx|jsx|ts|js|mjs|cjs)$/.test(file))
|
|
1024
|
+
return out;
|
|
1025
|
+
if (/\.d\.ts$/.test(file))
|
|
1026
|
+
return out;
|
|
1027
|
+
traverse(ast, {
|
|
1028
|
+
Program(p) {
|
|
1029
|
+
for (const [name, binding] of Object.entries(p.scope.bindings)) {
|
|
1030
|
+
if (!binding.referenced && binding.constant && binding.kind !== "param") {
|
|
1031
|
+
if (name.startsWith("_"))
|
|
1032
|
+
continue;
|
|
1033
|
+
if (name === "React")
|
|
1034
|
+
continue; // Ignore React import if unused
|
|
1035
|
+
// Ignore exports
|
|
1036
|
+
if (binding.path.parentPath?.isExportDeclaration() || binding.path.parentPath?.isExportDefaultDeclaration())
|
|
1037
|
+
continue;
|
|
1038
|
+
if (binding.path.isExportDeclaration() || binding.path.isExportDefaultDeclaration())
|
|
1039
|
+
continue;
|
|
1040
|
+
const typeLabel = binding.kind === "module" ? "import" : "variable";
|
|
1041
|
+
out.push(mkFinding({
|
|
1042
|
+
id: `unused-${typeLabel}`,
|
|
1043
|
+
category: "Polish & Embarrassment Risks",
|
|
1044
|
+
severity: "low",
|
|
1045
|
+
file, line: binding.identifier.loc?.start.line ?? 1,
|
|
1046
|
+
message: `Unused ${typeLabel}: '${name}'.`,
|
|
1047
|
+
why: "Unused variables and imports clutter the codebase, increase bundle size, and make code harder to read.",
|
|
1048
|
+
fix: `Remove the unused ${typeLabel}.`,
|
|
1049
|
+
aiPrompt: `In ${file} near line ${binding.identifier.loc?.start.line ?? 1}, remove the unused ${typeLabel} '${name}'.`,
|
|
1050
|
+
}));
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
},
|
|
1054
|
+
Function(p) {
|
|
1055
|
+
for (const [name, binding] of Object.entries(p.scope.bindings)) {
|
|
1056
|
+
if (!binding.referenced && binding.kind !== "param") {
|
|
1057
|
+
if (name.startsWith("_"))
|
|
1058
|
+
continue;
|
|
1059
|
+
out.push(mkFinding({
|
|
1060
|
+
id: "unused-variable",
|
|
1061
|
+
category: "Polish & Embarrassment Risks",
|
|
1062
|
+
severity: "low",
|
|
1063
|
+
file, line: binding.identifier.loc?.start.line ?? 1,
|
|
1064
|
+
message: `Unused variable: '${name}'.`,
|
|
1065
|
+
why: "Unused variables clutter the codebase and make code harder to read.",
|
|
1066
|
+
fix: "Remove the unused variable.",
|
|
1067
|
+
aiPrompt: `In ${file} near line ${binding.identifier.loc?.start.line ?? 1}, remove the unused variable '${name}'.`,
|
|
1068
|
+
}));
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
});
|
|
1073
|
+
return out;
|
|
1074
|
+
};
|
|
1075
|
+
// ───────────────────────────────────────────────────────────────────────
|
|
985
1076
|
// Registry
|
|
986
1077
|
// ───────────────────────────────────────────────────────────────────────
|
|
987
1078
|
const CHECKS = [
|
|
@@ -1014,6 +1105,8 @@ const CHECKS = [
|
|
|
1014
1105
|
sqlStringConcat,
|
|
1015
1106
|
mysqlNoUtf8mb4,
|
|
1016
1107
|
heavyLibImport,
|
|
1108
|
+
missingErrorTyping,
|
|
1109
|
+
unusedVariablesImports,
|
|
1017
1110
|
];
|
|
1018
1111
|
export const PER_FILE_CHECK_COUNT = CHECKS.length;
|
|
1019
1112
|
export function runChecks(source, file, ast) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "periderm-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.59",
|
|
4
4
|
"description": "Periderm CLI: A pre-launch checklist to catch user-losing bugs, legal liabilities, revenue leaks, runaway cloud bills and so many more before you ship.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"preferGlobal": true,
|