chore(hooks): install working pre-commit/pre-push git hooks - #82
chore(hooks): install working pre-commit/pre-push git hooks#82PenguinzTech wants to merge 1 commit into
Conversation
.git/hooks/pre-commit was a pre-commit-framework shim on repos branched from main with no .pre-commit-config.yaml, so every commit died with InvalidConfigError. v2.1.x already had a config but it predated the framework's pre-commit/pre-push stage naming, hand-rolled several checks with silent `|| true` tool-missing fallbacks, and linted Python with flake8/black/isort. - Modernize .pre-commit-config.yaml: pre-commit/pre-push stages, add missing hygiene hooks, framework-managed gitleaks/shellcheck/golangci-lint (pinned v1.64.8 to match CI, matching go-client-release.yml) instead of system-PATH-dependent local hooks, actionlint (shellcheck sub-check disabled -- redundant with the dedicated shellcheck hook), bandit + Dockerfile rootless check at pre-push. - Migrate Python lint from flake8/black/isort to ruff (backend-python.md): canonical [tool.ruff] in pyproject.toml, blocking hook scoped to --select=F,E9,B (flake8's prior bar), full canonical rule set advisory (~1,700 pre-existing findings, mostly missing docstrings/pyupgrade across 5 services -- not in scope here, tracked via the pyproject.toml comment for incremental adoption). Fixed all 50 findings in the blocking scope, including a real bug (dpop_service.py referenced `traceback` without importing it) and 4 missing `raise ... from`. Removed flake8/black/isort from requirements-dev.txt, .flake8, and CI. Also fixed pre-existing bandit findings (B104 false-positives on server listen sockets/config defaults, annotated; B113 missing requests timeout) and shellcheck findings (SC2145/SC2155/SC2034) surfaced by wiring the tools in for the first time. - Copy scripts/install-pre-commit.sh + lib/detect-os.sh + hooks/check-dockerfile-rootless.sh from admin; fix a worktree bug in --verify (used "$root/.git/hooks" instead of --git-common-dir, so it's a file not a dir inside a worktree and always reports NOT INSTALLED). - Add install-hooks/verify-hooks Makefile targets; make setup depend on install-hooks; update lint/fix-lint/format for ruff. - Update docs (CONTRIBUTING/DEVELOPMENT/PRE_COMMIT/STANDARDS/WORKFLOWS) to match. Verified: pre-commit run --all-files and --hook-stage pre-push both pass clean. make lint and make install-hooks/verify-hooks pass. Unit tests for touched files pass where the local environment has their deps installed; 6 pre-existing failures (dpop_service crypto, observability, saml/scim missing `saml2` package) reproduce identically against the unmodified files and are out of scope here. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning Review the following alerts detected in dependencies. According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.
|
|
Filed the tenant-isolation finding as #83 ( On closer inspection it is broader than noted in the PR body: the root cause is No change to this PR; hooks work is unaffected. |
Summary
.git/hooks/pre-commitwas a pre-commit-framework shim with no.pre-commit-config.yamlon branches offmain— every commit died withInvalidConfigError.v2.1.xalready had a config, but it predated pre-commit'spre-commit/pre-pushstage naming, hand-rolled several checks with silent|| truetool-missing fallbacks, and linted Python with flake8/black/isort..pre-commit-config.yaml: proper pre-commit/pre-push staging, framework-managed gitleaks/shellcheck/golangci-lint (pinnedv1.64.8to matchgo-client-release.yml, fixing a v1-vs-v2 config-schema mismatch against system-installed golangci-lint) instead of PATH-dependent local hooks, actionlint (with its embedded shellcheck sub-check disabled — redundant with the dedicated shellcheck hook and otherwise surfaces dozens of pre-existing style findings), bandit + Dockerfile-rootless check at pre-push.backend-python.md): canonical[tool.ruff]inpyproject.toml; the blocking hook is scoped to--select=F,E9,B(the same bar flake8 already enforced) and all 50 findings in that scope are fixed, including a real bug (dpop_service.pycalledtraceback.print_exc()without importingtraceback, so any exception there raisedNameErrorand masked the original error) and 4 missingraise ... from. The full canonical rule set (docstrings/naming/pyupgrade/security) surfaces ~1,700 pre-existing findings across five services — documented as advisory/follow-up inpyproject.toml, not fixed here (out of scope for a hooks-installation chore). Removed flake8/black/isort fromrequirements-dev.txt(all 5 services),.flake8, and CI.requeststimeout) findings surfaced by wiring these checks in for the first time.scripts/install-pre-commit.sh+lib/detect-os.sh+hooks/check-dockerfile-rootless.shfromadmin; fixed a worktree bug in--verify(it used"$root/.git/hooks", which is a file not a directory inside a worktree, so it always reported hooks as NOT INSTALLED even when correctly installed).install-hooks/verify-hooksMakefile targets;setupnow depends oninstall-hooks; updatedlint/fix-lint/formatfor ruff.CONTRIBUTING.md,DEVELOPMENT.md,PRE_COMMIT.md,STANDARDS.md,WORKFLOWS.md) to match.--all-filesfor the first time (verified whitespace-only viagit diff).Not fully green — left open, not auto-merged
Per
devops.md's Auto-Merge gate, pre-existing failures block merge regardless of relation to this change.make test-securityandmake testcurrently fail for reasons unrelated to this PR and predating it:make test-security→gosec: 4 findings where the source uses//nolint:gosec(golangci-lint syntax), but the Makefile'stest-securitytarget runs baregosec ./..., which only understands#nosec— a pre-existing tooling mismatch, not something introduced here.make test-security→govulncheck: local Go toolchain skew (govulncheck built with go1.26,go liston PATH is go1.25) — environment issue, not a repo bug.make test: 6 pre-existing test failures reproduce identically against the unmodified files (test_dpop_service.pyx4 — crypto verification bug,test_observability.py— OpenTelemetry package version mismatch,test_app.py— missingsaml2package), plus several services' test suites can't even collect in a from-scratch environment without their per-service venv installed (responses,saml2,pyOpenSSLmissing).None of the above are touched by this PR's diff. The hook infrastructure itself is fully verified green (see Test plan).
Test plan
pre-commit run --all-files— all hooks passpre-commit run --all-files --hook-stage pre-push— all hooks passmake install-hooks/make verify-hooks— hooks installed, executable, non-empty (fixed the worktree false-negative)make lint— exits 0 (openapi spectral warnings are pre-existing/advisory, 0 errors)python3 -m py_compileon every edited.pyfiledns-server,squawk-client) pass in full;manager/backendfailures confirmed pre-existing by reproducing against the unmodified filesmake test-security/make test— pre-existing failures unrelated to this change (see above); not fixed here🤖 Generated with Claude Code