Skip to content
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

Add pre-commit hook definition + test #1877

Merged
merged 5 commits into from
Aug 21, 2024
Merged

Conversation

dbast
Copy link
Contributor

@dbast dbast commented Aug 20, 2024

This adds a .pre-commit-hooks.yaml (+ doc + test), which allows other projects to run Mythril via pre-commit.

pre-commit became pretty popular as framework to combine linters / code-formatters via hooks across different languages. It can be enabled as actual git hook or just used by running pre-commit run -a. pre-commit does its own dependency management (+cashing) and installs each hook into its own isolated folder/env.

pre-commit installs a hook by cloning the repo, checking out the specified git rev (=tag, branch, commit hash), parsing the .pre-commit-hooks.yaml and installing the hook (install method depending on the hook type).

Tested also via my Mythril fork, see dbast/sol-press#17

Requires a new tagged release after the PR merge to be able to reference a tag that contains the hook definition.

description: Analyze EVM bytecode with Mythril
entry: myth
args:
- analyze
Copy link
Collaborator

Choose a reason for hiding this comment

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

isn't this fairly restrictive to just one argument? Mythril has multiple commands

Copy link
Collaborator

@norhh norhh Aug 20, 2024

Choose a reason for hiding this comment

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

Adding disassemble and read-storage might be worth it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah... didn't want to add a hook for each possible command ... all subcommands can be selected via setting (=overwriting) args on user side... maybe worth to add to the README

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added to the README

README.md Outdated Show resolved Hide resolved
Co-authored-by: Nikhil Parasaram <tommycjniko@gmail.com>
Copy link
Collaborator

@norhh norhh left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

@norhh norhh merged commit 9bbe7d6 into Consensys:develop Aug 21, 2024
4 checks passed
@dbast dbast deleted the pre-commit-hook branch August 23, 2024 08:16
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.

2 participants