@clearrecord/check 1.1.0 → 1.1.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.
Files changed (2) hide show
  1. package/bin/check.js +52 -42
  2. package/package.json +2 -2
package/bin/check.js CHANGED
@@ -5781,14 +5781,15 @@ var require_out4 = __commonJS({
5781
5781
  }
5782
5782
  });
5783
5783
 
5784
- // src/cli.ts
5785
- var cli_exports = {};
5786
- __export(cli_exports, {
5784
+ // src/local-cli.ts
5785
+ var local_cli_exports = {};
5786
+ __export(local_cli_exports, {
5787
+ CLI_VERSION: () => CLI_VERSION,
5787
5788
  executeCli: () => executeCli,
5788
5789
  main: () => main,
5789
5790
  parseCliArgs: () => parseCliArgs
5790
5791
  });
5791
- module.exports = __toCommonJS(cli_exports);
5792
+ module.exports = __toCommonJS(local_cli_exports);
5792
5793
  var path2 = __toESM(require("path"));
5793
5794
  var fs2 = __toESM(require("fs/promises"));
5794
5795
 
@@ -5915,34 +5916,36 @@ ${f.remediation.fixScript}
5915
5916
  var RlsAnalyzer = class {
5916
5917
  async analyze(filePath, content) {
5917
5918
  const findings = [];
5918
- const lines = content.split("\\n");
5919
+ const lines = content.split(/\r?\n/);
5919
5920
  const tables = [];
5920
5921
  const enabledRls = /* @__PURE__ */ new Set();
5921
- const publicPolicies = /* @__PURE__ */ new Set();
5922
+ const publicPolicies = /* @__PURE__ */ new Map();
5922
5923
  const createTableRegex = /CREATE\s+TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?(?:public\.)?(\w+)/i;
5923
5924
  const enableRlsRegex = /ALTER\s+TABLE\s+(?:public\.)?(\w+)\s+ENABLE\s+ROW\s+LEVEL\s+SECURITY/i;
5924
5925
  const publicPolicyRegex = /CREATE\s+POLICY\s+".*?"\s+ON\s+(?:public\.)?(\w+)\s+FOR\s+SELECT\s+TO\s+public/i;
5925
- lines.forEach((line) => {
5926
+ lines.forEach((line, idx) => {
5927
+ const lineNumber = idx + 1;
5926
5928
  const tableMatch = line.match(createTableRegex);
5927
- if (tableMatch) tables.push(tableMatch[1]);
5929
+ if (tableMatch) tables.push({ name: tableMatch[1], line: lineNumber });
5928
5930
  const rlsMatch = line.match(enableRlsRegex);
5929
5931
  if (rlsMatch) enabledRls.add(rlsMatch[1]);
5930
5932
  const policyMatch = line.match(publicPolicyRegex);
5931
- if (policyMatch) publicPolicies.add(policyMatch[1]);
5933
+ if (policyMatch && !publicPolicies.has(policyMatch[1])) {
5934
+ publicPolicies.set(policyMatch[1], lineNumber);
5935
+ }
5932
5936
  });
5933
- for (const table of tables) {
5937
+ for (const { name: table, line: createLine } of tables) {
5934
5938
  if (!enabledRls.has(table)) {
5935
5939
  findings.push({
5936
- id: "CR-SEC-01",
5940
+ id: "CR-ARCH-02",
5937
5941
  moduleId: "rls-analyzer",
5938
5942
  title: "Anonymous Table Dump",
5939
5943
  severity: "CRITICAL",
5940
5944
  cvssScore: 9.1,
5941
5945
  location: {
5942
5946
  filePath,
5943
- startLine: 1,
5944
- // Simplified for this version
5945
- endLine: 1,
5947
+ startLine: createLine,
5948
+ endLine: createLine,
5946
5949
  startCol: 1,
5947
5950
  endCol: 100,
5948
5951
  snippet: `CREATE TABLE public.${table}`
@@ -5961,16 +5964,17 @@ CREATE POLICY "Users can read own" ON public.${table} FOR SELECT TO authenticate
5961
5964
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
5962
5965
  });
5963
5966
  } else if (publicPolicies.has(table)) {
5967
+ const policyLine = publicPolicies.get(table) || createLine;
5964
5968
  findings.push({
5965
- id: "CR-SEC-02",
5969
+ id: "CR-ARCH-03",
5966
5970
  moduleId: "rls-analyzer",
5967
5971
  title: "Publicly Accessible Data",
5968
5972
  severity: "CRITICAL",
5969
5973
  cvssScore: 8.5,
5970
5974
  location: {
5971
5975
  filePath,
5972
- startLine: 1,
5973
- endLine: 1,
5976
+ startLine: policyLine,
5977
+ endLine: policyLine,
5974
5978
  startCol: 1,
5975
5979
  endCol: 100,
5976
5980
  snippet: `CREATE POLICY ... TO public`
@@ -5998,7 +6002,7 @@ CREATE POLICY "Authenticated Read" ON public.${table} FOR SELECT TO authenticate
5998
6002
  var SecretScanner = class {
5999
6003
  secretPatterns = [
6000
6004
  {
6001
- id: "CR-SEC-03",
6005
+ id: "CR-SEC-02",
6002
6006
  title: "Supabase Service Role Leak",
6003
6007
  regex: /sb_admin_[a-zA-Z0-9]+/g,
6004
6008
  severity: "CRITICAL",
@@ -6008,7 +6012,7 @@ var SecretScanner = class {
6008
6012
  remediation: "Move this key to a server-side .env file and never expose it to the client bundle."
6009
6013
  },
6010
6014
  {
6011
- id: "CR-SEC-04",
6015
+ id: "CR-SEC-03",
6012
6016
  title: "Stripe Secret Key Leak",
6013
6017
  regex: /sk_live_[a-zA-Z0-9]+/g,
6014
6018
  severity: "CRITICAL",
@@ -6061,7 +6065,7 @@ var SecretScanner = class {
6061
6065
  return findings;
6062
6066
  }
6063
6067
  getLineNumber(content, index) {
6064
- return content.substring(0, index).split("\\n").length;
6068
+ return content.substring(0, index).split(/\r?\n/).length;
6065
6069
  }
6066
6070
  };
6067
6071
 
@@ -6073,7 +6077,7 @@ var BillingAuditor = class {
6073
6077
  const processesPayment = /update.*subscriptions|create.*customer|grant.*access|db\..*update|prisma\..*update|supabase\..*update/i.test(content);
6074
6078
  if (processesPayment && !hasConstructEvent) {
6075
6079
  findings.push({
6076
- id: "CR-BILL-01",
6080
+ id: "CR-BIL-01",
6077
6081
  moduleId: "billing-auditor",
6078
6082
  title: "Unsigned Stripe Webhook",
6079
6083
  severity: "CRITICAL",
@@ -6103,7 +6107,7 @@ var BillingAuditor = class {
6103
6107
  const secretMatch = content.match(/constructEvent\s*\(\s*[^,]+,\s*[^,]+,\s*['"]([^'"]*)['"]/);
6104
6108
  if (secretMatch && (secretMatch[1] === "" || secretMatch[1].toLowerCase().includes("placeholder"))) {
6105
6109
  findings.push({
6106
- id: "CR-BILL-02",
6110
+ id: "CR-BIL-02",
6107
6111
  moduleId: "billing-auditor",
6108
6112
  title: "Missing Webhook Secret",
6109
6113
  severity: "HIGH",
@@ -6243,8 +6247,8 @@ var DependencyTriage = class {
6243
6247
 
6244
6248
  // src/auditor/risk-matrix.ts
6245
6249
  var RISK_MATRIX = {
6246
- "CR-SEC-01": {
6247
- findingId: "CR-SEC-01",
6250
+ "CR-ARCH-02": {
6251
+ findingId: "CR-ARCH-02",
6248
6252
  moduleId: "rls-analyzer",
6249
6253
  technicalTitle: "Anonymous Table Dump",
6250
6254
  impact: {
@@ -6260,8 +6264,8 @@ var RISK_MATRIX = {
6260
6264
  executiveVerdict: "Fatal deal blocker. An acquirer's counsel will not sign off on acquiring uncontained customer data exposure. Must be patched before diligence data room opens."
6261
6265
  }
6262
6266
  },
6263
- "CR-SEC-02": {
6264
- findingId: "CR-SEC-02",
6267
+ "CR-ARCH-03": {
6268
+ findingId: "CR-ARCH-03",
6265
6269
  moduleId: "rls-analyzer",
6266
6270
  technicalTitle: "Publicly Accessible Data",
6267
6271
  impact: {
@@ -6277,8 +6281,8 @@ var RISK_MATRIX = {
6277
6281
  executiveVerdict: "Severe compliance failure. The existence of permissive public policies signals undisciplined engineering, triggering deep forensics and deal retrades."
6278
6282
  }
6279
6283
  },
6280
- "CR-SEC-03": {
6281
- findingId: "CR-SEC-03",
6284
+ "CR-SEC-02": {
6285
+ findingId: "CR-SEC-02",
6282
6286
  moduleId: "secret-scanner",
6283
6287
  technicalTitle: "Supabase Service Role Leak",
6284
6288
  impact: {
@@ -6294,8 +6298,8 @@ var RISK_MATRIX = {
6294
6298
  executiveVerdict: "Catastrophic root credential compromise. Acquirers treat service role leaks as presumed breaches requiring emergency key rotation and forensic logs audit."
6295
6299
  }
6296
6300
  },
6297
- "CR-SEC-04": {
6298
- findingId: "CR-SEC-04",
6301
+ "CR-SEC-03": {
6302
+ findingId: "CR-SEC-03",
6299
6303
  moduleId: "secret-scanner",
6300
6304
  technicalTitle: "Stripe Secret Key Leak",
6301
6305
  impact: {
@@ -6311,8 +6315,8 @@ var RISK_MATRIX = {
6311
6315
  executiveVerdict: "Immediate financial deal killer. Live payment keys in source control contaminate financial statements and expose the business to direct capital loss."
6312
6316
  }
6313
6317
  },
6314
- "CR-BILL-01": {
6315
- findingId: "CR-BILL-01",
6318
+ "CR-BIL-01": {
6319
+ findingId: "CR-BIL-01",
6316
6320
  moduleId: "billing-auditor",
6317
6321
  technicalTitle: "Unsigned Stripe Webhook",
6318
6322
  impact: {
@@ -6328,8 +6332,8 @@ var RISK_MATRIX = {
6328
6332
  executiveVerdict: "Substantial valuation discount. If subscription state can be spoofed, reported ARR and customer metrics are non-defensible in financial due diligence."
6329
6333
  }
6330
6334
  },
6331
- "CR-BILL-02": {
6332
- findingId: "CR-BILL-02",
6335
+ "CR-BIL-02": {
6336
+ findingId: "CR-BIL-02",
6333
6337
  moduleId: "billing-auditor",
6334
6338
  technicalTitle: "Missing Webhook Secret",
6335
6339
  impact: {
@@ -6731,9 +6735,9 @@ var CertificateGenerator = class {
6731
6735
  const randomHex = crypto.randomBytes(3).toString("hex").toUpperCase();
6732
6736
  const certificateId = `CR-CERT-${yearStr}-${monthStr}-${randomHex}`;
6733
6737
  const hasRlsFlaw = memo.exitKillers.some(
6734
- (k) => k.findingId === "CR-SEC-01" || k.findingId === "CR-SEC-02"
6738
+ (k) => k.findingId === "CR-ARCH-02" || k.findingId === "CR-ARCH-03"
6735
6739
  );
6736
- const hasWebhookFlaw = memo.exitKillers.some((k) => k.findingId === "CR-BILL-01");
6740
+ const hasWebhookFlaw = memo.exitKillers.some((k) => k.findingId === "CR-BIL-01");
6737
6741
  const metrics = {
6738
6742
  repositoryStatus: status === "CERTIFIED_CLEAN" ? "CLEAN (0 CVEs)" : `AT RISK (${memo.financialExposure.dealKillersCount} Deal Killers)`,
6739
6743
  rlsCoveragePercent: hasRlsFlaw ? 60 : 100,
@@ -6840,7 +6844,8 @@ var CertificateGenerator = class {
6840
6844
  }
6841
6845
  };
6842
6846
 
6843
- // src/cli.ts
6847
+ // src/local-cli.ts
6848
+ var CLI_VERSION = "1.1.1";
6844
6849
  function parseCliArgs(args) {
6845
6850
  const options = {
6846
6851
  targetDir: process.cwd(),
@@ -6867,12 +6872,16 @@ function parseCliArgs(args) {
6867
6872
  } else if (arg === "--no-report") {
6868
6873
  options.saveReport = false;
6869
6874
  } else if (arg === "--dir" || arg === "-d") {
6870
- if (args[i + 1]) {
6871
- options.targetDir = path2.resolve(args[++i]);
6875
+ const nextArg = args[i + 1];
6876
+ if (nextArg) {
6877
+ i += 1;
6878
+ options.targetDir = path2.resolve(nextArg);
6872
6879
  }
6873
6880
  } else if (arg === "--output" || arg === "-o") {
6874
- if (args[i + 1]) {
6875
- options.reportPath = path2.resolve(args[++i]);
6881
+ const nextArg = args[i + 1];
6882
+ if (nextArg) {
6883
+ i += 1;
6884
+ options.reportPath = path2.resolve(nextArg);
6876
6885
  }
6877
6886
  }
6878
6887
  }
@@ -6906,7 +6915,7 @@ async function executeCli(options) {
6906
6915
  return { exitCode: 0, outputText: helpText };
6907
6916
  }
6908
6917
  if (options.version) {
6909
- return { exitCode: 0, outputText: "1.1.0" };
6918
+ return { exitCode: 0, outputText: CLI_VERSION };
6910
6919
  }
6911
6920
  const engine = new ClearRecordEngine(options.targetDir);
6912
6921
  const result = await engine.run();
@@ -6984,6 +6993,7 @@ if (require.main === module) {
6984
6993
  }
6985
6994
  // Annotate the CommonJS export names for ESM import in node:
6986
6995
  0 && (module.exports = {
6996
+ CLI_VERSION,
6987
6997
  executeCli,
6988
6998
  main,
6989
6999
  parseCliArgs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clearrecord/check",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Deterministic Air-Gapped Code Audit & M&A Due Diligence Scanner",
5
5
  "main": "bin/check.js",
6
6
  "bin": {
@@ -13,7 +13,7 @@
13
13
  "README.md"
14
14
  ],
15
15
  "scripts": {
16
- "build": "esbuild index.ts --bundle --platform=node --target=node18 --outfile=bin/thin-client.js",
16
+ "build": "esbuild src/local-cli.ts --bundle --platform=node --target=node18 --format=cjs --banner:js=\"#!/usr/bin/env node\" --outfile=bin/check.js && esbuild index.ts --bundle --platform=node --target=node18 --outfile=bin/thin-client.js",
17
17
  "test": "jest",
18
18
  "prepack": "npm run build"
19
19
  },