@justmpm/firebase-audit 0.5.14 → 0.5.15
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/{chunk-4RVGY4EB.js → chunk-SYGLJ457.js} +29 -5
- package/dist/{chunk-B5CIZS4Y.js → chunk-ZILSDI3F.js} +1 -1
- package/dist/cli.js +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -2
- package/dist/mcp-cli.js +2 -2
- package/dist/mcp.js +2 -2
- package/dist/{scan-DDGH7LPH.js → scan-3XBJMCAO.js} +1 -1
- package/package.json +1 -1
- package/skill/SKILL.md +1 -1
|
@@ -255,6 +255,30 @@ function checksAdminPower(cond, condRaw, rule, helperDetailed) {
|
|
|
255
255
|
}
|
|
256
256
|
return false;
|
|
257
257
|
}
|
|
258
|
+
function branchHasCallerDocGate(branch) {
|
|
259
|
+
const args = [];
|
|
260
|
+
const re = /\b(?:exists|get)\s*\(/gi;
|
|
261
|
+
let m;
|
|
262
|
+
while ((m = re.exec(branch)) !== null) {
|
|
263
|
+
let depth = 0;
|
|
264
|
+
const start = m.index + m[0].length;
|
|
265
|
+
let end = -1;
|
|
266
|
+
for (let i = start - 1; i < branch.length; i++) {
|
|
267
|
+
if (branch[i] === "(") depth += 1;
|
|
268
|
+
else if (branch[i] === ")") {
|
|
269
|
+
depth -= 1;
|
|
270
|
+
if (depth === 0) {
|
|
271
|
+
end = i;
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (end !== -1) args.push(branch.slice(start, end));
|
|
277
|
+
}
|
|
278
|
+
return args.some(
|
|
279
|
+
(arg) => /\/admins\//i.test(arg) && /request\.auth\.(uid|token)/i.test(arg)
|
|
280
|
+
);
|
|
281
|
+
}
|
|
258
282
|
async function runChecks(model, rootDir, opts = {}) {
|
|
259
283
|
const { ev } = createEvidence();
|
|
260
284
|
const findings = [];
|
|
@@ -541,7 +565,8 @@ async function runChecks(model, rootDir, opts = {}) {
|
|
|
541
565
|
}
|
|
542
566
|
for (const rule of model.rules) {
|
|
543
567
|
const segments = rule.path.split("/").filter((s) => s.length > 0).map((s) => s.toLowerCase());
|
|
544
|
-
|
|
568
|
+
const adminIdx = segments.indexOf("admins");
|
|
569
|
+
if (adminIdx === -1 || adminIdx + 1 >= segments.length) continue;
|
|
545
570
|
const ruleOps = new Set(rule.operations.flatMap(expandOp));
|
|
546
571
|
const escalating = ["create", "write", "update"].filter((o) => ruleOps.has(o));
|
|
547
572
|
if (escalating.length === 0) continue;
|
|
@@ -554,8 +579,7 @@ async function runChecks(model, rootDir, opts = {}) {
|
|
|
554
579
|
const condInlined = inlineHelpersInCondition(condRaw, helperDetailed);
|
|
555
580
|
const cond = condResolved !== condRaw ? condResolved : condInlined !== condRaw ? condInlined : condRaw;
|
|
556
581
|
if (checksAdminPower(cond, condRaw, rule, helperDetailed)) continue;
|
|
557
|
-
|
|
558
|
-
if (docGate) continue;
|
|
582
|
+
if (cond.split("||").every(branchHasCallerDocGate)) continue;
|
|
559
583
|
const checksAuth = rule.authReferences.length > 0;
|
|
560
584
|
if (!checksAuth) continue;
|
|
561
585
|
findings.push(
|
|
@@ -563,14 +587,14 @@ async function runChecks(model, rootDir, opts = {}) {
|
|
|
563
587
|
"FBA014",
|
|
564
588
|
"WARNING",
|
|
565
589
|
"PROBABLE",
|
|
566
|
-
`Rule ${rule.path} permite ${escalating.join("/")} sem exigir poder de admin (sem claim/papel de admin nem doc-gate em admins/). Qualquer logado cria/altera o pr\xF3prio doc \u2014 se o cadastro escrever role 'admin', \xE9 auto-promo\xE7\xE3o. Confirme o c\xF3digo de signup e valide no Emulator.`,
|
|
590
|
+
`Rule ${rule.path} permite ${escalating.join("/")} sem exigir poder de admin (sem claim/papel de admin nem doc-gate em /admins/ amarrado ao seu login). Qualquer logado cria/altera o pr\xF3prio doc \u2014 se o cadastro escrever role 'admin', \xE9 auto-promo\xE7\xE3o. Confirme o c\xF3digo de signup e valide no Emulator.`,
|
|
567
591
|
`FBA014:${rule.path}:${normalizeTarget(rule.operations.join(","))}:${conditionKeyForFingerprint(rule.condition)}`,
|
|
568
592
|
{
|
|
569
593
|
file: rule.location.file,
|
|
570
594
|
line: rule.location.start.line,
|
|
571
595
|
resource: rule.path,
|
|
572
596
|
evidence: [ev("self-admin-create", rule.condition ?? "sem condi\xE7\xE3o", "PROBABLE", rule.location.file, rule.location.start.line)],
|
|
573
|
-
fix: "Exigir claim/papel de admin ou doc-gate (exists/get em admins/) no create/update; nunca deixar o cadastro escrever role 'admin' para usu\xE1rio comum. Valide no Emulator (matriz anonymous/user/admin)."
|
|
597
|
+
fix: "Exigir claim/papel de admin ou doc-gate (exists/get em /admins/ amarrado ao request.auth.uid) no create/update; nunca deixar o cadastro escrever role 'admin' para usu\xE1rio comum. Valide no Emulator (matriz anonymous/user/admin)."
|
|
574
598
|
}
|
|
575
599
|
)
|
|
576
600
|
);
|
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-SYGLJ457.js";
|
|
5
5
|
import "./chunk-7J3ADEBW.js";
|
|
6
6
|
|
|
7
7
|
// src/cli.ts
|
|
@@ -84,7 +84,7 @@ Uso: firebase-audit scan|check|verify|drift [--json] ...`);
|
|
|
84
84
|
const { resolve: resolveRoot } = await import("path");
|
|
85
85
|
const rootDir = cwdArg ? resolveRoot(process.cwd(), cwdArg) : process.cwd();
|
|
86
86
|
if (cmd === "verify") {
|
|
87
|
-
const { scan: scanForVerify } = await import("./scan-
|
|
87
|
+
const { scan: scanForVerify } = await import("./scan-3XBJMCAO.js");
|
|
88
88
|
const { verify } = await import("./verify-GQSR4FQL.js");
|
|
89
89
|
const { resolve: resolveVerify } = await import("path");
|
|
90
90
|
const coverageArg = getArg("coverage");
|
package/dist/index.d.ts
CHANGED
|
@@ -742,7 +742,8 @@ declare function findPublicAllowsContent(rawContent: string): {
|
|
|
742
742
|
* Checks (FBA001–FBA004, FBA009–FBA014, subconjunto intencional).
|
|
743
743
|
* Fingerprints: FBA001/FBA002 por regra-lógica + hash da condição
|
|
744
744
|
* (estáveis a formatação, únicos por regra duplicada);
|
|
745
|
-
* FBA003/FBA004/FBA010
|
|
745
|
+
* FBA003/FBA004/FBA010 com linha (únicos por ocorrência);
|
|
746
|
+
* FBA012/FBA014 por path + target + hash da condição (estáveis, sem linha).
|
|
746
747
|
*/
|
|
747
748
|
|
|
748
749
|
declare const IMPLEMENTED_CHECKS: readonly ["FBA001", "FBA002", "FBA003", "FBA004", "FBA009", "FBA010", "FBA011", "FBA012", "FBA013", "FBA014"];
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createMcpServer,
|
|
3
3
|
startMcpServer
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ZILSDI3F.js";
|
|
5
5
|
import {
|
|
6
6
|
AccessOriginSchema,
|
|
7
7
|
AuditYamlSchema,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
runChecks,
|
|
35
35
|
scan,
|
|
36
36
|
validateClaimSamples
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-SYGLJ457.js";
|
|
38
38
|
import {
|
|
39
39
|
buildFullPath,
|
|
40
40
|
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-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-ZILSDI3F.js";
|
|
5
|
+
import "./chunk-SYGLJ457.js";
|
|
6
6
|
import "./chunk-7J3ADEBW.js";
|
|
7
7
|
import "./chunk-CSMT4PIP.js";
|
|
8
8
|
import "./chunk-LD3F73XI.js";
|
package/dist/mcp.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createMcpServer,
|
|
3
3
|
startMcpServer
|
|
4
|
-
} from "./chunk-
|
|
5
|
-
import "./chunk-
|
|
4
|
+
} from "./chunk-ZILSDI3F.js";
|
|
5
|
+
import "./chunk-SYGLJ457.js";
|
|
6
6
|
import "./chunk-7J3ADEBW.js";
|
|
7
7
|
import "./chunk-CSMT4PIP.js";
|
|
8
8
|
import "./chunk-LD3F73XI.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@justmpm/firebase-audit",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.15",
|
|
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",
|
package/skill/SKILL.md
CHANGED
|
@@ -23,7 +23,7 @@ Skill para agentes usarem o `@justmpm/firebase-audit` do jeito certo.
|
|
|
23
23
|
- Storage resolve funções auxiliares do `.rules` antes de acusar (portaria com auth dentro não é "sem auth", inclui `let` do rules v2); helper não declarado vira PROBABLE com o nome na mensagem, nunca silêncio
|
|
24
24
|
- Storage tolera CRLF (arquivo Windows) e path `/(unknown)` nunca repete fingerprint (sufixo de linha só no degenerado)
|
|
25
25
|
- Regra com `auth != null && exists(admins/uid)` diz "login + documento via exists()", não "qualquer autenticado" — sem claim/provider, anônimo com login passa no conjunto se obtiver o doc
|
|
26
|
-
- FBA014: `allow create/update` próprio em `admins/` sem claim/papel de admin nem doc-gate é auto-promoção provável (caso cadastro que escreve `role: 'admin'`) — confirme o signup e o Emulator; `users/{uid}` + campo role
|
|
26
|
+
- FBA014: `allow create/update` próprio em `admins/` sem claim/papel de admin nem doc-gate é auto-promoção provável (caso cadastro que escreve `role: 'admin'`) — doc-gate só vale amarrado ao uid em todo ramo de `||`; confirme o signup e o Emulator; `users/{uid}` + campo role e `admin` singular estão fora do escopo estático
|
|
27
27
|
- Storage avalia disjunção por ramo (`auth || tamanho` acusa o ramo sem auth) e `return false` via helper é deny silencioso, igual ao `if false`
|
|
28
28
|
- Seeds/fixtures com Admin SDK moram em `scripts/` ou `server/`, nunca em `src/` (senão o scan acusa FBA003 de propósito)
|
|
29
29
|
|