Skip to content

Improve pre-commit actions - #221

Merged
Max Freedman (mfreedman-moj) merged 7 commits into
mainfrom
update-pre-commit
Oct 29, 2026
Merged

Max Freedman (mfreedman-moj) merged 7 commits into
mainfrom
update-pre-commit

Conversation

@wmartin-gss

Copy link
Copy Markdown
Collaborator

This PR introduces a few improvements to the pre-commit hooks:

  1. Hash-pins the actions (to mitigate supply-chain attacks)
  2. Moves away from the legacy ruff hook to the updated syntax
  3. Stops ruff check automatically fixing things (but still flags errors)
  4. Stops ruff format automatically formatting things (but still flags errors)
  5. Adds some secrets detection with betterleaks

To test, clone the repo, update your pre-commit hooks and maybe experiment with the new behaviour (namely ruff and secrets detection). In my testing, betterleaks managed to catch an API key.

Just adding an extra layer of security.
We were using the legacy ruff hooks, and we were auto-formatting. It's
been pointed out that having it auto-format stuff is not always
super-helpful, so I've taken that out and used the non-legacy hook
names.
This is to limit the potential for secrets being committed.
Changing the behaviour so, similarly to disabling the --fix flag for
ruff lint, this will flag non-compliant formatting but not automatically
fix it, leaving it up to the author to manually fix.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new hashes unintentionally downgrade Ruff and uv from their previously configured versions.

1 open finding
What changed in this PR

Hash-pins pre-commit hooks, updates Ruff hook behavior, and adds secret detection.

Changes:

  • Replaces version tags with immutable commit hashes.
  • Makes Ruff linting and formatting check-only.
  • Adds the Betterleaks secret scanner.
File Description
.pre-commit-config.yaml Updates and expands pre-commit hook configuration.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .pre-commit-config.yaml Resolved
Updated ruff-pre-commit version from v0.16.8 to v0.16.10.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@mfreedman-moj

Copy link
Copy Markdown
Contributor

LGTM just need to resolve test failure

@mfreedman-moj
Max Freedman (mfreedman-moj) merged commit bf3cb5f into main Oct 29, 2026
9 checks passed
@mfreedman-moj
Max Freedman (mfreedman-moj) deleted the update-pre-commit branch October 29, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants