Closed nathandem closed 1 year ago
Hi @nathandem! Thanks for the report. Here are few questions to try and narrow the issue down:
slither --version
). If you have an older version locally and that one works, it could indicate there's a regression in the latest release.name: Slither Analysis
on:
push:
branches:
- main
pull_request:
jobs:
analyze:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
env:
NODOCKER: 1
steps:
- uses: actions/checkout@v3
- name: Run Slither
uses: crytic/slither-action@v0.2.0
id: slither
with:
node-version: 16
slither-config: slither.config.json
We are using slither 0.9.1 both in CI and locally. We use both foundry and hardhat in our project. When we let slither compile, it fails when it tries to install the dependencies from the foundry.toml:
yarn install v1.22.19
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
[4/5] Linking dependencies...
warning " > @matterlabs/hardhat-zksync-solc@0.3.11-beta.1" has incorrect peer dependency "hardhat@^2.12.1".
warning " > @nomiclabs/hardhat-waffle@2.0.3" has incorrect peer dependency "ethereum-waffle@^3.2.0".
warning " > @primitivefi/hardhat-dodoc@0.2.3" has unmet peer dependency "squirrelly@^8.0.8".
warning " > @typechain/ethers-v5@10.1.0" has unmet peer dependency "@ethersproject/abi@^5.0.0".
warning " > @typechain/ethers-v5@10.1.0" has unmet peer dependency "@ethersproject/bytes@^5.0.0".
warning " > @typechain/ethers-v5@10.1.0" has unmet peer dependency "@ethersproject/providers@^5.0.0".
warning " > @typechain/hardhat@6.1.3" has unmet peer dependency "@ethersproject/abi@^5.4.7".
warning " > @typechain/hardhat@6.1.3" has unmet peer dependency "@ethersproject/providers@^5.4.7".
warning " > prb-math@2.4.3" has unmet peer dependency "@ethersproject/bignumber@5.x".
warning " > prb-math@2.4.3" has unmet peer dependency "evm-bn@1.x".
warning " > prb-math@2.4.3" has unmet peer dependency "mathjs@10.x".
[5/5] Building fresh packages...
$ node scripts/postinstall.js
Running postinstall script...
check out from github
Cloning into 'forge-std'...
Already on 'master'
Submodule 'lib/ds-test' (https://github.com/dapphub/ds-test) registered for path 'lib/ds-test'
Cloning into '/github/workspace/node_modules/forge-std/lib/ds-test'...
installing...
postinstall complete.
$ node ./.setup.js && test -n "$NODOCKER" || yarn update-local
Done in 48.60s.
[-] Installing dependencies from requirements.txt in a venv
Collecting wheel
Downloading wheel-0.38.4-py3-none-any.whl (36 kB)
Installing collected packages: wheel
Successfully installed wheel-0.38.4
Collecting asttokens==2.0.5
Downloading asttokens-2.0.5-py2.py3-none-any.whl (20 kB)
Collecting pycryptodome==3.15.0
Downloading pycryptodome-3.15.0-cp35-abi3-manylinux2010_x86_64.whl (2.3 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.3/2.3 MB 71.4 MB/s eta 0:00:00
Collecting semantic-version==2.8.5
Downloading semantic_version-2.8.5-py2.py3-none-any.whl (15 kB)
Collecting six==1.16.0
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting vyper==0.3.3
Downloading vyper-0.3.3-py3-none-any.whl (261 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 261.3/261.3 KB 303.4 MB/s eta 0:00:00
Requirement already satisfied: wheel in /opt/dependencies/lib/python3.9/site-packages (from vyper==0.3.3->-r requirements.txt (line 5)) (0.38.4)
Installing collected packages: six, semantic-version, pycryptodome, asttokens, vyper
Successfully installed asttokens-2.0.5 pycryptodome-3.15.0 semantic-version-2.8.5 six-1.16.0 vyper-0.3.3
[-] Installing dependencies from foundry.toml
Error:
error: pathspec '/github/workspace/lib' did not match any file(s) known to git
foundry.toml
[profile.default]
ffi = false
fuzz_runs = 256
optimizer = true
optimizer_runs = 999999
remappings = ["ds-test/=node_modules/forge-std/lib/ds-test/src", "hardhat/=node_modules/hardhat/","@openzeppelin/=node_modules/@openzeppelin/","hardhat-deploy/=node_modules/hardhat-deploy/", "forge-std/=node_modules/forge-std/src/", "util-contracts/=node_modules/@gnosis.pm/util-contracts/contracts/"]
verbosity = 1
libs = ['node_modules']
src = "contracts/"
test = 'test/foundry'
out = 'out'
cache_path = 'forge-cache'
solc = '0.8.16' # set solc version
# auto_detect_solc = true
slither.yml
name: Slither Analysis
on:
push:
branches:
- main
pull_request:
jobs:
analyze:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
env:
NODOCKER: 1
steps:
- uses: actions/checkout@v3
- name: Run Slither
uses: crytic/slither-action@v0.2.0
id: slither
with:
node-version: 16
slither-config: slither.config.json
That foundry error you got is not from the action itself -- all the action does there is forge install
. Can you confirm if that works on a fresh clone of the repository, after running yarn install
?
As for your original workflow, does yarn compile
run hardhat build
? Do you have "compile_force_framework": "hardhat"
set in your slither config?
You are right, executing forge install
fails in any case.
Can you avoid executing the command? We install dependencies with yarn.
To compile the contracts we use hardhat:
"compile": "hardhat compile",
We dont have "compile_force_framework": "hardhat"
set.
slither.config.json
:
{
"detectors_to_exclude": "timestamp,solc-version",
"filter_paths": "test|mocks"
}
The only way right now to skip running it is not having a foundry.toml
file -- you could try adding a step like the following before running the slither action. This will make it skip the foundry dependency part.
- name: Disable foundry
run: rm foundry.toml
That failed for me with the following error:
An unexpected error occurred:
[Error: EACCES: permission denied, mkdir '/github/home/.cache/hardhat-nodejs'] {
errno: -13,
code: 'EACCES',
syscall: 'mkdir',
path: '/github/home/.cache/hardhat-nodejs'
}
Traceback (most recent call last):
File "/opt/slither/lib/python3.9/site-packages/slither/__main__.py", line 826, in main_impl
) = process_all(filename, args, detector_classes, printer_classes)
File "/opt/slither/lib/python3.9/site-packages/slither/__main__.py", line 86, in process_all
compilations = compile_all(target, **vars(args))
File "/opt/slither/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 637, in compile_all
compilations.append(CryticCompile(target, **kwargs))
File "/opt/slither/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 117, in __init__
self._compile(**kwargs)
File "/opt/slither/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 548, in _compile
self._platform.compile(self, **kwargs)
File "/opt/slither/lib/python3.9/site-packages/crytic_compile/platform/hardhat.py", line 92, in compile
os.listdir(build_directory), key=lambda x: os.path.getmtime(Path(build_directory, x))
FileNotFoundError: [Errno 2] No such file or directory: 'artifacts/build-info'
Error in .
Traceback (most recent call last):
File "/opt/slither/lib/python3.9/site-packages/slither/__main__.py", line 826, in main_impl
) = process_all(filename, args, detector_classes, printer_classes)
File "/opt/slither/lib/python3.9/site-packages/slither/__main__.py", line 86, in process_all
compilations = compile_all(target, **vars(args))
File "/opt/slither/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 637, in compile_all
compilations.append(CryticCompile(target, **kwargs))
File "/opt/slither/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 117, in __init__
self._compile(**kwargs)
File "/opt/slither/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 548, in _compile
self._platform.compile(self, **kwargs)
File "/opt/slither/lib/python3.9/site-packages/crytic_compile/platform/hardhat.py", line 92, in compile
os.listdir(build_directory), key=lambda x: os.path.getmtime(Path(build_directory, x))
FileNotFoundError: [Errno 2] No such file or directory: 'artifacts/build-info'
I did some more digging and slither runs with the previous slither.yml when removing restore-keys
.
name: Slither Analysis
on:
push:
branches:
- main
pull_request:
jobs:
analyze:
runs-on: ubuntu-latest
env:
NODOCKER: 1
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
cache: 'yarn'
- uses: actions/cache@v3
with:
path: |
cache
artifacts
key: ${{ runner.OS }}-contracts-slither-${{ hashFiles('contracts/*.sol', 'contracts/**/*.sol', 'hardhat.config.ts', 'yarn.lock') }}
- name: Installing dependencies
run: yarn install --prefer-offline --frozen-lockfile
- name: Compile and create artifacts
run: yarn compile
- name: Run Slither
uses: crytic/slither-action@v0.2.0
id: slither
with:
ignore-compile: true
node-version: 16
slither-config: slither.config.json
Thanks for the help :+1:
So Slither fails if the artifacts used are from different compiler runs. Happy to close the issue if this is the expected behavior.
If you can reproduce it outside of the action with different runs, it might be worth reporting in the slither issue tracker, and we can close this issue. But as a general thing, artifacts can usually go out of sync with the code if you modify and recompile (eg leftover artifacts from previous runs that don't get cleaned up), and it's best if you generate them from scratch before an analysis.
We get this error in the CI, which doesn't seem related to our code. But it doesn't fail when running slither locally.
Here's the error:
Here's our github action:
The error happens are the "Run Slither" step.
Any idea?