mirror of https://github.com/crytic/slither
commit
a603935a08
@ -0,0 +1,38 @@ |
||||
--- |
||||
body: |
||||
- |
||||
attributes: |
||||
label: "What operating system are you using?" |
||||
id: os |
||||
type: textarea |
||||
validations: |
||||
required: true |
||||
- |
||||
attributes: |
||||
label: "How did you install slither?" |
||||
description: | |
||||
For example, using git or python's pip. |
||||
id: install-method |
||||
type: textarea |
||||
validations: |
||||
required: true |
||||
- type: dropdown |
||||
id: python |
||||
attributes: |
||||
label: Do you have python added to your $PATH? |
||||
multiple: true |
||||
options: |
||||
- "Yes" |
||||
- "No" |
||||
- "Not sure" |
||||
- |
||||
attributes: |
||||
description: | |
||||
Please copy and paste any relevant log output. This |
||||
will be automatically formatted into code, so no need for backticks. |
||||
render: shell |
||||
label: "Output of running `slither-doctor .`:" |
||||
id: logs |
||||
labels: |
||||
- installation-help |
||||
title: "[Installation-Help]: " |
@ -1,55 +0,0 @@ |
||||
--- |
||||
body: |
||||
- |
||||
attributes: |
||||
value: | |
||||
Please check the issues tab to avoid duplicates. |
||||
Thanks for taking the time to fill out this bug report! |
||||
type: markdown |
||||
- |
||||
attributes: |
||||
label: "What operating system are you using?" |
||||
id: os |
||||
type: textarea |
||||
validations: |
||||
required: true |
||||
- |
||||
attributes: |
||||
label: "How did you install slither?" |
||||
description: | |
||||
For example, using git or python's pip. |
||||
id: install-method |
||||
type: textarea |
||||
validations: |
||||
required: true |
||||
- type: dropdown |
||||
id: python |
||||
attributes: |
||||
label: Do you have python added to your $PATH? |
||||
multiple: true |
||||
options: |
||||
- "Yes" |
||||
- "No" |
||||
- "Not sure" |
||||
- type: dropdown |
||||
id: solc |
||||
attributes: |
||||
label: Do you have solc-select installed? |
||||
multiple: true |
||||
options: |
||||
- "Yes" |
||||
- "No" |
||||
- |
||||
attributes: |
||||
description: | |
||||
Please copy and paste any relevant log output. This |
||||
will be automatically formatted into code, so no need for backticks. |
||||
render: shell |
||||
label: "Output of running `slither-doctor .`:" |
||||
id: logs |
||||
type: textarea |
||||
description: "Get help troubleshooting slither installation" |
||||
labels: |
||||
- installation-help |
||||
name: "Trouble with Installing Slither" |
||||
title: "[Installation-Help]: " |
@ -0,0 +1,61 @@ |
||||
--- |
||||
body: |
||||
- |
||||
attributes: |
||||
value: | |
||||
Please check the issues tab to avoid duplicates. |
||||
Thanks for helping make Slither the best it can be! |
||||
type: markdown |
||||
- |
||||
attributes: |
||||
label: "What bug did Slither miss and which detector did you anticipate would catch it?" |
||||
id: what-happened |
||||
type: textarea |
||||
validations: |
||||
required: true |
||||
- |
||||
attributes: |
||||
label: Frequency |
||||
description: How often do you run across this false negative? |
||||
options: |
||||
- Very Frequently |
||||
- Occasionally |
||||
- Rarely |
||||
- Not sure |
||||
id: frequency |
||||
type: dropdown |
||||
validations: |
||||
required: true |
||||
- |
||||
attributes: |
||||
description: "It can be a github repo, etherscan link, or code snippet." |
||||
label: "Code example to reproduce the issue:" |
||||
placeholder: "`contract A {}`\n" |
||||
id: reproduce |
||||
type: textarea |
||||
validations: |
||||
required: true |
||||
- |
||||
attributes: |
||||
description: | |
||||
What version of slither are you running? |
||||
Run `slither --version` |
||||
label: "Version:" |
||||
id: version |
||||
type: textarea |
||||
validations: |
||||
required: true |
||||
- |
||||
attributes: |
||||
description: | |
||||
Please copy and paste the result output. This |
||||
will be automatically formatted into code, so no need for backticks. |
||||
render: shell |
||||
label: "Relevant log output:" |
||||
id: logs |
||||
type: textarea |
||||
description: "Slither missed a bug it should find." |
||||
labels: |
||||
- false-negative |
||||
name: False Negative |
||||
title: "[False Negative]: " |
@ -0,0 +1,61 @@ |
||||
--- |
||||
body: |
||||
- |
||||
attributes: |
||||
value: | |
||||
Please check the issues tab to avoid duplicates. |
||||
Thanks for helping make Slither the best it can be! |
||||
type: markdown |
||||
- |
||||
attributes: |
||||
label: "Describe the false alarm that Slither raise and how you know it's inaccurate:" |
||||
id: what-happened |
||||
type: textarea |
||||
validations: |
||||
required: true |
||||
- |
||||
attributes: |
||||
label: Frequency |
||||
description: How often do you run across this false positive? |
||||
options: |
||||
- Very Frequently |
||||
- Occasionally |
||||
- Rarely |
||||
- Not sure |
||||
id: frequency |
||||
type: dropdown |
||||
validations: |
||||
required: true |
||||
- |
||||
attributes: |
||||
description: "It can be a github repo, etherscan link, or code snippet." |
||||
label: "Code example to reproduce the issue:" |
||||
placeholder: "`contract A {}`\n" |
||||
id: reproduce |
||||
type: textarea |
||||
validations: |
||||
required: true |
||||
- |
||||
attributes: |
||||
description: | |
||||
What version of slither are you running? |
||||
Run `slither --version` |
||||
label: "Version:" |
||||
id: version |
||||
type: textarea |
||||
validations: |
||||
required: true |
||||
- |
||||
attributes: |
||||
description: | |
||||
Please copy and paste the result output. This |
||||
will be automatically formatted into code, so no need for backticks. |
||||
render: shell |
||||
label: "Relevant log output:" |
||||
id: logs |
||||
type: textarea |
||||
description: "Slither warned of an issue that is not legitimate and does not need to be fixed." |
||||
labels: |
||||
- false-positive |
||||
name: "False Positive" |
||||
title: "[False-Positive]: " |
@ -0,0 +1,30 @@ |
||||
# Derived from <https://github.com/pyca/cryptography/blob/SOME_REF/.github/actions/upload-coverage/action.yml> |
||||
# Originally authored by the PyCA Cryptography maintainers, and licensed under |
||||
# the terms of the BSD license: |
||||
# <https://github.com/pyca/cryptography/blob/main/LICENSE.BSD> |
||||
|
||||
name: Upload Coverage |
||||
description: Upload coverage files |
||||
|
||||
runs: |
||||
using: "composite" |
||||
|
||||
steps: |
||||
# FIXME(jl): codecov has the option of including machine information in filename that would solve this unique naming |
||||
# issue more completely. |
||||
# This method has the limitation of 1 coverage file per run, limiting some coverage between online/offline tests. |
||||
- run: | |
||||
COVERAGE_UUID=$(python3 -c "import uuid; print(uuid.uuid4())") |
||||
echo "COVERAGE_UUID=${COVERAGE_UUID}" >> $GITHUB_OUTPUT |
||||
if [ -f .coverage ]; then |
||||
mv .coverage .coverage.${COVERAGE_UUID} |
||||
fi |
||||
id: coverage-uuid |
||||
shell: bash |
||||
- uses: actions/upload-artifact@v3.1.0 |
||||
with: |
||||
name: coverage-data |
||||
path: | |
||||
.coverage.* |
||||
*.lcov |
||||
if-no-files-found: ignore |
@ -0,0 +1,8 @@ |
||||
--- |
||||
version: 2 |
||||
updates: |
||||
- package-ecosystem: "github-actions" |
||||
directory: "/" |
||||
target-branch: "dev" |
||||
schedule: |
||||
interval: "weekly" |
@ -0,0 +1,13 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
# used to pass --cov=$path and --cov-append to pytest |
||||
if [ "$1" != "" ]; then |
||||
pytest "$1" tests/e2e/ -n auto |
||||
status_code=$? |
||||
python -m coverage report |
||||
else |
||||
pytest tests/e2e/ -n auto |
||||
status_code=$? |
||||
fi |
||||
|
||||
exit "$status_code" |
@ -0,0 +1,13 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
# used to pass --cov=$path and --cov-append to pytest |
||||
if [ "$1" != "" ]; then |
||||
pytest "$1" tests/tools/read-storage/test_read_storage.py |
||||
status_code=$? |
||||
python -m coverage report |
||||
else |
||||
pytest tests/tools/read-storage/test_read_storage.py |
||||
status_code=$? |
||||
fi |
||||
|
||||
exit "$status_code" |
@ -0,0 +1,13 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
# used to pass --cov=$path and --cov-append to pytest |
||||
if [ "$1" != "" ]; then |
||||
pytest "$1" tests/unit/ -n auto |
||||
status_code=$? |
||||
python -m coverage report |
||||
else |
||||
pytest tests/unit/ -n auto |
||||
status_code=$? |
||||
fi |
||||
|
||||
exit "$status_code" |
@ -1,51 +0,0 @@ |
||||
--- |
||||
name: IR tests |
||||
|
||||
defaults: |
||||
run: |
||||
# To load bashrc |
||||
shell: bash -ieo pipefail {0} |
||||
|
||||
on: |
||||
pull_request: |
||||
branches: [master, dev] |
||||
schedule: |
||||
# run CI every day even if no PRs/merges occur |
||||
- cron: '0 12 * * *' |
||||
|
||||
concurrency: |
||||
group: ${{ github.workflow }}-${{ github.ref }} |
||||
cancel-in-progress: true |
||||
|
||||
jobs: |
||||
build: |
||||
name: IR tests |
||||
runs-on: ${{ matrix.os }} |
||||
strategy: |
||||
fail-fast: false |
||||
matrix: |
||||
os: [ubuntu-latest, windows-2022] |
||||
|
||||
steps: |
||||
- name: Checkout Code |
||||
uses: actions/checkout@v3 |
||||
|
||||
- name: Set up Python 3.8 |
||||
uses: actions/setup-python@v3 |
||||
with: |
||||
python-version: 3.8 |
||||
|
||||
- name: Install dependencies |
||||
run: | |
||||
pip install ".[dev]" |
||||
solc-select install 0.5.0 |
||||
solc-select use 0.8.11 --always-install |
||||
|
||||
- name: Install old solc |
||||
if: matrix.os == 'ubuntu-latest' |
||||
run: solc-select install 0.4.0 |
||||
|
||||
|
||||
- name: Test with pytest |
||||
run: | |
||||
pytest tests/test_ssa_generation.py |
@ -1,45 +0,0 @@ |
||||
--- |
||||
name: Detectors tests |
||||
|
||||
defaults: |
||||
run: |
||||
# To load bashrc |
||||
shell: bash -ieo pipefail {0} |
||||
|
||||
on: |
||||
pull_request: |
||||
branches: [master, dev] |
||||
schedule: |
||||
# run CI every day even if no PRs/merges occur |
||||
- cron: '0 12 * * *' |
||||
|
||||
concurrency: |
||||
group: ${{ github.workflow }}-${{ github.ref }} |
||||
cancel-in-progress: true |
||||
|
||||
jobs: |
||||
build: |
||||
name: Detectors tests |
||||
runs-on: ${{ matrix.os }} |
||||
strategy: |
||||
fail-fast: false |
||||
matrix: |
||||
os: [ubuntu-latest, windows-2022] |
||||
|
||||
steps: |
||||
- name: Checkout Code |
||||
uses: actions/checkout@v3 |
||||
|
||||
- name: Set up Python 3.8 |
||||
uses: actions/setup-python@v3 |
||||
with: |
||||
python-version: 3.8 |
||||
|
||||
- name: Install dependencies |
||||
run: | |
||||
pip install ".[dev]" |
||||
|
||||
solc-select use 0.7.3 --always-install |
||||
- name: Test with pytest |
||||
run: | |
||||
pytest tests/test_detectors.py |
@ -1,55 +0,0 @@ |
||||
--- |
||||
name: Features tests |
||||
|
||||
defaults: |
||||
run: |
||||
# To load bashrc |
||||
shell: bash -ieo pipefail {0} |
||||
|
||||
on: |
||||
pull_request: |
||||
branches: [master, dev] |
||||
schedule: |
||||
# run CI every day even if no PRs/merges occur |
||||
- cron: '0 12 * * *' |
||||
|
||||
concurrency: |
||||
group: ${{ github.workflow }}-${{ github.ref }} |
||||
cancel-in-progress: true |
||||
|
||||
jobs: |
||||
build: |
||||
name: Features tests |
||||
runs-on: ${{ matrix.os }} |
||||
strategy: |
||||
fail-fast: false |
||||
matrix: |
||||
os: [ubuntu-latest, windows-2022] |
||||
|
||||
steps: |
||||
- name: Checkout Code |
||||
uses: actions/checkout@v3 |
||||
|
||||
- name: Set up Python 3.8 |
||||
uses: actions/setup-python@v3 |
||||
with: |
||||
python-version: 3.8 |
||||
|
||||
- name: Install dependencies |
||||
run: | |
||||
pip install ".[dev]" |
||||
|
||||
solc-select use 0.8.0 --always-install |
||||
|
||||
cd tests/test_node_modules/ |
||||
npm install hardhat |
||||
cd ../.. |
||||
|
||||
- name: Test with pytest |
||||
run: | |
||||
pytest tests/test_features.py |
||||
pytest tests/test_constant_folding.py |
||||
pytest tests/slithir/test_ternary_expressions.py |
||||
pytest tests/test_functions_ids.py |
||||
pytest tests/test_function.py |
||||
pytest tests/test_source_mapping.py |
@ -1,49 +0,0 @@ |
||||
--- |
||||
name: Parser tests |
||||
|
||||
defaults: |
||||
run: |
||||
# To load bashrc |
||||
shell: bash -ieo pipefail {0} |
||||
|
||||
on: |
||||
pull_request: |
||||
branches: [master, dev] |
||||
schedule: |
||||
# run CI every day even if no PRs/merges occur |
||||
- cron: '0 12 * * *' |
||||
|
||||
concurrency: |
||||
group: ${{ github.workflow }}-${{ github.ref }} |
||||
cancel-in-progress: true |
||||
|
||||
jobs: |
||||
build: |
||||
name: Parser tests |
||||
runs-on: ${{ matrix.os }} |
||||
strategy: |
||||
fail-fast: false |
||||
matrix: |
||||
os: [ubuntu-latest, windows-2022] |
||||
|
||||
steps: |
||||
- name: Checkout Code |
||||
uses: actions/checkout@v3 |
||||
|
||||
- name: Set up Python 3.8 |
||||
uses: actions/setup-python@v3 |
||||
with: |
||||
python-version: 3.8 |
||||
|
||||
- name: Install dependencies |
||||
run: | |
||||
pip install ".[dev]" |
||||
|
||||
- name: Install solc |
||||
run: | |
||||
solc-select install all |
||||
solc-select use 0.8.0 |
||||
|
||||
- name: Test with pytest |
||||
run: | |
||||
pytest tests/test_ast_parsing.py -n auto |
@ -0,0 +1,54 @@ |
||||
name: Publish to PyPI |
||||
|
||||
on: |
||||
release: |
||||
types: [published] |
||||
|
||||
jobs: |
||||
build-release: |
||||
|
||||
runs-on: ubuntu-latest |
||||
|
||||
steps: |
||||
- uses: actions/checkout@v3 |
||||
|
||||
- name: Set up Python |
||||
uses: actions/setup-python@v4 |
||||
with: |
||||
python-version: '3.x' |
||||
|
||||
- name: Build distributions |
||||
run: | |
||||
python -m pip install --upgrade pip |
||||
python -m pip install build |
||||
python -m build |
||||
- name: Upload distributions |
||||
uses: actions/upload-artifact@v3 |
||||
with: |
||||
name: slither-dists |
||||
path: dist/ |
||||
|
||||
publish: |
||||
runs-on: ubuntu-latest |
||||
environment: release |
||||
permissions: |
||||
id-token: write # For trusted publishing + codesigning. |
||||
contents: write # For attaching signing artifacts to the release. |
||||
needs: |
||||
- build-release |
||||
steps: |
||||
- name: fetch dists |
||||
uses: actions/download-artifact@v3 |
||||
with: |
||||
name: slither-dists |
||||
path: dist/ |
||||
|
||||
- name: publish |
||||
uses: pypa/gh-action-pypi-publish@v1.8.6 |
||||
|
||||
- name: sign |
||||
uses: sigstore/gh-action-sigstore-python@v1.2.3 |
||||
with: |
||||
inputs: ./dist/*.tar.gz ./dist/*.whl |
||||
release-signing-artifacts: true |
||||
bundle-only: true |
@ -1,54 +0,0 @@ |
||||
--- |
||||
name: Test slither-read-storage |
||||
|
||||
defaults: |
||||
run: |
||||
# To load bashrc |
||||
shell: bash -ieo pipefail {0} |
||||
|
||||
on: |
||||
pull_request: |
||||
branches: [master, dev] |
||||
schedule: |
||||
# run CI every day even if no PRs/merges occur |
||||
- cron: '0 12 * * *' |
||||
|
||||
concurrency: |
||||
group: ${{ github.workflow }}-${{ github.ref }} |
||||
cancel-in-progress: true |
||||
|
||||
jobs: |
||||
build: |
||||
name: Test slither-read-storage |
||||
runs-on: ubuntu-latest |
||||
|
||||
steps: |
||||
- uses: actions/checkout@v3 |
||||
- name: Setup node |
||||
uses: actions/setup-node@v2 |
||||
with: |
||||
node-version: '14' |
||||
|
||||
- name: Install ganache |
||||
run: npm install --global ganache |
||||
|
||||
- name: Set up Python 3.8 |
||||
uses: actions/setup-python@v2 |
||||
with: |
||||
python-version: 3.8 |
||||
|
||||
- name: Install python dependencies |
||||
run: | |
||||
pip install ".[dev]" |
||||
pip install web3 |
||||
solc-select install 0.8.1 |
||||
solc-select install 0.8.10 |
||||
solc-select use 0.8.1 |
||||
|
||||
- name: Run slither-read-storage |
||||
run: | |
||||
pytest tests/test_read_storage.py |
||||
|
||||
- name: Run storage layout tests |
||||
run: | |
||||
pytest tests/test_storage_layout.py |
@ -0,0 +1,105 @@ |
||||
--- |
||||
name: Pytest |
||||
|
||||
defaults: |
||||
run: |
||||
shell: bash |
||||
|
||||
on: |
||||
push: |
||||
branches: [master, dev] |
||||
pull_request: |
||||
schedule: |
||||
# run CI every day even if no PRs/merges occur |
||||
- cron: '0 12 * * *' |
||||
|
||||
concurrency: |
||||
group: ${{ github.workflow }}-${{ github.ref }} |
||||
cancel-in-progress: true |
||||
|
||||
jobs: |
||||
tests: |
||||
runs-on: ${{ matrix.os }} |
||||
strategy: |
||||
fail-fast: false |
||||
matrix: |
||||
os: ["ubuntu-latest", "windows-2022"] |
||||
type: ["unit", "integration", "tool"] |
||||
steps: |
||||
- uses: actions/checkout@v3 |
||||
- name: Set up Python 3.8 |
||||
uses: actions/setup-python@v4 |
||||
with: |
||||
python-version: 3.8 |
||||
cache: "pip" |
||||
cache-dependency-path: setup.py |
||||
|
||||
- name: Install dependencies |
||||
run: | |
||||
pip install ".[test]" |
||||
|
||||
- name: Setup node |
||||
uses: actions/setup-node@v3 |
||||
with: |
||||
node-version: '16' |
||||
cache: 'npm' |
||||
cache-dependency-path: '**/package-lock.json' |
||||
|
||||
- name: Install test dependencies |
||||
run: | |
||||
if [ ${{ matrix.type }} = "tool" ]; then |
||||
# Setup Ganache for slither-read-storage tests. |
||||
npm install --global ganache |
||||
elif [ ${{ matrix.type }} = "integration" ]; then |
||||
# Setup Hardhat for compilation tests. |
||||
pushd tests/e2e/compilation/test_data/test_node_modules/ || exit |
||||
npm install hardhat |
||||
popd || exit |
||||
fi |
||||
|
||||
- name: Run ${{ matrix.type }} tests |
||||
env: |
||||
TEST_TYPE: ${{ matrix.type }} |
||||
# Only run coverage on ubuntu-latest. |
||||
run: | |
||||
if [ ${{ matrix.os }} = "ubuntu-latest" ]; then |
||||
TEST_ARGS="--cov=slither --cov-append" |
||||
elif [ ${{ matrix.os }} = "windows-2022" ]; then |
||||
TEST_ARGS="" |
||||
fi |
||||
bash "./.github/scripts/${TEST_TYPE}_test_runner.sh" $TEST_ARGS |
||||
|
||||
|
||||
- name: Upload coverage |
||||
uses: ./.github/actions/upload-coverage |
||||
# only aggregate test coverage over linux-based tests to avoid any OS-specific filesystem information stored in |
||||
# coverage metadata. |
||||
if: ${{ matrix.os == 'ubuntu-latest' }} |
||||
|
||||
coverage: |
||||
needs: |
||||
- tests |
||||
|
||||
runs-on: ubuntu-latest |
||||
|
||||
steps: |
||||
- uses: actions/checkout@v3 |
||||
- name: Set up Python 3.8 |
||||
uses: actions/setup-python@v4 |
||||
with: |
||||
python-version: 3.8 |
||||
|
||||
- run: pip install coverage[toml] |
||||
|
||||
- name: download coverage data |
||||
uses: actions/download-artifact@v3.0.2 |
||||
with: |
||||
name: coverage-data |
||||
|
||||
- name: combine coverage data |
||||
id: combinecoverage |
||||
run: | |
||||
set +e |
||||
python -m coverage combine |
||||
echo "## python coverage" >> $GITHUB_STEP_SUMMARY |
||||
python -m coverage report -m --format=markdown >> $GITHUB_STEP_SUMMARY |
@ -0,0 +1,88 @@ |
||||
SHELL := /bin/bash
|
||||
|
||||
PY_MODULE := slither
|
||||
TEST_MODULE := tests
|
||||
|
||||
ALL_PY_SRCS := $(shell find $(PY_MODULE) -name '*.py') \
|
||||
$(shell find test -name '*.py')
|
||||
|
||||
# Optionally overriden by the user, if they're using a virtual environment manager.
|
||||
VENV ?= env
|
||||
|
||||
# On Windows, venv scripts/shims are under `Scripts` instead of `bin`.
|
||||
VENV_BIN := $(VENV)/bin
|
||||
ifeq ($(OS),Windows_NT) |
||||
VENV_BIN := $(VENV)/Scripts
|
||||
endif |
||||
|
||||
# Optionally overridden by the user in the `release` target.
|
||||
BUMP_ARGS :=
|
||||
|
||||
# Optionally overridden by the user in the `test` target.
|
||||
TESTS :=
|
||||
|
||||
# Optionally overridden by the user/CI, to limit the installation to a specific
|
||||
# subset of development dependencies.
|
||||
SLITHER_EXTRA := dev
|
||||
|
||||
# If the user selects a specific test pattern to run, set `pytest` to fail fast
|
||||
# and only run tests that match the pattern.
|
||||
# Otherwise, run all tests and enable coverage assertions, since we expect
|
||||
# complete test coverage.
|
||||
ifneq ($(TESTS),) |
||||
TEST_ARGS := -x -k $(TESTS)
|
||||
COV_ARGS :=
|
||||
else |
||||
TEST_ARGS := -n auto
|
||||
COV_ARGS := # --fail-under 100
|
||||
endif |
||||
|
||||
.PHONY: all |
||||
all: |
||||
@echo "Run my targets individually!"
|
||||
|
||||
.PHONY: dev |
||||
dev: $(VENV)/pyvenv.cfg |
||||
|
||||
.PHONY: run |
||||
run: $(VENV)/pyvenv.cfg |
||||
@. $(VENV_BIN)/activate && slither $(ARGS)
|
||||
|
||||
$(VENV)/pyvenv.cfg: pyproject.toml |
||||
# Create our Python 3 virtual environment
|
||||
python3 -m venv env
|
||||
$(VENV_BIN)/python -m pip install --upgrade pip
|
||||
$(VENV_BIN)/python -m pip install -e .[$(SLITHER_EXTRA)]
|
||||
|
||||
.PHONY: lint |
||||
lint: $(VENV)/pyvenv.cfg |
||||
. $(VENV_BIN)/activate && \
|
||||
black --check . && \
|
||||
pylint $(PY_MODULE) $(TEST_MODULE)
|
||||
# ruff $(ALL_PY_SRCS) && \
|
||||
# mypy $(PY_MODULE) &&
|
||||
|
||||
.PHONY: reformat |
||||
reformat: |
||||
. $(VENV_BIN)/activate && \
|
||||
black .
|
||||
|
||||
.PHONY: test tests |
||||
test tests: $(VENV)/pyvenv.cfg |
||||
. $(VENV_BIN)/activate && \
|
||||
pytest --cov=$(PY_MODULE) $(T) $(TEST_ARGS) && \
|
||||
python -m coverage report -m $(COV_ARGS)
|
||||
|
||||
.PHONY: doc |
||||
doc: $(VENV)/pyvenv.cfg |
||||
. $(VENV_BIN)/activate && \
|
||||
PDOC_ALLOW_EXEC=1 pdoc -o html slither '!slither.tools'
|
||||
|
||||
.PHONY: package |
||||
package: $(VENV)/pyvenv.cfg |
||||
. $(VENV_BIN)/activate && \
|
||||
python3 -m build
|
||||
|
||||
.PHONY: edit |
||||
edit: |
||||
$(EDITOR) $(ALL_PY_SRCS)
|
@ -1,3 +1,9 @@ |
||||
contract A{ |
||||
pragma solidity 0.8.19; |
||||
|
||||
} |
||||
error RevertIt(); |
||||
|
||||
contract Example { |
||||
function reverts() external pure { |
||||
revert RevertIt(); |
||||
} |
||||
} |
@ -1,5 +1,16 @@ |
||||
import "./a.sol"; |
||||
|
||||
contract B is A{ |
||||
pragma solidity 0.8.19; |
||||
|
||||
enum B { |
||||
a, |
||||
b |
||||
} |
||||
|
||||
contract T { |
||||
Example e = new Example(); |
||||
function b() public returns(uint) { |
||||
B b = B.a; |
||||
return 4; |
||||
} |
||||
} |
@ -0,0 +1,95 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
### Test slither-interface |
||||
|
||||
DIR_TESTS="tests/tools/interface" |
||||
|
||||
solc-select use 0.8.19 --always-install |
||||
|
||||
#Test 1 - Etherscan target |
||||
slither-interface WETH9 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2 |
||||
DIFF=$(diff crytic-export/interfaces/IWETH9.sol "$DIR_TESTS/test_1.sol" --strip-trailing-cr) |
||||
if [ "$DIFF" != "" ] |
||||
then |
||||
echo "slither-interface test 1 failed" |
||||
cat "crytic-export/interfaces/IWETH9.sol" |
||||
echo "" |
||||
cat "$DIR_TESTS/test_1.sol" |
||||
exit 255 |
||||
fi |
||||
|
||||
|
||||
#Test 2 - Local file target |
||||
slither-interface Mock tests/tools/interface/ContractMock.sol |
||||
DIFF=$(diff crytic-export/interfaces/IMock.sol "$DIR_TESTS/test_2.sol" --strip-trailing-cr) |
||||
if [ "$DIFF" != "" ] |
||||
then |
||||
echo "slither-interface test 2 failed" |
||||
cat "crytic-export/interfaces/IMock.sol" |
||||
echo "" |
||||
cat "$DIR_TESTS/test_2.sol" |
||||
exit 255 |
||||
fi |
||||
|
||||
|
||||
#Test 3 - unroll structs |
||||
slither-interface Mock tests/tools/interface/ContractMock.sol --unroll-structs |
||||
DIFF=$(diff crytic-export/interfaces/IMock.sol "$DIR_TESTS/test_3.sol" --strip-trailing-cr) |
||||
if [ "$DIFF" != "" ] |
||||
then |
||||
echo "slither-interface test 3 failed" |
||||
cat "crytic-export/interfaces/IMock.sol" |
||||
echo "" |
||||
cat "$DIR_TESTS/test_3.sol" |
||||
exit 255 |
||||
fi |
||||
|
||||
#Test 4 - exclude structs |
||||
slither-interface Mock tests/tools/interface/ContractMock.sol --exclude-structs |
||||
DIFF=$(diff crytic-export/interfaces/IMock.sol "$DIR_TESTS/test_4.sol" --strip-trailing-cr) |
||||
if [ "$DIFF" != "" ] |
||||
then |
||||
echo "slither-interface test 4 failed" |
||||
cat "crytic-export/interfaces/IMock.sol" |
||||
echo "" |
||||
cat "$DIR_TESTS/test_4.sol" |
||||
exit 255 |
||||
fi |
||||
|
||||
#Test 5 - exclude errors |
||||
slither-interface Mock tests/tools/interface/ContractMock.sol --exclude-errors |
||||
DIFF=$(diff crytic-export/interfaces/IMock.sol "$DIR_TESTS/test_5.sol" --strip-trailing-cr) |
||||
if [ "$DIFF" != "" ] |
||||
then |
||||
echo "slither-interface test 5 failed" |
||||
cat "crytic-export/interfaces/IMock.sol" |
||||
echo "" |
||||
cat "$DIR_TESTS/test_5.sol" |
||||
exit 255 |
||||
fi |
||||
|
||||
#Test 6 - exclude enums |
||||
slither-interface Mock tests/tools/interface/ContractMock.sol --exclude-enums |
||||
DIFF=$(diff crytic-export/interfaces/IMock.sol "$DIR_TESTS/test_6.sol" --strip-trailing-cr) |
||||
if [ "$DIFF" != "" ] |
||||
then |
||||
echo "slither-interface test 6 failed" |
||||
cat "crytic-export/interfaces/IMock.sol" |
||||
echo "" |
||||
cat "$DIR_TESTS/test_6.sol" |
||||
exit 255 |
||||
fi |
||||
|
||||
#Test 7 - exclude events |
||||
slither-interface Mock tests/tools/interface/ContractMock.sol --exclude-events |
||||
DIFF=$(diff crytic-export/interfaces/IMock.sol "$DIR_TESTS/test_7.sol" --strip-trailing-cr) |
||||
if [ "$DIFF" != "" ] |
||||
then |
||||
echo "slither-interface test 7 failed" |
||||
cat "crytic-export/interfaces/IMock.sol" |
||||
echo "" |
||||
cat "$DIR_TESTS/test_7.sol" |
||||
exit 255 |
||||
fi |
||||
|
||||
rm -r crytic-export |
@ -1 +1,4 @@ |
||||
""" |
||||
.. include:: ../README.md |
||||
""" |
||||
from .slither import Slither |
||||
|
@ -1,19 +0,0 @@ |
||||
from typing import TYPE_CHECKING |
||||
|
||||
from slither.core.source_mapping.source_mapping import SourceMapping |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.declarations import Contract |
||||
|
||||
|
||||
class ChildContract(SourceMapping): |
||||
def __init__(self) -> None: |
||||
super().__init__() |
||||
self._contract = None |
||||
|
||||
def set_contract(self, contract: "Contract") -> None: |
||||
self._contract = contract |
||||
|
||||
@property |
||||
def contract(self) -> "Contract": |
||||
return self._contract |
@ -1,17 +0,0 @@ |
||||
from typing import TYPE_CHECKING |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.declarations import Event |
||||
|
||||
|
||||
class ChildEvent: |
||||
def __init__(self) -> None: |
||||
super().__init__() |
||||
self._event = None |
||||
|
||||
def set_event(self, event: "Event"): |
||||
self._event = event |
||||
|
||||
@property |
||||
def event(self) -> "Event": |
||||
return self._event |
@ -1,18 +0,0 @@ |
||||
from typing import TYPE_CHECKING, Union |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.expressions.expression import Expression |
||||
from slither.slithir.operations import Operation |
||||
|
||||
|
||||
class ChildExpression: |
||||
def __init__(self) -> None: |
||||
super().__init__() |
||||
self._expression = None |
||||
|
||||
def set_expression(self, expression: Union["Expression", "Operation"]) -> None: |
||||
self._expression = expression |
||||
|
||||
@property |
||||
def expression(self) -> Union["Expression", "Operation"]: |
||||
return self._expression |
@ -1,17 +0,0 @@ |
||||
from typing import TYPE_CHECKING |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.declarations import Function |
||||
|
||||
|
||||
class ChildFunction: |
||||
def __init__(self) -> None: |
||||
super().__init__() |
||||
self._function = None |
||||
|
||||
def set_function(self, function: "Function") -> None: |
||||
self._function = function |
||||
|
||||
@property |
||||
def function(self) -> "Function": |
||||
return self._function |
@ -1,17 +0,0 @@ |
||||
from typing import TYPE_CHECKING |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.declarations import Contract |
||||
|
||||
|
||||
class ChildInheritance: |
||||
def __init__(self) -> None: |
||||
super().__init__() |
||||
self._contract_declarer = None |
||||
|
||||
def set_contract_declarer(self, contract: "Contract") -> None: |
||||
self._contract_declarer = contract |
||||
|
||||
@property |
||||
def contract_declarer(self) -> "Contract": |
||||
return self._contract_declarer |
@ -1,31 +0,0 @@ |
||||
from typing import TYPE_CHECKING |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.compilation_unit import SlitherCompilationUnit |
||||
from slither.core.cfg.node import Node |
||||
from slither.core.declarations import Function, Contract |
||||
|
||||
|
||||
class ChildNode: |
||||
def __init__(self) -> None: |
||||
super().__init__() |
||||
self._node = None |
||||
|
||||
def set_node(self, node: "Node") -> None: |
||||
self._node = node |
||||
|
||||
@property |
||||
def node(self) -> "Node": |
||||
return self._node |
||||
|
||||
@property |
||||
def function(self) -> "Function": |
||||
return self.node.function |
||||
|
||||
@property |
||||
def contract(self) -> "Contract": |
||||
return self.node.function.contract |
||||
|
||||
@property |
||||
def compilation_unit(self) -> "SlitherCompilationUnit": |
||||
return self.node.compilation_unit |
@ -1,17 +0,0 @@ |
||||
from typing import TYPE_CHECKING |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.declarations import Structure |
||||
|
||||
|
||||
class ChildStructure: |
||||
def __init__(self) -> None: |
||||
super().__init__() |
||||
self._structure = None |
||||
|
||||
def set_structure(self, structure: "Structure") -> None: |
||||
self._structure = structure |
||||
|
||||
@property |
||||
def structure(self) -> "Structure": |
||||
return self._structure |
@ -0,0 +1,29 @@ |
||||
from typing import TYPE_CHECKING, Optional |
||||
|
||||
from slither.core.source_mapping.source_mapping import SourceMapping |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.declarations import Contract |
||||
|
||||
|
||||
class ContractLevel(SourceMapping): |
||||
""" |
||||
This class is used to represent objects that are at the contract level |
||||
The opposite is TopLevel |
||||
|
||||
""" |
||||
|
||||
def __init__(self) -> None: |
||||
super().__init__() |
||||
# TODO remove all the setters for the child objects |
||||
# And make it a constructor arguement |
||||
# This will remove the optional |
||||
self._contract: Optional["Contract"] = None |
||||
|
||||
def set_contract(self, contract: "Contract") -> None: |
||||
self._contract = contract |
||||
|
||||
@property |
||||
def contract(self) -> "Contract": |
||||
assert self._contract |
||||
return self._contract |
@ -1,20 +0,0 @@ |
||||
from typing import Optional, TYPE_CHECKING |
||||
|
||||
from slither.core.expressions.expression import Expression |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.solidity_types.type import Type |
||||
|
||||
|
||||
class ExpressionTyped(Expression): # pylint: disable=too-few-public-methods |
||||
def __init__(self) -> None: |
||||
super().__init__() |
||||
self._type: Optional["Type"] = None |
||||
|
||||
@property |
||||
def type(self) -> Optional["Type"]: |
||||
return self._type |
||||
|
||||
@type.setter |
||||
def type(self, new_type: "Type"): |
||||
self._type = new_type |
@ -1,32 +1,23 @@ |
||||
from typing import Union, TYPE_CHECKING |
||||
|
||||
from typing import TYPE_CHECKING |
||||
|
||||
from slither.core.expressions.expression import Expression |
||||
from slither.core.solidity_types.type import Type |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.solidity_types.elementary_type import ElementaryType |
||||
from slither.core.solidity_types.type_alias import TypeAliasTopLevel |
||||
from slither.core.solidity_types.array_type import ArrayType |
||||
|
||||
|
||||
class NewArray(Expression): |
||||
|
||||
# note: dont conserve the size of the array if provided |
||||
def __init__( |
||||
self, depth: int, array_type: Union["TypeAliasTopLevel", "ElementaryType"] |
||||
) -> None: |
||||
def __init__(self, array_type: "ArrayType") -> None: |
||||
super().__init__() |
||||
assert isinstance(array_type, Type) |
||||
self._depth: int = depth |
||||
self._array_type: Type = array_type |
||||
# pylint: disable=import-outside-toplevel |
||||
from slither.core.solidity_types.array_type import ArrayType |
||||
|
||||
@property |
||||
def array_type(self) -> Type: |
||||
return self._array_type |
||||
assert isinstance(array_type, ArrayType) |
||||
self._array_type = array_type |
||||
|
||||
@property |
||||
def depth(self) -> int: |
||||
return self._depth |
||||
def array_type(self) -> "ArrayType": |
||||
return self._array_type |
||||
|
||||
def __str__(self): |
||||
return "new " + str(self._array_type) + "[]" * self._depth |
||||
return "new " + str(self._array_type) |
||||
|
@ -1,6 +1,19 @@ |
||||
from typing import TYPE_CHECKING, Optional |
||||
from slither.core.variables.variable import Variable |
||||
from slither.core.children.child_structure import ChildStructure |
||||
|
||||
|
||||
class StructureVariable(ChildStructure, Variable): |
||||
pass |
||||
if TYPE_CHECKING: |
||||
from slither.core.declarations import Structure |
||||
|
||||
|
||||
class StructureVariable(Variable): |
||||
def __init__(self) -> None: |
||||
super().__init__() |
||||
self._structure: Optional["Structure"] = None |
||||
|
||||
def set_structure(self, structure: "Structure") -> None: |
||||
self._structure = structure |
||||
|
||||
@property |
||||
def structure(self) -> "Structure": |
||||
return self._structure |
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue