sirwart / ripsecrets

A command-line tool to prevent committing secret keys into your source code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`pre-commit` hook should use pre-built binaries instead of requiring `cargo install`

bgianfo opened this issue · comments

Since there are already pre-built binaries for each release, it would be nice if we could utilize them in the pre-commit hook instead of requiring a dependency on cargo install, which isn't necessarily available in all environments you would want to check for secrets.

Seems like there is some discussion about previous solutions: pre-commit/pre-commit#1453

If @sirwart were to list this crate on crates.io, we could use cargo binstall and use a system language pre-commit hook. This would considerably reduce dev container image build time or complexity of fetching pre-build binaries.

  cargo binstall ripsecrets

 INFO resolve: Resolving package: 'ripsecrets'
ERROR Fatal error:

  × For crate ripsecrets: crates.io API error for ripsecrets: could not GET https://crates.io/api/v1/crates/ripsecrets: HTTP status client error (404 Not Found) for url (https://crates.io/api/v1/crates/ripsecrets)
  ├─▶ crates.io API error for ripsecrets: could not GET https://crates.io/api/v1/crates/ripsecrets: HTTP status client error (404 Not Found) for url (https://crates.io/api/v1/crates/ripsecrets)
  ├─▶ could not GET https://crates.io/api/v1/crates/ripsecrets: HTTP status client error (404 Not Found) for url (https://crates.io/api/v1/crates/ripsecrets)
  ╰─▶ HTTP status client error (404 Not Found) for url (https://crates.io/api/v1/crates/ripsecrets)

Another thought: something I see as a rough edge of the pre-commit workflow is having to either have a Rust setup or have installed ripsecrets through something else, e.g. Homebrew. Pre-commit knows how to setup a Python environment. What if there was a simple PyO3 wrapper around ripsecrets as a library, and ripsecrets published Python packages to PyPI? That would eliminate the Rust compile step and alleviate the prerequisite. The exchange would be more setup and care for ripsecrets, but automatable.

That's a good point, I think you could even just publish the existing rust binary as a python wheel.

@bgianfo does publishing the binary to crates.io + system hook solve the problem for you? I have a visceral reaction to publishing as a Python library since one of the reasons I created ripsecrets was because at my previous job I couldn't commit because my system Python install was borked that was preventing the secret detector from running.

@sirwart Following #85, the release Actions workflow now includes publishing to crates.io. Would you be willing to release a patch version to make the crate available?

@bgianfo, @colindean sirwart has published ripsecrets to crates.io as ripsecrets. You should be unblocked if you want to use cargo binstall.