Skip to content

Commit

Permalink
Merge branch 'master'
Browse files Browse the repository at this point in the history
* master: (43 commits)
  Syscall specific hooks (#2389)
  TUI Support Infrastructure (#1620)
  Fix coveralls upload (#2387)
  docs: fix simple typo, straigth -> straight (#2381)
  Attempt to allow symbolic balances from the start (#1818)
  Fix state.cpu.PC member (#1825)
  Bump black and mypy (#1824)
  Manticore 0.3.5 (#1808)
  Fix yices timeout argument (#1817)
  Detect default solver (#1820)
  Ignore Gas Calculations by Default (#1816)
  native/cpu/x86: Add support for CPUID EAX=80000000h (#1811)
  Change types.FunctionType=<class 'function'> (#1803)
  Fix test regressions (#1804)
  State Introspection API (#1775)
  Fix EVM account existence checks for selfdestruct and call (#1801)
  Add partial implementation of sendto syscall (#1791)
  crytic-compile: use latest release (#1795)
  Update gas metering for calls to empty accounts (#1774)
  Fix BitVec with symbolic offset and fix TranslatorSmtlib.unique thread safety (#1792)
  ...
  • Loading branch information
ekilmer committed Feb 27, 2021
2 parents 27db1b8 + d85a9a2 commit 040bd6f
Show file tree
Hide file tree
Showing 95 changed files with 20,467 additions and 15,757 deletions.
15 changes: 15 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,18 @@
source = manticore
omit =
*__init__.py

[report]
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover

# Don't try to cover special syntax "..." in abstract class
@abstractmethod

# Ignore informational/debugging log statements
logger.info
logger.debug

# We don't bother testing code that's explicitly unimplemented
raise NotImplementedError
222 changes: 43 additions & 179 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ jobs:
git fetch --depth=1 origin $BASE_SHA
echo "Files Changed:"
git diff --name-only $BASE_SHA... | tee .diff_names.txt
cat .diff_names.txt | python scripts/pyfile_exists.py | xargs black --diff --check
NAMES=$(cat .diff_names.txt | python scripts/pyfile_exists.py)
if test -z $NAMES
then
black --diff --check .
else
echo $NAMES | xargs black --diff --check
fi
mypy --version
mypy
tests:
Expand Down Expand Up @@ -61,187 +67,45 @@ jobs:
# Install solc unconditionally because it only takes a second or two
sudo wget -O /usr/bin/solc https://github.com/ethereum/solidity/releases/download/v0.4.24/solc-static-linux
sudo chmod +x /usr/bin/solc
pip install coveralls
pip install -e ".[dev-noks]"
- name: Run Tests
env:
TEST_TYPE: ${{ matrix.type }}
run: |
# Launches all examples; this assumes PWD is examples/script
launch_examples() {
COVERAGE_RCFILE=$GITHUB_WORKSPACE/.coveragerc
# concolic assumes presence of ../linux/simpleassert
echo "Running concolic.py..."
HW=../linux/helloworld
coverage run ./concolic.py
if [ $? -ne 0 ]; then
return 1
fi
echo "Running count_instructions.py..."
coverage run ./count_instructions.py $HW |grep -q Executed
if [ $? -ne 0 ]; then
return 1
fi
echo "Running introduce_symbolic_bytes.py..."
gcc -static -g src/state_explore.c -o state_explore
ADDRESS=0x$(objdump -S state_explore | grep -A 1 '((value & 0xff) != 0)' |
tail -n 1 | sed 's|^\s*||g' | cut -f1 -d:)
coverage run ./introduce_symbolic_bytes.py state_explore $ADDRESS
if [ $? -ne 0 ]; then
return 1
fi
echo "Running run_simple.py..."
gcc -x c -static -o hello test_run_simple.c
coverage run ./run_simple.py hello
if [ $? -ne 0 ]; then
return 1
fi
echo "Running run_hook.py..."
MAIN_ADDR=$(nm $HW|grep 'T main' | awk '{print "0x"$1}')
coverage run ./run_hook.py $HW $MAIN_ADDR
if [ $? -ne 0 ]; then
return 1
fi
echo "Running state_control.py..."
# Straight from the header of state_control.py
gcc -static -g src/state_explore.c -o state_explore
SE_ADDR=0x$(objdump -S state_explore | grep -A 1 'value == 0x41' |
tail -n 1 | sed 's|^\s*||g' | cut -f1 -d:)
coverage run ./state_control.py state_explore $SE_ADDR
if [ $? -ne 0 ]; then
return 1
fi
return 0
}
make_vmtests(){
DIR=`pwd`
if [ ! -f ethereum_vm/.done ]; then
echo "Automaking VMTests" `pwd`
cd ./tests/ && mkdir -p ethereum_vm/VMTests_concrete && mkdir -p ethereum_vm/VMTests_symbolic
rm -Rf vmtests; git clone https://github.com/ethereum/tests --depth=1 vmtests
for i in ./vmtests/BlockchainTests/ValidBlocks/VMTests/*/*json; do python ./auto_generators/make_VMTests.py -f istanbul -i $i -o ethereum_vm/VMTests_concrete; done
rm ethereum_vm/VMTests_concrete/test_loop*.py #too slow
rm -rf ./vmtests
touch ethereum_vm/.done
fi
cd $DIR
}
make_wasm_tests(){
DIR=`pwd`
if [ ! -f .wasm_done ]; then
echo "Automaking WASM Tests" `pwd`
cd ./tests/wasm
./generate_tests.sh
touch .wasm_done
fi
cd $DIR
}
make_wasm_sym_tests(){
DIR=`pwd`
if [ ! -f .wasm_sym_done ]; then
echo "Automaking Symbolic WASM Tests" `pwd`
cd ./tests/wasm_sym
./generate_symbolic_tests.sh
touch .wasm_sym_done
fi
cd $DIR
}
install_truffle(){
npm install -g truffle
}
run_truffle_tests(){
COVERAGE_RCFILE=$GITHUB_WORKSPACE/.coveragerc
mkdir truffle_tests
cd truffle_tests
truffle unbox metacoin
coverage run -m manticore . --contract MetaCoin --workspace output --exclude-all --evm.oog ignore --evm.txfail optimistic
# Truffle smoke test. We test if manticore is able to generate states
# from a truffle project.
if [ "$(ls output/*tx -l | wc -l)" != "26" ]; then
echo "Truffle test failed" `ls output/*tx -l | wc -l` "!= 26"
return 1
fi
echo "Truffle test succeded"
coverage xml
cd ..
cp truffle_tests/coverage.xml .
return 0
}
run_tests_from_dir() {
DIR=$1
COVERAGE_RCFILE=$GITHUB_WORKSPACE/.coveragerc
echo "Running only the tests from 'tests/$DIR' directory"
pytest --durations=100 --cov=manticore --cov-config=$GITHUB_WORKSPACE/.coveragerc -n auto "tests/$DIR"
coverage xml
}
run_examples() {
pushd examples/linux
make
for example in $(make list); do
./$example < /dev/zero > /dev/null
done
echo Built and ran Linux examples
popd
pushd examples/script
launch_examples
RESULT=$?
echo Ran example scripts
coverage xml
popd
cp examples/script/coverage.xml .
return $RESULT
}
# Test type
case $TEST_TYPE in
ethereum_vm)
make_vmtests
run_tests_from_dir $TEST_TYPE
;;
ethereum_truffle)
echo "Running truffle test"
install_truffle
run_truffle_tests
;;
wasm)
make_wasm_tests
run_tests_from_dir $TEST_TYPE
;;
wasm_sym)
make_wasm_sym_tests ;& # Fallthrough
native) ;& # Fallthrough
ethereum) ;& # Fallthrough
ethereum_bench) ;& # Fallthrough
other)
run_tests_from_dir $TEST_TYPE
;;
examples)
run_examples
;;
*)
echo "Unknown TEST_TYPE: '$TEST_TYPE'"
exit 3;
;;
esac
- name: Coverage Upload
uses: codecov/codecov-action@v1
cp scripts/run_tests.sh .
./run_tests.sh
- name: Coveralls Parallel
run: |
coveralls --service=github
env:
COVERALLS_PARALLEL: true
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Send notification when all tests have finished to combine coverage results
coverage-finish:
needs: tests
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
upload:
runs-on: ubuntu-latest
if: github.event_name == 'schedule'
needs: tests
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.6
uses: actions/setup-python@v1
with:
python-version: 3.6
- name: Build Dist
run: |
python3 -m pip install wheel
python3 setup.py --dev_release sdist bdist_wheel
- name: Upload to PyPI
uses: pypa/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
yml: ./codecov.yml
# Disabled this line because Codecov has been extra flaky lately, and having to re-run the entire
# test suite until every coverage upload step succeeds is more of a hassle than it's worth.
# fail_ci_if_error: true
password: ${{ secrets.PYPI_UPLOAD }}
45 changes: 45 additions & 0 deletions .github/workflows/osx.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: MacOS Tests

on:
schedule:
# Run every day at 11 PM.
- cron: '0 23 * * *'

jobs:
tests:
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
type: ["ethereum_truffle", "ethereum_bench", "ethereum", "ethereum_vm", "wasm", "wasm_sym", "other"]
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.6
uses: actions/setup-python@v1
with:
python-version: 3.6
- name: Install NPM
uses: actions/setup-node@v1
with:
node-version: '13.x'
- name: Install dependencies
env:
TEST_TYPE: ${{ matrix.type }}
run: |
EXTRAS="dev-noks"
pip install -e .[$EXTRAS]
- name: Install Mac Dependencies
run: |
brew install bash
brew tap ethereum/ethereum
brew install solidity@4
brew install wabt
brew install SRI-CSL/sri-csl/yices2
brew tap cvc4/cvc4
brew install cvc4/cvc4/cvc4
- name: Run Tests
env:
TEST_TYPE: ${{ matrix.type }}
run: |
cp scripts/run_tests.sh .
./run_tests.sh
86 changes: 84 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,90 @@
# Change Log

## [Unreleased](https://github.com/trailofbits/manticore/compare/0.3.3...HEAD)
## [Unreleased](https://github.com/trailofbits/manticore/compare/0.3.5...HEAD)

## 0.3.3 - 2020-01
## 0.3.5 - 2020-11-06

Thanks to our external contributors!
- [wolfo](https://github.com/trailofbits/manticore/commits?author=wolfo)
- [geohot](https://github.com/trailofbits/manticore/commits?author=geohot)
- [romits800](https://github.com/trailofbits/manticore/commits?author=romits800)

### Ethereum
* Made EVM module ignore runtime gas calculations by default [#1816](https://github.com/trailofbits/manticore/pull/1816)
* Updated gas calculations for calls to empty accounts [#1774](https://github.com/trailofbits/manticore/pull/1774)
* Fixed account existence checks for `selfdestruct` and `call` [#1801](https://github.com/trailofbits/manticore/pull/1801)

### Native
* **[Added API]** new `strlen` models [#1725](https://github.com/trailofbits/manticore/pull/1725)
* **[Added API]** State-specific hooks [#1777](https://github.com/trailofbits/manticore/pull/1777)
* Improved system call argument handling [#1785](https://github.com/trailofbits/manticore/pull/1785)
* Improved `stat` support for file descriptors [#1780](https://github.com/trailofbits/manticore/pull/1780)
* Support symbolic-length reads from sockets [#1786](https://github.com/trailofbits/manticore/pull/1786)
* Add stubs for `sendto` [#1791](https://github.com/trailofbits/manticore/pull/1791)

### WASM
* Fix type confusion when importing external functions [#1803](https://github.com/trailofbits/manticore/pull/1803)

### Other
* Made [Yices2](https://yices.csl.sri.com/) the default SMT Solver [#1820](https://github.com/trailofbits/manticore/pull/1820)
* **[Added API]** Added an API for introspecting live states [#1775](https://github.com/trailofbits/manticore/pull/1775)
* Changed default multiprocessing type to threading [#1779](https://github.com/trailofbits/manticore/pull/1779)
* Improved array serialization performance [#1756](https://github.com/trailofbits/manticore/pull/1756)
* Fix name collisions in SMT variables [#1792](https://github.com/trailofbits/manticore/pull/1792)


## 0.3.4 - 2020-06-26

Thanks to our external contributors!
- [jimpo](https://github.com/trailofbits/manticore/commits?author=jimpo)
- [langston-barrett](https://github.com/trailofbits/manticore/commits?author=langston-barrett)

### Ethereum
* Support and test against EVM Istanbul [#1676](https://github.com/trailofbits/manticore/pull/1676)
* **[Added API]** Added a `manticore-verifier` script for checking properties of smart contracts [#1717](https://github.com/trailofbits/manticore/pull/1717)
* Fixed RETURNDATASIZE [#1612](https://github.com/trailofbits/manticore/pull/1612)
* Added strategies for symbolic SHA3 replacement [#1609](https://github.com/trailofbits/manticore/pull/1609)
* Fixed GAS instruction [#1633](https://github.com/trailofbits/manticore/pull/1633)
* Improved balance-related exploration [#1615](https://github.com/trailofbits/manticore/pull/1615)
* Add `__format__` to EVM accounts [#1613](https://github.com/trailofbits/manticore/pull/1613)
* Discard basic blocks that unavoidably REVERT [#1630](https://github.com/trailofbits/manticore/pull/1630)
* Extract printable bytes from return data [#1671](https://github.com/trailofbits/manticore/pull/1671)
* Support CHAINID, EXTCODEHASH, and SELFBALANCE instructions [#1644](https://github.com/trailofbits/manticore/pull/1644)
* **[Changed API]** Renamed several arguments in EVM API, including `gaslimit` --> `gas` [#1652](https://github.com/trailofbits/manticore/pull/1652)
* Explore states that self-destruct [#1699](https://github.com/trailofbits/manticore/pull/1699)
* Lazy solving for the Ethereum leak detector [#1727](https://github.com/trailofbits/manticore/pull/1727)

### Native
* Support for ARM modified-immediate encodings [#1638](https://github.com/trailofbits/manticore/pull/1638)
* Support for `/proc/self/maps` [#1639](https://github.com/trailofbits/manticore/pull/1639)
* Support for `llseek` [#1640](https://github.com/trailofbits/manticore/pull/1640)
* Support for `arm_fadvise64_64` [#1648](https://github.com/trailofbits/manticore/pull/1648)
* Allow symbolic sockets in `accept` [#1618](https://github.com/trailofbits/manticore/pull/1618)
* Fixes to `open` [#1657](https://github.com/trailofbits/manticore/pull/1657)
* Overhauled filesystem emulation [#1673](https://github.com/trailofbits/manticore/pull/1673)
* Fixed system call argument concretization [#1697](https://github.com/trailofbits/manticore/pull/1697)
* **[Added API]** Add a symbolic model for `strcpy` [#1681](https://github.com/trailofbits/manticore/pull/1681)

### WASM
* Delay branch condition concretization for better coverage [#1641](https://github.com/trailofbits/manticore/pull/1641)

### Other
* **[Added API]** Added a snapshot system [#1710](https://github.com/trailofbits/manticore/pull/1710)
* Transparent compression for state files [#1624](https://github.com/trailofbits/manticore/pull/1624)
* Unify around singleton interface for solver [#1649](https://github.com/trailofbits/manticore/pull/1649)
* Use `__slots__` to reduce memory usage in expression system [#1635](https://github.com/trailofbits/manticore/pull/1635)
* **[Removed API]** Removed `policy` argument from ManticoreBase, added `outputspace_url` to optionally separate working files from output files [#1651](https://github.com/trailofbits/manticore/pull/1651)
* Disable broken `get_related` logic [#1674](https://github.com/trailofbits/manticore/pull/1674)
* Disable flaky Z3 tactics [#1691](https://github.com/trailofbits/manticore/pull/1691)
* Remove Keystone engine from dependencies [#1684](https://github.com/trailofbits/manticore/pull/1684)
* Improved error messages [#1632](https://github.com/trailofbits/manticore/pull/1632), [#1704](https://github.com/trailofbits/manticore/pull/1704)
* Made ConstraintSets hashable [#1703](https://github.com/trailofbits/manticore/pull/1703)
* Added system to dynamically enable/disable plugins [#1696](https://github.com/trailofbits/manticore/pull/1696) [#1708](https://github.com/trailofbits/manticore/pull/1708)
* Re-establish support for Yices and CVC4 [#1714](https://github.com/trailofbits/manticore/pull/1714)
* Improved constant folding and constraint set slicing [#1706](https://github.com/trailofbits/manticore/pull/1706)


## 0.3.3 - 2020-01-30

Thanks to our external contributors!

Expand Down
Loading

0 comments on commit 040bd6f

Please sign in to comment.