Commit 5a03aa19 authored by smartcontracts's avatar smartcontracts Committed by GitHub

feat(ci): add semgrep to ci-builder (#12376)

Adds semgrep to ci builder and adds justfile commands to install
semgrep like everything else.
parent dd010961
issues: issues:
./ops/scripts/todo-checker.sh ./ops/scripts/todo-checker.sh
semgrep-scan-local: # Runs semgrep on the entire monorepo.
semgrep scan --config=.semgrep semgrep:
semgrep scan --config=.semgrep --error .
lint-shellcheck: lint-shellcheck:
find . -type f -name '*.sh' -not -path '*/node_modules/*' -not -path './packages/contracts-bedrock/lib/*' -not -path './packages/contracts-bedrock/kout*/*' -exec sh -c 'echo \"Checking $1\"; shellcheck \"$1\"' _ {} \\; find . -type f -name '*.sh' -not -path '*/node_modules/*' -not -path './packages/contracts-bedrock/lib/*' -not -path './packages/contracts-bedrock/kout*/*' -exec sh -c 'echo \"Checking $1\"; shellcheck \"$1\"' _ {} \\;
...@@ -45,3 +46,15 @@ check-slither: ...@@ -45,3 +46,15 @@ check-slither:
upgrade-slither: upgrade-slither:
jq '.slither = $v' --arg v $(just print-slither) <<<$(cat versions.json) > versions.json jq '.slither = $v' --arg v $(just print-slither) <<<$(cat versions.json) > versions.json
install-semgrep:
pip3 install semgrep
print-semgrep:
semgrep --version
check-semgrep:
[ "$(just print-semgrep)" = "$(jq -r .semgrep < versions.json)" ] && echo '✓ semgrep versions match' || (echo '✗ semgrep version mismatch. Run `just upgrade-semgrep` to upgrade.' && exit 1)
upgrade-semgrep:
jq '.semgrep = $v' --arg v $(just print-semgrep) <<<$(cat versions.json) > versions.json
...@@ -105,6 +105,7 @@ RUN /bin/sh -c set -eux; \ ...@@ -105,6 +105,7 @@ RUN /bin/sh -c set -eux; \
apt-get install -y docker-ce-cli; \ apt-get install -y docker-ce-cli; \
ln -s /usr/local/go/bin/gofmt /usr/local/bin/gofmt; \ ln -s /usr/local/go/bin/gofmt /usr/local/bin/gofmt; \
pip install capstone pyelftools; \ pip install capstone pyelftools; \
pip install semgrep==$(jq -r .semgrep < versions.json); \
curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/master/install.sh | bash; \ curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/master/install.sh | bash; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
rm -rf /var/lib/apt/lists/*; \ rm -rf /var/lib/apt/lists/*; \
......
...@@ -9,5 +9,6 @@ ...@@ -9,5 +9,6 @@
"slither": "0.10.2", "slither": "0.10.2",
"kontrol": "0.1.316", "kontrol": "0.1.316",
"just": "1.34.0", "just": "1.34.0",
"binary_signer": "1.0.4" "binary_signer": "1.0.4",
"semgrep": "1.90.0"
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment