Skip to content

Commit 5407656

Browse files
authored
ci: add scans (#118)
* ci: add scans * editorconfig * security_opt: no-new-privileges * fix: apply megalinter fixes * disable devskim, kics
1 parent b802798 commit 5407656

File tree

9 files changed

+339
-102
lines changed

9 files changed

+339
-102
lines changed

.editorconfig

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
root = true
22

33
[*]
4-
charset = utf-8
5-
end_of_line = lf
6-
indent_size = 4
7-
indent_style = space
8-
insert_final_newline = true
9-
trim_trailing_whitespace = true
4+
charset=utf-8
5+
end_of_line=lf
6+
indent_size=2
7+
indent_style=space
8+
insert_final_newline=true
9+
tab_width=2
10+
trim_trailing_whitespace=true
1011

11-
[*.{json, yaml, yml}]
12-
indent_size = 2
12+
[*.{bat,cmd,ps1}]
13+
end_of_line=crlf
1314

14-
[*.md]
15-
trim_trailing_whitespace = false
15+
[*.{md,mdx}]
16+
trim_trailing_whitespace=false
1617

17-
[Makefile]
18-
indent_style = tab
18+
[*.{py,rs}]
19+
indent_size=4
20+
tab_width=4
21+
22+
[{*.{go,lua,tsv},go.{mod,sum},Makefile}]
23+
indent_size=4
24+
indent_style=tab
25+
tab_width=4

.github/workflows/ci.yml

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,28 @@ on:
1111
workflow_call:
1212
workflow_dispatch:
1313

14+
permissions: {}
15+
16+
concurrency:
17+
group: ${{ github.workflow }}-${{ github.ref }}
18+
cancel-in-progress: ${{ github.ref_name != github.event.repository.default_branch }}
19+
1420
jobs:
1521
python:
1622
strategy:
1723
matrix:
1824
os: [ubuntu-latest, macos-latest, windows-latest]
1925
python: [3.12]
2026

21-
name: python
2227
runs-on: ${{ matrix.os }}
2328
env:
2429
ENVIRONMENT: ci
2530
steps:
26-
- name: Checkout
27-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
31+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
2832

29-
- name: Set up UV
30-
uses: astral-sh/setup-uv@4db96194c378173c656ce18a155ffc14a9fc4355 # v5
33+
- uses: astral-sh/setup-uv@4db96194c378173c656ce18a155ffc14a9fc4355 # v5
3134

32-
- name: Set up Python
33-
id: setup-python
35+
- id: setup-python
3436
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5
3537
with:
3638
python-version: ${{ matrix.python }}
@@ -39,39 +41,35 @@ jobs:
3941
if: ${{ runner.os != 'Windows' }}
4042
run: |
4143
mkdir -p .venv
42-
echo "$(realpath .venv)/bin" >> ${GITHUB_PATH}
44+
echo "$(realpath .venv)/bin" >> "${GITHUB_PATH}"
4345
4446
- name: Set up environment (Windows)
4547
if: ${{ runner.os == 'Windows' }}
4648
run: |
4749
New-Item -Type Directory -Force .venv
48-
"$(Resolve-Path .venv)/Scripts" | Out-File -FilePath ${env:GITHUB_PATH} -Append
50+
"$(Resolve-Path .venv)/Scripts" | Out-File -FilePath "${env:GITHUB_PATH}" -Append
4951
50-
- name: Install dependencies
51-
run: uv sync
52+
- run: uv sync
5253

53-
- name: Lint and test
54-
run: make lint test
54+
- run: make lint test
5555

5656
docker:
57-
name: docker
5857
permissions:
5958
contents: read
6059
packages: write
60+
6161
runs-on: ubuntu-latest
6262
env:
6363
GHCR_IMAGE_NAME: ghcr.io/${{ github.repository }}
6464

6565
steps:
66-
- name: Checkout
67-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
66+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
6867
with:
6968
sparse-checkout: |
7069
Dockerfile
7170
uv.lock
7271
73-
- name: Cache buildkit mounts
74-
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
72+
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4
7573
with:
7674
path: |
7775
var-cache-apt
@@ -82,8 +80,7 @@ jobs:
8280
buildkit-mounts-${{ runner.os }}
8381
buildkit-mounts-${{ runner.os }}
8482
85-
- name: Inject cache into docker
86-
uses: reproducible-containers/buildkit-cache-dance@5b6db76d1da5c8b307d5d2e0706d266521b710de # v3
83+
- uses: reproducible-containers/buildkit-cache-dance@5b6db76d1da5c8b307d5d2e0706d266521b710de # v3
8784
with:
8885
cache-map: |
8986
{
@@ -93,11 +90,9 @@ jobs:
9390
"root-cache-uv": "/root/.cache/uv"
9491
}
9592
96-
- name: Set up Docker Buildx
97-
uses: docker/setup-buildx-action@f7ce87c1d6bead3e36075b2ce75da1f6cc28aaca # v3
93+
- uses: docker/setup-buildx-action@f7ce87c1d6bead3e36075b2ce75da1f6cc28aaca # v3
9894

99-
- name: Build CI image
100-
id: build-ci
95+
- id: build-ci
10196
env:
10297
ENVIRONMENT: ci
10398
uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991 # v6
@@ -108,25 +103,21 @@ jobs:
108103
${{ env.GHCR_IMAGE_NAME }}:cache
109104
load: true
110105

111-
- name: Run CI image
112-
run: docker run --rm ${{ steps.build-ci.outputs.imageid }}
106+
- run: docker run --rm ${{ steps.build-ci.outputs.imageid }}
113107

114-
- name: Docker metadata
115-
id: docker_metadata
108+
- id: docker_metadata
116109
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5
117110
with:
118111
images: ${{ env.GHCR_IMAGE_NAME }}
119112

120-
- name: Login to GHCR
121-
if: ${{ github.event_name != 'pull_request' }}
113+
- if: ${{ github.event_name != 'pull_request' }}
122114
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
123115
with:
124116
registry: ghcr.io
125117
username: ${{ github.repository_owner }}
126118
password: ${{ secrets.GITHUB_TOKEN }}
127119

128-
- name: Build and push dev image
129-
if: ${{ github.event_name != 'pull_request' }}
120+
- if: ${{ github.event_name != 'pull_request' }}
130121
env:
131122
ENVIRONMENT: dev
132123
uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991 # v6
@@ -139,10 +130,7 @@ jobs:
139130
tags: ${{ env.GHCR_IMAGE_NAME }}:dev
140131
push: ${{ github.event_name != 'pull_request' }}
141132

142-
- name: Build and push prod image
143-
if: ${{ github.event_name != 'pull_request' }}
144-
env:
145-
ENVIRONMENT: prod
133+
- if: ${{ github.event_name != 'pull_request' }}
146134
uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991 # v6
147135
with:
148136
cache-from: |
@@ -153,3 +141,5 @@ jobs:
153141
labels: ${{ steps.docker_metadata.outputs.labels }}
154142
annotations: ${{ steps.docker_metadata.outputs.annotations }}
155143
push: ${{ github.event_name != 'pull_request' }}
144+
env:
145+
ENVIRONMENT: prod

.github/workflows/dependabot.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: dependabot
2+
on:
3+
pull_request:
4+
branches: [main]
5+
6+
permissions: {}
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: ${{ github.ref_name != github.event.repository.default_branch }}
11+
12+
jobs:
13+
dependabot:
14+
permissions:
15+
contents: write
16+
pull-requests: write
17+
18+
if: ${{ github.actor == 'dependabot[bot]' }}
19+
runs-on: ubuntu-latest
20+
steps:
21+
- id: metadata
22+
uses: dependabot/fetch-metadata@d7267f607e9d3fb96fc2fbe83e0af444713e90b7 # v2
23+
24+
- name: log metadata
25+
run: echo "${DEPENDABOT_METADATA}"
26+
env:
27+
DEPENDABOT_METADATA: ${{ toJson(steps.metadata.outputs) }}
28+
29+
- name: automerge
30+
if: ${{ !contains(steps.metadata.outputs.update-type, 'major' ) }}
31+
run: gh pr merge --auto --squash "${PR_NUMBER}"
32+
env:
33+
PR_NUMBER: ${{ github.event.pull_request.number }}
34+
GH_REPO: ${{ github.repository }}
35+
GH_TOKEN: ${{ github.token }}

.github/workflows/ossf.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: ossf
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
branches: [main]
7+
merge_group:
8+
branches: [main]
9+
workflow_call:
10+
workflow_dispatch:
11+
12+
permissions: {}
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: ${{ github.ref_name != github.event.repository.default_branch }}
17+
18+
jobs:
19+
ossf:
20+
permissions:
21+
contents: read
22+
# Needed for GitHub OIDC token if publish_results is true
23+
id-token: write
24+
# Needed for Code scanning upload
25+
security-events: write
26+
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
30+
31+
- uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2
32+
with:
33+
results_file: results.sarif
34+
results_format: sarif
35+
# Scorecard team runs a weekly scan of public GitHub repos,
36+
# see https://github.com/ossf/scorecard#public-data.
37+
# Setting `publish_results: true` helps us scale by leveraging your workflow to
38+
# extract the results instead of relying on our own infrastructure to run scans.
39+
# And it's free for you!
40+
publish_results: true
41+
42+
# Upload the results to GitHub's code scanning dashboard (optional).
43+
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
44+
- uses: github/codeql-action/upload-sarif@9e8d0789d4a0fa9ceb6b1738f7e269594bdd67f0 # v3
45+
with:
46+
sarif_file: results.sarif

.github/workflows/pr.yml

Lines changed: 16 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,46 @@
11
name: pr
2-
32
on:
43
pull_request:
5-
types:
6-
- opened
7-
- edited
8-
- reopened
9-
- synchronize
4+
types: [opened, synchronize, reopened, edited]
5+
branches: [main]
6+
7+
permissions: {}
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: ${{ github.ref_name != github.event.repository.default_branch }}
1012

1113
jobs:
1214
lint-title:
1315
permissions:
1416
pull-requests: read
17+
1518
runs-on: ubuntu-latest
1619
steps:
17-
- name: semantic-pull-request
18-
uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 # v5
20+
- uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 # v5
1921
env:
20-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
GITHUB_TOKEN: ${{ github.token }}
2123

2224
label:
2325
permissions:
2426
contents: read
2527
pull-requests: write
28+
2629
runs-on: ubuntu-latest
2730
steps:
28-
- name: labeler
29-
uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5
31+
- uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5
3032

3133
label-size:
3234
permissions:
3335
contents: read
3436
pull-requests: write
37+
3538
runs-on: ubuntu-latest
3639
steps:
37-
- name: size-label
38-
uses: pascalgn/size-label-action@f8edde36b3be04b4f65dcfead05dc8691b374348 # v0.5.5
40+
- uses: pascalgn/size-label-action@f8edde36b3be04b4f65dcfead05dc8691b374348 # v0.5.5
3941
env:
40-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
GITHUB_TOKEN: ${{ github.token }}
4143
IGNORED: |
4244
package-lock.json
4345
*.lock
4446
docs/**
45-
46-
dependabot:
47-
if: github.actor == 'dependabot[bot]'
48-
permissions:
49-
contents: write
50-
pull-requests: write
51-
runs-on: ubuntu-latest
52-
steps:
53-
- id: metadata
54-
uses: dependabot/fetch-metadata@d7267f607e9d3fb96fc2fbe83e0af444713e90b7 # v2
55-
56-
- name: log metadata
57-
env:
58-
DEPENDABOT_METADATA: ${{ toJson(steps.metadata.outputs) }}
59-
run: echo ${DEPENDABOT_METADATA}
60-
61-
- name: automerge
62-
if: ${{ !contains(steps.metadata.outputs.update-type, 'major' ) }}
63-
run: gh pr merge --auto --squash ${PR_NUMBER}
64-
env:
65-
PR_NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }}
66-
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)