@clearrecord/check 1.3.0 → 1.3.1
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/check.js +69 -12
- package/package.json +2 -1
package/bin/check.js
CHANGED
|
@@ -5883,11 +5883,13 @@ var ReportSynthesizer = class {
|
|
|
5883
5883
|
}
|
|
5884
5884
|
const counts = { CRITICAL: 0, HIGH: 0, MEDIUM: 0, LOW: 0 };
|
|
5885
5885
|
findings.forEach((f) => counts[f.severity]++);
|
|
5886
|
-
let output = "--- CLEAR RECORD SCAN SUMMARY
|
|
5887
|
-
output += `CRITICAL: ${counts.CRITICAL} | HIGH: ${counts.HIGH} | MEDIUM: ${counts.MEDIUM} | LOW: ${counts.LOW}
|
|
5888
|
-
|
|
5886
|
+
let output = "--- CLEAR RECORD SCAN SUMMARY ---\n";
|
|
5887
|
+
output += `CRITICAL: ${counts.CRITICAL} | HIGH: ${counts.HIGH} | MEDIUM: ${counts.MEDIUM} | LOW: ${counts.LOW}
|
|
5888
|
+
`;
|
|
5889
|
+
output += "---------------------------------\n";
|
|
5889
5890
|
findings.forEach((f) => {
|
|
5890
|
-
output += `[${f.severity}] ${f.title} - ${f.location.filePath}
|
|
5891
|
+
output += `[${f.severity}] ${f.title} - ${f.location.filePath}
|
|
5892
|
+
`;
|
|
5891
5893
|
});
|
|
5892
5894
|
return output;
|
|
5893
5895
|
}
|
|
@@ -6388,7 +6390,10 @@ var BillingAuditor = class {
|
|
|
6388
6390
|
}
|
|
6389
6391
|
const codeOnly = content.replace(/\/\*[\s\S]*?\*\//g, (b) => b.replace(/[^\r\n]/g, " ")).replace(/\/\/.*$/gm, "");
|
|
6390
6392
|
const isHttpWebhookEndpoint = lowerPath.includes("webhook") && (baseName === "route.ts" || baseName === "route.js" || /\/pages\/api\/.+\.(?:ts|js|mjs)$/i.test(normalizedPath) || /\/supabase\/functions\/[^/]+\/index\.(?:ts|js)$/i.test(normalizedPath) || /\bapp\.post\s*\(/.test(codeOnly));
|
|
6391
|
-
|
|
6393
|
+
const isPureReExportRoute = /^\s*export\s+(?:\*|\{[^}]+\})\s+from\s+['"][^'"]+['"]/m.test(codeOnly) && !/\b(?:async\s+function|function\s+\w+|const\s+(?:GET|POST|PUT|DELETE|PATCH)\s*=)/.test(
|
|
6394
|
+
codeOnly
|
|
6395
|
+
);
|
|
6396
|
+
if (!isHttpWebhookEndpoint || isPureReExportRoute) {
|
|
6392
6397
|
return [];
|
|
6393
6398
|
}
|
|
6394
6399
|
const isLemonRoute = lowerPath.includes("lemon") || /lemonsqueezy|x-signature/i.test(codeOnly);
|
|
@@ -6794,24 +6799,33 @@ verify_jwt = true`,
|
|
|
6794
6799
|
return [];
|
|
6795
6800
|
}
|
|
6796
6801
|
const codeOnly = content.replace(/\/\*[\s\S]*?\*\//g, (b) => b.replace(/[^\r\n]/g, " ")).replace(/\/\/.*$/gm, "");
|
|
6797
|
-
const
|
|
6802
|
+
const isPureReExportRoute = /^\s*export\s+(?:\*|\{[^}]+\})\s+from\s+['"][^'"]+['"]/m.test(codeOnly) && !/\b(?:async\s+function|function\s+\w+|const\s+(?:GET|POST|PUT|DELETE|PATCH)\s*=)/.test(
|
|
6803
|
+
codeOnly
|
|
6804
|
+
);
|
|
6805
|
+
const isPublicAuthOrWebhookPath = isPureReExportRoute || /\/(?:\(auth\)\/)?(?:auth\/)?(?:\([^/]+\)\/)?(?:callback|confirm|login|signin|sign-in|signup|sign-up|register|logout|signout|sign-out|reset-password|forgot-password|verify|magic-link)\b/i.test(
|
|
6798
6806
|
normalizedPath
|
|
6799
6807
|
) || /(?:^|\/)(?:auth[-_.]?actions?|actions\/auth|sign[-_]?in\.actions?|sign[-_]?up\.actions?)\.[jt]sx?$/i.test(
|
|
6800
6808
|
normalizedPath
|
|
6801
|
-
) || normalizedPath.includes("[...nextauth]") || normalizedPath.includes("/api/auth/") || /\/pages\/api\/hello\.[jt]s$/i.test(normalizedPath) || lowerPath.includes("webhook") || /\/api\/(?:health|status|ping|public|og)\b/i.test(normalizedPath) ||
|
|
6809
|
+
) || normalizedPath.includes("[...nextauth]") || normalizedPath.includes("/api/auth/") || /\/pages\/api\/hello\.[jt]s$/i.test(normalizedPath) || lowerPath.includes("webhook") || /\/api\/(?:health|status|ping|public|og)\b/i.test(normalizedPath) || /\/api\/(?:[^/]+\/)*(?:pixel|track|beacon|collect|ingest|telemetry|csp-report|unsubscribe)\b/i.test(
|
|
6810
|
+
normalizedPath
|
|
6811
|
+
) || /\/api\/(?:[^/]+\/)*(?:slack|discord|telegram|twilio|svix|qstash|inngest|trigger|intercom|zendesk|linear|cal|calendly|hubspot|zapier|loops|resend)\//i.test(
|
|
6812
|
+
normalizedPath
|
|
6813
|
+
) || codeOnly.includes("COMMON_CORS_HEADERS") || /['"]Access-Control-Allow-Origin['"]\s*:\s*['"]\*['"]/i.test(codeOnly) || codeOnly.includes("NextAuth(") || codeOnly.includes("toNextJsHandler(") || codeOnly.includes("ImageResponse") || codeOnly.includes("exchangeCodeForSession") || codeOnly.includes("verifyOtp") || codeOnly.includes("signInWithPassword") || codeOnly.includes("signInWithOAuth") || codeOnly.includes("signInWithOtp") || codeOnly.includes("resetPasswordForEmail") || codeOnly.includes("signUp(") || codeOnly.includes("signOut(");
|
|
6802
6814
|
if (isPublicAuthOrWebhookPath) {
|
|
6803
6815
|
return [];
|
|
6804
6816
|
}
|
|
6805
|
-
if ((isAppRouterEndpoint || isPagesRouterEndpoint) && options?.middlewareProtectsApi) {
|
|
6817
|
+
if ((isAppRouterEndpoint || isPagesRouterEndpoint) && (options?.middlewareProtectsApi || options?.hasImportedAuthHelper)) {
|
|
6806
6818
|
return [];
|
|
6807
6819
|
}
|
|
6808
6820
|
const hasMutatingAppMethod = /\bexport\s+(?:async\s+)?function\s+(?:POST|PUT|DELETE|PATCH)\b/.test(codeOnly) || /\bexport\s+const\s+(?:POST|PUT|DELETE|PATCH)\b/.test(codeOnly);
|
|
6809
6821
|
if (isAppRouterEndpoint && !hasMutatingAppMethod) {
|
|
6810
6822
|
return [];
|
|
6811
6823
|
}
|
|
6812
|
-
const hasAuth = codeOnly.includes("auth()") || codeOnly.includes("auth.getUser") || codeOnly.includes("auth.getSession") || codeOnly.includes("auth.api.getSession") || codeOnly.includes("getServerSession") || codeOnly.includes("getSession") || codeOnly.includes("requireUser") || codeOnly.includes("currentUser") || codeOnly.includes("authenticator") || codeOnly.includes("protectedProcedure") || codeOnly.includes("createProtectedRoute") || codeOnly.includes("constructEvent") || codeOnly.includes("createHmac") || codeOnly.includes("unmarshal") || codeOnly.includes("timingSafeEqual") || /\b(?:getUser|getCurrentUser|validateRequest|getKindeServerSession)\s*\(/.test(codeOnly) || /headers(?:\(\))?\.get\s*\(\s*['"](?:authorization|x-api-key|stripe-signature|x-signature|paddle-signature)['"]\s*\)/i.test(
|
|
6824
|
+
const hasAuth = codeOnly.includes("auth()") || codeOnly.includes("auth.getUser") || codeOnly.includes("auth.getSession") || codeOnly.includes("auth.api.getSession") || codeOnly.includes("getServerSession") || codeOnly.includes("getSession") || codeOnly.includes("requireUser") || codeOnly.includes("currentUser") || codeOnly.includes("authenticator") || codeOnly.includes("protectedProcedure") || codeOnly.includes("createProtectedRoute") || codeOnly.includes("constructEvent") || codeOnly.includes("createHmac") || codeOnly.includes("unmarshal") || codeOnly.includes("timingSafeEqual") || codeOnly.includes("timingSafeCompare") || /\b(?:getUser|getCurrentUser|validateRequest|getKindeServerSession)\s*\(/.test(codeOnly) || /headers(?:\(\))?\.get\s*\(\s*['"](?:authorization|x-api-key|stripe-signature|x-signature|paddle-signature|x-slack-signature|svix-signature|upstash-signature|x-hub-signature-256|x-shopify-hmac-sha256|x-hubspot-signature|webhook-signature)['"]\s*\)/i.test(
|
|
6825
|
+
codeOnly
|
|
6826
|
+
) || /req\.headers\[['"](?:authorization|x-api-key|stripe-signature|x-slack-signature|svix-signature|upstash-signature)['"]\]/i.test(
|
|
6813
6827
|
codeOnly
|
|
6814
|
-
) ||
|
|
6828
|
+
) || /\b(?:verify|authenticate|validate|require|assert|checkAuth|withAuth|withSession|withCron|withWorkspace|withAdmin|withSuperAdmin|withToken|withCustomer|withPartner|ensureAuth|requireSession|authActionClient)[A-Za-z0-9_]*\s*(?:\(|\.)/.test(
|
|
6815
6829
|
codeOnly
|
|
6816
6830
|
);
|
|
6817
6831
|
if (!hasAuth) {
|
|
@@ -7446,6 +7460,7 @@ var ClearRecordEngine = class {
|
|
|
7446
7460
|
let sawSupabaseMarker = false;
|
|
7447
7461
|
let sawNonSupabaseOrm = false;
|
|
7448
7462
|
const clientModuleRelPaths = /* @__PURE__ */ new Set();
|
|
7463
|
+
const authHelperModules = /* @__PURE__ */ new Set();
|
|
7449
7464
|
const moduleImportEdges = /* @__PURE__ */ new Map();
|
|
7450
7465
|
const serverServiceRoleModules = /* @__PURE__ */ new Map();
|
|
7451
7466
|
const uniqueProjectFiles = new Set(Object.values(manifest.files).flat());
|
|
@@ -7513,8 +7528,18 @@ var ClearRecordEngine = class {
|
|
|
7513
7528
|
if (isClientFile) {
|
|
7514
7529
|
clientModuleRelPaths.add(modKey);
|
|
7515
7530
|
}
|
|
7531
|
+
const isStrictCallerAuthHelper = codeOnly.includes("auth()") || codeOnly.includes("auth.getUser") || codeOnly.includes("auth.getSession") || codeOnly.includes("auth.api.getSession") || codeOnly.includes("getServerSession") || codeOnly.includes("requireUser") || codeOnly.includes("currentUser") || codeOnly.includes("constructEvent") || codeOnly.includes("timingSafeEqual") || codeOnly.includes("timingSafeCompare") || /\b(?:getCurrentUser|validateRequest|getKindeServerSession|verifySlackSignature|verifyQstashSignature|verifySignature|verifyWebhook|verifyRequestSignature|checkAuth|withAuth|withSession|withCron|withWorkspace|withAdmin|withSuperAdmin|withToken|withCustomer|withPartner|ensureAuth|requireSession|authActionClient)\s*\(/.test(
|
|
7532
|
+
codeOnly
|
|
7533
|
+
) || /headers(?:\(\))?\.get\s*\(\s*['"](?:authorization|x-api-key|stripe-signature|x-signature|paddle-signature|x-slack-signature|svix-signature|upstash-signature|x-hub-signature-256|x-shopify-hmac-sha256|x-hubspot-signature|webhook-signature)['"]\s*\)/i.test(
|
|
7534
|
+
codeOnly
|
|
7535
|
+
);
|
|
7536
|
+
if (isStrictCallerAuthHelper) {
|
|
7537
|
+
authHelperModules.add(modKey);
|
|
7538
|
+
}
|
|
7516
7539
|
if (!isTopLevelUseServer) {
|
|
7517
7540
|
const edges = moduleImportEdges.get(modKey) || /* @__PURE__ */ new Set();
|
|
7541
|
+
const workspacePrefixMatch = relPath.match(/^((?:apps|packages)\/[^/]+)\//);
|
|
7542
|
+
const workspacePrefix = workspacePrefixMatch ? workspacePrefixMatch[1] : null;
|
|
7518
7543
|
const importSpecRegex = /(?:import|export)\s+(?!type\b)(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
7519
7544
|
let impMatch;
|
|
7520
7545
|
while ((impMatch = importSpecRegex.exec(codeOnly)) !== null) {
|
|
@@ -7524,6 +7549,10 @@ var ClearRecordEngine = class {
|
|
|
7524
7549
|
const sub = stripCodeExt(spec.slice(2));
|
|
7525
7550
|
edges.add(sub);
|
|
7526
7551
|
edges.add(`src/${sub}`);
|
|
7552
|
+
if (workspacePrefix) {
|
|
7553
|
+
edges.add(`${workspacePrefix}/${sub}`);
|
|
7554
|
+
edges.add(`${workspacePrefix}/src/${sub}`);
|
|
7555
|
+
}
|
|
7527
7556
|
} else if (spec.startsWith("./") || spec.startsWith("../")) {
|
|
7528
7557
|
const baseDir = path5.posix.dirname(relPath);
|
|
7529
7558
|
const resolved = stripCodeExt(path5.posix.normalize(path5.posix.join(baseDir, spec)));
|
|
@@ -7569,7 +7598,33 @@ var ClearRecordEngine = class {
|
|
|
7569
7598
|
for (const filePath of files) {
|
|
7570
7599
|
try {
|
|
7571
7600
|
const content = await readCached(filePath);
|
|
7572
|
-
|
|
7601
|
+
let hasImportedAuthHelper = false;
|
|
7602
|
+
if (moduleId === "route-auth-analyzer") {
|
|
7603
|
+
const relRoute = stripCodeExt(path5.relative(this.rootDir, filePath).replace(/\\/g, "/"));
|
|
7604
|
+
const hop1Set = moduleImportEdges.get(relRoute);
|
|
7605
|
+
if (hop1Set) {
|
|
7606
|
+
for (const hop1 of hop1Set) {
|
|
7607
|
+
if (authHelperModules.has(hop1)) {
|
|
7608
|
+
hasImportedAuthHelper = true;
|
|
7609
|
+
break;
|
|
7610
|
+
}
|
|
7611
|
+
const hop2Set = moduleImportEdges.get(hop1);
|
|
7612
|
+
if (hop2Set) {
|
|
7613
|
+
for (const hop2 of hop2Set) {
|
|
7614
|
+
if (authHelperModules.has(hop2)) {
|
|
7615
|
+
hasImportedAuthHelper = true;
|
|
7616
|
+
break;
|
|
7617
|
+
}
|
|
7618
|
+
}
|
|
7619
|
+
}
|
|
7620
|
+
if (hasImportedAuthHelper) break;
|
|
7621
|
+
}
|
|
7622
|
+
}
|
|
7623
|
+
}
|
|
7624
|
+
const findings = moduleId === "route-auth-analyzer" ? await analyzer.analyze(filePath, content, {
|
|
7625
|
+
middlewareProtectsApi,
|
|
7626
|
+
hasImportedAuthHelper
|
|
7627
|
+
}) : await analyzer.analyze(filePath, content);
|
|
7573
7628
|
allFindings.push(...findings);
|
|
7574
7629
|
} catch (err) {
|
|
7575
7630
|
console.error(`Error analyzing ${filePath}:`, err);
|
|
@@ -7789,7 +7844,7 @@ var CertificateGenerator = class {
|
|
|
7789
7844
|
};
|
|
7790
7845
|
|
|
7791
7846
|
// src/local-cli.ts
|
|
7792
|
-
var CLI_VERSION = "1.3.
|
|
7847
|
+
var CLI_VERSION = "1.3.1";
|
|
7793
7848
|
function parseCliArgs(args) {
|
|
7794
7849
|
const options = {
|
|
7795
7850
|
targetDir: process.cwd(),
|
|
@@ -7827,6 +7882,8 @@ function parseCliArgs(args) {
|
|
|
7827
7882
|
i += 1;
|
|
7828
7883
|
options.reportPath = path6.resolve(nextArg);
|
|
7829
7884
|
}
|
|
7885
|
+
} else if (arg && !arg.startsWith("-")) {
|
|
7886
|
+
options.targetDir = path6.resolve(arg);
|
|
7830
7887
|
}
|
|
7831
7888
|
}
|
|
7832
7889
|
if (options.certificate) {
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clearrecord/check",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Local Air-Gapped Code Security, Route Auth, SQL RLS, Billing & Index Scanner",
|
|
5
5
|
"main": "bin/check.js",
|
|
6
6
|
"bin": {
|
|
7
|
+
"check": "bin/check.js",
|
|
7
8
|
"clearrecord": "bin/check.js",
|
|
8
9
|
"clearrecord-check": "bin/check.js",
|
|
9
10
|
"clearrecord-cloud": "bin/thin-client.js"
|