Skip to content

Commit

Permalink
Merge pull request #49 from crytic/woodruffw-patch-1
Browse files Browse the repository at this point in the history
Add `pip-audit` workflow
  • Loading branch information
woodruffw authored Jun 17, 2022
2 parents 59499d6 + db6a28b commit 17403de
Show file tree
Hide file tree
Showing 4 changed files with 348 additions and 165 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.6
uses: actions/setup-python@v1
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: 3.6
python-version: 3.7
- name: Lint
if: github.event_name == 'pull_request'
env:
Expand All @@ -25,7 +25,7 @@ jobs:
pip install mypy
python setup.py install
black --version
git diff --name-only $BASE_SHA..$HEAD_SHA | grep "*.py" | xargs black --diff --check
black pyevmasm
mypy --version
mypy pyevmasm
Expand All @@ -36,7 +36,7 @@ jobs:
- uses: actions/checkout@v2

- name: Set up Python 3.7
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Run Tests 37
Expand All @@ -51,7 +51,7 @@ jobs:
- uses: actions/checkout@v2

- name: Set up Python 2.7
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: 2.7
- name: Run Tests 27
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/pip-audit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Scan dependencies for vulnerabilities with pip-audit

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
schedule:
- cron: "0 12 * * *"

jobs:
pip-audit:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Install project
run: |
python -m venv /tmp/pip-audit-env
source /tmp/pip-audit-env/bin/activate
python -m pip install --upgrade pip
python -m pip install .
- name: Run pip-audit
uses: trailofbits/[email protected]
with:
virtual-environment: /tmp/pip-audit-env

56 changes: 46 additions & 10 deletions pyevmasm/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,49 @@


def main():
parser = argparse.ArgumentParser(description="pyevmasm the EVM assembler and disassembler")
parser = argparse.ArgumentParser(
description="pyevmasm the EVM assembler and disassembler"
)
group_action = parser.add_mutually_exclusive_group(required=True)
group_action.add_argument("-a", "--assemble", action="store_true", help="Assemble EVM instructions to opcodes")
group_action.add_argument("-d", "--disassemble", action="store_true", help="Disassemble EVM to opcodes")
group_action.add_argument("-t", "--print-opcode-table", action="store_true", help="List supported EVM opcodes")
parser.add_argument("-bi", "--binary-input", action="store_true", help="Binary input mode (-d only)")
parser.add_argument("-bo", "--binary-output", action="store_true", help="Binary output mode (-a only)")
group_action.add_argument(
"-a",
"--assemble",
action="store_true",
help="Assemble EVM instructions to opcodes",
)
group_action.add_argument(
"-d", "--disassemble", action="store_true", help="Disassemble EVM to opcodes"
)
group_action.add_argument(
"-t",
"--print-opcode-table",
action="store_true",
help="List supported EVM opcodes",
)
parser.add_argument(
"-i", "--input", nargs="?", default=sys.stdin, type=argparse.FileType("r"), help="Input file, default=stdin"
"-bi", "--binary-input", action="store_true", help="Binary input mode (-d only)"
)
parser.add_argument(
"-o", "--output", nargs="?", default=sys.stdout, type=argparse.FileType("w"), help="Output file, default=stdout"
"-bo",
"--binary-output",
action="store_true",
help="Binary output mode (-a only)",
)
parser.add_argument(
"-i",
"--input",
nargs="?",
default=sys.stdin,
type=argparse.FileType("r"),
help="Input file, default=stdin",
)
parser.add_argument(
"-o",
"--output",
nargs="?",
default=sys.stdout,
type=argparse.FileType("w"),
help="Output file, default=stdout",
)
parser.add_argument(
"-f",
Expand All @@ -46,7 +77,8 @@ def main():
fork = block_to_fork(block_number)
except ValueError:
sys.stderr.write(
"Wrong fork name or block number. " "Please provide an integer or one of %s.\n" % accepted_forks
"Wrong fork name or block number. "
"Please provide an integer or one of %s.\n" % accepted_forks
)
sys.exit(1)
else:
Expand All @@ -55,7 +87,11 @@ def main():
instruction_table = instruction_tables[fork]
if args.print_opcode_table:
for instr in instruction_table:
print("0x{:02x}: {:16s} {:s}".format(instr.opcode, instr.name, instr.description))
print(
"0x{:02x}: {:16s} {:s}".format(
instr.opcode, instr.name, instr.description
)
)
sys.exit(0)

if args.assemble:
Expand Down
Loading

0 comments on commit 17403de

Please sign in to comment.