Skip to content

Commit

Permalink
Merge branch 'develop' into fix-svm-rs
Browse files Browse the repository at this point in the history
  • Loading branch information
dbast authored Aug 22, 2024
2 parents ed7ebfd + 0717111 commit 8e8172f
Show file tree
Hide file tree
Showing 189 changed files with 844 additions and 701 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/pre-commit-hooks-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: pre-commit

on:
push:
branches:
- master
- develop
tags:
- '*'
pull_request:
paths:
- .github/workflows/pre-commit-hooks-test.yml
- .pre-commit-hooks.yaml
- tests/pre-commit-hooks/*
- requirements.txt
- setup.py

jobs:
hooks-test:
runs-on: ubuntu-latest
name: test hooks
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install pre-commit
run: |
python -m pip install pre-commit
- name: Test hooks
run: |
./tests/pre-commit-hooks/test.sh
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ repos:
hooks:
- id: check-toml
- id: check-yaml
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.6.1
hooks:
- id: ruff
args: [--fix, --show-fixes]
- repo: https://github.com/psf/black
rev: 24.8.0
hooks:
- id: black
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.8.0-1
hooks:
Expand Down
8 changes: 8 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- id: mythril
name: Mythril
description: Analyze EVM bytecode with Mythril
entry: myth
args:
- analyze
language: python
types: ["solidity"]
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ Install from Pypi (Python 3.7-3.10):
$ pip3 install mythril
```

Use it via pre-commit hook (replace `$GIT_TAG` with real tag):

```YAML
- repo: https://github.com/Consensys/mythril
rev: $GIT_TAG
hooks:
- id: mythril
```
Additionally, set `args: [disassemble]` or `args: [read-storage]` to use a different command than `analyze`.

See the [docs](https://mythril-classic.readthedocs.io/en/master/installation.html) for more detailed instructions.

## Usage
Expand Down
9 changes: 5 additions & 4 deletions mypy-stubs/z3/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
from typing import (
overload,
Tuple,
Any,
List,
Iterable,
Iterator,
List,
Optional,
Sequence,
Tuple,
TypeVar,
Union,
Sequence,
overload,
)

from .z3types import Ast, ContextObj

class Context: ...
Expand Down
2 changes: 1 addition & 1 deletion myth
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
http://www.github.com/ConsenSys/mythril
"""
from sys import exit
import mythril.interfaces.cli

import mythril.interfaces.cli

if __name__ == "__main__":
mythril.interfaces.cli.main()
Expand Down
3 changes: 2 additions & 1 deletion mythril/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
__docformat__ = "restructuredtext"
import logging

from mythril.plugin.loader import MythrilPluginLoader

# Accept mythril.VERSION to get mythril's current version number
from .__version__ import __version__ as VERSION
from mythril.plugin.loader import MythrilPluginLoader

log = logging.getLogger(__name__)
4 changes: 2 additions & 2 deletions mythril/analysis/call_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

from typing import Union

from mythril.analysis.ops import VarType, Call, get_variable
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.analysis.ops import Call, VarType, get_variable
from mythril.laser.ethereum.natives import PRECOMPILE_COUNT
from mythril.laser.ethereum.state.global_state import GlobalState


def get_call_from_state(state: GlobalState) -> Union[Call, None]:
Expand Down
2 changes: 1 addition & 1 deletion mythril/analysis/issue_annotation.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from copy import deepcopy
from typing import List

from mythril.analysis.report import Issue
from mythril.laser.ethereum.state.annotation import StateAnnotation
from mythril.laser.smt import SMTBool as Bool
from copy import deepcopy


class IssueAnnotation(StateAnnotation):
Expand Down
2 changes: 1 addition & 1 deletion mythril/analysis/module/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from mythril.analysis.module.base import EntryPoint, DetectionModule
from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.analysis.module.loader import ModuleLoader
from mythril.analysis.module.util import (
get_detection_module_hooks,
Expand Down
6 changes: 3 additions & 3 deletions mythril/analysis/module/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"""

import logging
from typing import List, Set, Optional, Tuple
from abc import ABC, abstractmethod
from enum import Enum
from typing import List, Optional, Set, Tuple

from mythril.analysis.report import Issue
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.support.support_args import args
from mythril.support.support_utils import get_code_hash
from abc import ABC, abstractmethod
from enum import Enum

# Get logger instance
log = logging.getLogger(__name__)
Expand Down
15 changes: 6 additions & 9 deletions mythril/analysis/module/loader.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.support.support_utils import Singleton
from mythril.support.support_args import args
from typing import List, Optional

from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.analysis.module.modules.arbitrary_jump import ArbitraryJump
from mythril.analysis.module.modules.arbitrary_write import ArbitraryStorage
from mythril.analysis.module.modules.delegatecall import ArbitraryDelegateCall
from mythril.analysis.module.modules.dependence_on_origin import TxOrigin
from mythril.analysis.module.modules.dependence_on_predictable_vars import (
PredictableVariables,
)
from mythril.analysis.module.modules.dependence_on_origin import TxOrigin
from mythril.analysis.module.modules.ether_thief import EtherThief
from mythril.analysis.module.modules.exceptions import Exceptions
from mythril.analysis.module.modules.external_calls import ExternalCalls
Expand All @@ -23,13 +22,11 @@
TransactionOrderDependence,
)
from mythril.analysis.module.modules.unchecked_retval import UncheckedRetval
from mythril.analysis.module.modules.user_assertions import UserAssertions
from mythril.analysis.module.modules.unexpected_ether import UnexpectedEther


from mythril.analysis.module.modules.user_assertions import UserAssertions
from mythril.exceptions import DetectorNotFoundError

from typing import Optional, List
from mythril.support.support_args import args
from mythril.support.support_utils import Singleton


class ModuleLoader(object, metaclass=Singleton):
Expand Down
5 changes: 2 additions & 3 deletions mythril/analysis/module/modules/arbitrary_jump.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import logging

from mythril.analysis.solver import get_transaction_sequence, UnsatError
from mythril.analysis.issue_annotation import IssueAnnotation
from mythril.analysis.module.base import DetectionModule, Issue, EntryPoint
from mythril.analysis.module.base import DetectionModule, EntryPoint, Issue
from mythril.analysis.solver import UnsatError, get_transaction_sequence
from mythril.analysis.swc_data import ARBITRARY_JUMP

from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.smt import And, BitVec, symbol_factory
from mythril.support.model import get_model
Expand Down
4 changes: 2 additions & 2 deletions mythril/analysis/module/modules/arbitrary_write.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""This module contains the detection code for arbitrary storage write."""

import logging

from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.analysis.potential_issues import (
get_potential_issues_annotation,
PotentialIssue,
get_potential_issues_annotation,
)

from mythril.analysis.swc_data import WRITE_TO_ARBITRARY_STORAGE
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.smt import symbol_factory
Expand Down
10 changes: 5 additions & 5 deletions mythril/analysis/module/modules/delegatecall.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
import logging
from typing import List

from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.analysis.potential_issues import (
get_potential_issues_annotation,
PotentialIssue,
get_potential_issues_annotation,
)
from mythril.analysis.swc_data import DELEGATECALL_TO_UNTRUSTED_CONTRACT
from mythril.exceptions import UnsatError
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.ethereum.transaction.symbolic import ACTORS
from mythril.laser.ethereum.transaction.transaction_models import (
ContractCreationTransaction,
)
from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.exceptions import UnsatError
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.smt import symbol_factory, UGT
from mythril.laser.smt import UGT, symbol_factory

log = logging.getLogger(__name__)

Expand Down
7 changes: 4 additions & 3 deletions mythril/analysis/module/modules/dependence_on_origin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@

import logging
from copy import copy
from typing import List

from mythril.analysis import solver
from mythril.analysis.issue_annotation import IssueAnnotation
from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.analysis.report import Issue
from mythril.exceptions import UnsatError
from mythril.analysis import solver
from mythril.analysis.swc_data import TX_ORIGIN_USAGE
from mythril.exceptions import UnsatError
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.smt import And
from typing import List

log = logging.getLogger(__name__)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
dependence."""

import logging
from typing import List, cast

from mythril.analysis import solver
from mythril.analysis.issue_annotation import IssueAnnotation
from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.analysis.module.module_helpers import is_prehook
from mythril.analysis.report import Issue
from mythril.exceptions import UnsatError
from mythril.analysis import solver
from mythril.laser.smt import And, ULT, symbol_factory
from mythril.analysis.swc_data import TIMESTAMP_DEPENDENCE, WEAK_RANDOMNESS
from mythril.analysis.module.module_helpers import is_prehook
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.exceptions import UnsatError
from mythril.laser.ethereum.state.annotation import StateAnnotation
from typing import cast, List
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.smt import ULT, And, symbol_factory

log = logging.getLogger(__name__)

Expand Down
8 changes: 4 additions & 4 deletions mythril/analysis/module/modules/ether_thief.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import logging
from copy import copy

from mythril.analysis import solver
from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.analysis.potential_issues import (
get_potential_issues_annotation,
PotentialIssue,
get_potential_issues_annotation,
)
from mythril.laser.ethereum.transaction.symbolic import ACTORS
from mythril.analysis.swc_data import UNPROTECTED_ETHER_WITHDRAWAL
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.analysis import solver
from mythril.exceptions import UnsatError
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.ethereum.transaction.symbolic import ACTORS
from mythril.laser.smt import UGT

log = logging.getLogger(__name__)
Expand Down
8 changes: 3 additions & 5 deletions mythril/analysis/module/modules/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
"""This module contains the detection code for reachable exceptions."""

import logging
from typing import List, Optional, cast

from typing import cast, List, Optional
from mythril.analysis import solver
from mythril.analysis.issue_annotation import IssueAnnotation
from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.analysis.report import Issue
from mythril.analysis.swc_data import ASSERT_VIOLATION
from mythril.exceptions import UnsatError

from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.ethereum.state.annotation import StateAnnotation
from mythril.laser.ethereum import util
from mythril.laser.ethereum.state.annotation import StateAnnotation
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.laser.smt import And

from mythril.support.support_utils import get_code_hash

log = logging.getLogger(__name__)
Expand Down
15 changes: 8 additions & 7 deletions mythril/analysis/module/modules/external_calls.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
"""This module contains the detection code for potentially insecure low-level
calls."""

import logging
from copy import copy

from mythril.analysis import solver
from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.analysis.potential_issues import (
PotentialIssue,
get_potential_issues_annotation,
)
from mythril.analysis.swc_data import REENTRANCY
from mythril.laser.ethereum.state.constraints import Constraints
from mythril.laser.ethereum.transaction.symbolic import ACTORS
from mythril.analysis.module.base import DetectionModule, EntryPoint
from mythril.laser.smt import UGT, symbol_factory, Or, BitVec
from mythril.exceptions import UnsatError
from mythril.laser.ethereum.natives import PRECOMPILE_COUNT
from mythril.laser.ethereum.state.constraints import Constraints
from mythril.laser.ethereum.state.global_state import GlobalState
from mythril.exceptions import UnsatError
from copy import copy
import logging
from mythril.laser.ethereum.transaction.symbolic import ACTORS
from mythril.laser.smt import UGT, BitVec, Or, symbol_factory

log = logging.getLogger(__name__)

Expand Down
Loading

0 comments on commit 8e8172f

Please sign in to comment.