How to exclude Foundry test from Slither? #1866
-
I have realized that the I tried to exclude it using the {
"compile_force_framework": "foundry",
"foundry_out_directory": "foundry/out",
"filter_paths": "test"
} The error I get in this case: $ slither .
'forge clean' running (wd: /home/guido/codes/UBET/ubet-devenv/workspace/ubet/blockchain/evm)
'forge build --build-info --force' running
Compiling 111 files with 0.8.17
Solc 0.8.17 finished in 11.09s
Compiler run successful
Traceback (most recent call last):
File "/home/guido/.local/lib/python3.8/site-packages/slither/__main__.py", line 837, in main_impl
) = process_all(filename, args, detector_classes, printer_classes)
File "/home/guido/.local/lib/python3.8/site-packages/slither/__main__.py", line 101, in process_all
) = process_single(compilation, args, detector_classes, printer_classes)
File "/home/guido/.local/lib/python3.8/site-packages/slither/__main__.py", line 79, in process_single
slither = Slither(target, ast_format=ast, **vars(args))
File "/home/guido/.local/lib/python3.8/site-packages/slither/slither.py", line 135, in __init__
self._init_parsing_and_analyses(kwargs.get("skip_analyze", False))
File "/home/guido/.local/lib/python3.8/site-packages/slither/slither.py", line 155, in _init_parsing_and_analyses
raise e
File "/home/guido/.local/lib/python3.8/site-packages/slither/slither.py", line 151, in _init_parsing_and_analyses
parser.analyze_contracts()
File "/home/guido/.local/lib/python3.8/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 528, in analyze_contracts
self._convert_to_slithir()
File "/home/guido/.local/lib/python3.8/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 753, in _convert_to_slithir
func.generate_slithir_ssa({})
File "/home/guido/.local/lib/python3.8/site-packages/slither/core/declarations/function_top_level.py", line 96, in generate_slithir_ssa
add_ssa_ir(self, all_ssa_state_variables_instances)
File "/home/guido/.local/lib/python3.8/site-packages/slither/slithir/utils/ssa.py", line 196, in add_ssa_ir
generate_ssa_irs(
File "/home/guido/.local/lib/python3.8/site-packages/slither/slithir/utils/ssa.py", line 311, in generate_ssa_irs
generate_ssa_irs(
File "/home/guido/.local/lib/python3.8/site-packages/slither/slithir/utils/ssa.py", line 311, in generate_ssa_irs
generate_ssa_irs(
File "/home/guido/.local/lib/python3.8/site-packages/slither/slithir/utils/ssa.py", line 308, in generate_ssa_irs
new_ir.lvalue.add_refers_to(new_ir.rvalue)
File "/home/guido/.local/lib/python3.8/site-packages/slither/slithir/variables/local_variable.py", line 71, in add_refers_to
assert isinstance(variable, (SlithIRVariable, TemporaryVariable))
AssertionError
ERROR:root:Error in . But I still have the issue. Another thing I tried was to modify the {
"compile_force_framework": "foundry",
"foundry_out_directory": "foundry/out",
"compile_custom_build": "forge build --build-info --force --skip test",
"ignore_compile": true,
"skip_clean": true
} For this case, I get: $ slither .
Compiling 97 files with 0.8.17
Solc 0.8.17 finished in 5.20s
Compiler run successful
WARNING:Slither:No contract was analyzed
INFO:Slither:. analyzed (0 contracts with 85 detectors), 0 result(s) found Would there an alternative for making Slither to not consider this test folder and make as it wouldn't exist? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
This a great idea but doesn't work for a few reasons. It seems like custom build instructions are not working properly (I've opened an issue. Aside, the config |
Beta Was this translation helpful? Give feedback.
-
UPDATE: you should be able to accomplish this by doing |
Beta Was this translation helpful? Give feedback.
UPDATE: you should be able to accomplish this by doing
forge build --build-info --skip test script && && slither . --ignore-compile
. Note, this assumes that there is not aslither.config.json
. Will consider making this more straightforward in future releases