-
Notifications
You must be signed in to change notification settings - Fork 9
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
Pre-commit hooks #589
Pre-commit hooks #589
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
repos: | ||
- repo: https://github.com/kongzii/pre-commit-hooks | ||
rev: peter/web3 | ||
hooks: | ||
- id: detect-private-key | ||
- id: check-added-large-files | ||
args: ['--maxkb=5000'] | ||
- id: detect-web3-private-key | ||
exclude: 'poetry.lock' |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,13 @@ | ||||||||||||||||||||||||||||||||
#!/bin/bash | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
# Install pre-commit if not already installed | ||||||||||||||||||||||||||||||||
if ! command -v pre-commit &> /dev/null | ||||||||||||||||||||||||||||||||
then | ||||||||||||||||||||||||||||||||
echo "pre-commit is not installed. Installing now..." | ||||||||||||||||||||||||||||||||
brew install pre-commit | ||||||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||||||
Comment on lines
+6
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add cross-platform support for pre-commit installation. The script assumes if ! command -v pre-commit &> /dev/null
then
echo "pre-commit is not installed. Installing now..."
- brew install pre-commit
+ if command -v brew &> /dev/null; then
+ brew install pre-commit
+ elif command -v apt-get &> /dev/null; then
+ sudo apt-get install -y pre-commit
+ elif command -v pip &> /dev/null; then
+ pip install pre-commit
+ else
+ echo "Error: Could not find a package manager to install pre-commit"
+ exit 1
+ fi
fi 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
# Install the hooks | ||||||||||||||||||||||||||||||||
pre-commit install | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
echo "Pre-commit hooks installed successfully." |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,5 +82,5 @@ def secretstr_to_v1_secretstr(s: SecretStr | None) -> SecretStrV1 | None: | |
|
||
|
||
def int_to_hexbytes(v: int) -> HexBytes: | ||
# Example: 1 -> HexBytes("0x0000000000000000000000000000000000000000000000000000000000000001"). | ||
# Example: 1 -> HexBytes("0x0000000000000000000000000000000000000000000000000000000000000001"). # web3-private-key-ok | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like private keys don't have any strong format. I had to add this @gabrielfior please check out scripts/detect_web3_private_keys.py, if you know a better way of how to detect private keys, I'll be happy 😄 |
||
return HexBytes.fromhex(format(v, "064x")) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
ANVIL_PKEY1 = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" | ||
ANVIL_PKEY1 = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" # web3-private-key-ok |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pre-commit needs to be installed locally (see
install_hooks.sh
), but as a last resort, also run it in CI, so at least we won't miss it by accident if the key gets leaked.