Repository navigation
161 lines (139 loc) · 4.64 KB
/
Copy pathquality.yml
File metadata and controls
161 lines (139 loc) · 4.64 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: Quality
on:
merge_group:
pull_request:
branches: [main, gui]
push:
branches: [main, actions, gui, py]
schedule:
- cron: "17 4 * * 1"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: quality-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
languages:
name: Detect languages
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
matrix: ${{ steps.detect.outputs.matrix }}
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Build CodeQL matrix
id: detect
shell: bash
run: |
if git grep -Il '^#!/usr/bin/env -S uv run --script' -- '*.py' 'bin/*' >/dev/null 2>&1; then
echo 'matrix={"include":[{"language":"actions"},{"language":"python"}]}' >> "$GITHUB_OUTPUT"
else
echo 'matrix={"include":[{"language":"actions"}]}' >> "$GITHUB_OUTPUT"
fi
codeql:
name: CodeQL / ${{ matrix.language }}
needs: languages
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.languages.outputs.matrix) }}
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Initialize CodeQL
uses: github/codeql-action/init@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6
with:
languages: ${{ matrix.language }}
build-mode: none
queries: security-and-quality
- name: Analyze
uses: github/codeql-action/analyze@5595ccaf912efad79be6eef63a5619ff05969be3 # v4.37.6
with:
category: /language:${{ matrix.language }}
dependency-review:
name: Dependency review
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Review dependency changes
uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0
with:
fail-on-severity: moderate
osv:
name: OSV scan
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
permissions:
actions: read
contents: read
security-events: write
uses: google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@8deb546fdb875b9996d27d4950be7312dac076a1 # v2.5.0
python-audit:
name: Python / dependencies
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@ae62891fec2bb8e7d6c99fc78c9fec3a63790f8d # v10.0.0
with:
version: "0.11.32"
python-version: "3.11"
enable-cache: false
- name: Audit script dependencies
shell: bash
run: |
mapfile -t scripts < <(
git grep -Il '^#!/usr/bin/env -S uv run --script' -- '*.py' 'bin/*' || true
)
for script in "${scripts[@]}"; do
uv audit --script "$script"
done
(( ${#scripts[@]} )) || echo "No dependency-bearing Python scripts found"
python-security:
name: Python / security lint
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Install uv
uses: astral-sh/setup-uv@ae62891fec2bb8e7d6c99fc78c9fec3a63790f8d # v10.0.0
with:
version: "0.11.32"
python-version: "3.11"
enable-cache: false
- name: Scan Python scripts
shell: bash
run: |
mapfile -t python_files < <(
git ls-files -- 'bin/_common.py'
git grep -Il '^#!/usr/bin/env -S uv run --script' -- '*.py' 'bin/*' || true
)
if (( ${#python_files[@]} == 0 )); then
echo "No Python scripts found"
exit 0
fi
uvx bandit@1.9.4 --quiet --severity-level medium "${python_files[@]}"