Detect secrets in pushed content #339

closed cmc opened this on 2026-10-31 06:12 UTC

Discussion

cmc 2026-10-31 06:12 UTC

Nothing inspects pushed content for credentials. The quality job in this repository runs trufflehog over the checked-out tree, which covers one repository and only after the push has landed.

Approach: in the pre-receive hook, scan the blobs a push introduces (the quarantined objects, not history) with gitleaks' detector as a Go library (MIT). The hook reports findings over hook.sock and the daemon decides per repository whether to refuse the push or accept it and notify, keeping git facts in the hook and policy in the daemon. Default to warn: a false positive that blocks a push costs more than a late notification. A refusal is the usual pkt-line ERR naming path, line and rule, never the matched value.

Bounds: skip binary blobs and blobs over a size limit, and cap scanned bytes per push alongside receive.maxInputSize, so a large push cannot stall the hook.

Content that never passes through the push hook (history predating the feature, repo import, pull mirrors) needs an on-demand full-history scan per repository. A per-repository allowlist covers test fixtures.

closed by cmc in commit 4158ea427f: Scan pushes for credentials

2026-10-31 06:44 UTC