Skip to content

Commit

Permalink
Merge pull request #1 from pcaversaccio/dev
Browse files Browse the repository at this point in the history
Merge `dev` into `patch-1`
  • Loading branch information
pcaversaccio authored Sep 26, 2022
2 parents 1c1b471 + 719e4e9 commit 94159fa
Show file tree
Hide file tree
Showing 609 changed files with 14,178 additions and 6,360 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/IR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,14 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v2

- name: Set up Python 3.6
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: 3.6
python-version: 3.8

- 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"
pip install ".[dev]"
solc-select install all
solc-select use 0.8.11
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v2

- name: Set up Python 3.6
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: 3.6
python-version: 3.8

- name: Install dependencies
run: |
pip install .
pip install deepdiff numpy
mkdir -p .github/linters
cp pyproject.toml .github/linters
Expand Down
13 changes: 2 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
"path_filtering",
# "embark",
"erc",
"etherlime",
# "etherlime",
# "etherscan"
"find_paths",
"flat",
Expand All @@ -44,26 +44,17 @@ jobs:
- os: windows-2022
type: dapp
# Requires nvm
- os: windows-2022
type: etherlime
# Requires nvm
- os: windows-2022
type: truffle
steps:
- uses: actions/checkout@v1

- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: 3.8
- name: Install dependencies
run: |
python setup.py install
# Used by ci_test.sh
pip install deepdiff
pip install "solc-select>=v1.0.0b1"
pip install ".[dev]"
solc-select install all
solc-select use 0.5.1
pip install typing_extensions==4.1.1
Expand Down
12 changes: 3 additions & 9 deletions .github/workflows/detectors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,15 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v2

- name: Set up Python 3.6
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: 3.6
python-version: 3.8

- name: Install dependencies
run: |
pip install ".[dev]"
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
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Docker

on:
push:
branches:
- master
- dev
tags:
- '*'

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
id: buildx
with:
install: true

- name: Set Docker metadata
id: metadata
uses: docker/metadata-action@v4
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@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker Build and Push
uses: docker/build-push-action@v3
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
15 changes: 6 additions & 9 deletions .github/workflows/features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,15 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v2

- name: Set up Python 3.6
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: 3.6
python-version: 3.8

- name: Install dependencies
run: |
pip install ".[dev]"
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
Expand All @@ -53,3 +47,6 @@ jobs:
pytest tests/test_features.py
pytest tests/test_constant_folding_unary.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
7 changes: 2 additions & 5 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v2

- name: Set up Python 3.6
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: 3.6
python-version: 3.8

- name: Install dependencies
run: |
pip install .
pip install deepdiff numpy
mkdir -p .github/linters
cp pyproject.toml .github/linters
Expand Down
12 changes: 3 additions & 9 deletions .github/workflows/parser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,14 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v2

- name: Set up Python 3.6
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: 3.6
python-version: 3.8

- 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"
pip install ".[dev]"
- name: Install solc
run: |
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,13 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v2

- name: Set up Python 3.6
- name: Set up Python 3.8
uses: actions/setup-python@v3
with:
python-version: 3.6
python-version: 3.8

- name: Install dependencies
run: |
pip install .
pip install deepdiff numpy
mkdir -p .github/linters
cp pyproject.toml .github/linters
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/read_storage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,15 @@ jobs:
- name: Install ganache
run: npm install --global ganache

- name: Set up Python 3.6
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.6
python-version: 3.8

- 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
pip install ".[dev]"
pip install web3
solc-select install 0.8.1
solc-select install 0.8.10
solc-select use 0.8.1
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,6 @@ ENV/

# Test results
test_artifacts/

# crytic export
crytic-export/
5 changes: 1 addition & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ A code walkthrough is available [here](https://www.youtube.com/watch?v=EUl3UlYSl
## Development Environment
Instructions for installing a development version of Slither can be found in our [wiki](https://github.com/crytic/slither/wiki/Developer-installation).

To run the unit tests, you need
- `deepdiff` installed (`pip install deepdiff`).
- `pycov` installed (`pip install pytest-cov`).
- [`solc-select`](https://github.com/crytic/solc-select) installed.
To run the unit tests, you need to clone this repository and run `pip install ".[dev]"`.

### Linters

Expand Down
36 changes: 25 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
FROM ubuntu:focal
# syntax=docker/dockerfile:1.3
FROM ubuntu:jammy AS python-wheels
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
gcc \
python3-dev \
python3-pip \
&& rm -rf /var/lib/apt/lists/*

COPY . /slither

RUN cd /slither && \
echo pip3 install --no-cache-dir --upgrade pip && \
pip3 wheel -w /wheels . solc-select pip setuptools wheel


FROM ubuntu:jammy AS final

LABEL name=slither
LABEL src="https://github.com/trailofbits/slither"
Expand All @@ -8,22 +23,21 @@ LABEL desc="Static Analyzer for Solidity"

RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get upgrade -yq \
&& apt-get install -yq gcc git python3 python3-dev python3-setuptools wget software-properties-common

RUN wget -q https://github.com/ethereum/solidity/releases/download/v0.4.25/solc-static-linux \
&& chmod +x solc-static-linux \
&& mv solc-static-linux /usr/bin/solc
&& apt-get install -y --no-install-recommends python3-pip \
&& rm -rf /var/lib/apt/lists/*

RUN useradd -m slither
USER slither

# If this fails, the solc-static-linux binary has changed while it should not.
RUN [ "c9b268750506b88fe71371100050e9dd1e7edcf8f69da34d1cd09557ecb24580 /usr/bin/solc" = "$(sha256sum /usr/bin/solc)" ]

COPY --chown=slither:slither . /home/slither/slither
WORKDIR /home/slither/slither

RUN python3 setup.py install --user
ENV PATH="/home/slither/.local/bin:${PATH}"

# no-index ensures we install the freshly-built wheels
RUN --mount=type=bind,target=/mnt,source=/wheels,from=python-wheels \
pip3 install --user --no-cache-dir --upgrade --no-index --find-links /mnt pip slither-analyzer solc-select

RUN solc-select install 0.4.25 && solc-select use 0.4.25

CMD /bin/bash
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ See the [Tool documentation](https://github.com/crytic/slither/wiki/Tool-Documen

## How to install

Slither requires Python 3.6+ and [solc](https://github.com/ethereum/solidity/), the Solidity compiler.
Slither requires Python 3.8+ and [solc](https://github.com/ethereum/solidity/), the Solidity compiler.

### Using Pip

Expand Down
3 changes: 3 additions & 0 deletions examples/scripts/taint_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@


def visit_node(node, visited):
if node is None:
return

if node in visited:
return

Expand Down
2 changes: 1 addition & 1 deletion plugin_example/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
author="Trail of Bits",
version="0.0",
packages=find_packages(),
python_requires=">=3.6",
python_requires=">=3.8",
install_requires=["slither-analyzer==0.1"],
entry_points={
"slither_analyzer.plugin": "slither my-plugin=slither_my_plugin:make_plugin",
Expand Down
6 changes: 2 additions & 4 deletions scripts/ci_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ 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 ]
if ! slither "$1" --solc-disable-warnings --detect "$2" --json "$DIR/tmp-test.json";
then
echo "Slither crashed"
exit 255
Expand All @@ -40,8 +39,7 @@ test_slither(){
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 ]
if ! slither "$1" --solc-disable-warnings --detect "$2" --legacy-ast --json "$DIR/tmp-test.json";
then
echo "Slither crashed"
exit 255
Expand Down
Loading

0 comments on commit 94159fa

Please sign in to comment.