forked from ChelseaKR/id-churn-sentinel
-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (67 loc) · 2.39 KB
/
Copy pathcodeql.yml
File metadata and controls
72 lines (67 loc) · 2.39 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# CodeQL SAST. The `actions` language pack analyzes the workflow YAML itself,
# not just the Python.
#
# Like every workflow in this repository: **do not assume it ever runs.** The
# account has an Actions spending limit (see ci.yml's header). `make verify`
# already runs ruff's bandit (S) rules locally on every gate pass; this adds a
# second, deeper SAST engine whenever Actions does run.
#
# This repository is public, so the job uploads SARIF to the code-scanning
# dashboard and also checks the same output in-run. A finding therefore fails
# the gate even if branch protection is reconfigured later.
name: codeql
on:
push:
branches: [main]
pull_request:
schedule:
- cron: "42 6 * * 2" # weekly, staggered off ci.yml's Monday cron
permissions:
contents: read
concurrency:
group: codeql-${{ github.ref }}
cancel-in-progress: true
jobs:
analyze:
name: analyze (${{ matrix.language }})
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
language: [python, actions]
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
- uses: github/codeql-action/init@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
with:
languages: ${{ matrix.language }}
- uses: github/codeql-action/analyze@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
with:
category: "/language:${{ matrix.language }}"
output: sarif-results
- name: Fail on findings
run: |
python3 - <<'EOF'
import glob
import json
import sys
findings = 0
for path in sorted(glob.glob("sarif-results/*.sarif")):
with open(path) as fh:
sarif = json.load(fh)
for run in sarif.get("runs", []):
for result in run.get("results", []):
findings += 1
rule = result.get("ruleId", "<no rule id>")
message = result.get("message", {}).get("text", "")
print(f"{path}: {rule}: {message}")
if findings:
print(f"CodeQL reported {findings} finding(s) — failing the gate.")
sys.exit(1)
print("CodeQL: no findings.")
EOF