crytic / slither-action

GNU Affero General Public License v3.0
127 stars 19 forks source link

Python error #40

Closed zozidalom closed 1 year ago

zozidalom commented 1 year ago

Hi, How to fix this issue?

My code:

    - name: Slither code analysis
      uses: crytic/slither-action@v0.2.0
      with:
        fail-on: high

Error:

Run crytic/slither-action@v0.2.0

                                                                           0.1%
#######                                                                   10.4%
###########################                                               37.7%
######################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v19.0.0 (npm v8.19.2)
Creating default alias: default -> node (-> v19.0.0 *)
[-] Did not find a package.json, proceeding without installing JS dependencies.
[-] Did not find a requirements.txt, proceeding without installing Python dependencies.
[-] Did not find a foundry.toml, proceeding without installing Foundry dependencies.
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 658, in compile_all
    compilations.append(CryticCompile(filename, **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/solc.py", line [15]()4, in compile
    targets_json = _get_targets_json(compilation_unit, self._target, **kwargs)
  File "/opt/slither/lib/python3.9/site-packages/crytic_compile/platform/solc.py", line 276, in _get_targets_json
    return _run_solc(
  File "/opt/slither/lib/python3.9/site-packages/crytic_compile/platform/solc.py", line 468, in _run_solc
    raise InvalidCompilation(f"{filename} does not exist (are you in the correct directory?)")
crytic_compile.platform.exceptions.InvalidCompilation: . does not exist (are you in the correct directory?)
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 658, in compile_all
    compilations.append(CryticCompile(filename, **kwargs))
  File "/opt/slither/lib/python3.9/site-packages/crytic_compile/crytic_compile.py", line 1[17](), 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/solc.py", line 154, in compile
    targets_json = _get_targets_json(compilation_unit, self._target, **kwargs)
  File "/opt/slither/lib/python3.9/site-packages/crytic_compile/platform/solc.py", line [27]()6, in _get_targets_json
    return _run_solc(
  File "/opt/slither/lib/python3.9/site-packages/crytic_compile/platform/solc.py", line [46](8, in _run_solc
    raise InvalidCompilation(f"{filename} does not exist (are you in the correct directory?)")
crytic_compile.platform.exceptions.InvalidCompilation: . does not exist (are you in the correct directory?)
elopez commented 1 year ago

Hi @zozidalom, is your project stored on the repository root? If it's not the case, you will need to add the target option to the action with the right folder.

    - name: Slither code analysis
      uses: crytic/slither-action@v0.2.0
      with:
        fail-on: high
        target: folder/myproject

where folder/myproject/ in the repository contains your project files (things like package lock, hardhat config, foundry config, etc.)

zozidalom commented 1 year ago

Ohh so it does not inherit the working-directory of the job?

It does not work still after specifying the folder.

zozidalom commented 1 year ago

crytic_compile.platform.exceptions.InvalidCompilation: . does not exist (are you in the correct directory?)

elopez commented 1 year ago

My understanding is that setting a default working-directory only applies to run steps, but not to actions, so you'll need to specify target.

Are you trying to set slither action up in this PR? I see you added target to another action instead of the slither one, let me know if it works after fixing that.

zozidalom commented 1 year ago

Yes, exactly, that PR

elopez commented 1 year ago

I'm assuming this got resolved, feel free to open a new issue if you encounter any other issues!