mirror of https://github.com/crytic/slither
commit
2bf85163dd
@ -0,0 +1,25 @@ |
||||
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json |
||||
language: "en" |
||||
early_access: false |
||||
knowledge_base: |
||||
learnings: |
||||
scope: auto |
||||
issues: |
||||
scope: global |
||||
reviews: |
||||
profile: "chill" |
||||
request_changes_workflow: false |
||||
high_level_summary: true |
||||
poem: false |
||||
review_status: true |
||||
collapse_walkthrough: true |
||||
auto_review: |
||||
enabled: true |
||||
ignore_title_keywords: |
||||
- "WIP" |
||||
- "DO NOT MERGE" |
||||
drafts: false |
||||
base_branches: |
||||
- dev |
||||
chat: |
||||
auto_reply: true |
@ -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]: " |
@ -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,31 @@ |
||||
# 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@v4 |
||||
with: |
||||
name: coverage-data-${{ steps.coverage-uuid.outputs.COVERAGE_UUID }} |
||||
path: | |
||||
.coverage.* |
||||
*.lcov |
||||
if-no-files-found: ignore |
||||
include-hidden-files: true |
@ -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 |
||||
status_code=$? |
||||
python -m coverage report |
||||
else |
||||
pytest tests/tools |
||||
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,48 +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 * * *' |
||||
|
||||
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@v2 |
||||
|
||||
- name: Set up Python 3.6 |
||||
uses: actions/setup-python@v3 |
||||
with: |
||||
python-version: 3.6 |
||||
|
||||
- name: Install dependencies |
||||
run: | |
||||
python setup.py install |
||||
pip install deepdiff |
||||
pip install pytest==7.0.1 |
||||
pip install typing_extensions==4.1.1 |
||||
pip install importlib_metadata==4.8.3 |
||||
|
||||
pip install "solc-select>=v1.0.0b1" |
||||
solc-select install all |
||||
solc-select use 0.8.11 |
||||
|
||||
- name: Test with pytest |
||||
run: | |
||||
pytest tests/test_ssa_generation.py |
@ -0,0 +1,43 @@ |
||||
--- |
||||
name: Run black (auto) |
||||
|
||||
defaults: |
||||
run: |
||||
# To load bashrc |
||||
shell: bash -ieo pipefail {0} |
||||
|
||||
on: |
||||
pull_request: |
||||
branches: [master, dev] |
||||
paths: |
||||
- "**/*.py" |
||||
|
||||
concurrency: |
||||
group: ${{ github.workflow }}-${{ github.ref }} |
||||
cancel-in-progress: true |
||||
|
||||
jobs: |
||||
build: |
||||
name: Black |
||||
runs-on: ubuntu-latest |
||||
|
||||
steps: |
||||
- name: Checkout Code |
||||
uses: actions/checkout@v4 |
||||
|
||||
- name: Set up Python 3.8 |
||||
uses: actions/setup-python@v5 |
||||
with: |
||||
python-version: 3.8 |
||||
|
||||
- name: Run black |
||||
uses: psf/black@stable |
||||
with: |
||||
options: "" |
||||
summary: false |
||||
version: "~= 22.3.0" |
||||
|
||||
- name: Annotate diff changes using reviewdog |
||||
uses: reviewdog/action-suggester@v1 |
||||
with: |
||||
tool_name: blackfmt |
@ -1,48 +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 * * *' |
||||
|
||||
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@v2 |
||||
|
||||
- name: Set up Python 3.6 |
||||
uses: actions/setup-python@v3 |
||||
with: |
||||
python-version: 3.6 |
||||
|
||||
- name: Install dependencies |
||||
run: | |
||||
|
||||
python setup.py install |
||||
pip install deepdiff |
||||
pip install pytest==7.0.1 |
||||
pip install typing_extensions==4.1.1 |
||||
pip install importlib_metadata==4.8.3 |
||||
|
||||
pip install "solc-select>=v1.0.0b1" |
||||
solc-select install all |
||||
solc-select use 0.7.3 |
||||
- name: Test with pytest |
||||
run: | |
||||
pytest tests/test_detectors.py |
@ -0,0 +1,60 @@ |
||||
name: Docker |
||||
|
||||
on: |
||||
push: |
||||
branches: |
||||
- master |
||||
- dev |
||||
tags: |
||||
- '*' |
||||
|
||||
concurrency: |
||||
group: ${{ github.workflow }}-${{ github.ref }} |
||||
cancel-in-progress: true |
||||
|
||||
jobs: |
||||
docker: |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- name: Checkout |
||||
uses: actions/checkout@v4 |
||||
|
||||
- name: Set up QEMU |
||||
uses: docker/setup-qemu-action@v3 |
||||
|
||||
- name: Set up Docker Buildx |
||||
uses: docker/setup-buildx-action@v3 |
||||
id: buildx |
||||
with: |
||||
install: true |
||||
|
||||
- name: Set Docker metadata |
||||
id: metadata |
||||
uses: docker/metadata-action@v5 |
||||
with: |
||||
images: | |
||||
ghcr.io/${{ github.repository }} |
||||
tags: | |
||||
type=ref,event=tag |
||||
type=ref,event=branch,prefix=testing- |
||||
type=edge |
||||
|
||||
- name: GitHub Container Registry Login |
||||
uses: docker/login-action@v3 |
||||
with: |
||||
registry: ghcr.io |
||||
username: ${{ github.actor }} |
||||
password: ${{ secrets.GITHUB_TOKEN }} |
||||
|
||||
- name: Docker Build and Push |
||||
uses: docker/build-push-action@v6 |
||||
with: |
||||
platforms: linux/amd64,linux/arm64/v8,linux/arm/v7 |
||||
target: final |
||||
file: Dockerfile |
||||
pull: true |
||||
push: true |
||||
tags: ${{ steps.metadata.outputs.tags }} |
||||
labels: ${{ steps.metadata.outputs.labels }} |
||||
cache-from: type=gha |
||||
cache-to: type=gha,mode=max |
@ -0,0 +1,46 @@ |
||||
name: docs |
||||
|
||||
on: |
||||
# Runs on pushes targeting the default branch |
||||
push: |
||||
branches: ["master"] |
||||
|
||||
# Allows you to run this workflow manually from the Actions tab |
||||
workflow_dispatch: |
||||
|
||||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
||||
permissions: |
||||
contents: read |
||||
pages: write |
||||
id-token: write |
||||
|
||||
# Allow one concurrent deployment |
||||
concurrency: |
||||
group: "pages" |
||||
cancel-in-progress: true |
||||
|
||||
jobs: |
||||
# Single deploy job since we're just deploying |
||||
build: |
||||
environment: |
||||
name: Slither Documentation |
||||
url: ${{ steps.deployment.outputs.page_url }} |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- name: Checkout |
||||
uses: actions/checkout@v4 |
||||
- name: Setup Pages |
||||
uses: actions/configure-pages@v5 |
||||
- uses: actions/setup-python@v5 |
||||
with: |
||||
python-version: '3.8' |
||||
- run: pip install -e ".[doc]" |
||||
- run: pdoc -o html/ slither '!slither.tools' #TODO fix import errors on pdoc run |
||||
- name: Upload artifact |
||||
uses: actions/upload-pages-artifact@v3 |
||||
with: |
||||
# Upload the doc |
||||
path: './html/' |
||||
- name: Deploy to GitHub Pages |
||||
id: deployment |
||||
uses: actions/deploy-pages@v4 |
@ -0,0 +1,91 @@ |
||||
--- |
||||
name: Doctor |
||||
|
||||
defaults: |
||||
run: |
||||
shell: bash |
||||
|
||||
on: |
||||
workflow_dispatch: |
||||
pull_request: |
||||
paths: |
||||
- 'slither/tools/doctor/**' |
||||
- '.github/workflows/doctor.yml' |
||||
|
||||
concurrency: |
||||
group: ${{ github.workflow }}-${{ github.ref }} |
||||
cancel-in-progress: true |
||||
|
||||
jobs: |
||||
slither-doctor: |
||||
runs-on: ${{ matrix.os }} |
||||
strategy: |
||||
fail-fast: false |
||||
matrix: |
||||
os: ["ubuntu-latest", "windows-2022"] |
||||
python: ["3.8", "3.9", "3.10", "3.11", "3.12"] |
||||
exclude: |
||||
# strange failure |
||||
- os: windows-2022 |
||||
python: 3.8 |
||||
steps: |
||||
- uses: actions/checkout@v4 |
||||
|
||||
- name: Set up Python ${{ matrix.python }} |
||||
uses: actions/setup-python@v5 |
||||
with: |
||||
python-version: ${{ matrix.python }} |
||||
|
||||
- name: Try system-wide Slither |
||||
run: | |
||||
echo "::group::Install slither" |
||||
pip3 install . |
||||
echo "::endgroup::" |
||||
|
||||
# escape cwd so python doesn't pick up local module |
||||
cd / |
||||
|
||||
echo "::group::Via module" |
||||
python3 -m slither.tools.doctor . |
||||
echo "::endgroup::" |
||||
|
||||
echo "::group::Via binary" |
||||
slither-doctor . |
||||
echo "::endgroup::" |
||||
|
||||
- name: Try user Slither |
||||
run: | |
||||
echo "::group::Install slither" |
||||
pip3 install --user . |
||||
echo "::endgroup::" |
||||
|
||||
# escape cwd so python doesn't pick up local module |
||||
cd / |
||||
|
||||
echo "::group::Via module" |
||||
python3 -m slither.tools.doctor . |
||||
echo "::endgroup::" |
||||
|
||||
echo "::group::Via binary" |
||||
slither-doctor . |
||||
echo "::endgroup::" |
||||
|
||||
- name: Try venv Slither |
||||
run: | |
||||
echo "::group::Install slither" |
||||
python3 -m venv venv |
||||
source venv/bin/activate || source venv/Scripts/activate |
||||
hash -r |
||||
pip3 install . |
||||
echo "::endgroup::" |
||||
|
||||
# escape cwd so python doesn't pick up local module |
||||
cd / |
||||
|
||||
echo "::group::Via module" |
||||
python3 -m slither.tools.doctor . |
||||
echo "::endgroup::" |
||||
|
||||
echo "::group::Via binary" |
||||
slither-doctor . |
||||
echo "::endgroup::" |
@ -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 * * *' |
||||
|
||||
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@v2 |
||||
|
||||
- name: Set up Python 3.6 |
||||
uses: actions/setup-python@v3 |
||||
with: |
||||
python-version: 3.6 |
||||
|
||||
- name: Install dependencies |
||||
run: | |
||||
|
||||
python setup.py install |
||||
pip install deepdiff |
||||
pip install pytest==7.0.1 |
||||
pip install typing_extensions==4.1.1 |
||||
pip install importlib_metadata==4.8.3 |
||||
|
||||
pip install "solc-select>=v1.0.0b1" |
||||
solc-select install all |
||||
solc-select use 0.8.0 |
||||
|
||||
cd tests/test_node_modules/ |
||||
npm install hardhat |
||||
cd ../.. |
||||
|
||||
- name: Test with pytest |
||||
run: | |
||||
pytest tests/test_features.py |
||||
pytest tests/test_constant_folding_unary.py |
||||
pytest tests/slithir/test_ternary_expressions.py |
@ -0,0 +1,40 @@ |
||||
name: Monthly issue metrics |
||||
on: |
||||
workflow_dispatch: |
||||
schedule: |
||||
- cron: '3 2 1 * *' |
||||
|
||||
permissions: |
||||
issues: write |
||||
pull-requests: read |
||||
|
||||
jobs: |
||||
build: |
||||
name: issue metrics |
||||
runs-on: ubuntu-latest |
||||
steps: |
||||
- name: Get dates for last month |
||||
shell: bash |
||||
run: | |
||||
# Calculate the first day of the previous month |
||||
first_day=$(date -d "last month" +%Y-%m-01) |
||||
|
||||
# Calculate the last day of the previous month |
||||
last_day=$(date -d "$first_day +1 month -1 day" +%Y-%m-%d) |
||||
|
||||
#Set an environment variable with the date range |
||||
echo "$first_day..$last_day" |
||||
echo "last_month=$first_day..$last_day" >> "$GITHUB_ENV" |
||||
|
||||
- name: Run issue-metrics tool |
||||
uses: github/issue-metrics@v3 |
||||
env: |
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
||||
SEARCH_QUERY: 'repo:crytic/slither is:issue created:${{ env.last_month }} -reason:"not planned" -reason:"duplicate"' |
||||
|
||||
- name: Create issue |
||||
uses: peter-evans/create-issue-from-file@v5 |
||||
with: |
||||
title: Monthly issue metrics report |
||||
token: ${{ secrets.GITHUB_TOKEN }} |
||||
content-filepath: ./issue_metrics.md |
@ -0,0 +1,32 @@ |
||||
{ |
||||
"problemMatcher": [ |
||||
{ |
||||
"owner": "pylint-error", |
||||
"severity": "error", |
||||
"pattern": [ |
||||
{ |
||||
"regexp": "^(.+):(\\d+):(\\d+):\\s(([EF]\\d{4}):\\s.+)$", |
||||
"file": 1, |
||||
"line": 2, |
||||
"column": 3, |
||||
"message": 4, |
||||
"code": 5 |
||||
} |
||||
] |
||||
}, |
||||
{ |
||||
"owner": "pylint-warning", |
||||
"severity": "warning", |
||||
"pattern": [ |
||||
{ |
||||
"regexp": "^(.+):(\\d+):(\\d+):\\s(([CRW]\\d{4}):\\s.+)$", |
||||
"file": 1, |
||||
"line": 2, |
||||
"column": 3, |
||||
"message": 4, |
||||
"code": 5 |
||||
} |
||||
] |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,22 @@ |
||||
{ |
||||
"problemMatcher": [ |
||||
{ |
||||
"owner": "yamllint", |
||||
"pattern": [ |
||||
{ |
||||
"regexp": "^(.*\\.ya?ml)$", |
||||
"file": 1 |
||||
}, |
||||
{ |
||||
"regexp": "^\\s{2}(\\d+):(\\d+)\\s+(error|warning)\\s+(.*?)\\s+\\((.*)\\)$", |
||||
"line": 1, |
||||
"column": 2, |
||||
"severity": 3, |
||||
"message": 4, |
||||
"code": 5, |
||||
"loop": true |
||||
} |
||||
] |
||||
} |
||||
] |
||||
} |
@ -1,51 +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 * * *' |
||||
|
||||
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@v2 |
||||
|
||||
- name: Set up Python 3.6 |
||||
uses: actions/setup-python@v3 |
||||
with: |
||||
python-version: 3.6 |
||||
|
||||
- name: Install dependencies |
||||
run: | |
||||
|
||||
python setup.py install |
||||
pip install deepdiff |
||||
pip install pytest==7.0.1 |
||||
pip install typing_extensions==4.1.1 |
||||
pip install importlib_metadata==4.8.3 |
||||
pip install "solc-select>=v1.0.0b1" |
||||
|
||||
- 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 |
@ -0,0 +1,53 @@ |
||||
name: Publish to PyPI |
||||
|
||||
on: |
||||
release: |
||||
types: [published] |
||||
|
||||
jobs: |
||||
build-release: |
||||
|
||||
runs-on: ubuntu-latest |
||||
|
||||
steps: |
||||
- uses: actions/checkout@v4 |
||||
|
||||
- name: Set up Python |
||||
uses: actions/setup-python@v5 |
||||
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@v4 |
||||
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@v4 |
||||
with: |
||||
name: slither-dists |
||||
path: dist/ |
||||
|
||||
- name: publish |
||||
uses: pypa/gh-action-pypi-publish@v1.10.3 |
||||
|
||||
- name: sign |
||||
uses: sigstore/gh-action-sigstore-python@v3.0.0 |
||||
with: |
||||
inputs: ./dist/*.tar.gz ./dist/*.whl |
||||
release-signing-artifacts: true |
@ -1,53 +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 * * *' |
||||
|
||||
jobs: |
||||
build: |
||||
name: Test slither-read-storage |
||||
runs-on: ubuntu-latest |
||||
|
||||
steps: |
||||
- uses: actions/checkout@v2 |
||||
- 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.6 |
||||
uses: actions/setup-python@v2 |
||||
with: |
||||
python-version: 3.6 |
||||
|
||||
- name: Install python dependencies |
||||
run: | |
||||
python3 setup.py install |
||||
pip install web3 pytest deepdiff solc-select |
||||
pip install pytest==7.0.1 |
||||
pip install typing_extensions==4.1.1 |
||||
pip install importlib_metadata==4.8.3 |
||||
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,123 @@ |
||||
--- |
||||
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"] |
||||
python: ${{ (github.event_name == 'pull_request' && fromJSON('["3.8", "3.12"]')) || fromJSON('["3.8", "3.9", "3.10", "3.11", "3.12"]') }} |
||||
steps: |
||||
- uses: actions/checkout@v4 |
||||
- name: Set up Python ${{ matrix.python }} |
||||
uses: actions/setup-python@v5 |
||||
with: |
||||
python-version: ${{ matrix.python }} |
||||
cache: "pip" |
||||
cache-dependency-path: setup.py |
||||
|
||||
- name: Install dependencies |
||||
run: | |
||||
pip install ".[test]" |
||||
|
||||
- name: Setup node |
||||
uses: actions/setup-node@v4 |
||||
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: Install Vyper |
||||
run: | |
||||
INSTALLDIR="$RUNNER_TEMP/vyper-install" |
||||
if [[ "$RUNNER_OS" = "Windows" ]]; then |
||||
URL="https://github.com/vyperlang/vyper/releases/download/v0.3.7/vyper.0.3.7+commit.6020b8bb.windows.exe" |
||||
FILENAME="vyper.exe" |
||||
elif [[ "$RUNNER_OS" = "Linux" ]]; then |
||||
URL="https://github.com/vyperlang/vyper/releases/download/v0.3.7/vyper.0.3.7+commit.6020b8bb.linux" |
||||
FILENAME="vyper" |
||||
else |
||||
echo "Unknown OS" |
||||
exit 1 |
||||
fi |
||||
mkdir -p "$INSTALLDIR" |
||||
curl "$URL" -o "$INSTALLDIR/$FILENAME" -L |
||||
chmod 755 "$INSTALLDIR/$FILENAME" |
||||
echo "$INSTALLDIR" >> "$GITHUB_PATH" |
||||
- 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' && matrix.python == '3.8' }} |
||||
|
||||
coverage: |
||||
needs: |
||||
- tests |
||||
|
||||
runs-on: ubuntu-latest |
||||
|
||||
steps: |
||||
- uses: actions/checkout@v4 |
||||
- name: Set up Python 3.8 |
||||
uses: actions/setup-python@v5 |
||||
with: |
||||
python-version: 3.8 |
||||
|
||||
- run: pip install coverage[toml] |
||||
|
||||
- name: download coverage data |
||||
uses: actions/download-artifact@v4 |
||||
with: |
||||
pattern: coverage-data-* |
||||
merge-multiple: true |
||||
|
||||
- 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,9 @@ |
||||
- id: slither |
||||
name: Slither |
||||
description: Run Slither on your project |
||||
entry: slither |
||||
args: |
||||
- . |
||||
pass_filenames: false |
||||
language: python |
||||
files: \.sol$ |
@ -0,0 +1,64 @@ |
||||
cff-version: 1.2.0 |
||||
title: Slither Analyzer |
||||
message: >- |
||||
If you use this software, please cite it using the |
||||
metadata from this file. |
||||
type: software |
||||
authors: |
||||
- given-names: Josselin |
||||
family-names: Feist |
||||
- given-names: Gustavo |
||||
family-names: Grieco |
||||
- given-names: Alex |
||||
family-names: Groce |
||||
identifiers: |
||||
- type: doi |
||||
value: 10.48550/arXiv.1908.09878 |
||||
description: arXiv.1908.09878 |
||||
- type: url |
||||
value: 'https://arxiv.org/abs/1908.09878' |
||||
description: arxiv |
||||
- type: doi |
||||
value: 10.1109/wetseb.2019.00008 |
||||
repository-code: 'https://github.com/crytic/slither' |
||||
url: 'https://www.trailofbits.com/' |
||||
repository-artifact: 'https://github.com/crytic/slither/releases' |
||||
abstract: >- |
||||
Slither is a static analysis framework designed to provide |
||||
rich information about Ethereum smart contracts. |
||||
|
||||
It works by converting Solidity smart contracts into an |
||||
intermediate representation called SlithIR. |
||||
|
||||
SlithIR uses Static Single Assignment (SSA) form and a |
||||
reduced instruction set to ease implementation of analyses |
||||
while preserving semantic information that would be lost |
||||
in transforming Solidity to bytecode. |
||||
|
||||
Slither allows for the application of commonly used |
||||
program analysis techniques like dataflow and taint |
||||
tracking. |
||||
|
||||
|
||||
Our framework has four main use cases: |
||||
|
||||
(1) automated detection of vulnerabilities, |
||||
|
||||
(2) automated detection of code optimization |
||||
opportunities, |
||||
|
||||
(3) improvement of the user's understanding of the |
||||
contracts, and |
||||
|
||||
(4) assistance with code review. |
||||
keywords: |
||||
- Ethereum |
||||
- Static Analysis |
||||
- Smart contracts |
||||
- EVM |
||||
- bug detection |
||||
- Software Engineering |
||||
license: AGPL-3.0-only |
||||
commit: 3d4f934d3228f072b7df2c5e7252c64df4601bc8 |
||||
version: 0.9.5 |
||||
date-released: '2023-06-28' |
@ -0,0 +1,5 @@ |
||||
* @montyly @smonicas |
||||
/slither/tools/doctor/ @elopez |
||||
/slither/slithir/ @montyly |
||||
/slither/analyses/ @montyly |
||||
/.github/workflows/ @elopez |
@ -0,0 +1,12 @@ |
||||
{ |
||||
"Optimism": { |
||||
"op-mainnet": { |
||||
"ownedBy": "0xc44F30Be3eBBEfdDBB5a85168710b4f0e18f4Ff0" |
||||
} |
||||
}, |
||||
"drips": { |
||||
"ethereum": { |
||||
"ownedBy": "0xc44F30Be3eBBEfdDBB5a85168710b4f0e18f4Ff0" |
||||
} |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
@ -1,8 +1,13 @@ |
||||
from typing import Tuple, List, Type |
||||
|
||||
from slither_my_plugin.detectors.example import Example |
||||
|
||||
from slither.detectors.abstract_detector import AbstractDetector |
||||
from slither.printers.abstract_printer import AbstractPrinter |
||||
|
||||
|
||||
def make_plugin(): |
||||
def make_plugin() -> Tuple[List[Type[AbstractDetector]], List[Type[AbstractPrinter]]]: |
||||
plugin_detectors = [Example] |
||||
plugin_printers = [] |
||||
plugin_printers: List[Type[AbstractPrinter]] = [] |
||||
|
||||
return plugin_detectors, plugin_printers |
||||
|
@ -1,86 +0,0 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
### Test Detectors |
||||
|
||||
DIR="$(cd "$(dirname "$0")" && pwd)" |
||||
|
||||
CURRENT_PATH=$(pwd) |
||||
TRAVIS_PATH='/home/travis/build/crytic/slither' |
||||
|
||||
# test_slither file.sol detectors |
||||
test_slither(){ |
||||
|
||||
expected="$DIR/../tests/expected_json/$(basename "$1" .sol).$2.json" |
||||
|
||||
# run slither detector on input file and save output as json |
||||
slither "$1" --solc-disable-warnings --detect "$2" --json "$DIR/tmp-test.json" |
||||
if [ $? -eq 255 ] |
||||
then |
||||
echo "Slither crashed" |
||||
exit 255 |
||||
fi |
||||
|
||||
if [ ! -f "$DIR/tmp-test.json" ]; then |
||||
echo "" |
||||
echo "Missing generated file" |
||||
echo "" |
||||
exit 1 |
||||
fi |
||||
sed "s|$CURRENT_PATH|$TRAVIS_PATH|g" "$DIR/tmp-test.json" -i |
||||
result=$(python "$DIR/json_diff.py" "$expected" "$DIR/tmp-test.json") |
||||
|
||||
rm "$DIR/tmp-test.json" |
||||
if [ "$result" != "{}" ]; then |
||||
echo "" |
||||
echo "failed test of file: $1, detector: $2" |
||||
echo "" |
||||
echo "$result" |
||||
echo "" |
||||
exit 1 |
||||
fi |
||||
|
||||
# run slither detector on input file and save output as json |
||||
slither "$1" --solc-disable-warnings --detect "$2" --legacy-ast --json "$DIR/tmp-test.json" |
||||
if [ $? -eq 255 ] |
||||
then |
||||
echo "Slither crashed" |
||||
exit 255 |
||||
fi |
||||
|
||||
if [ ! -f "$DIR/tmp-test.json" ]; then |
||||
echo "" |
||||
echo "Missing generated file" |
||||
echo "" |
||||
exit 1 |
||||
fi |
||||
|
||||
sed "s|$CURRENT_PATH|$TRAVIS_PATH|g" "$DIR/tmp-test.json" -i |
||||
result=$(python "$DIR/json_diff.py" "$expected" "$DIR/tmp-test.json") |
||||
|
||||
rm "$DIR/tmp-test.json" |
||||
if [ "$result" != "{}" ]; then |
||||
echo "" |
||||
echo "failed test of file: $1, detector: $2" |
||||
echo "" |
||||
echo "$result" |
||||
echo "" |
||||
exit 1 |
||||
fi |
||||
} |
||||
|
||||
# generate_expected_json file.sol detectors |
||||
generate_expected_json(){ |
||||
# generate output filename |
||||
# e.g. file: uninitialized.sol detector: uninitialized-state |
||||
# ---> uninitialized.uninitialized-state.json |
||||
output_filename="$DIR/../tests/expected_json/$(basename "$1" .sol).$2.json" |
||||
output_filename_txt="$DIR/../tests/expected_json/$(basename "$1" .sol).$2.txt" |
||||
|
||||
# run slither detector on input file and save output as json |
||||
slither "$1" --solc-disable-warnings --detect "$2" --json "$output_filename" > "$output_filename_txt" 2>&1 |
||||
|
||||
|
||||
sed "s|$CURRENT_PATH|$TRAVIS_PATH|g" "$output_filename" -i |
||||
sed "s|$CURRENT_PATH|$TRAVIS_PATH|g" "$output_filename_txt" -i |
||||
} |
||||
|
@ -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 |
@ -0,0 +1,15 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
### Test path filtering across POSIX and Windows |
||||
|
||||
solc-select use 0.8.0 |
||||
slither "tests/e2e/config/test_path_filtering/test_path_filtering.sol" --config "tests/e2e/config/test_path_filtering/slither.config.json" > "output.txt" 2>&1 |
||||
|
||||
if ! grep -q "0 result(s) found" "output.txt" |
||||
then |
||||
echo "Path filtering across POSIX and Windows failed" |
||||
rm output.txt |
||||
exit 5 |
||||
else |
||||
rm output.txt |
||||
fi |
@ -1,27 +0,0 @@ |
||||
import sys |
||||
import json |
||||
from pprint import pprint |
||||
from deepdiff import DeepDiff # pip install deepdiff |
||||
|
||||
|
||||
if len(sys.argv) != 3: |
||||
print("Usage: python json_diff.py 1.json 2.json") |
||||
sys.exit(-1) |
||||
|
||||
with open(sys.argv[1], encoding="utf8") as f: |
||||
d1 = json.load(f) |
||||
|
||||
with open(sys.argv[2], encoding="utf8") as f: |
||||
d2 = json.load(f) |
||||
|
||||
|
||||
# Remove description field to allow non deterministic print |
||||
for elem in d1: |
||||
if "description" in elem: |
||||
del elem["description"] |
||||
for elem in d2: |
||||
if "description" in elem: |
||||
del elem["description"] |
||||
|
||||
|
||||
pprint(DeepDiff(d1, d2, ignore_order=True, verbose_level=2)) |
@ -0,0 +1,28 @@ |
||||
import json |
||||
from pathlib import Path |
||||
import urllib.request |
||||
|
||||
|
||||
def retrieve_json(url): |
||||
with urllib.request.urlopen(url) as response: |
||||
data = response.read().decode("utf-8") |
||||
return json.loads(data) |
||||
|
||||
|
||||
def organize_data(json_data): |
||||
version_bugs = {} |
||||
for version, info in json_data.items(): |
||||
version_bugs[version] = info["bugs"] |
||||
return version_bugs |
||||
|
||||
|
||||
if __name__ == "__main__": |
||||
bug_list_url = ( |
||||
"https://raw.githubusercontent.com/ethereum/solidity/develop/docs/bugs_by_version.json" |
||||
) |
||||
bug_data = retrieve_json(bug_list_url) |
||||
bugs_by_version = organize_data(bug_data) |
||||
|
||||
with open(Path.cwd() / Path("slither/utils/buggy_versions.py"), "w", encoding="utf-8") as file: |
||||
file.write("# pylint: disable=too-many-lines\n") |
||||
file.write(f"bugs_by_version = {bugs_by_version}") |
@ -1 +1,4 @@ |
||||
""" |
||||
.. include:: ../README.md |
||||
""" |
||||
from .slither import Slither |
||||
|
@ -1,17 +0,0 @@ |
||||
from typing import TYPE_CHECKING |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.declarations import Contract |
||||
|
||||
|
||||
class ChildContract: |
||||
def __init__(self): |
||||
super().__init__() |
||||
self._contract = None |
||||
|
||||
def set_contract(self, contract: "Contract"): |
||||
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): |
||||
super().__init__() |
||||
self._event = None |
||||
|
||||
def set_event(self, event: "Event"): |
||||
self._event = event |
||||
|
||||
@property |
||||
def event(self) -> "Event": |
||||
return self._event |
@ -1,17 +0,0 @@ |
||||
from typing import TYPE_CHECKING |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.expressions.expression import Expression |
||||
|
||||
|
||||
class ChildExpression: |
||||
def __init__(self): |
||||
super().__init__() |
||||
self._expression = None |
||||
|
||||
def set_expression(self, expression: "Expression"): |
||||
self._expression = expression |
||||
|
||||
@property |
||||
def expression(self) -> "Expression": |
||||
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): |
||||
super().__init__() |
||||
self._function = None |
||||
|
||||
def set_function(self, function: "Function"): |
||||
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): |
||||
super().__init__() |
||||
self._contract_declarer = None |
||||
|
||||
def set_contract_declarer(self, contract: "Contract"): |
||||
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): |
||||
super().__init__() |
||||
self._node = None |
||||
|
||||
def set_node(self, node: "Node"): |
||||
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.contract.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): |
||||
super().__init__() |
||||
self._structure = None |
||||
|
||||
def set_structure(self, structure: "Structure"): |
||||
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,12 +1,22 @@ |
||||
from slither.core.children.child_contract import ChildContract |
||||
from typing import TYPE_CHECKING |
||||
from slither.core.declarations.contract_level import ContractLevel |
||||
|
||||
|
||||
from slither.core.declarations.custom_error import CustomError |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.declarations import Contract |
||||
|
||||
class CustomErrorContract(CustomError, ChildContract): |
||||
def is_declared_by(self, contract): |
||||
|
||||
class CustomErrorContract(CustomError, ContractLevel): |
||||
def is_declared_by(self, contract: "Contract") -> bool: |
||||
""" |
||||
Check if the element is declared by the contract |
||||
:param contract: |
||||
:return: |
||||
""" |
||||
return self.contract == contract |
||||
|
||||
@property |
||||
def canonical_name(self) -> str: |
||||
return self.contract.name + "." + self.full_name |
||||
|
@ -0,0 +1,25 @@ |
||||
from typing import TYPE_CHECKING |
||||
|
||||
from slither.core.declarations.contract_level import ContractLevel |
||||
from slither.core.declarations import Event |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.declarations import Contract |
||||
|
||||
|
||||
class EventContract(Event, ContractLevel): |
||||
def is_declared_by(self, contract: "Contract") -> bool: |
||||
""" |
||||
Check if the element is declared by the contract |
||||
:param contract: |
||||
:return: |
||||
""" |
||||
return self.contract == contract |
||||
|
||||
@property |
||||
def canonical_name(self) -> str: |
||||
"""Return the function signature as a str |
||||
Returns: |
||||
str: contract.func_name(type1,type2) |
||||
""" |
||||
return self.contract.name + "." + self.full_name |
@ -0,0 +1,13 @@ |
||||
from typing import TYPE_CHECKING |
||||
|
||||
from slither.core.declarations import Event |
||||
from slither.core.declarations.top_level import TopLevel |
||||
|
||||
if TYPE_CHECKING: |
||||
from slither.core.scope.scope import FileScope |
||||
|
||||
|
||||
class EventTopLevel(Event, TopLevel): |
||||
def __init__(self, scope: "FileScope") -> None: |
||||
super().__init__() |
||||
self.file_scope: "FileScope" = scope |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue