From 63647f4c1d52025d1ee4ddc1c9724f4b3da5ee07 Mon Sep 17 00:00:00 2001 From: sripwoud Date: Thu, 18 Jul 2024 12:16:12 +0200 Subject: [PATCH] chore: add local `slither` script re #10 --- package.json | 4 +++- packages/excubiae/package.json | 3 ++- packages/imt/package.json | 3 ++- packages/lazy-imt/package.json | 3 ++- packages/lazytower/package.json | 3 ++- packages/lean-imt/package.json | 3 ++- scripts/check-slither.sh | 19 +++++++++++++++++++ 7 files changed, 32 insertions(+), 6 deletions(-) create mode 100755 scripts/check-slither.sh diff --git a/package.json b/package.json index a144320..ffd4bd0 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,9 @@ "format": "prettier -c .", "format:write": "prettier -w .", "remove:stable-version-field": "ts-node scripts/remove-stable-version-field.ts ${0} && yarn format:write", - "postinstall": "husky && git config --local core.editor cat" + "lint": "yarn workspaces foreach -Ap run lint", + "postinstall": "husky && git config --local core.editor cat", + "slither": "./scripts/check-slither.sh && yarn workspaces foreach -Ap run slither" }, "keywords": [ "solidity", diff --git a/packages/excubiae/package.json b/packages/excubiae/package.json index 8e72642..b99ddd3 100644 --- a/packages/excubiae/package.json +++ b/packages/excubiae/package.json @@ -9,7 +9,8 @@ "test:report-gas": "REPORT_GAS=true hardhat test", "test:coverage": "hardhat coverage", "typechain": "hardhat typechain", - "lint": "solhint 'contracts/**/*.sol'" + "lint": "solhint 'contracts/**/*.sol'", + "slither": "slither . --include-paths contracts --exclude-dependencies --ignore-compile" }, "devDependencies": { "@nomicfoundation/hardhat-chai-matchers": "^2.0.3", diff --git a/packages/imt/package.json b/packages/imt/package.json index 754bcd8..5b36728 100644 --- a/packages/imt/package.json +++ b/packages/imt/package.json @@ -8,7 +8,8 @@ "test:report-gas": "REPORT_GAS=true hardhat test", "test:coverage": "hardhat coverage", "typechain": "hardhat typechain", - "lint": "solhint 'contracts/**/*.sol'" + "lint": "solhint 'contracts/**/*.sol'", + "slither": "slither . --include-paths contracts --exclude-dependencies --ignore-compile" }, "devDependencies": { "@nomicfoundation/hardhat-chai-matchers": "^2.0.3", diff --git a/packages/lazy-imt/package.json b/packages/lazy-imt/package.json index 98ad51e..e157b7b 100644 --- a/packages/lazy-imt/package.json +++ b/packages/lazy-imt/package.json @@ -8,7 +8,8 @@ "test:report-gas": "REPORT_GAS=true hardhat test", "test:coverage": "hardhat coverage", "typechain": "hardhat typechain", - "lint": "solhint 'contracts/**/*.sol'" + "lint": "solhint 'contracts/**/*.sol'", + "slither": "slither . --include-paths contracts --exclude-dependencies --ignore-compile" }, "devDependencies": { "@nomicfoundation/hardhat-chai-matchers": "^2.0.3", diff --git a/packages/lazytower/package.json b/packages/lazytower/package.json index e8dbd76..a6e582e 100644 --- a/packages/lazytower/package.json +++ b/packages/lazytower/package.json @@ -9,7 +9,8 @@ "test:report-gas": "REPORT_GAS=true hardhat test", "test:coverage": "hardhat coverage", "typechain": "hardhat typechain", - "lint": "solhint 'contracts/**/*.sol'" + "lint": "solhint 'contracts/**/*.sol'", + "slither": "slither . --include-paths contracts --exclude-dependencies --ignore-compile" }, "devDependencies": { "@nomicfoundation/hardhat-chai-matchers": "^2.0.3", diff --git a/packages/lean-imt/package.json b/packages/lean-imt/package.json index 643701c..35446ce 100644 --- a/packages/lean-imt/package.json +++ b/packages/lean-imt/package.json @@ -8,7 +8,8 @@ "test:report-gas": "REPORT_GAS=true hardhat test", "test:coverage": "hardhat coverage", "typechain": "hardhat typechain", - "lint": "solhint 'contracts/**/*.sol'" + "lint": "solhint 'contracts/**/*.sol'", + "slither": "slither . --include-paths contracts --exclude-dependencies --ignore-compile" }, "devDependencies": { "@nomicfoundation/hardhat-chai-matchers": "^2.0.3", diff --git a/scripts/check-slither.sh b/scripts/check-slither.sh new file mode 100755 index 0000000..ca2b2f6 --- /dev/null +++ b/scripts/check-slither.sh @@ -0,0 +1,19 @@ +#!/bin/sh +set -eu + +CYAN="\033[36m" +RED="\033[31m" +RESET="\033[0m" + +log() { + printf "%b\n" "$1" +} + +main() { + if ! command -v slither >/dev/null; then + log "${RED}error: slither is required but is not installed${RESET}.\nFollow instructions at ${CYAN}https://github.com/crytic/slither?tab=readme-ov-file#how-to-install${RESET} and try again." + exit 1 + fi +} + +main