Skip to content

Commit 06702d8

Browse files
committed
Merge branch 'master' into native-arb-cf-redirect-detector
* master: Restore old init hook behavior (#1447) Fix invalid pip argument (#1445) Blacken Manticore (#1438) Relegate coverage file to plugin (#1442) x86: movhps support (#1444) Delete statically generated tests (#1443) Hardcode expected matching concrete registers (#1437) Symbolic tests rf otf (#1441) Unicorn dependency update (#1440) aarch64: do not use the 'procs' argument (#1439) Symbolic tests rf (#1431)
2 parents 82e23e6 + ddb833d commit 06702d8

40 files changed

Lines changed: 606 additions & 71638 deletions

.codeclimate.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ plugins:
4848
enabled: false
4949
E701:
5050
enabled: false
51+
E203:
52+
enabled: false
53+
W503:
54+
enabled: false
5155
sonar-python:
5256
enabled: false
5357
config:

.travis.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@ python:
77
- 3.6.6
88

99
stages:
10+
- format
1011
- prepare
1112
- test
1213
- submit
1314

1415
env:
1516
global:
1617
- CC_TEST_REPORTER_ID=db72f1ed59628c16eb0c00cbcd629c4c71f68aa1892ef42d18c7c2b8326f460a
17-
- JOB_COUNT=3 # Three jobs generate test coverage: ethereum, native, and other
18+
- JOB_COUNT=4 # Four jobs generate test coverage: ethereum, ethereum_vm, native, and other
1819
- PYTHONWARNINGS="default::ResourceWarning" # Enable ResourceWarnings
1920
matrix:
2021
- TEST_TYPE=examples
2122
- TEST_TYPE=ethereum
23+
- TEST_TYPE=ethereum_vm
2224
- TEST_TYPE=native
2325
- TEST_TYPE=other
2426

@@ -35,6 +37,10 @@ cache:
3537

3638
jobs:
3739
include:
40+
- stage: format
41+
env: TEST_TYPE=format
42+
script:
43+
- git diff --name-only $TRAVIS_COMMIT_RANGE | python3 scripts/pyfile_exists.py | xargs black -t py36 -l 100 --check
3844
- stage: prepare
3945
env: TEST_TYPE=env
4046
script:
@@ -52,7 +58,7 @@ install:
5258
- scripts/travis_install.sh $TEST_TYPE
5359

5460
script:
55-
- scripts/travis_test.sh $TEST_TYPE
61+
- travis_wait 60 scripts/travis_test.sh $TEST_TYPE
5662

5763
after_success:
5864
- ./cc-test-reporter format-coverage -t coverage.py -o "coverage/codeclimate.$TEST_TYPE.json"

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ more documentation, look [here](https://guides.github.com/activities/forking/).
3030

3131
Some pull request guidelines:
3232

33+
- We use the [`black`](https://black.readthedocs.io/en/stable/index.html) auto-formatter
34+
to enforce style conventions in Manticore. To ensure your code is properly
35+
formatted, run `black -t py36 -l 100 .` in the manticore directory before
36+
committing.
3337
- Minimize irrelevant changes (formatting, whitespace, etc) to code that would
3438
otherwise not be touched by this patch. Save formatting or style corrections
3539
for a separate pull request that does not make any semantic changes.

docs/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@
4646

4747
# General information about the project.
4848
project = "Manticore"
49-
copyright = "2017, Trail of Bits"
49+
copyright = "2019, Trail of Bits"
5050
author = "Trail of Bits"
5151

5252
# The version info for the project you're documenting, acts as replacement for
5353
# |version| and |release|, also used in various other places throughout the
5454
# built documents.
5555
#
5656
# The short X.Y version.
57-
version = "0.1.0"
57+
version = "0.2.5"
5858
# The full version, including alpha/beta/rc tags.
59-
release = "0.1.0"
59+
release = "0.2.5"
6060

6161
# The language for content autogenerated by Sphinx. Refer to documentation
6262
# for a list of supported languages.

examples/script/aarch64/basic.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@
2222

2323

2424
@m.init
25-
def init(m, ready_states):
26-
for state in ready_states:
27-
state.platform.input.write(state.symbolicate_buffer(STDIN, label="STDIN"))
25+
def init(state):
26+
state.platform.input.write(state.symbolicate_buffer(STDIN, label="STDIN"))
2827

2928

3029
# Hook the 'if' case.

examples/script/aarch64/hello42.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,6 @@ def execute_instruction(self, insn, msg):
4949
lambda self, state, last_pc, pc, insn: execute_instruction(self, insn, "done"),
5050
)
5151

52-
m.run(procs=1)
52+
m.run()
5353

5454
print(f"Executed {m.context['count']} instructions")

manticore/__main__.py

Lines changed: 23 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def positive(value):
5757
)
5858
parser.add_argument("--context", type=str, default=None, help=argparse.SUPPRESS)
5959
parser.add_argument(
60-
"--coverage", type=str, default=None, help="Where to write the coverage data"
60+
"--coverage", type=str, default="visited.txt", help="Where to write the coverage data"
6161
)
6262
parser.add_argument("--names", type=str, default=None, help=argparse.SUPPRESS)
6363
parser.add_argument(
@@ -105,36 +105,6 @@ def positive(value):
105105
help="Manticore config file (.yml) to use. (default config file pattern is: ./[.]m[anti]core.yml)",
106106
)
107107

108-
detectors = parser.add_argument_group("Detectors")
109-
110-
detectors.add_argument(
111-
"--list-ethereum-detectors",
112-
help="List available ethereum detectors",
113-
action=ListEthereumDetectors,
114-
nargs=0,
115-
default=False,
116-
)
117-
118-
detectors.add_argument(
119-
"--list-native-detectors",
120-
help="List available native detectors",
121-
action=ListNativeDetectors,
122-
nargs=0,
123-
default=False,
124-
)
125-
126-
detectors.add_argument(
127-
"--exclude",
128-
help="Comma-separated list of detectors that should be excluded",
129-
action="store",
130-
dest="detectors_to_exclude",
131-
default="",
132-
)
133-
134-
detectors.add_argument(
135-
"--exclude-all", help="Excludes all detectors", action="store_true", default=False
136-
)
137-
138108
bin_flags = parser.add_argument_group("Binary flags")
139109
bin_flags.add_argument("--entrysymbol", type=str, default=None, help="Symbol as entry point")
140110
bin_flags.add_argument("--assertions", type=str, default=None, help=argparse.SUPPRESS)
@@ -201,6 +171,28 @@ def positive(value):
201171
"--contract", type=str, help="Contract name to analyze in case of multiple contracts"
202172
)
203173

174+
eth_detectors = parser.add_argument_group("Ethereum detectors")
175+
176+
eth_detectors.add_argument(
177+
"--list-detectors",
178+
help="List available detectors",
179+
action=ListEthereumDetectors,
180+
nargs=0,
181+
default=False,
182+
)
183+
184+
eth_detectors.add_argument(
185+
"--exclude",
186+
help="Comma-separated list of detectors that should be excluded",
187+
action="store",
188+
dest="detectors_to_exclude",
189+
default="",
190+
)
191+
192+
eth_detectors.add_argument(
193+
"--exclude-all", help="Excludes all detectors", action="store_true", default=False
194+
)
195+
204196
eth_flags.add_argument(
205197
"--avoid-constant",
206198
action="store_true",
@@ -246,13 +238,5 @@ def __call__(self, parser, *args, **kwargs):
246238
parser.exit()
247239

248240

249-
class ListNativeDetectors(argparse.Action):
250-
def __call__(self, parser, *args, **kwargs):
251-
from .native.detectors import get_detectors_classes, output_detectors
252-
253-
output_detectors(get_detectors_classes())
254-
parser.exit()
255-
256-
257241
if __name__ == "__main__":
258242
main()

manticore/core/smtlib/visitors.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,18 @@ def visit_BitVecSub(self, expression, *operands):
488488
return left.operands[1]
489489
elif self._same_constant(left.operands[1], right):
490490
return left.operands[0]
491+
elif isinstance(left, BitVecSub) and isinstance(right, Constant):
492+
subleft = left.operands[0]
493+
subright = left.operands[1]
494+
if isinstance(subright, Constant):
495+
return BitVecSub(
496+
subleft,
497+
BitVecConstant(
498+
subleft.size,
499+
subright.value + right.value,
500+
taint=subright.taint | right.taint,
501+
),
502+
)
491503

492504
def visit_BitVecOr(self, expression, *operands):
493505
""" a | 0 => a

manticore/ethereum/manticore.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,6 @@ def multi_tx_analysis(
11651165
if contract_account is None:
11661166
logger.info("Failed to create contract: exception in constructor")
11671167
return
1168-
11691168
prev_coverage = 0
11701169
current_coverage = 0
11711170
tx_no = 0
@@ -1478,13 +1477,16 @@ def generate_testcase(self, state, message="", only_if=None, name="user"):
14781477
else:
14791478
return False
14801479

1480+
blockchain = state.platform
1481+
14811482
# FIXME. workspace should not be responsible for formating the output
14821483
# each object knows its secrets, and each class should be able to report
14831484
# its final state
1484-
testcase = super().generate_testcase(state, message, name=name)
1485+
testcase = super().generate_testcase(
1486+
state, message + f"({len(blockchain.human_transactions)} txs)", name=name
1487+
)
14851488
# TODO(mark): Refactor ManticoreOutput to let the platform be more in control
14861489
# so this function can be fully ported to EVMWorld.generate_workspace_files.
1487-
blockchain = state.platform
14881490

14891491
local_findings = set()
14901492
for detector in self.detectors.values():

manticore/native/cli.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def native_main(args, _logger):
4747

4848
# Default plugins for now.. FIXME REMOVE!
4949
m.register_plugin(InstructionCounter())
50-
m.register_plugin(Visited())
50+
m.register_plugin(Visited(args.coverage))
5151
m.register_plugin(Tracer())
5252
m.register_plugin(RecordSymbolicBranches())
5353

@@ -65,10 +65,9 @@ def native_main(args, _logger):
6565
m.load_assertions(args.assertions)
6666

6767
@m.init
68-
def init(m, ready_states):
68+
def init(state):
6969
for file in args.files:
70-
for state in ready_states:
71-
state.platform.add_symbolic_file(file)
70+
state.platform.add_symbolic_file(file)
7271

7372
for detector in list(m.detectors):
7473
m.unregister_detector(detector)

0 commit comments

Comments
 (0)