From 6981173e3fcaca85afd14baf2a3f3ba5842ae528 Mon Sep 17 00:00:00 2001 From: Charlie Date: Thu, 23 Jun 2022 05:16:57 -0600 Subject: [PATCH] Exclude libraries from Slither (#12) * Added ability to include or exclude uniswap/OZ libraries from scan * Fixed import * Script improvements Co-authored-by: Lucas Janon --- scripts/slither.ts | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/scripts/slither.ts b/scripts/slither.ts index cce46da0..ae6dc2d2 100644 --- a/scripts/slither.ts +++ b/scripts/slither.ts @@ -35,6 +35,20 @@ async function getPackageName() { } } +async function getFilterPaths() { + if (process.env.CI) return ""; + + const { confirm: includeLibraries } = await inquirer.prompt([ + { + type: "confirm", + message: "Do you want to include OpenZeppelin & Uniswap libraries in this scan?", + name: "confirm", + }, + ]); + + return includeLibraries ? "" : `--filter-paths "node_modules/@openzeppelin/","node_modules/@uniswap/"`; +} + const run = async (command: string) => { try { console.log("Starting -- This may take a few minutes..."); @@ -50,21 +64,17 @@ const run = async (command: string) => { console.error(`${error}`); } }; - -function runSlither(packageName: string) { +function runSlither(packageName: string, filterPaths: string) { const dockerCommand = `cd /home/trufflecon/packages/${packageName} && \ solc-select use ${solcVersion} && \ slither --json ../../scripts/slither-results/${packageName}-${timestamp}.json \ --sarif ../../scripts/slither-results/${packageName}-${timestamp}.sarif \ - --checklist ./ | tee ../../scripts/slither-results/${packageName}-${timestamp}.md`; - + --checklist ./ ${filterPaths} | tee ../../scripts/slither-results/${packageName}-${timestamp}.md`; run(`docker run -v "${projectRoot}":/home/trufflecon trailofbits/eth-security-toolbox -c "${dockerCommand}"`); } async function main() { - const packageName = await getPackageName(); - - runSlither(packageName); + runSlither(await getPackageName(), await getFilterPaths()); } main()