@justmpm/firebase-audit 0.3.0 → 0.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.
|
@@ -61,7 +61,10 @@ function classifyOrigin(file, content) {
|
|
|
61
61
|
const rel = file.replace(/\\/g, "/");
|
|
62
62
|
const segs = rel.split("/");
|
|
63
63
|
const hasSeg = (...names) => names.some((n) => segs.includes(n));
|
|
64
|
-
if (
|
|
64
|
+
if (hasSeg("pages", "api") && rel.includes("pages/api/")) {
|
|
65
|
+
return "SERVER";
|
|
66
|
+
}
|
|
67
|
+
if (hasSeg("app", "api") && rel.includes("app/api/")) {
|
|
65
68
|
return "SERVER";
|
|
66
69
|
}
|
|
67
70
|
if (segs.includes("app") && rel.endsWith("route.ts") || segs.includes("app") && rel.endsWith("route.js")) {
|
|
@@ -641,10 +644,19 @@ async function collectAdminImports(rootDir) {
|
|
|
641
644
|
const out = [];
|
|
642
645
|
const patterns = [
|
|
643
646
|
'import { $$$ITEMS } from "$MODULE"',
|
|
647
|
+
"import { $$$ITEMS } from '$MODULE'",
|
|
644
648
|
'import $DEFAULT from "$MODULE"',
|
|
649
|
+
"import $DEFAULT from '$MODULE'",
|
|
645
650
|
'import * as $NS from "$MODULE"',
|
|
651
|
+
"import * as $NS from '$MODULE'",
|
|
652
|
+
'import "$MODULE"',
|
|
653
|
+
"import '$MODULE'",
|
|
646
654
|
'const $X = require("$MODULE")',
|
|
647
|
-
|
|
655
|
+
"const $X = require('$MODULE')",
|
|
656
|
+
'require("$MODULE")',
|
|
657
|
+
"require('$MODULE')",
|
|
658
|
+
'import("$MODULE")',
|
|
659
|
+
"import('$MODULE')"
|
|
648
660
|
];
|
|
649
661
|
const seen = /* @__PURE__ */ new Set();
|
|
650
662
|
for (const pattern of patterns) {
|
|
@@ -825,7 +837,7 @@ var FindingSchema = z.strictObject({
|
|
|
825
837
|
});
|
|
826
838
|
var PermissionNameSchema = z.string().regex(/^[a-z][a-z0-9_-]*(\.[a-z][a-z0-9_-]*)*$/);
|
|
827
839
|
var RoleNameSchema = z.string().regex(/^[a-z][a-z0-9_-]*$/);
|
|
828
|
-
var AuditYamlSchema = z.
|
|
840
|
+
var AuditYamlSchema = z.strictObject({
|
|
829
841
|
authorization: z.strictObject({
|
|
830
842
|
adapter: z.strictObject({ function: z.string().min(1) }).optional(),
|
|
831
843
|
roles: z.record(RoleNameSchema, z.strictObject({ permissions: z.array(PermissionNameSchema) })),
|
|
@@ -881,18 +893,24 @@ async function scan(rootDir, opts = {}) {
|
|
|
881
893
|
const validModes = ["ASCENDING", "DESCENDING", "ARRAY_CONTAINS", "VECTOR"];
|
|
882
894
|
const entries = [];
|
|
883
895
|
let skipped = 0;
|
|
896
|
+
let scopeSkipped = 0;
|
|
884
897
|
for (const i of raw.indexes ?? []) {
|
|
885
898
|
if (typeof i.collectionGroup !== "string" || i.collectionGroup.length === 0) {
|
|
886
899
|
skipped += 1;
|
|
887
900
|
continue;
|
|
888
901
|
}
|
|
902
|
+
if (i.queryScope !== void 0 && i.queryScope !== "COLLECTION" && i.queryScope !== "COLLECTION_GROUP") {
|
|
903
|
+
scopeSkipped += 1;
|
|
904
|
+
continue;
|
|
905
|
+
}
|
|
889
906
|
const fields = [];
|
|
890
907
|
for (const f of i.fields ?? []) {
|
|
891
|
-
if (typeof f.fieldPath !== "string" || f.fieldPath.length === 0) {
|
|
908
|
+
if (typeof f.fieldPath !== "string" || f.fieldPath.length === 0 || f.fieldPath === "__name__") {
|
|
892
909
|
skipped += 1;
|
|
893
910
|
continue;
|
|
894
911
|
}
|
|
895
|
-
const
|
|
912
|
+
const rawMode = f.vectorConfig ? "VECTOR" : f.arrayConfig === "CONTAINS" ? "ARRAY_CONTAINS" : typeof f.mode === "string" ? f.mode : f.order;
|
|
913
|
+
const mode = rawMode;
|
|
896
914
|
if (mode !== "ASCENDING" && mode !== "DESCENDING" && mode !== "ARRAY_CONTAINS" && mode !== "VECTOR") {
|
|
897
915
|
skipped += 1;
|
|
898
916
|
continue;
|
|
@@ -906,15 +924,16 @@ async function scan(rootDir, opts = {}) {
|
|
|
906
924
|
});
|
|
907
925
|
}
|
|
908
926
|
model.indexes = entries;
|
|
909
|
-
|
|
927
|
+
const totalSkipped = skipped + scopeSkipped;
|
|
928
|
+
if (totalSkipped > 0) {
|
|
910
929
|
findings_pre.push({
|
|
911
930
|
rule: "INDEXES_INVALID",
|
|
912
931
|
severity: "WARNING",
|
|
913
932
|
confidence: "CONFIRMED",
|
|
914
|
-
message: `firestore.indexes.json com ${
|
|
933
|
+
message: `firestore.indexes.json com ${totalSkipped} entrada(s) inv\xE1lidas ignoradas \u2014 verifique campos.`,
|
|
915
934
|
fingerprint: "INDEXES_INVALID",
|
|
916
935
|
evidence: [
|
|
917
|
-
{ id: "ev-indexes-skipped", kind: "indexes-parse", summary: `${
|
|
936
|
+
{ id: "ev-indexes-skipped", kind: "indexes-parse", summary: `${totalSkipped} inv\xE1lidas`, confidence: "CONFIRMED" }
|
|
918
937
|
]
|
|
919
938
|
});
|
|
920
939
|
}
|
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
scan
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UMQH7UDI.js";
|
|
5
5
|
|
|
6
6
|
// src/cli.ts
|
|
7
7
|
import { createRequire } from "module";
|
|
@@ -64,7 +64,7 @@ Uso: firebase-audit scan|check|verify|drift [--json] ...`);
|
|
|
64
64
|
const { resolve: resolveRoot } = await import("path");
|
|
65
65
|
const rootDir = cwdArg ? resolveRoot(process.cwd(), cwdArg) : process.cwd();
|
|
66
66
|
if (cmd === "verify") {
|
|
67
|
-
const { scan: scanForVerify } = await import("./scan-
|
|
67
|
+
const { scan: scanForVerify } = await import("./scan-TLHI777J.js");
|
|
68
68
|
const { verify } = await import("./verify-Y7BWAFPL.js");
|
|
69
69
|
const { resolve: resolveVerify } = await import("path");
|
|
70
70
|
const coverageArg = getArg("coverage");
|
package/dist/index.d.ts
CHANGED
|
@@ -591,7 +591,7 @@ declare const AuditYamlSchema: z.ZodObject<{
|
|
|
591
591
|
samples: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodJSONSchema>>>;
|
|
592
592
|
}, z.core.$strict>>;
|
|
593
593
|
}, z.core.$strict>;
|
|
594
|
-
}, z.core.$
|
|
594
|
+
}, z.core.$strict>;
|
|
595
595
|
type ProjectModel = z.infer<typeof ProjectModelSchema>;
|
|
596
596
|
type Finding = z.infer<typeof FindingSchema>;
|
|
597
597
|
type AuditYaml = z.infer<typeof AuditYamlSchema>;
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justmpm/firebase-audit",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
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",
|