Repository navigation
feat: add site-private leak-check hook - #1950
Merged
Merged
Conversation
gerchowl
force-pushed
the
feature/1932-site-leak-check
branch
from
October 29, 2026 01:11
1500caf to
49dddd8
Compare
Contributor
Author
|
S4 final-round contract for S6: PR #1938 provides |
10 of 22 tasks
gerchowl
added a commit
that referenced
this pull request
Oct 29, 2026
## Description Add `check-site-config` and `site-init` for per-worktree site bindings. Both commands resolve the git toplevel from any subdirectory and refuse outside git. Initialization discovers trusted external tools or writes an unbound template, validates staged files, then publishes them. ## Type of Change - [x] `feat` -- New feature - [x] `fix` -- Bug fix - [ ] `docs` -- Documentation only - [ ] `chore` -- Maintenance task (deps, config, etc.) - [ ] `refactor` -- Code restructuring (no behavior change) - [x] `test` -- Adding or updating tests - [ ] `ci` -- CI/CD pipeline changes - [ ] `build` -- Build system or dependency changes - [ ] `revert` -- Reverts a previous commit - [ ] `style` -- Code style (formatting, whitespace) ### Modifiers - [ ] Breaking change (`!`) -- This change breaks backward compatibility ## Changes Made - Add the managed `just site-init` recipe while preserving `help` as the default; ignore `.site/` and `.aws/` in scaffolds. - Validate schema v1, active-site lookup, credential restrictions and bound location forms. Reject whitespace/control characters, unsafe file URIs, invalid S3 bucket names and reserved site names; errors name fields without exposing values. - Anchor discovery, staging and lookup to the resolved git worktree root, including linked worktrees. Exclude relative and in-tree PATH directories and resolved executable targets. - Detect `.site/` changes recursively and refuse symlinks/special files. Clean staging and newly created empty directories after failure; enforce `--force` before publishing. - Expose `validate_patterns(path: Path) -> None` for S6. Its self-contained pattern rule is recorded once in the ADR Amendments: case-insensitive keys without ambiguous variants, at least one usable id-plus-regex/path rule, no extend, missing files mean no check. Pattern values are never checked as site credentials or exposed in errors. - Record the ADR §8/§9 clarification: empty locations are valid unbound bindings with notices; consumers must refuse unbound bindings with actionable errors. ## Changelog Entry ### Added - **Per-clone site bindings and initializer hook** ([#1930](#1930)) - Validate site configuration and initialize bindings from PATH or an unbound template. - Discover only external initializers, validate supported location forms, and accept gitleaks pattern definitions separately from site bindings. - Anchor site operations to the git worktree, reject unsafe locations and reserved names, inspect recursive writes, and share self-contained pattern validation with the leak checker. ## Testing - RED: final-round regression suite, 91 failed and 48 passed (exit 1); tests committed before fixes. Additional userinfo field-name regression: 1 failed and 4 passed (exit 1), also committed before its fix. - GREEN after rebase: `PYTHONPATH="$PWD/packages/vig-utils/src" uv run --with pytest-xdist pytest packages/vig-utils/tests/test_site_config.py -n 4 --basetemp="$HOME/.cache/devkit-pytest/1930"`: 139 passed (exit 0). - Commit hooks run in `nix develop`: formatting, lint, security, documentation and manifest checks passed. CI checks run on the pushed head. - [ ] Tests pass locally (`just test`) - [ ] Manual testing performed (describe below) ### Manual Testing Details ## Checklist - [x] My code follows the project's style guidelines - [x] I have performed a self-review of my code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have updated the documentation accordingly (edit `docs/templates/`, then run `just docs`) - [x] I have updated `CHANGELOG.md` in the `[Unreleased]` section (and pasted the entry above) - [ ] My changes generate no new warnings or errors - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published ## Additional Notes Initializers are trusted external programs, not sandboxed processes. Recursive metadata checks detect changed entries but cannot prevent arbitrary writes or an initializer restoring metadata. This limit is documented in ADR §9. S6 coordination: #1950 (comment). Refs: #1930
gerchowl
force-pushed
the
feature/1932-site-leak-check
branch
from
October 29, 2026 01:42
49dddd8 to
5d60ccd
Compare
9 of 13 tasks
gerchowl
force-pushed
the
feature/1932-site-leak-check
branch
from
October 29, 2026 02:26
5d60ccd to
d4c6a5d
Compare
gerchowl
added a commit
that referenced
this pull request
Oct 29, 2026
## Description Rewrites `docs/MIGRATION.md`'s "Run CI on self-hosted runners" section to document the shipped site-agnostic runner mechanism (`CI_RUNNER_SMALL`/`LARGE`/`XLARGE` variables, the fork predicate, size classes and the `DEVKIT_CI_LANE_SIZES` lane override, and the N/N+1/N+2 deprecation timeline) in place of the stale, pre-migration `DEVKIT_CI_RUNNER`-comma-list description. Source of truth: `docs/rfcs/ADR-site-agnostic-projects.md`, cross-checked against the merged S1/S1b/S1d/S2/S3 code (`resolve-toolchain/action.yml`, `ci.yml`, `devkit-upgrade.yml`, `init-workspace.sh`). ## Type of Change - [x] `docs` -- Documentation only ### Modifiers - [ ] Breaking change (`!`) -- This change breaks backward compatibility ## Changes Made - Rewrote the variable-selection, fork-safety and deprecation-timeline content of "Run CI on self-hosted runners", replacing the removed comma-separated `DEVKIT_CI_RUNNER` mechanism and the site-specific example label/`gh variable set` value (both replaced with `<label>`) - Added `####` subsections: Size classes and the lane override, Fork safety (including decision (f)'s remedy for forks of a private repo, and the owner-confirmed wording that the fork predicate is accident-prevention, not the security boundary), Deprecation timeline, and Known symptoms (the "CI never starts on a private repo" §3 notice limit, and the whitespace-only/malformed `CI_RUNNER_SMALL` symptom) - Updated the `.vig-os` manifest key table: rewrote the now-deprecated `DEVKIT_CI_RUNNER` row and added the missing `DEVKIT_CI_LANE_SIZES` row - Fixed one stale cross-reference to the old mechanism in the adjacent "Keep the dev-shell gcroot" section - Left the already-correct "Seeded hook runner migration" subsection (S3, #1949) untouched, including its anchor ## Changelog Entry ### Changed - **Rewrite the self-hosted CI runner migration guide** ([#1933](#1933)) - `docs/MIGRATION.md`'s "Run CI on self-hosted runners" section now documents the shipped `CI_RUNNER_SMALL`/`LARGE`/`XLARGE` variables, the per-lane `DEVKIT_CI_LANE_SIZES` override, fork safety (including the private-fork remedy) and the full N/N+1/N+2 deprecation timeline, replacing the stale description of the removed `DEVKIT_CI_RUNNER`-only mechanism - Add "CI never starts on a private repo" and whitespace-only `CI_RUNNER_SMALL` symptom entries, and scrub the site-specific example label from the section and the manifest key table ## Testing - [x] Tests pass locally (targeted subset, not full `just test` per the shared-host rule) - [x] Manual testing performed (describe below) ### Manual Testing Details - `nix develop --command prek run pymarkdown --files docs/MIGRATION.md CHANGELOG.md --show-diff-on-failure --color=always` → **Passed**, exit 0 (the repo's actual docs/markdown lint; `fix` mode made no further changes) - A one-off script (not committed) extracted every `MIGRATION.md#…` anchor referenced anywhere in the repo outside `docs/issues/`/`docs/pull-requests/` (`git grep -n 'MIGRATION.md#'`) and compared it against the GitHub-slugified headings in the rewritten `docs/MIGRATION.md`: 16 distinct anchors, all resolve - `nix develop --command uv run --with pytest-xdist pytest tests/test_seeded_hook_runner_migration.py::test_migration_docs_and_changelog_match_the_new_contract tests/test_rust_scaffold.py::test_bypass_notice_links_to_a_real_migration_heading tests/test_ci_runner.py -n 4` → **280 passed** - `git diff` scanned for the scrubbed site-specific label — only present in removed (`-`) lines - Checked the section contains no site label, hostname, org-specific runner name, `/mnt/...` path or real IP ## Checklist - [x] My code follows the project's style guidelines - [x] I have performed a self-review of my code - [ ] I have commented my code, particularly in hard-to-understand areas - [x] I have updated the documentation accordingly (edit `docs/templates/`, then run `just docs`) -- N/A, no template change - [x] I have updated `CHANGELOG.md` in the `[Unreleased]` section (and pasted the entry above) - [x] My changes generate no new warnings or errors - [ ] I have added tests that prove my fix is effective or that my feature works -- N/A, docs-only change - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published ## Additional Notes No code changes. S6 (#1950, leak-check hook) is still open and may also touch `MIGRATION.md`; rebasing onto it if it lands first is on me per the brief. Refs: #1933
gerchowl
force-pushed
the
feature/1932-site-leak-check
branch
from
October 29, 2026 19:11
1a5f265 to
bc7e2f0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add the ADR §10 default-on site leak-check hook. A clone without private patterns exits silently; configured clones scan staged changes or selected working-tree files through gitleaks and publish only file, line and rule ID.
Type of Change
feat-- New featurefix-- Bug fixdocs-- Documentation onlychore-- Maintenance taskrefactor-- Code restructuringtest-- Adding or updating testsci-- CI/CD pipeline changesbuild-- Build system or dependency changesrevert-- Reverts a previous commitstyle-- Code styleModifiers
!)Changes Made
Resolve
DEVKIT_LEAK_PATTERNSbefore.site/leak-patterns.toml. Use merged S4's publicvig_utils.site_config.validate_patternsand preserve its safe error messages with exit 2. The S4 ADR amendment defines the single pattern-file contract; a missing selected file is a silent no-check without fallback.Materialize raw blobs from the index for added, copied, modified, renamed and type-changed paths. Use Git's NUL-delimited metadata only for path selection, with no external diff or textconv; stream raw blobs through one
git cat-file --batchprocess, avoiding checkout filters and per-blob process creation. Staged, filename and all-files modes then share one gitleaks directory scanner.Cover full index content at changed paths, including pure renames; skip deleted and untouched paths. Filename mode skips NUL-containing inputs to enforce the text-hook contract, while direct staged and all-files scans include those bytes.
Scan selected site bindings and repository ignore files as data. Isolate gitleaks 8.30.1's automatic source-ignore loading by scanning a root
.gitleaksignoreseparately; the private config remains explicit.Define the default-on text/symlink hook once in
nix/hooks.nixand mirror both portable configs. Pin gitleaks in Nix-generated hooks, and publish only file, line and rule ID. Document scan boundaries, printed paths, linked worktrees and intentional exceptions.Pass
--in every hook definition before filenames; reject help-looking CLI options and disable option abbreviation. Real installed-hook commits cover-h,--help,--heand--all-filesfilenames.Own private snapshots in one cleanup routine on success, findings, errors and signals. Block SIGINT/SIGTERM/SIGHUP before deleting, restore the previous mask/handlers, and honour pending signals only after deletion with a conventional exit code and no traceback. Identify unreadable pattern files and report input read/materialization errors using only safe path metadata.
Scan symlink link text as regular snapshot content in staged, filename and all-files modes, without following targets. Select links through
types: []plustypes_or: [text, symlink], clearing the hook runner's default file-only filter. Preserve raw link text, including repeated separators, and apply path rules to link names.Changelog Entry
Added
success when no site patterns exist and redacted finding diagnostics.
and reject present pattern files without usable rules.
reader despite Git attributes; share S4's safe pattern validation.
and report filesystem failures with paths and OS reasons without file contents.
despite repeated termination signals.
Testing
Manual Testing Details
pytest tests/test_site_leak_check.py -n 4 --basetemp=$HOME/.cache/devkit-pytest/1932-r6 -qinside the Nix environment with worktreePYTHONPATHfirst exited 1: 9 failed / 112 passed. Tests were committed before implementation.nix develop:PYTHONPATH="$PWD/packages/vig-utils/src" uv run --with pytest-xdist pytest tests/test_site_leak_check.py tests/test_hardcoded_endpoints.py packages/vig-utils/tests/test_site_config.py -n 4 --basetemp=$HOME/.cache/devkit-pytest/1932-r6 -qexited 0: 379 passed.nix developwith hooks enabled. Container and Nix evaluation suites are reserved for CI.Checklist
CHANGELOG.mdin theUnreleasedsectionAdditional Notes
Rebased onto S3 (#1949) and S4 (#1938). Conflict resolution preserved both S3 and S6 changelog entries in
CHANGELOG.mdandassets/workspace/.devcontainer/CHANGELOG.md, and preserved all S3/S4/S6 amendments indocs/rfcs/ADR-site-agnostic-projects.md.S6 consumes S4's public pattern validator; the S4 ADR amendment remains the single rule definition. Rule IDs and matching file paths must be safe for public logs. The snapshot scanner never follows symlink targets; independently selected regular files are scanned normally.
Refs: #1932