Skip to content

Hash-pinning pre-commit hooks #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mathbunnyru opened this issue Apr 24, 2025 · 0 comments
Open

Hash-pinning pre-commit hooks #108

mathbunnyru opened this issue Apr 24, 2025 · 0 comments

Comments

@mathbunnyru
Copy link
Member

mathbunnyru commented Apr 24, 2025

From what I've seen, everyone only pins revisions when using pre-commit hooks.

Even though usually these hooks are run in a separate workflow, malicious code can also be run in a developer's environment without any changes to our source code (someone can push the malicious code to hook using the same revision).

To overcome this, we can pin hooks using commit hash like this: rev: ce40a160603ab0e7d9c627ae33d7ef3906e2d2b2 # frozen: v3.19.1.

The best part is that this can be done automatically: running pre-commit autoupdate --freeze does it for you. This will also update the pre-commit hooks versions, but usually that's a good thing.

I made an example in jupyter/docker-stacks repo: jupyter/docker-stacks#2289

@mathbunnyru mathbunnyru changed the title Freeze pre-commit hooks Hash-pinning pre-commit hooks Apr 24, 2025
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

No branches or pull requests

1 participant