-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (46 loc) · 1.47 KB
/
Copy pathcodeql.yml
File metadata and controls
49 lines (46 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
name: CodeQL
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "17 3 * * 1"
permissions:
actions: read
contents: read
security-events: write
jobs:
analyze:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v7
- uses: github/codeql-action/init@v4
with:
languages: javascript-typescript
- id: analyze
uses: github/codeql-action/analyze@v4
- name: Enforce CodeQL findings
env:
SARIF_DIR: ${{ steps.analyze.outputs.sarif-output }}
run: |
set -euo pipefail
findings="$(jq -s '
[
.[]
| .runs[]?.results[]?
| select((.level // "warning") == "error" or (.level // "warning") == "warning")
]
| length
' "$SARIF_DIR"/*.sarif)"
echo "CodeQL warning/error findings: $findings" | tee -a "$GITHUB_STEP_SUMMARY"
if [ "$findings" -ne 0 ]; then
jq -rs '
.[]
| .runs[]?.results[]?
| select((.level // "warning") == "error" or (.level // "warning") == "warning")
| "\(.level // "warning") \(.ruleId // "unknown-rule") \(.locations[0].physicalLocation.artifactLocation.uri // "unknown-file"):\(.locations[0].physicalLocation.region.startLine // 0): \(.message.text // "No message")"
' "$SARIF_DIR"/*.sarif
fi
test "$findings" -eq 0