security-scan gate (shared felhom.eu/scripts/security_scan_gate.py) in the fast set and CI, warn-first, with the accepted-hits file and decoys (R-986)
gates / gates (push) Successful in 40s

This commit is contained in:
admin committed 2026-10-19 21:11:51 +02:00
1 parent 30eea97662
commit 87f558836f
6 files changed
+86

No files matched your search

+8
View File
@@ -42,10 +42,18 @@ jobs:
git fetch -q --depth 1 origin "$GITHUB_SHA"
git checkout -q FETCH_HEAD
echo "checked out $(git rev-parse HEAD)"
# R-986: the security-scan gate is SHARED (felhom.eu/scripts/security_scan_gate.py, never copied), so the
# sibling clone is needed beside this one — the agent's and the controller's shape.
cd .. && git clone -q --depth 1 http://gitea.gitea-system.svc.cluster.local:3000/admin/felhom.eu.git felhom.eu
echo "sibling felhom.eu present at $(cd felhom.eu && git rev-parse --short HEAD)"
- name: Run the gate entry point
# The ONLY thing CI runs. No go build, no go test, no linting, no deploy. The
# exit code IS the result: no `|| true`, no pipe that could swallow it.
env:
# R-986: the security-scan gate fetches the PINNED gitleaks here (sha256-checked); no Go, so govulncheck says
# NOT CHECKED in CI, out loud. Warn-first either way: the scan lists, it never fails this job.
FELHOM_SCAN_FETCH: "1"
run: cd ws/app-catalog-felhom.eu && python3 scripts/catalog_gates.py --fast
- name: Manual proof - alarm key present, optional forced failure (dispatch only, R-1129)
+4
View File
@@ -0,0 +1,4 @@
# .security-accepted — hits security_scan_gate.py (felhom.eu/scripts, R-986) lists as ACCEPTED, not WARN.
# One per line: <tool> <id> <where> # reason. govulncheck: OSV id + module dir; gitleaks: rule@<sha256[:12] of the line> + file.
# The first scan's verdicts (2026-10-19): felhom.eu documentation/audits/night-2026-10-19/P7/triage.md
# (nothing accepted yet)
+9
View File
@@ -1,3 +1,12 @@
## 2026-10-19 — the security-scan gate (R-986); no template change
- `catalog_gates.py` registers `security-scan` (FAST set: the pre-push hook and CI) through `scripts/check-security-scan.py`,
which runs the SHARED `felhom.eu/scripts/security_scan_gate.py` on this repo and FAILS if the sibling is missing (never a
skip). No Go module here, so it is gitleaks on the pushed commits only, **warn-first** (it lists, it never refuses).
CI now clones the felhom.eu sibling and fetches the pinned gitleaks (`FELHOM_SCAN_FETCH=1`). `.security-accepted`:
nothing accepted (today's tree: 0 hits). Decoys: the shared 8, the wrapper on this tree, the wrapper with the shared
gate missing (exit 1).
## 2026-10-18 — Immich's and Nextcloud's Redis run without a volume (R-1117)
- Both Redis services now run as upstream runs them: `redis-server --save "" --appendonly no`, `/data` on a tmpfs, and no
+6
View File
@@ -36,6 +36,8 @@ Gates, in order (all must pass; **non-zero exit on any failure**):
16. redis-persistence static, instant, whole repo — no template's Redis/Valkey service runs append-only (R-1096)
17. privileges static, instant, whole repo — no template or ladder step asks for a container right the box's
allow-list does not give (R-971); the box (controller >= 0.328.0) refuses on its own
18. security-scan the SHARED scanner (felhom.eu/scripts/security_scan_gate.py) — gitleaks on the pushed commits,
WARN-FIRST: it lists, it never refuses (R-986); no Go module here, so no govulncheck
15. gate-decoys the decoy suite (test_gate_decoys.py) — each gate above still convicts its decoys
(R-1115). ~3 minutes, needs PyYAML: the full run only, never --fast
4. engine-major static, needs GIT HISTORY — no database engine pin crosses a MAJOR version
@@ -162,6 +164,10 @@ GATES = [
# data roots, ...). The box (controller >= 0.328.0) is the authority and refuses on its own; this is the early
# warning, so a bad template fails here instead of on every box. Static, stdlib only: the hook and CI.
("privileges", "check-privileges.py", False, True, False),
# R-986 (2026-10-19): the shared dependency and secret scanner, WARN-FIRST (exit 0 whatever it finds). It reads no
# network here (no Go module, so no govulncheck); gitleaks on the pushed commits, ~1 s. CI fetches the pinned gitleaks
# (FELHOM_SCAN_FETCH=1 in gates.yml).
("security-scan", "check-security-scan.py", False, True, False),
# R-1115 (2026-10-17): the gates' OWN decoy suite — every gate above is red-proved against its decoys here. It
# was not in this table, so a case that stopped convicting (a template edit removed its premise) failed for a
# night with nobody looking. Static (a local clone, a stub docker), but ~3 minutes and it needs PyYAML, so NOT
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""check-security-scan.py — runs the SHARED dependency and secret scanner on this repo (R-986).
The gate itself lives in ONE place, `felhom.eu/scripts/security_scan_gate.py` (the reuse_refs_check.py rule: never
copied), and is WARN-FIRST — it lists hits and exits 0. This repo has no Go module, so it runs gitleaks on the pushed
commits only. If the sibling felhom.eu clone is absent this FAILS and names the path it tried: a runner that quietly
skips a gate is the inert-seam failure this project has shipped four times.
"""
import os
import subprocess
import sys
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SHARED = os.path.join(os.path.dirname(ROOT), "felhom.eu", "scripts", "security_scan_gate.py")
if __name__ == "__main__":
if not os.path.isfile(SHARED):
print("FAIL: the shared gate is MISSING beside this clone (tried %s) — a failure, never a skip" % SHARED)
sys.exit(1)
sys.exit(subprocess.call([sys.executable, SHARED, ROOT]))
+38
View File
@@ -47,6 +47,7 @@ ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Read by felhom.eu/scripts/decoy_coverage_gate.py, which AST-parses this literal. A gate named here
# MUST have a decoy below that has been seen to fail.
COVERS = {
"security-scan": "R-986: the shared gate's own decoys (felhom.eu scripts/test_security_scan_gate.py, 8 cases in SCRATCH git repos: a planted token listed by rule and file, its value never printed; a second secret on another line of an accepted file still listed; a called govulncheck finding listed, an imported-only one not; no tool is NOT CHECKED out loud), run from here; plus this repo's wrapper on its own tree (exit 0 and the summary line) and the wrapper with the shared gate MISSING (exit 1, never a skip)",
"volume-persistence": "the classifier and the self-test via the injected-prober suite scripts/test_check_volume_persistence.py, RUN FROM HERE and required green (a blind prober and a crying-wolf prober are refused rc=3; `wrote nothing`, a container not running, a path token alone, an unresolved suspect are UNDETERMINED or clean, never a false CLEAN/BROKEN; the papra signature convicts); and END TO END with a PATH-STUB docker that fails every call, no docker at all, nothing to judge - each HARNESS REFUSED rc=3, never 0 (R-426)",
"image-resolvable": "END TO END through the gate's own `docker manifest inspect` call, with a PATH-STUB docker (PATH holds ONLY the stub, so the real runtime is unreachable): the label of success without the fact - rc=0 carrying a throttle or any error text, a docker that resolves EVERYTHING incl. the .invalid canary, no docker at all, nothing to judge - each INCONCLUSIVE or HARNESS REFUSED, never 0; the cry-wolf direction - a throttle or an unrecognised error on rc=1 is never an accusation; vs a registry that positively says `manifest unknown` (convicted, naming the app) and a clean run (R-426)",
"image-pins": "the pin's LABEL without the pin: a registry PORT (`:5000`) read as a tag, `@sha256:` with no digest behind it, a QUOTED `\"image\":` key, an interpolated `${APP_IMAGE:-nginx}`, `:LATEST`/`:latest` in quotes - vs the inert shapes that must pass (a commented `# image: nginx`, an `x-image:` extension field, a README line) and the genuine pins (a tag, a real 64-hex digest, `:latest@sha256:` pinned by its digest, a port with a tag) (R-426)",
@@ -1531,6 +1532,42 @@ def guide_cases(clone):
must_contain=("1 hidden", "hidden — guidedecoy"), must_not=("WARN",))
def security_scan_cases():
"""R-986: the shared scanner's decoys, the wrapper on this tree, and the wrapper with the shared gate missing."""
global ran
shared_dir = os.path.join(os.path.dirname(ROOT), "felhom.eu", "scripts")
wrapper = os.path.join(ROOT, "scripts", "check-security-scan.py")
suite = os.path.join(shared_dir, "test_security_scan_gate.py")
if not os.path.isfile(suite):
fails.append("security-scan: the shared decoy suite is MISSING (tried %s) - a failure, never a skip" % suite)
return
for name, argv, want_rc, must in (
("security-scan: the shared gate's 8 decoys", [sys.executable, suite], 0, "all 8 cases passed"),
("security-scan: GENUINE: the wrapper on this tree", [sys.executable, wrapper], 0, "security-scan:")):
ran += 1
p = subprocess.run(argv, cwd=ROOT, capture_output=True, text=True, input="")
if p.returncode != want_rc or must not in p.stdout + p.stderr:
fails.append("%s: rc=%d (want %d), %r missing\n%s" % (name, p.returncode, want_rc, must, (p.stdout + p.stderr)[-700:]))
else:
print(" ok %s" % name)
# The wrapper copied next to an EMPTY felhom.eu: the shared gate is missing → exit 1, never a skip.
ran += 1
tmp = tempfile.mkdtemp(prefix="secscan-missing-")
try:
os.makedirs(os.path.join(tmp, "app-catalog-felhom.eu", "scripts"))
os.makedirs(os.path.join(tmp, "felhom.eu", "scripts"))
w2 = os.path.join(tmp, "app-catalog-felhom.eu", "scripts", "check-security-scan.py")
shutil.copy(wrapper, w2)
p = subprocess.run([sys.executable, w2], cwd=tmp, capture_output=True, text=True, input="")
if p.returncode != 1 or "MISSING" not in p.stdout:
fails.append("security-scan: FACT: the shared gate missing - rc=%d, want 1 naming MISSING - LIVE HOLE\n%s"
% (p.returncode, p.stdout[-400:]))
else:
print(" ok security-scan: FACT: the shared gate missing is a failure")
finally:
shutil.rmtree(tmp, ignore_errors=True)
def main():
gate = os.path.join(ROOT, "scripts", "check-engine-major.py")
if not os.path.isfile(gate):
@@ -2070,6 +2107,7 @@ i18n:
image_volumes_cases()
redis_persistence_cases()
privileges_cases()
security_scan_cases()
if fails:
print()