Skip to content

Commit e0a3e13

Browse files
committed
Merge branch 'master' into native-arb-cf-redirect-detector
* master: (33 commits) removes travis entirely (#1572) Run mypy on manticore directory by default (#1573) Fix deprecation warnings related to setting verbosity (#1574) Bump version to fix pip install on Python 3.6 (#1571) Direct CI badge directly to CI action (#1570) switch to github actions (take two) (#1568) Add --quick-mode to configure Manticore for fast exploration (#1555) pytest-xdist prevents disturbing stdout, revert to travis_wait (#1566) Show black diff on travis builds (#1565) various changes to resolve test timeout/invalid dep issues (#1563) try pytest xdist (#1561) switch to pytest (#1560) Fixes different problems found by lgtm (#1558) reorg some deps a bit, usee env markers for dataclasses (#1559) fix some deprecation warnings (#1556) Add flag to only generate alive states when finalizing Manticore (#1554) Arrayvarname (#1552) Fix Z3 version parsing (#1551) Update README.md (#1553) Manticore 0.3.2 (#1547) ...
2 parents 5811f21 + fae081d commit e0a3e13

File tree

113 files changed

+7908
-1418
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+7908
-1418
lines changed

.github/workflows/ci.yml

Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
schedule:
9+
# run CI every day even if no PRs/merges occur
10+
- cron: '0 12 * * *'
11+
12+
jobs:
13+
# needs to run only on pull_request
14+
lint:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v1
18+
- name: Set up Python 3.6
19+
uses: actions/setup-python@v1
20+
with:
21+
python-version: 3.6
22+
- name: Lint
23+
if: github.event_name == 'pull_request'
24+
env:
25+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
26+
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
27+
run: |
28+
pip install -e .[lint]
29+
black --version
30+
git diff --name-only $BASE_SHA..$HEAD_SHA | python scripts/pyfile_exists.py | xargs black --diff --check
31+
mypy --version
32+
mypy
33+
tests:
34+
runs-on: ubuntu-latest
35+
strategy:
36+
matrix:
37+
type: ["examples", "ethereum", "ethereum_bench", "ethereum_vm", "native", "wasm", "other"]
38+
steps:
39+
- uses: actions/checkout@v1
40+
- name: Set up Python 3.6
41+
uses: actions/setup-python@v1
42+
with:
43+
python-version: 3.6
44+
- name: Install dependencies
45+
env:
46+
TEST_TYPE: ${{ matrix.type }}
47+
run: |
48+
# Install solc unconditionally because it only takes a second or two
49+
sudo wget -O /usr/bin/solc https://github.com/ethereum/solidity/releases/download/v0.4.24/solc-static-linux
50+
sudo chmod +x /usr/bin/solc
51+
EXTRAS="dev-noks"
52+
if [[ "$TEST_TYPE" != "ethereum"* ]]; then
53+
EXTRAS="dev"
54+
fi
55+
pip install -e .[$EXTRAS]
56+
- name: Run Tests
57+
env:
58+
TEST_TYPE: ${{ matrix.type }}
59+
run: |
60+
# Launches all examples; this assumes PWD is examples/script
61+
launch_examples() {
62+
# concolic assumes presence of ../linux/simpleassert
63+
echo "Running concolic.py..."
64+
HW=../linux/helloworld
65+
python ./concolic.py
66+
if [ $? -ne 0 ]; then
67+
return 1
68+
fi
69+
70+
echo "Running count_instructions.py..."
71+
python ./count_instructions.py $HW |grep -q Executed
72+
if [ $? -ne 0 ]; then
73+
return 1
74+
fi
75+
76+
echo "Running introduce_symbolic_bytes.py..."
77+
gcc -static -g src/state_explore.c -o state_explore
78+
ADDRESS=0x$(objdump -S state_explore | grep -A 1 '((value & 0xff) != 0)' |
79+
tail -n 1 | sed 's|^\s*||g' | cut -f1 -d:)
80+
python ./introduce_symbolic_bytes.py state_explore $ADDRESS
81+
if [ $? -ne 0 ]; then
82+
return 1
83+
fi
84+
85+
echo "Running run_simple.py..."
86+
gcc -x c -static -o hello test_run_simple.c
87+
python ./run_simple.py hello
88+
if [ $? -ne 0 ]; then
89+
return 1
90+
fi
91+
92+
echo "Running run_hook.py..."
93+
MAIN_ADDR=$(nm $HW|grep 'T main' | awk '{print "0x"$1}')
94+
python ./run_hook.py $HW $MAIN_ADDR
95+
if [ $? -ne 0 ]; then
96+
return 1
97+
fi
98+
99+
echo "Running state_control.py..."
100+
# Straight from the header of state_control.py
101+
gcc -static -g src/state_explore.c -o state_explore
102+
SE_ADDR=0x$(objdump -S state_explore | grep -A 1 'value == 0x41' |
103+
tail -n 1 | sed 's|^\s*||g' | cut -f1 -d:)
104+
python ./state_control.py state_explore $SE_ADDR
105+
if [ $? -ne 0 ]; then
106+
return 1
107+
fi
108+
109+
return 0
110+
}
111+
112+
make_vmtests(){
113+
DIR=`pwd`
114+
if [ ! -f ethereum_vm/.done ]; then
115+
echo "Automaking VMTests" `pwd`
116+
cd ./tests/ && mkdir -p ethereum_vm/VMTests_concrete && mkdir -p ethereum_vm/VMTests_symbolic
117+
rm -Rf vmtests; git clone https://github.com/ethereum/tests --depth=1 vmtests
118+
for i in ./vmtests/VMTests/*; do python ./auto_generators/make_VMTests.py $i; done
119+
for i in ./vmtests/VMTests/*; do python ./auto_generators/make_VMTests.py $i --symbolic; done
120+
rm -rf ./vmtests
121+
touch ethereum_vm/.done
122+
fi
123+
cd $DIR
124+
}
125+
126+
make_wasm_tests(){
127+
DIR=`pwd`
128+
if [ ! -f .wasm_done ]; then
129+
echo "Automaking WASM Tests" `pwd`
130+
cd ./tests/wasm
131+
./generate_tests.sh
132+
touch .wasm_done
133+
fi
134+
cd $DIR
135+
}
136+
137+
install_truffle(){
138+
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
139+
source ~/.nvm/nvm.sh
140+
nvm install --lts
141+
nvm use --lts
142+
143+
npm install -g truffle
144+
}
145+
146+
run_truffle_tests(){
147+
mkdir truffle_tests
148+
cd truffle_tests
149+
truffle unbox metacoin
150+
manticore . --contract MetaCoin --workspace output
151+
### The original comment says we should get 41 states, but after implementing the shift
152+
### insructions, we get 31. Was the original comment a typo?
153+
154+
# The correct answer should be 41
155+
# but Manticore fails to explore the paths due to the lack of the 0x1f opcode support
156+
# see https://github.com/trailofbits/manticore/issues/1166
157+
# if [ "$(ls output/*tx -l | wc -l)" != "41" ]; then
158+
if [ "$(ls output/*tx -l | wc -l)" != "13" ]; then
159+
echo "Truffle test failed" `ls output/*tx -l | wc -l` "!= 13"
160+
return 1
161+
fi
162+
echo "Truffle test succeded"
163+
cd ..
164+
return 0
165+
}
166+
167+
run_tests_from_dir() {
168+
DIR=$1
169+
pytest --cov=manticore -n auto "tests/$DIR"
170+
coverage xml
171+
}
172+
173+
run_examples() {
174+
pushd examples/linux
175+
make
176+
for example in $(make list); do
177+
./$example < /dev/zero > /dev/null
178+
done
179+
echo Built and ran Linux examples
180+
popd
181+
182+
pushd examples/script
183+
launch_examples
184+
RESULT=$?
185+
echo Ran example scripts
186+
popd
187+
return $RESULT
188+
}
189+
190+
# Test type
191+
case $TEST_TYPE in
192+
ethereum_vm)
193+
make_vmtests
194+
echo "Running only the tests from 'tests/$TEST_TYPE' directory"
195+
run_tests_from_dir $TEST_TYPE
196+
RV=$?
197+
198+
echo "Running truffle test"
199+
install_truffle
200+
run_truffle_tests
201+
RV=$(($RV + $?))
202+
;;
203+
wasm)
204+
make_wasm_tests ;& # Fallthrough
205+
native) ;& # Fallthrough
206+
ethereum) ;& # Fallthrough
207+
ethereum_bench) ;& # Fallthrough
208+
other)
209+
echo "Running only the tests from 'tests/$TEST_TYPE' directory"
210+
run_tests_from_dir $TEST_TYPE
211+
RV=$?
212+
;;
213+
214+
examples)
215+
run_examples
216+
;;
217+
218+
all)
219+
echo "Running all tests registered in travis_test.sh: examples, native, ethereum, ethereum_vm, other";
220+
221+
# Functions should return 0 on success and 1 on failure
222+
RV=0
223+
run_tests_from_dir native
224+
RV=$(($RV + $?))
225+
run_tests_from_dir ethereum
226+
RV=$(($RV + $?))
227+
make_vmtests; run_tests_from_dir ethereum_vm
228+
RV=$(($RV + $?))
229+
make_wasm_tests; run_tests_from_dir wasm
230+
RV=$(($RV + $?))
231+
run_tests_from_dir other
232+
RV=$(($RV + $?))
233+
run_examples
234+
RV=$(($RV + $?))
235+
;;
236+
237+
*)
238+
echo "Usage: $0 [examples|native|ethereum|ethereum_vm|other|all]"
239+
exit 3;
240+
;;
241+
esac
242+
- name: Coverage Upload
243+
uses: codecov/codecov-action@v1
244+
with:
245+
token: ${{ secrets.CODECOV_TOKEN }}
246+
file: ./coverage.xml
247+
yml: ./codecov.yml

.travis.yml

Lines changed: 0 additions & 66 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,50 @@
11
# Change Log
22

3-
## [Unreleased](https://github.com/trailofbits/manticore/compare/0.3.1...HEAD)
3+
## [Unreleased](https://github.com/trailofbits/manticore/compare/0.3.2...HEAD)
4+
5+
## 0.3.2 - 2019-11-11
6+
7+
Thanks to our external contributors!
8+
9+
- [Srinivas11789](https://github.com/trailofbits/manticore/commits?author=Srinivas11789)
10+
- [catenacyber](https://github.com/trailofbits/manticore/commits?author=catenacyber)
11+
- [Boyan-MILANOV](https://github.com/trailofbits/manticore/commits?author=Boyan-MILANOV)
12+
13+
### Ethereum
14+
* **[added API]** Use higher-level test generation to symbolically execute SHA3 [#1526](https://github.com/trailofbits/manticore/pull/1526)
15+
* **[added API]** Added fast unsound SHA3 strategy [#1549](https://github.com/trailofbits/manticore/pull/1549)
16+
* **[added API]** Added plugin for discarding states without changes to storage [#1507](https://github.com/trailofbits/manticore/pull/1507)
17+
* **[fixed API]** Fix `ADDMOD` and `MULMOD` [#1531](https://github.com/trailofbits/manticore/pull/1531)
18+
* Warn on missing bytecode [#1534](https://github.com/trailofbits/manticore/pull/1534)
19+
* Simplifiy PC upon modification [#1523](https://github.com/trailofbits/manticore/pull/1523)
20+
21+
22+
### Native
23+
* Better memory tests ([#1506](https://github.com/trailofbits/manticore/pull/1506), [1524](https://github.com/trailofbits/manticore/pull/1524))
24+
* Memory IO performance improvements [#1509](https://github.com/trailofbits/manticore/pull/1509)
25+
* **[added API]** Expose ELF dynamic load addresses [#1515](https://github.com/trailofbits/manticore/pull/1515)
26+
* Optimize instruction decoding ([#1522](https://github.com/trailofbits/manticore/pull/1522), [#1527](https://github.com/trailofbits/manticore/pull/1527))
27+
* Add partial support for `recvfrom` syscall [#1514](https://github.com/trailofbits/manticore/pull/1514)
28+
* **[fixed API]** Add `will_write_memory` event to `write_bytes` [#1535](https://github.com/trailofbits/manticore/pull/1535)
29+
* Update supported Unicorn version [#1536](https://github.com/trailofbits/manticore/pull/1536)
30+
* Fix file pointer leak in ELF interpreter [#1538](https://github.com/trailofbits/manticore/pull/1538)
31+
* Deduplicate socket symbol names [#1542](https://github.com/trailofbits/manticore/pull/1542)
32+
* Improve environment variable parsing [#1545](https://github.com/trailofbits/manticore/pull/1545)
33+
* **[fixed API]** Reduce chance of orphaned `did_execute_instruction` event [#1529](https://github.com/trailofbits/manticore/pull/1529)
34+
35+
### WASM
36+
* **[added API]** Added initial support for webassembly [#1495](https://github.com/trailofbits/manticore/pull/1495)
37+
38+
### Other
39+
* Incorporate type checking (mypy) into CI [#1544](https://github.com/trailofbits/manticore/pull/1544)
40+
* Fixes to smtlib ([#1512](https://github.com/trailofbits/manticore/pull/1512), [#1511](https://github.com/trailofbits/manticore/pull/1511))
41+
* Remove runtime type checking from smtlib to improve performance [#1543](https://github.com/trailofbits/manticore/pull/1543)
42+
* Logging improvements ([#1518](https://github.com/trailofbits/manticore/pull/1518), [#1520](https://github.com/trailofbits/manticore/pull/1520))
43+
* Simplify unsigned division constant folding [#1530](https://github.com/trailofbits/manticore/pull/1530)
44+
* Improve signed division logic [#1540](https://github.com/trailofbits/manticore/pull/1540)
45+
* **[changed API]** Move to manticore-specific exception types [#1537](https://github.com/trailofbits/manticore/pull/1537)
46+
* **[changed API]** Save profiling data in the workspace instead of the current directory [#1539](https://github.com/trailofbits/manticore/pull/1539)
47+
448

549
## 0.3.1 - 2019-08-06
650

CONTRIBUTING.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,20 @@ 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 .` in the manticore directory before
36-
committing.
33+
- We use the [`black`](https://black.readthedocs.io/en/stable/index.html)
34+
auto-formatter to enforce style conventions in Manticore. To ensure your code
35+
is properly formatted, run `black .` in the Manticore directory before
36+
committing. Although unlikely, if you are still having trouble with getting
37+
your code to pass formatting, check that you have the same version of `black`
38+
installed as what is used in the CI.
39+
- We use the [`mypy`](https://github.com/python/mypy) static typing tool to
40+
catch inconsistencies in the code base. At the time of this writing, we
41+
only check the [manticore](./manticore) directory for inconsistencies and do
42+
not yet enforce new contributions to include type hints. However, we greatly
43+
appreciate if you do include/add them in any code that you touch in your PR!
44+
Though, remember the next guideline if you are adding many type-hints, and
45+
ask for input on how to organize the addition of a massive amount of type
46+
hints. Check the CI configuration for the exact version of `mypy`.
3747
- Minimize irrelevant changes (formatting, whitespace, etc) to code that would
3848
otherwise not be touched by this patch. Save formatting or style corrections
3949
for a separate pull request that does not make any semantic changes.

0 commit comments

Comments
 (0)