Security analysis tool for EVM bytecode. Supports smart contracts built for Ethereum, Hedera, Quorum, Vechain, Roostock, Tron and other EVM-compatible blockchains.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
mythril/tests/pre-commit-hooks/test.sh

30 lines
898 B

#!/usr/bin/env bash
set -o errtrace -o nounset -o pipefail -o errexit
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
# Create temp working directory for mock repo
MOCK_REPO=$(mktemp -d)
if [[ ! "$MOCK_REPO" || ! -d "$MOCK_REPO" ]]; then
echo "Could not create temp dir"
exit 1
fi
function cleanup {
echo "Deleting temp working directory $MOCK_REPO"
rm -rf "$MOCK_REPO"
}
trap cleanup EXIT
# Filling the mock repo
pushd "$MOCK_REPO" >/dev/null || exit 1
git init --initial-branch=master
git config user.email "test@example.com"
git config user.name "pre-commit test"
cp "$SCRIPT_DIR/Counter.sol" .
git add .
git commit -m "Initial commit"
# Run pre-commit inside the mock repo while referencing the mythril directory,
# where the .pre-commit-hooks.yaml is located.
pre-commit try-repo "$SCRIPT_DIR/../.." mythril --verbose --color=always --all-files