hooks/revs-pinned
Hook repositories are pinned to versions
| Severity | warning |
| Tiers | 1, 2 |
| Stacks | any |
| Scope | root |
| Kind | expr |
| Source | library v0.4.0 |
| Selected by | fleetlint-recommended@v0.4.0 |
Requirement
Every rev: in .pre-commit-config.yaml is a version tag or a commit SHA, never a branch name (main, master, HEAD, develop, trunk, latest, stable, 2.x); a rev without a digit is taken for a branch.
Why
A hook at a branch runs whatever was pushed there last, on every developer’s machine, before anything is reviewed.
Applies when
file(".pre-commit-config.yaml") && type(yaml(".pre-commit-config.yaml")) == map && "repos" in yaml(".pre-commit-config.yaml") && type(yaml(".pre-commit-config.yaml").repos) == listCheck
For each item in:
yaml(".pre-commit-config.yaml").repos.filter(r, type(r) == map && "rev" in r).map(r, {
"path": ".pre-commit-config.yaml",
"name": ("repo" in r ? string(r.repo) : "?") + "@" + string(r.rev),
"rev": string(r.rev)
})item.rev.matches("^[0-9a-f]{40}$") || (item.rev.matches("[0-9]") && !item.rev.matches("(?i)(^|[-/])(main|master|head|develop|dev|trunk|latest|stable|nightly|next)$|\\.x$"))Fix
Run prek update (pre-commit: pre-commit autoupdate) to replace branch revs with the latest tags.
Agent instruction: Replace each flagged rev with the repository’s latest release tag (prek update does this); do not change hooks or args.
Sources
- https://pre-commit.com/ (spec, .pre-commit-config.yaml - repos)
- https://github.com/ossf/scorecard/blob/main/docs/checks.md (standard, Pinned-Dependencies)
- https://fleetlint.org/baseline/#git-hooks
- https://fleetlint.org/baseline/#security
Generated by fleetlint docs from catalog v0.4.0.