Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit c1a0756

Browse files
authored
chore(security): added better GHAS check (#64537)
This PR attempts to handle GHAS check to be non-zero exit code in semgrep scan script ## Test plan - CI 🟢 ## Changelog - chore(security): Fix GHAS check as non-zero exit code <!-- OPTIONAL; info at https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c -->
1 parent d89d803 commit c1a0756

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

dev/ci/semgrep-scan.sh

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,13 @@ CODE_SCANNING_ENABLED="false"
2121
is_code_scanning_enabled() {
2222
local repo="$1"
2323

24-
# Try to list code scanning alerts
25-
if gh api "repos/$repo/code-scanning/alerts" &>/dev/null; then
26-
CODE_SCANNING_ENABLED="true"
24+
error=$(gh api "repos/$repo/code-scanning/alerts" || true)
25+
if echo "$error" | grep -q "Advanced Security must be enabled"; then
26+
CODE_SCANNING_ENABLED="false"
27+
elif echo "$error" | grep -q "Not Found"; then
28+
CODE_SCANNING_ENABLED="false"
2729
else
28-
# Check the specific error message
29-
error=$(gh api "repos/$repo/code-scanning/alerts" 2>&1)
30-
if echo "$error" | grep -q "Advanced Security must be enabled"; then
31-
CODE_SCANNING_ENABLED="false"
32-
elif echo "$error" | grep -q "Not Found"; then
33-
CODE_SCANNING_ENABLED="false"
34-
else
35-
CODE_SCANNING_ENABLED="false"
36-
fi
30+
CODE_SCANNING_ENABLED="true"
3731
fi
3832
}
3933

0 commit comments

Comments
 (0)