@davoodmehraban89 / Aram-2 Mirror · read-only / commits / 73889c7
Fork 0

Mirrored from https://github.com/davoodmehraban89/Aram.git

Synced Dec 4, 10:30 UTC

Fix: exclude .secrets.baseline from its own secret scan

The baseline stores hashed_secret values and "hashed_secret" keys, which are secret-shaped by construction: the moment the file became tracked, every scan reported 22 self-referential findings (caught by the first CI run of PR #99; the pre-commit step of the same run passed). The gate now scans with --exclude-files '^\.secrets\.baseline$'; the documented regeneration command carries the same exclusion. PROJECT_LOG entry updated (same-PR doc). Verified: gate 0 new (18 baselined) on the tracked-baseline tree; negative test (staged fake secret) still exits 1 with file:line; pre-commit --all-files all hooks pass with zero modifications; git diff --check clean. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>

davoodmehraban89 committed Dec 4, 2026 at 10:00 UTC 73889c7f8329c788b12ffc8481796cf3782a156a
2 files changed +14 -4
docs/PROJECT_LOG.md
+1 -1
@@ -435,7 +435,7 @@ Each new entry must record: UTC timestamp, actor, task/phase, base branch and SH
435
436 - Actor: Arena agent (implementation). Trigger: owner asked which tooling would best improve the software and selected the four low-risk items in chat (pre-commit + detect-secrets; prod npm-audit gate; frontend coverage gate; Dependabot). Worked on `arena/2d4eda07-aram` off verified base `07a8ae0e621e706e4ce1583a611699bc2bc6d38d` (= `origin/source-data-cleanup` at fetch time; Arena single-branch session constraint, same as R1).
437 - `.pre-commit-config.yaml`: pre-commit-hooks v6.0.0 (large-files 1 MB with `data/`+`samples/` excluded, merge-conflict, toml, yaml, detect-private-key, trailing-whitespace) + ruff-pre-commit v0.17.6 (satisfies backend `ruff>=0.8,<1`; revs verified via GitHub API 2026-12-04; hook scopes mirror Backend CI exactly: check on `backend/{src,tests}`, format on domain/services/migrations). `end-of-file-fixer` deliberately NOT enabled: 14 pre-existing files (incl. governance-frozen `docs/handoff/CHATGPT_BOOTSTRAP_PROMPT.txt` and `docs/archive/`) lack the convention; repo-wide normalization is unrelated churn against the focused-diff rule, and the existing `git diff --check` CI steps keep PR diffs clean. `trailing-whitespace` enabled — zero pre-existing violations (verified).
438 -- Secret scanning: `.secrets.baseline` (9 files / 18 findings — reviewed false positives: backend test-fixture passwords, the CI PostgreSQL dummy password, docs SHA-256 hashes) + `scripts/check_secrets_baseline.py`, a churn-free gate failing only on NEW (file, plugin type, line-hash) triples; `# pragma: allowlist secret` is the documented escape hatch. detect-secrets is intentionally NOT a pre-commit hook: its baseline mode rewrites line numbers (exit 3) whenever a baselined file is edited — churn incompatible with الف‌4 diff discipline. Gate negative-tested: staged fake secret → exit 1 with file:line; pragma variant → exit 0; cleanup → exit 0.
438 +- Secret scanning: `.secrets.baseline` (9 files / 18 findings — reviewed false positives: backend test-fixture passwords, the CI PostgreSQL dummy password, docs SHA-256 hashes) + `scripts/check_secrets_baseline.py`, a churn-free gate failing only on NEW (file, plugin type, line-hash) triples; `# pragma: allowlist secret` is the documented escape hatch. The baseline excludes **itself** from the scan (`--exclude-files '^\.secrets\.baseline$'`): its `hashed_secret` values are secret-shaped by construction, so once the file is tracked a naive scan reports 22 self-referential findings (caught by this PR's first CI run; the gate script and the documented regeneration command carry the same exclusion). detect-secrets is intentionally NOT a pre-commit hook: its baseline mode rewrites line numbers (exit 3) whenever a baselined file is edited — churn incompatible with الف‌4 diff discipline. Gate negative-tested: staged fake secret → exit 1 with file:line; pragma variant → exit 0; cleanup → exit 0.
439 - CI: new `Repo Hygiene` workflow (`.github/workflows/repo-hygiene.yml`) — `pre-commit run --all-files` + the secret gate on every PR and accepted-branch push (no path filter). Frontend CI quality job: added `npm audit --omit=dev --audit-level=moderate` (prod deps must be moderate-clean; install keeps `--no-audit` for speed) and replaced bare `npm test` with `npm run test:coverage`.
440 - Frontend coverage gate (`frontend/vite.config.ts`, `@vitest/coverage-v8` ^2.1.9): scope `src/**` excluding test files/main.tsx/d.ts; thresholds lines/statements 30, branches 70, functions 40 against the measured 2026-12-04 baseline (33.97/72.97/42.85/33.97, 15 tests); `autoUpdate: false`. Raising toward the C9 80/90 target is a separate test-growing task.
441 - `.github/dependabot.yml`: weekly updates — github-actions (/), npm (frontend, minor+patch grouped, majors individual), pip (backend). Documented limitation: Dependabot does not manage `.pre-commit-config.yaml` revs (bump deliberately via `pre-commit autoupdate`).
scripts/check_secrets_baseline.py
+13 -3
@@ -11,8 +11,14 @@ produces churn. Line-number drift is deliberately ignored.
11 False positives in *new* code are escaped inline with the native detect-secrets
12 marker: # pragma: allowlist secret (or: # pragma: allowlist nextline secret)
13
14 +The baseline file excludes itself from the scan (`--exclude-files`): its
15 +`hashed_secret` values and `"hashed_secret":` keys are, by construction,
16 +secret-shaped, so scanning it would report 22 self-referential findings the
17 +moment the file becomes tracked. The baseline is a reviewed collection of
18 +findings, not new leakage.
19 +
20 After an intentional, reviewed change to what is allowed, regenerate:
15 - detect-secrets scan > .secrets.baseline
21 + detect-secrets scan --exclude-files '^\\.secrets\\.baseline$' > .secrets.baseline
22 and review the diff before committing (never blanket-regenerate to silence
23 a real secret).
24
@@ -33,6 +39,9 @@ from typing import Any
39
40 ROOT = Path(__file__).resolve().parent.parent
41 BASELINE = ROOT / ".secrets.baseline"
42 +# The baseline must not be scanned as a normal file: its hashed_secret values
43 +# and keys are secret-shaped by construction (see module docstring).
44 +BASELINE_EXCLUDE = r"^\.secrets\.baseline$"
45
46
47 def _triples(results: dict[str, Any]) -> set[tuple[str, str, str]]:
@@ -47,7 +56,8 @@ def main() -> int:
56 if not BASELINE.exists():
57 print(
58 "ERROR: .secrets.baseline is missing.\n"
50 - "Generate it with: detect-secrets scan > .secrets.baseline\n"
59 + "Generate it with: detect-secrets scan "
60 + "--exclude-files '^\\.secrets\\.baseline$' > .secrets.baseline\n"
61 "and commit the reviewed baseline.",
62 file=sys.stderr,
63 )
@@ -60,7 +70,7 @@ def main() -> int:
70
71 try:
72 scan = subprocess.run(
63 - ["detect-secrets", "scan"],
73 + ["detect-secrets", "scan", "--exclude-files", BASELINE_EXCLUDE],
74 cwd=ROOT,
75 capture_output=True,
76 text=True,