periderm-cli 0.1.61 → 0.1.63
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/bin.js +1 -1
- package/dist/config.js +4 -2
- package/dist/index.js +28 -20
- package/dist/lighthouse.js +7 -7
- package/dist/report/markdown.js +14 -4
- package/dist/report/terminal.js +2 -2
- package/dist/report/verdict.js +2 -7
- package/dist/review/deep.js +1 -1
- package/dist/scanner/checks.js +162 -81
- package/dist/scanner/index.js +7 -4
- package/dist/scanner/legal.js +28 -0
- package/dist/scanner/policy-checks.js +60 -20
- package/dist/scanner/project-context.js +21 -13
- package/dist/scanner/repo-checks.js +134 -44
- package/dist/scanner/seo-checks.js +25 -15
- package/dist/scanner/walk.js +6 -6
- package/dist/update-notifier.js +1 -1
- package/package.json +1 -1
package/dist/scanner/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { runRepoChecks, REPO_WIDE_CHECK_COUNT } from "./repo-checks.js";
|
|
|
7
7
|
import { runPolicyChecks, POLICY_CHECK_COUNT } from "./policy-checks.js";
|
|
8
8
|
import { runSeoChecks, SEO_CHECK_COUNT } from "./seo-checks.js";
|
|
9
9
|
import { runMobileChecks, MOBILE_CHECK_COUNT } from "./mobile-checks.js";
|
|
10
|
-
import { detectProjectContext, shouldSkipFinding, buildContextSummary
|
|
10
|
+
import { detectProjectContext, shouldSkipFinding, buildContextSummary } from "./project-context.js";
|
|
11
11
|
import { enhanceContextWithGroq, triageFindingsWithGroq, resolveGroqApiKey, } from "./context-agent.js";
|
|
12
12
|
import { computeScores, computeVerdict } from "../report/verdict.js";
|
|
13
13
|
import { renderMarkdown } from "../report/markdown.js";
|
|
@@ -44,6 +44,7 @@ export async function scan(root, options = {}) {
|
|
|
44
44
|
onProgress?.({ type: "checks", current: checksRun, total: estimatedChecks });
|
|
45
45
|
};
|
|
46
46
|
let policySignalsChecked = 0;
|
|
47
|
+
let policyPagesFound = 0;
|
|
47
48
|
await mapWithProgress(files, 6, async (abs) => {
|
|
48
49
|
let src;
|
|
49
50
|
try {
|
|
@@ -74,9 +75,10 @@ export async function scan(root, options = {}) {
|
|
|
74
75
|
rawFindings.push(...(await runRepoChecks(root, files, ctx)));
|
|
75
76
|
bumpChecks(REPO_WIDE_CHECK_COUNT);
|
|
76
77
|
onProgress?.({ type: "phase", label: "Cross-referencing privacy policy vs codebase…" });
|
|
77
|
-
const
|
|
78
|
-
rawFindings.push(...
|
|
79
|
-
policySignalsChecked =
|
|
78
|
+
const policy = await runPolicyChecks(root, files);
|
|
79
|
+
rawFindings.push(...policy.findings);
|
|
80
|
+
policySignalsChecked = policy.signalsChecked;
|
|
81
|
+
policyPagesFound = policy.legalPagesFound;
|
|
80
82
|
bumpChecks(POLICY_CHECK_COUNT);
|
|
81
83
|
onProgress?.({ type: "phase", label: "Checking SEO & social meta…" });
|
|
82
84
|
rawFindings.push(...(await runSeoChecks(root, files)));
|
|
@@ -94,6 +96,7 @@ export async function scan(root, options = {}) {
|
|
|
94
96
|
repoWideCheckCount: REPO_WIDE_CHECK_COUNT,
|
|
95
97
|
seoCheckCount: SEO_CHECK_COUNT,
|
|
96
98
|
policySignalsChecked,
|
|
99
|
+
policyPagesFound,
|
|
97
100
|
totalChecksRun: checksRun,
|
|
98
101
|
projectProfile: ctx.profile,
|
|
99
102
|
stacks: ctx.stacks,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Legal-page detection shared by repo-wide checks and the privacy-policy
|
|
3
|
+
* cross-reference.
|
|
4
|
+
*
|
|
5
|
+
* Only real legal *pages/documents* count as legal pages. A file whose path
|
|
6
|
+
* merely contains "tos"/"policy" as a substring must NOT be treated as one —
|
|
7
|
+
* e.g. `lib/convertToSubcurrency.ts` contains "ToS" (convert**ToS**ubcurrency),
|
|
8
|
+
* and matching it suppresses the "no legal pages" finding while making the
|
|
9
|
+
* report claim a Privacy Policy exists when none does.
|
|
10
|
+
*/
|
|
11
|
+
const LEGAL_KEYWORD_RE = /\b(?:privacy|privacypolicy|terms|termsofservice|tos|eula|legal|legalnotice|compliance|cookies?|cookiepolicy|policies?)\b/i;
|
|
12
|
+
/** Document-like files that can hold legal copy. */
|
|
13
|
+
const PAGE_EXT_RE = /\.(?:tsx|jsx|md|mdx|html|htm|txt|svelte|vue|astro)$/i;
|
|
14
|
+
/** Framework route entry files (e.g. app/privacy/page.tsx). */
|
|
15
|
+
const ROUTE_STEM_RE = /^(?:page|index|\+page)$/i;
|
|
16
|
+
export function isLegalPage(rel) {
|
|
17
|
+
const parts = rel.split(/[\\/]/);
|
|
18
|
+
const basename = parts[parts.length - 1] ?? "";
|
|
19
|
+
// Standalone legal doc: privacy.md, terms.tsx, cookie-policy.html, policies.svelte…
|
|
20
|
+
if (LEGAL_KEYWORD_RE.test(basename))
|
|
21
|
+
return PAGE_EXT_RE.test(basename);
|
|
22
|
+
// Framework route: app/privacy/page.tsx, pages/terms/index.jsx, content/legal/index.md…
|
|
23
|
+
const stem = basename.replace(/\.[^.]+$/, "");
|
|
24
|
+
return ROUTE_STEM_RE.test(stem) && parts.slice(0, -1).some((seg) => LEGAL_KEYWORD_RE.test(seg));
|
|
25
|
+
}
|
|
26
|
+
export function findLegalPages(relFiles) {
|
|
27
|
+
return relFiles.filter(isLegalPage);
|
|
28
|
+
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import fs from "node:fs/promises";
|
|
6
6
|
import path from "node:path";
|
|
7
|
+
import { findLegalPages } from "./legal.js";
|
|
7
8
|
async function readMaybe(p) {
|
|
8
9
|
try {
|
|
9
10
|
return await fs.readFile(p, "utf8");
|
|
@@ -14,53 +15,91 @@ async function readMaybe(p) {
|
|
|
14
15
|
}
|
|
15
16
|
/** Signals that user data is sent to trackers, ad networks, or data brokers. */
|
|
16
17
|
const TRACKING_IN_CODE = [
|
|
17
|
-
[
|
|
18
|
+
[
|
|
19
|
+
/gtag\s*\(|googletagmanager|google-analytics|GA_MEASUREMENT_ID|G-[A-Z0-9]{6,}/i,
|
|
20
|
+
"Google Analytics / gtag",
|
|
21
|
+
],
|
|
18
22
|
[/fbq\s*\(|facebook\.net\/en_US\/fbevents|connect\.facebook\.net/i, "Meta / Facebook Pixel"],
|
|
19
23
|
[/posthog\.(?:capture|init)|import\s+posthog/i, "PostHog analytics"],
|
|
20
24
|
[/mixpanel\.(?:track|init)|from\s+['"]mixpanel/i, "Mixpanel"],
|
|
21
25
|
[/analytics\.(?:track|page)|segment\.(?:track|page)|@segment\//i, "Segment analytics"],
|
|
22
26
|
[/amplitude\.(?:track|init)|@amplitude\//i, "Amplitude"],
|
|
23
27
|
[/hotjar|hj\s*\(|clarity\.ms|fullstory|logrocket/i, "Session recording / heatmap tool"],
|
|
24
|
-
[
|
|
28
|
+
[
|
|
29
|
+
/doubleclick|googlesyndication|googleadservices|ads\.twitter|tiktok.*track/i,
|
|
30
|
+
"Ad / retargeting network",
|
|
31
|
+
],
|
|
25
32
|
[/linkedin\.com\/px|snap\.licdn|taboola|outbrain|criteo/i, "Ad / retargeting pixel"],
|
|
26
33
|
[/plausible\(|umami\.track|heap\.(?:track|load)/i, "Analytics SDK"],
|
|
27
34
|
];
|
|
28
35
|
/** Strong privacy promises that contradict the signals above. */
|
|
29
36
|
const PRIVACY_PROMISES = [
|
|
30
|
-
[
|
|
37
|
+
[
|
|
38
|
+
/(?:do|does|will|shall)\s+not\s+(?:share|sell|disclose|transfer)/i,
|
|
39
|
+
"promises not to share/sell/disclose data",
|
|
40
|
+
],
|
|
31
41
|
[/never\s+(?:share|sell|disclose|transfer)/i, "promises never to share/sell data"],
|
|
32
42
|
[/(?:remain|stays?|keeping?|keep)\s+(?:private|confidential)/i, "claims user data stays private"],
|
|
33
|
-
[
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
[
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
[
|
|
44
|
+
/not\s+(?:shared|sold|disclosed|transferred)\s+(?:with|to)\s+third/i,
|
|
45
|
+
"denies third-party sharing",
|
|
46
|
+
],
|
|
47
|
+
[
|
|
48
|
+
/(?:no|without)\s+third[- ]party\s+(?:sharing|access|tracking|data)/i,
|
|
49
|
+
"denies third-party tracking/sharing",
|
|
50
|
+
],
|
|
51
|
+
[
|
|
52
|
+
/(?:do|does)\s+not\s+(?:use|employ|utilize)\s+(?:tracking|analytics|advertising|ad\s)/i,
|
|
53
|
+
"denies use of tracking/analytics/ads",
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
/information\s+(?:will|shall)\s+(?:remain|stay)\s+private/i,
|
|
57
|
+
"claims information will remain private",
|
|
58
|
+
],
|
|
59
|
+
[
|
|
60
|
+
/(?:personal\s+information|user\s+data).{0,40}(?:is\s+not|are\s+not|will\s+not\s+be)\s+sold/i,
|
|
61
|
+
"claims personal data is not sold",
|
|
62
|
+
],
|
|
63
|
+
[
|
|
64
|
+
/(?:only|solely)\s+(?:for|to)\s+(?:provide|operate|improve)\s+(?:the\s+)?(?:service|app|site)/i,
|
|
65
|
+
"claims data is used only to provide the service",
|
|
66
|
+
],
|
|
67
|
+
[
|
|
68
|
+
/(?:do|does)\s+not\s+(?:use|set)\s+cookies?\s+(?:for|to)\s+(?:track|advertis|market)/i,
|
|
69
|
+
"denies tracking/ad cookies",
|
|
70
|
+
],
|
|
40
71
|
[/(?:no|without)\s+(?:advertising|marketing)\s+cookies?/i, "denies advertising cookies"],
|
|
41
72
|
];
|
|
42
73
|
const COOKIE_TRACKING_IN_CODE = [
|
|
43
74
|
[/document\.cookie\s*[+=]|cookies?\.set\s*\(/i, "sets cookies in JavaScript"],
|
|
44
|
-
[
|
|
45
|
-
|
|
75
|
+
[
|
|
76
|
+
/localStorage\.setItem\s*\(\s*['"][^'"]*(?:track|analytics|pixel|utm|session|user)/i,
|
|
77
|
+
"persists tracking identifiers in localStorage",
|
|
78
|
+
],
|
|
79
|
+
[
|
|
80
|
+
/sessionStorage\.setItem\s*\(\s*['"][^'"]*(?:track|analytics|pixel|utm|session|user)/i,
|
|
81
|
+
"persists tracking identifiers in sessionStorage",
|
|
82
|
+
],
|
|
46
83
|
];
|
|
47
84
|
const TRACKING_DEPS = /posthog|mixpanel|segment|amplitude|google-analytics|@vercel\/analytics|plausible|heap-js|hotjar/i;
|
|
48
85
|
export const POLICY_CHECK_COUNT = 2;
|
|
86
|
+
/** Total signal categories the cross-reference tests for. */
|
|
87
|
+
export const POLICY_SIGNAL_COUNT = TRACKING_IN_CODE.length + COOKIE_TRACKING_IN_CODE.length + 1; // +1 for TRACKING_DEPS
|
|
49
88
|
export async function runPolicyChecks(root, files) {
|
|
50
89
|
const out = [];
|
|
51
90
|
const relFiles = files.map((f) => path.relative(root, f));
|
|
52
|
-
const legalPaths = relFiles
|
|
53
|
-
|| /(?:privacy|terms|cookie|policy|legal|compliance|eula|tos).*\.(?:tsx|jsx|md|html)$/i.test(path.basename(f)));
|
|
91
|
+
const legalPaths = findLegalPages(relFiles);
|
|
54
92
|
if (legalPaths.length === 0)
|
|
55
|
-
return out;
|
|
93
|
+
return { findings: out, legalPagesFound: 0, signalsChecked: 0 };
|
|
56
94
|
let legalText = "";
|
|
57
95
|
for (const rel of legalPaths) {
|
|
58
96
|
const content = await readMaybe(path.join(root, rel));
|
|
59
97
|
if (content)
|
|
60
98
|
legalText += `\n${content}`;
|
|
61
99
|
}
|
|
62
|
-
if (!legalText.trim())
|
|
63
|
-
return out;
|
|
100
|
+
if (!legalText.trim()) {
|
|
101
|
+
return { findings: out, legalPagesFound: legalPaths.length, signalsChecked: 0 };
|
|
102
|
+
}
|
|
64
103
|
const legalLower = legalText.toLowerCase();
|
|
65
104
|
// Collect what the codebase actually does
|
|
66
105
|
const codeSignals = new Map(); // label -> first file
|
|
@@ -87,8 +126,9 @@ export async function runPolicyChecks(root, files) {
|
|
|
87
126
|
}
|
|
88
127
|
}
|
|
89
128
|
}
|
|
90
|
-
if (codeSignals.size === 0)
|
|
91
|
-
return out;
|
|
129
|
+
if (codeSignals.size === 0) {
|
|
130
|
+
return { findings: out, legalPagesFound: legalPaths.length, signalsChecked: 0 };
|
|
131
|
+
}
|
|
92
132
|
// Flag outright contradictions: policy promises privacy, code sends data to trackers
|
|
93
133
|
const brokenPromises = [];
|
|
94
134
|
for (const [re, claim] of PRIVACY_PROMISES) {
|
|
@@ -130,5 +170,5 @@ export async function runPolicyChecks(root, files) {
|
|
|
130
170
|
`Found in code: ${[...codeSignals.keys()].join(", ")}. Align the policy with reality or remove the SDKs.`,
|
|
131
171
|
});
|
|
132
172
|
}
|
|
133
|
-
return out;
|
|
173
|
+
return { findings: out, legalPagesFound: legalPaths.length, signalsChecked: codeSignals.size };
|
|
134
174
|
}
|
|
@@ -37,10 +37,7 @@ const INTERNAL_ONLY_SKIP = new Set([
|
|
|
37
37
|
"Accessibility",
|
|
38
38
|
"Polish & Embarrassment Risks",
|
|
39
39
|
]);
|
|
40
|
-
const ADMIN_ONLY_SKIP = new Set([
|
|
41
|
-
"Legal & Compliance",
|
|
42
|
-
"SEO & Discoverability",
|
|
43
|
-
]);
|
|
40
|
+
const ADMIN_ONLY_SKIP = new Set(["Legal & Compliance", "SEO & Discoverability"]);
|
|
44
41
|
const MOBILE_SKIP = new Set([
|
|
45
42
|
"Legal & Compliance",
|
|
46
43
|
"SEO & Discoverability",
|
|
@@ -113,11 +110,11 @@ export async function detectProjectContext(root, files) {
|
|
|
113
110
|
// Stack detection from manifests
|
|
114
111
|
const hasPubspec = await readMaybe(path.join(root, "pubspec.yaml"));
|
|
115
112
|
const hasAppJson = await readMaybe(path.join(root, "app.json"));
|
|
116
|
-
const hasExpo = await readMaybe(path.join(root, "app.config.js"))
|
|
117
|
-
|
|
113
|
+
const hasExpo = (await readMaybe(path.join(root, "app.config.js"))) ??
|
|
114
|
+
(await readMaybe(path.join(root, "app.config.ts")));
|
|
118
115
|
const pkgRaw = await readMaybe(path.join(root, "package.json"));
|
|
119
|
-
const hasPackageSwift = relFiles.some((f) => /Package\.swift$/i.test(f))
|
|
120
|
-
|
|
116
|
+
const hasPackageSwift = relFiles.some((f) => /Package\.swift$/i.test(f)) ||
|
|
117
|
+
relFiles.some((f) => /\.xcodeproj\//i.test(f));
|
|
121
118
|
const hasDart = relFiles.some((f) => f.endsWith(".dart"));
|
|
122
119
|
const hasSwift = relFiles.some((f) => f.endsWith(".swift"));
|
|
123
120
|
let pkg = {};
|
|
@@ -150,9 +147,20 @@ export async function detectProjectContext(root, files) {
|
|
|
150
147
|
reasoning.push("Detected Swift/iOS.");
|
|
151
148
|
}
|
|
152
149
|
const isWebJs = [
|
|
153
|
-
"react",
|
|
154
|
-
|
|
155
|
-
|
|
150
|
+
"react",
|
|
151
|
+
"vite",
|
|
152
|
+
"next",
|
|
153
|
+
"svelte",
|
|
154
|
+
"vue",
|
|
155
|
+
"angular",
|
|
156
|
+
"astro",
|
|
157
|
+
"nuxt",
|
|
158
|
+
"remix",
|
|
159
|
+
"gatsby",
|
|
160
|
+
"@tanstack/react-router",
|
|
161
|
+
].some((d) => deps[d]);
|
|
162
|
+
if (isWebJs ||
|
|
163
|
+
(!hasRn && !hasExpoDep && !hasPubspec && !hasDart && !hasPackageSwift && !hasSwift)) {
|
|
156
164
|
stacks.push("web-js");
|
|
157
165
|
reasoning.push("Detected web JavaScript/TypeScript stack.");
|
|
158
166
|
}
|
|
@@ -260,8 +268,8 @@ export async function detectFaviconPresent(root, files) {
|
|
|
260
268
|
if (/apple-touch-icon|manifest\.webmanifest|site\.webmanifest/i.test(content))
|
|
261
269
|
return true;
|
|
262
270
|
}
|
|
263
|
-
const manifest = await readMaybe(path.join(root, "public/manifest.webmanifest"))
|
|
264
|
-
|
|
271
|
+
const manifest = (await readMaybe(path.join(root, "public/manifest.webmanifest"))) ??
|
|
272
|
+
(await readMaybe(path.join(root, "public/site.webmanifest")));
|
|
265
273
|
if (manifest && /"icons"\s*:/.test(manifest))
|
|
266
274
|
return true;
|
|
267
275
|
return false;
|
|
@@ -6,6 +6,7 @@ import fs from "node:fs/promises";
|
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import fg from "fast-glob";
|
|
8
8
|
import { detectFaviconPresent } from "./project-context.js";
|
|
9
|
+
import { isLegalPage } from "./legal.js";
|
|
9
10
|
async function exists(p) {
|
|
10
11
|
try {
|
|
11
12
|
await fs.access(p);
|
|
@@ -33,7 +34,8 @@ export async function runRepoChecks(root, _files, ctx) {
|
|
|
33
34
|
id: "missing-readme",
|
|
34
35
|
category: "Deployment & Testing Readiness",
|
|
35
36
|
severity: "medium",
|
|
36
|
-
file: "README.md",
|
|
37
|
+
file: "README.md",
|
|
38
|
+
line: 1,
|
|
37
39
|
message: "README.md is missing.",
|
|
38
40
|
why: "New contributors and your future self can't tell what the project is or how to run it.",
|
|
39
41
|
fix: "Add a README with a one-line description, install, run, and deploy commands.",
|
|
@@ -58,7 +60,8 @@ export async function runRepoChecks(root, _files, ctx) {
|
|
|
58
60
|
id: "missing-env-example",
|
|
59
61
|
category: "Deployment & Testing Readiness",
|
|
60
62
|
severity: "medium",
|
|
61
|
-
file: ".env.example",
|
|
63
|
+
file: ".env.example",
|
|
64
|
+
line: 1,
|
|
62
65
|
message: ".env.example is missing.",
|
|
63
66
|
why: "Anyone cloning the repo has to guess which env vars are required.",
|
|
64
67
|
fix: "Create a .env.example listing every env var with a placeholder value (no secrets).",
|
|
@@ -73,7 +76,7 @@ export async function runRepoChecks(root, _files, ctx) {
|
|
|
73
76
|
try {
|
|
74
77
|
const parsedPkg = JSON.parse(pkgRaw);
|
|
75
78
|
const combinedDeps = { ...parsedPkg.dependencies, ...parsedPkg.devDependencies };
|
|
76
|
-
looksLikeWeb = ["react", "vite", "next", "svelte", "vue", "astro", "nuxt", "remix"].some(d => combinedDeps[d]);
|
|
79
|
+
looksLikeWeb = ["react", "vite", "next", "svelte", "vue", "astro", "nuxt", "remix"].some((d) => combinedDeps[d]);
|
|
77
80
|
}
|
|
78
81
|
catch (e) {
|
|
79
82
|
if (process.env.DEBUG)
|
|
@@ -91,7 +94,8 @@ export async function runRepoChecks(root, _files, ctx) {
|
|
|
91
94
|
id: "missing-favicon",
|
|
92
95
|
category: "Polish & Embarrassment Risks",
|
|
93
96
|
severity: "medium",
|
|
94
|
-
file: "public/",
|
|
97
|
+
file: "public/",
|
|
98
|
+
line: 1,
|
|
95
99
|
message: "No favicon detected (checked link rel=icon tags, manifests, and public/ icon files).",
|
|
96
100
|
why: "Without a favicon the browser tab shows a generic blank icon. Looks unfinished.",
|
|
97
101
|
fix: "Add a favicon and reference it from your root layout head (any path/extension is fine).",
|
|
@@ -104,7 +108,8 @@ export async function runRepoChecks(root, _files, ctx) {
|
|
|
104
108
|
id: "missing-robots",
|
|
105
109
|
category: "SEO & Discoverability",
|
|
106
110
|
severity: "medium",
|
|
107
|
-
file: "public/robots.txt",
|
|
111
|
+
file: "public/robots.txt",
|
|
112
|
+
line: 1,
|
|
108
113
|
message: "robots.txt is missing.",
|
|
109
114
|
why: "Search engines may crawl pages you don't want indexed, or miss pages you do.",
|
|
110
115
|
fix: "Add a public/robots.txt with at minimum: User-agent: * Allow: / Sitemap: https://your-domain/sitemap.xml",
|
|
@@ -119,7 +124,8 @@ export async function runRepoChecks(root, _files, ctx) {
|
|
|
119
124
|
id: "mobile-legal-reminder",
|
|
120
125
|
category: "Legal & Compliance",
|
|
121
126
|
severity: "medium",
|
|
122
|
-
file: "App Stores",
|
|
127
|
+
file: "App Stores",
|
|
128
|
+
line: 1,
|
|
123
129
|
message: "Verify Privacy Policy URL is configured in App Store / Google Play.",
|
|
124
130
|
why: "Mobile apps must link to external legal policies in the app stores. Code scanners cannot verify external links.",
|
|
125
131
|
fix: "Ensure your App Store Connect and Google Play Console entries have valid, accessible URLs to your privacy policy and terms.",
|
|
@@ -127,16 +133,14 @@ export async function runRepoChecks(root, _files, ctx) {
|
|
|
127
133
|
});
|
|
128
134
|
}
|
|
129
135
|
else {
|
|
130
|
-
const legalFilePaths = _files.filter(f =>
|
|
131
|
-
const rel = path.relative(root, f);
|
|
132
|
-
return /terms|privacy|cookie|policy|legal|compliance|eula|tos/i.test(rel);
|
|
133
|
-
});
|
|
136
|
+
const legalFilePaths = _files.filter((f) => isLegalPage(path.relative(root, f)));
|
|
134
137
|
if (legalFilePaths.length === 0) {
|
|
135
138
|
out.push({
|
|
136
139
|
id: "missing-legal-docs",
|
|
137
140
|
category: "Legal & Compliance",
|
|
138
141
|
severity: "critical",
|
|
139
|
-
file: "root",
|
|
142
|
+
file: "root",
|
|
143
|
+
line: 1,
|
|
140
144
|
message: "Missing Documents: Privacy Policy, Terms of Service completely absent.",
|
|
141
145
|
why: "Running a web app handling user data without legal policies creates massive liability.",
|
|
142
146
|
fix: "Create a Terms of Service and Privacy Policy, and link them in your footer.",
|
|
@@ -162,12 +166,14 @@ export async function runRepoChecks(root, _files, ctx) {
|
|
|
162
166
|
if (content)
|
|
163
167
|
combinedLegalContent += content.toLowerCase();
|
|
164
168
|
}
|
|
169
|
+
const legalFile = path.relative(root, legalFilePaths[0]);
|
|
165
170
|
if (hasAuth && !/account|email|password|authentication|login/i.test(combinedLegalContent)) {
|
|
166
171
|
out.push({
|
|
167
172
|
id: "incomplete-legal-auth",
|
|
168
173
|
category: "Legal & Compliance",
|
|
169
174
|
severity: "high",
|
|
170
|
-
file:
|
|
175
|
+
file: legalFile,
|
|
176
|
+
line: 1,
|
|
171
177
|
message: "Privacy Policy does not mention User Accounts or Authentication.",
|
|
172
178
|
why: "The app uses authentication dependencies, but the legal pages do not disclose the collection of account data (e.g. emails).",
|
|
173
179
|
fix: "Update your Privacy Policy to disclose what user data is collected upon account creation and how it is protected.",
|
|
@@ -179,19 +185,22 @@ export async function runRepoChecks(root, _files, ctx) {
|
|
|
179
185
|
id: "incomplete-legal-payments",
|
|
180
186
|
category: "Legal & Compliance",
|
|
181
187
|
severity: "high",
|
|
182
|
-
file:
|
|
188
|
+
file: legalFile,
|
|
189
|
+
line: 1,
|
|
183
190
|
message: "Privacy Policy does not mention Payments or Billing.",
|
|
184
191
|
why: "The app uses payment processing dependencies, but the legal pages do not disclose the handling of financial data.",
|
|
185
192
|
fix: "Update your Privacy Policy to disclose that payment information is collected and processed by third-party providers.",
|
|
186
193
|
aiPrompt: "Update the Privacy Policy to include a section about Payments, disclosing that payment data is handled securely by a processor.",
|
|
187
194
|
});
|
|
188
195
|
}
|
|
189
|
-
if (hasAnalytics &&
|
|
196
|
+
if (hasAnalytics &&
|
|
197
|
+
!/analytic|tracking|cookie|mixpanel|posthog/i.test(combinedLegalContent)) {
|
|
190
198
|
out.push({
|
|
191
199
|
id: "incomplete-legal-analytics",
|
|
192
200
|
category: "Legal & Compliance",
|
|
193
201
|
severity: "high",
|
|
194
|
-
file:
|
|
202
|
+
file: legalFile,
|
|
203
|
+
line: 1,
|
|
195
204
|
message: "Privacy Policy does not mention Analytics or Tracking.",
|
|
196
205
|
why: "The app uses analytics dependencies, but the legal pages do not disclose tracking, cookies, or telemetry.",
|
|
197
206
|
fix: "Update your Privacy Policy to disclose the use of analytics tools and tracking cookies.",
|
|
@@ -203,7 +212,8 @@ export async function runRepoChecks(root, _files, ctx) {
|
|
|
203
212
|
id: "missing-legal-compliance",
|
|
204
213
|
category: "Legal & Compliance",
|
|
205
214
|
severity: "high",
|
|
206
|
-
file:
|
|
215
|
+
file: legalFile,
|
|
216
|
+
line: 1,
|
|
207
217
|
message: "Privacy Policy missing GDPR / CCPA compliance wording.",
|
|
208
218
|
why: "Failing to include required clauses for EU/CA users can result in severe FTC/regulatory fines and liabilities.",
|
|
209
219
|
fix: "Add sections explicitly covering GDPR and CCPA rights (right to delete, right to access).",
|
|
@@ -227,6 +237,20 @@ export async function runRepoChecks(root, _files, ctx) {
|
|
|
227
237
|
}
|
|
228
238
|
const runtimeDeps = Object.keys(pkg.dependencies ?? {});
|
|
229
239
|
const allDeps = [...runtimeDeps, ...Object.keys(pkg.devDependencies ?? {})];
|
|
240
|
+
// Deprecated / redundant build plugins
|
|
241
|
+
if (allDeps.includes("vite-tsconfig-paths")) {
|
|
242
|
+
out.push({
|
|
243
|
+
id: "redundant-vite-tsconfig-paths",
|
|
244
|
+
category: "Performance & Bundle Size",
|
|
245
|
+
severity: "medium",
|
|
246
|
+
file: "package.json",
|
|
247
|
+
line: 1,
|
|
248
|
+
message: 'The plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the resolve.tsconfigPaths option.',
|
|
249
|
+
why: "Vite added native support for tsconfig paths. Using an external plugin adds unnecessary build overhead and potential bugs.",
|
|
250
|
+
fix: "Remove the plugin from package.json and vite.config.ts, and set `resolve.tsconfigPaths: true` in your Vite config instead.",
|
|
251
|
+
aiPrompt: "Remove `vite-tsconfig-paths` from package.json and vite.config.ts, and enable native path resolution by adding `resolve: { tsconfigPaths: true }` to the vite config.",
|
|
252
|
+
});
|
|
253
|
+
}
|
|
230
254
|
// Build one combined haystack of source imports so we can answer
|
|
231
255
|
// "is this dep actually imported anywhere?" and "is this class used?".
|
|
232
256
|
let importHaystack = "";
|
|
@@ -261,7 +285,13 @@ export async function runRepoChecks(root, _files, ctx) {
|
|
|
261
285
|
},
|
|
262
286
|
{
|
|
263
287
|
name: "icon packs",
|
|
264
|
-
members: [
|
|
288
|
+
members: [
|
|
289
|
+
"react-icons",
|
|
290
|
+
"lucide-react",
|
|
291
|
+
"@heroicons/react",
|
|
292
|
+
"@fortawesome/react-fontawesome",
|
|
293
|
+
"@mui/icons-material",
|
|
294
|
+
],
|
|
265
295
|
recommend: "pick one icon set. Multiple icon packs balloon the bundle for no visual benefit.",
|
|
266
296
|
},
|
|
267
297
|
];
|
|
@@ -272,7 +302,8 @@ export async function runRepoChecks(root, _files, ctx) {
|
|
|
272
302
|
id: "duplicate-libs",
|
|
273
303
|
category: "Performance & Bundle Size",
|
|
274
304
|
severity: "medium",
|
|
275
|
-
file: "package.json",
|
|
305
|
+
file: "package.json",
|
|
306
|
+
line: 1,
|
|
276
307
|
message: `Multiple ${g.name} installed: ${present.join(", ")}.`,
|
|
277
308
|
why: "Shipping two libraries that solve the same problem doubles the bytes users download and doubles the surface area you need to maintain.",
|
|
278
309
|
fix: g.recommend,
|
|
@@ -282,29 +313,76 @@ export async function runRepoChecks(root, _files, ctx) {
|
|
|
282
313
|
}
|
|
283
314
|
// Unused runtime dependencies (best-effort: skip well-known "invisible" deps)
|
|
284
315
|
const invisibleDeps = new Set([
|
|
285
|
-
"typescript",
|
|
286
|
-
"
|
|
287
|
-
"
|
|
288
|
-
"
|
|
289
|
-
"
|
|
290
|
-
"
|
|
291
|
-
"@
|
|
292
|
-
"
|
|
293
|
-
"@
|
|
294
|
-
"
|
|
295
|
-
"
|
|
296
|
-
"
|
|
297
|
-
"
|
|
298
|
-
"
|
|
316
|
+
"typescript",
|
|
317
|
+
"vite",
|
|
318
|
+
"esbuild",
|
|
319
|
+
"tsx",
|
|
320
|
+
"ts-node",
|
|
321
|
+
"tsup",
|
|
322
|
+
"@types/node",
|
|
323
|
+
"@types/react",
|
|
324
|
+
"@types/react-dom",
|
|
325
|
+
"postcss",
|
|
326
|
+
"autoprefixer",
|
|
327
|
+
"tailwindcss",
|
|
328
|
+
"@tailwindcss/vite",
|
|
329
|
+
"@tailwindcss/typography",
|
|
330
|
+
"eslint",
|
|
331
|
+
"prettier",
|
|
332
|
+
"husky",
|
|
333
|
+
"lint-staged",
|
|
334
|
+
"vitest",
|
|
335
|
+
"jest",
|
|
336
|
+
"@vitest/ui",
|
|
337
|
+
"react",
|
|
338
|
+
"react-dom", // used via JSX runtime, not import
|
|
339
|
+
"@babel/parser",
|
|
340
|
+
"@babel/traverse",
|
|
341
|
+
"@babel/types",
|
|
342
|
+
"chalk",
|
|
343
|
+
"commander",
|
|
344
|
+
"fast-glob",
|
|
345
|
+
"open",
|
|
346
|
+
"ora",
|
|
347
|
+
"@babel/core",
|
|
348
|
+
"@babel/preset-env",
|
|
349
|
+
"@babel/preset-react",
|
|
350
|
+
"@babel/preset-typescript",
|
|
351
|
+
"webpack",
|
|
352
|
+
"rollup",
|
|
353
|
+
"parcel",
|
|
354
|
+
"nodemon",
|
|
355
|
+
"pm2",
|
|
356
|
+
"cross-env",
|
|
357
|
+
"dotenv",
|
|
358
|
+
"dotenv-expand",
|
|
359
|
+
"fs-extra",
|
|
360
|
+
"glob",
|
|
361
|
+
"rimraf",
|
|
362
|
+
"mkdirp",
|
|
363
|
+
"zx",
|
|
364
|
+
"execa",
|
|
365
|
+
"shelljs",
|
|
299
366
|
"semver",
|
|
300
|
-
"nitropack",
|
|
301
|
-
"
|
|
302
|
-
"
|
|
303
|
-
"
|
|
304
|
-
"
|
|
305
|
-
"
|
|
367
|
+
"nitropack",
|
|
368
|
+
"h3",
|
|
369
|
+
"@tanstack/router-plugin",
|
|
370
|
+
"@tanstack/react-router",
|
|
371
|
+
"@tanstack/react-query",
|
|
372
|
+
"@tanstack/react-start",
|
|
373
|
+
"vite-plugin-pwa",
|
|
374
|
+
"vite-tsconfig-paths",
|
|
375
|
+
"clsx",
|
|
376
|
+
"class-variance-authority",
|
|
377
|
+
"tailwind-merge",
|
|
378
|
+
"lucide-react",
|
|
379
|
+
"react-icons",
|
|
380
|
+
"date-fns",
|
|
381
|
+
"dayjs",
|
|
382
|
+
"luxon",
|
|
306
383
|
"framer-motion",
|
|
307
|
-
"marked",
|
|
384
|
+
"marked",
|
|
385
|
+
"dompurify",
|
|
308
386
|
"react-hook-form",
|
|
309
387
|
"recharts",
|
|
310
388
|
"sonner",
|
|
@@ -343,7 +421,8 @@ export async function runRepoChecks(root, _files, ctx) {
|
|
|
343
421
|
id: "unused-dependencies",
|
|
344
422
|
category: "Performance & Bundle Size",
|
|
345
423
|
severity: "low",
|
|
346
|
-
file: "package.json",
|
|
424
|
+
file: "package.json",
|
|
425
|
+
line: 1,
|
|
347
426
|
message: `${unused.length} dependenc${unused.length === 1 ? "y" : "ies"} in package.json appear unused: ${shown.join(", ")}${unused.length > shown.length ? ", …" : ""}.`,
|
|
348
427
|
why: "Unused deps still get installed, audited, and (if imported anywhere transitively) can end up in the bundle. They also slow every CI install and confuse new contributors.",
|
|
349
428
|
fix: "Verify each one carefully before removing - some may be used in build configs or scripts! Move build-only tools to devDependencies.",
|
|
@@ -358,7 +437,8 @@ export async function runRepoChecks(root, _files, ctx) {
|
|
|
358
437
|
id: "no-code-splitting",
|
|
359
438
|
category: "Performance & Bundle Size",
|
|
360
439
|
severity: "medium",
|
|
361
|
-
file: "src",
|
|
440
|
+
file: "src",
|
|
441
|
+
line: 1,
|
|
362
442
|
message: `${routeFiles.length} routes/pages and zero dynamic imports — everything ships in one bundle.`,
|
|
363
443
|
why: "Without code-splitting, a visitor to your landing page also downloads the admin dashboard, the settings screens, and every modal. First paint gets slower with every feature you add.",
|
|
364
444
|
fix: "Wrap heavy or rarely-used routes in React.lazy(() => import('./Route')) + <Suspense>, or use your router's built-in lazy() API. Split third-party charts, editors and 3D scenes the same way.",
|
|
@@ -369,7 +449,15 @@ export async function runRepoChecks(root, _files, ctx) {
|
|
|
369
449
|
// ─────────────────────────────────────────────────────────────────────
|
|
370
450
|
// Unused CSS classes (skip Tailwind / CSS-modules)
|
|
371
451
|
// ─────────────────────────────────────────────────────────────────────
|
|
372
|
-
const cssFiles = await fg([
|
|
452
|
+
const cssFiles = await fg([
|
|
453
|
+
"**/*.css",
|
|
454
|
+
"!**/node_modules/**",
|
|
455
|
+
"!**/dist/**",
|
|
456
|
+
"!**/build/**",
|
|
457
|
+
"!**/.next/**",
|
|
458
|
+
"!**/.output/**",
|
|
459
|
+
"!**/*.module.css",
|
|
460
|
+
], { cwd: root, absolute: true, dot: false });
|
|
373
461
|
if (cssFiles.length) {
|
|
374
462
|
// Build a haystack of everything CSS classes might be referenced from.
|
|
375
463
|
let refHaystack = "";
|
|
@@ -414,7 +502,8 @@ export async function runRepoChecks(root, _files, ctx) {
|
|
|
414
502
|
id: "unused-css-classes",
|
|
415
503
|
category: "Performance & Bundle Size",
|
|
416
504
|
severity: "low",
|
|
417
|
-
file: rel,
|
|
505
|
+
file: rel,
|
|
506
|
+
line: 1,
|
|
418
507
|
message: `${unused.length} CSS class${unused.length === 1 ? "" : "es"} in ${rel} appear unused: ${shown.join(", ")}${unused.length > shown.length ? ", …" : ""}.`,
|
|
419
508
|
why: "Dead CSS still ships to every visitor on every page load. Over time projects accumulate hundreds of orphan classes from deleted components — silent bloat that hurts First Contentful Paint on mobile.",
|
|
420
509
|
fix: "Delete the unused selectors, or (better) enable PurgeCSS / Tailwind JIT / lightningcss to strip them at build time. If a class is only added dynamically, keep it — this check is heuristic.",
|
|
@@ -438,7 +527,8 @@ export async function runRepoChecks(root, _files, ctx) {
|
|
|
438
527
|
id: "definer-rpc-execute",
|
|
439
528
|
category: "Security & Permissions",
|
|
440
529
|
severity: "critical",
|
|
441
|
-
file: rel,
|
|
530
|
+
file: rel,
|
|
531
|
+
line: 1,
|
|
442
532
|
message: "Signed-in users may have EXECUTE on a definer-scoped RPC.",
|
|
443
533
|
why: "SECURITY DEFINER functions run with the privileges of the creator (usually the postgres superuser). Granting EXECUTE to anon, public, or authenticated users can allow them to bypass Row Level Security (RLS) and escalate privileges.",
|
|
444
534
|
fix: "Ensure you restrict EXECUTE to a specific service role, or rewrite the function to be SECURITY INVOKER (the default) so it respects the caller's RLS policies.",
|