@justmpm/firebase-audit 0.5.5 → 0.5.6

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.
@@ -54,6 +54,10 @@ function discover(rootDir) {
54
54
  const first = (v) => Array.isArray(v) ? v[0] : v;
55
55
  const fs = first(raw.firestore);
56
56
  const st = first(raw.storage);
57
+ const fsAny = fs;
58
+ if (fsAny && typeof fsAny.database === "string" && fsAny.database.length > 0 && fsAny.database !== "(default)") {
59
+ databaseId = fsAny.database;
60
+ }
57
61
  if (typeof fs?.rules === "string") {
58
62
  const p = join(rootDir, fs.rules);
59
63
  if (existsSync(p)) rulesFile = p;
@@ -181,6 +185,10 @@ async function enrichWithGraph(rootDir, d) {
181
185
  import { readFileSync as readFileSync2, existsSync as existsSync2 } from "fs";
182
186
  import { join as join2 } from "path";
183
187
  import { executeFind } from "@justmpm/supergrep";
188
+ function isBuildOutput(file) {
189
+ const n = file.replace(/\\/g, "/");
190
+ return /(^|\/)(node_modules|dist|build|\.next|coverage|out)\//.test(n);
191
+ }
184
192
  var IMPLEMENTED_CHECKS = ["FBA001", "FBA002", "FBA003", "FBA004", "FBA009", "FBA010", "FBA011", "FBA012", "FBA013"];
185
193
  function createEvidence() {
186
194
  let counter = 0;
@@ -563,6 +571,7 @@ async function collectPermissionCalls(rootDir, adapterFn) {
563
571
  }
564
572
  const seen = /* @__PURE__ */ new Set();
565
573
  const pushLiteral = (file, line, permission) => {
574
+ if (isBuildOutput(file)) return;
566
575
  const k = `${file}:${line}:${permission}`;
567
576
  if (seen.has(k)) return;
568
577
  seen.add(k);
@@ -575,10 +584,12 @@ async function collectPermissionCalls(rootDir, adapterFn) {
575
584
  const raw = (m.metaVariables["PERM"] ?? "").trim();
576
585
  const line = m.line + 1;
577
586
  if (raw.includes("${")) {
578
- const k = `${m.file}:${line}:${raw}`;
579
- if (!seen.has(k)) {
580
- seen.add(k);
581
- dynamic.push({ file: m.file, line, text: m.text });
587
+ if (!isBuildOutput(m.file)) {
588
+ const k = `${m.file}:${line}:${raw}`;
589
+ if (!seen.has(k)) {
590
+ seen.add(k);
591
+ dynamic.push({ file: m.file, line, text: m.text });
592
+ }
582
593
  }
583
594
  continue;
584
595
  }
@@ -587,18 +598,22 @@ async function collectPermissionCalls(rootDir, adapterFn) {
587
598
  const perm = raw.replace(/^['"`]|['"`]$/g, "").trim();
588
599
  if (/^[a-z][a-z0-9_-]*(\.[a-z][a-z0-9_-]*)*$/.test(perm)) pushLiteral(m.file, line, perm);
589
600
  else {
590
- const k = `${m.file}:${line}:${raw}:invalid`;
601
+ if (!isBuildOutput(m.file)) {
602
+ const k = `${m.file}:${line}:${raw}:invalid`;
603
+ if (!seen.has(k)) {
604
+ seen.add(k);
605
+ dynamic.push({ file: m.file, line, text: m.text });
606
+ }
607
+ }
608
+ }
609
+ } else if (raw.length > 0) {
610
+ if (!isBuildOutput(m.file)) {
611
+ const k = `${m.file}:${line}:${raw}`;
591
612
  if (!seen.has(k)) {
592
613
  seen.add(k);
593
614
  dynamic.push({ file: m.file, line, text: m.text });
594
615
  }
595
616
  }
596
- } else if (raw.length > 0) {
597
- const k = `${m.file}:${line}:${raw}`;
598
- if (!seen.has(k)) {
599
- seen.add(k);
600
- dynamic.push({ file: m.file, line, text: m.text });
601
- }
602
617
  }
603
618
  }
604
619
  } catch {
@@ -635,6 +650,7 @@ async function collectAdminImports(rootDir) {
635
650
  for (const m of result.matches) {
636
651
  const mod = m.metaVariables["MODULE"] ?? "";
637
652
  if (mod.includes("firebase-admin") || mod.includes("firebase-functions")) {
653
+ if (isBuildOutput(m.file)) continue;
638
654
  const k = `${m.file}:${m.line}:${m.text}`;
639
655
  if (seen.has(k)) continue;
640
656
  seen.add(k);
@@ -1173,6 +1189,9 @@ async function scan(rootDir, opts = {}) {
1173
1189
  return `ev-storage-${prefix}-${evCounter}`;
1174
1190
  };
1175
1191
  for (const m of parseStorageAllows(clean)) {
1192
+ if (m.condition !== void 0 && stripOuterParens(m.condition).toLowerCase().replace(/\s+/g, "") === "false") {
1193
+ continue;
1194
+ }
1176
1195
  const ops = expandStorageOps(m.target);
1177
1196
  const key = conditionKeyForFingerprint(m.condition);
1178
1197
  const normCond = (m.condition ?? "").toLowerCase().replace(/\s+/g, "");
@@ -1405,7 +1424,7 @@ async function countAppCheckEnforced(rootDir) {
1405
1424
  continue;
1406
1425
  }
1407
1426
  if (isDir) {
1408
- if (name === "node_modules" || name === "dist" || name === "lib") continue;
1427
+ if (name === "node_modules" || name === "dist" || name === "lib" || name === "build" || name === ".next" || name === "coverage" || name === ".git" || name === "out") continue;
1409
1428
  stack.push(abs);
1410
1429
  continue;
1411
1430
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  scan
3
- } from "./chunk-ME6WO45S.js";
3
+ } from "./chunk-BB6XXEIK.js";
4
4
  import {
5
5
  verify
6
6
  } from "./chunk-DIO36A3I.js";
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  scan
4
- } from "./chunk-ME6WO45S.js";
4
+ } from "./chunk-BB6XXEIK.js";
5
5
  import "./chunk-FECVBQUO.js";
6
6
 
7
7
  // src/cli.ts
@@ -41,13 +41,13 @@ Uso: firebase-audit scan [--json] [--strict] [--adapter=fn] [--cwd=path]`);
41
41
  return void 0;
42
42
  };
43
43
  const strictArg = getArg("strict");
44
- const strict = args.includes("--strict") || strictArg === "true" || cmd === "check";
44
+ const strict = (args.includes("--strict") || strictArg === "true") && strictArg !== "false" || cmd === "check";
45
45
  if (strictArg !== void 0 && strictArg !== "true" && strictArg !== "false") {
46
46
  console.error(`Valor inv\xE1lido para --strict: ${strictArg} (use --strict, --strict=true ou --strict=false)`);
47
47
  process.exit(1);
48
48
  }
49
49
  const asJsonArg = getArg("json");
50
- const asJson = args.includes("--json") || asJsonArg === "true";
50
+ const asJson = (args.includes("--json") || asJsonArg === "true") && asJsonArg !== "false";
51
51
  if (asJsonArg !== void 0 && asJsonArg !== "true" && asJsonArg !== "false") {
52
52
  console.error(`Valor inv\xE1lido para --json: ${asJsonArg} (use --json, --json=true ou --json=false)`);
53
53
  process.exit(1);
@@ -81,7 +81,7 @@ Uso: firebase-audit scan|check|verify|drift [--json] ...`);
81
81
  const { resolve: resolveRoot } = await import("path");
82
82
  const rootDir = cwdArg ? resolveRoot(process.cwd(), cwdArg) : process.cwd();
83
83
  if (cmd === "verify") {
84
- const { scan: scanForVerify } = await import("./scan-HE5WAMWJ.js");
84
+ const { scan: scanForVerify } = await import("./scan-SDJSDRDQ.js");
85
85
  const { verify } = await import("./verify-DECP4IUW.js");
86
86
  const { resolve: resolveVerify } = await import("path");
87
87
  const coverageArg = getArg("coverage");
package/dist/index.d.ts CHANGED
@@ -753,8 +753,9 @@ interface ScanOptions {
753
753
  adapterFn?: string;
754
754
  strict?: boolean;
755
755
  /**
756
- * Opt-in: enriquece Discovery com grafo do ai-tool (clientFiles/serverFiles).
757
- * Default false (scan estático rápido; nenhum check consome o grafo por padrão).
756
+ * Prévia opt-in: enriquece Discovery com grafo do ai-tool (clientFiles/serverFiles).
757
+ * Nenhum check consome o grafo ainda — resultado idêntico com ou sem.
758
+ * Default false (scan estático rápido).
758
759
  */
759
760
  graph?: boolean;
760
761
  }
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createMcpServer,
3
3
  startMcpServer
4
- } from "./chunk-CHC7ZHUK.js";
4
+ } from "./chunk-SH6HFX5Y.js";
5
5
  import {
6
6
  AccessOriginSchema,
7
7
  AuditYamlSchema,
@@ -33,7 +33,7 @@ import {
33
33
  runChecks,
34
34
  scan,
35
35
  validateClaimSamples
36
- } from "./chunk-ME6WO45S.js";
36
+ } from "./chunk-BB6XXEIK.js";
37
37
  import {
38
38
  buildFullPath,
39
39
  conditionKeyForFingerprint,
package/dist/mcp-cli.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  startMcpServer
4
- } from "./chunk-CHC7ZHUK.js";
5
- import "./chunk-ME6WO45S.js";
4
+ } from "./chunk-SH6HFX5Y.js";
5
+ import "./chunk-BB6XXEIK.js";
6
6
  import "./chunk-FECVBQUO.js";
7
7
  import "./chunk-DIO36A3I.js";
8
8
  import "./chunk-XZ32YQQC.js";
package/dist/mcp.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  createMcpServer,
3
3
  startMcpServer
4
- } from "./chunk-CHC7ZHUK.js";
5
- import "./chunk-ME6WO45S.js";
4
+ } from "./chunk-SH6HFX5Y.js";
5
+ import "./chunk-BB6XXEIK.js";
6
6
  import "./chunk-FECVBQUO.js";
7
7
  import "./chunk-DIO36A3I.js";
8
8
  import "./chunk-XZ32YQQC.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  scan
3
- } from "./chunk-ME6WO45S.js";
3
+ } from "./chunk-BB6XXEIK.js";
4
4
  import "./chunk-FECVBQUO.js";
5
5
  export {
6
6
  scan
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justmpm/firebase-audit",
3
- "version": "0.5.5",
3
+ "version": "0.5.6",
4
4
  "description": "Auditor de consistência e segurança para projetos Firebase: código + Rules + índices + contrato vs comportamento. Static-first, nunca inventa certeza.",
5
5
  "keywords": [
6
6
  "firebase",