From a28260cc78a61b3c8ca5214e59ca3632ad5b2a9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= Date: Thu, 28 Jul 2022 19:22:41 -0300 Subject: [PATCH] Add a way to install Slither plugins This adds an extra option, `slither-plugins`, that lets users provide a requirements.txt file to be installed alongside Slither. This can be used to install Slither plugins. Fixes: #16 --- action.yml | 2 ++ entrypoint.sh | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/action.yml b/action.yml index f3d6ea3..75a2bb7 100644 --- a/action.yml +++ b/action.yml @@ -17,6 +17,8 @@ inputs: description: 'The path to the Slither configuration file. By default, `./slither.config.json` is used if present.' slither-version: description: 'The version of slither-analyzer to use. By default, the latest release in PyPI is used.' + slither-plugins: + description: 'A requirements.txt file to install alongside Slither. Useful to install custom plugins.' ignore-compile: description: 'Whether to ignore the compilation step when running crytic-compile and Slither.' default: false diff --git a/entrypoint.sh b/entrypoint.sh index a839ea5..5c3ca6c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -21,6 +21,7 @@ SARIFOUT="$4" SLITHERVER="$5" SLITHERARGS="$(get INPUT_SLITHER-ARGS)" SLITHERCONF="$(get INPUT_SLITHER-CONFIG)" +SLITHERPLUGINS="$(get INPUT_SLITHER-PLUGINS)" STDOUTFILE="/tmp/slither-stdout" IGNORECOMPILE="$(get INPUT_IGNORE-COMPILE)" @@ -185,6 +186,13 @@ install_slither() export PATH="/opt/slither/bin:$PATH" pip3 install wheel pip3 install "$SLITHERPKG" + + if [[ -n "$SLITHERPLUGINS" ]]; then + echo "[-] Slither plugins provided, installing them" + pushd "$(dirname "$SLITHERPLUGINS")" >/dev/null + pip3 install -r "$(basename "$SLITHERPLUGINS")" + popd >/dev/null + fi } install_deps()