Skip to content

Commit 9b0ab3a

Browse files
committed
ci: add security scanning workflows (#123)
1 parent 2e4fd81 commit 9b0ab3a

File tree

4 files changed

+163
-0
lines changed

4 files changed

+163
-0
lines changed

.github/dependabot.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ updates:
77
time: "06:00"
88
timezone: "America/Chicago"
99
labels: []
10+
commit-message:
11+
prefix: "ci"
1012
groups:
1113
github-actions:
1214
patterns:
@@ -19,8 +21,15 @@ updates:
1921
time: "06:00"
2022
timezone: "America/Chicago"
2123
labels: []
24+
commit-message:
25+
prefix: "chore"
2226
open-pull-requests-limit: 15
2327
groups:
2428
x:
2529
patterns:
2630
- "golang.org/x/*"
31+
ignore:
32+
# Ignore patch updates for all dependencies to reduce PR noise
33+
- dependency-name: "*"
34+
update-types:
35+
- version-update:semver-patch

.github/workflows/scorecard.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: OpenSSF Scorecard
2+
3+
on:
4+
branch_protection_rule:
5+
schedule:
6+
# Run weekly on Wednesdays at 7:27 UTC
7+
- cron: "27 7 * * 3"
8+
push:
9+
branches:
10+
- main
11+
12+
permissions: read-all
13+
14+
jobs:
15+
analysis:
16+
name: Scorecard analysis
17+
runs-on: ubuntu-latest
18+
permissions:
19+
security-events: write
20+
id-token: write
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@v4
25+
with:
26+
persist-credentials: false
27+
28+
- name: Run analysis
29+
uses: ossf/scorecard-action@v2.4.0
30+
with:
31+
results_file: results.sarif
32+
results_format: sarif
33+
repo_token: ${{ secrets.GITHUB_TOKEN }}
34+
publish_results: true
35+
36+
- name: Upload artifact
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: SARIF file
40+
path: results.sarif
41+
retention-days: 5
42+
43+
- name: Upload to code-scanning
44+
uses: github/codeql-action/upload-sarif@v3
45+
with:
46+
sarif_file: results.sarif

.github/workflows/security.yaml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: security
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
schedule:
9+
# Run every day at 10:00 UTC (6:00 AM ET / 3:00 AM PT)
10+
- cron: "0 10 * * *"
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
16+
# Cancel in-progress runs for pull requests when developers push
17+
# additional changes
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
21+
22+
jobs:
23+
codeql:
24+
name: CodeQL Analysis
25+
runs-on: ubuntu-latest
26+
permissions:
27+
security-events: write
28+
actions: read
29+
contents: read
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
34+
- name: Setup Go
35+
uses: actions/setup-go@v5
36+
with:
37+
go-version-file: "go.mod"
38+
39+
- name: Initialize CodeQL
40+
uses: github/codeql-action/init@v3
41+
with:
42+
languages: go
43+
44+
- name: Perform CodeQL Analysis
45+
uses: github/codeql-action/analyze@v3
46+
with:
47+
category: "/language:go"
48+
49+
trivy-repo:
50+
name: Trivy Filesystem Scan
51+
runs-on: ubuntu-latest
52+
permissions:
53+
security-events: write
54+
contents: read
55+
steps:
56+
- name: Checkout repository
57+
uses: actions/checkout@v4
58+
59+
- name: Run Trivy vulnerability scanner in repo mode
60+
uses: aquasecurity/trivy-action@0.28.0
61+
with:
62+
scan-type: "fs"
63+
scan-ref: "."
64+
format: "sarif"
65+
output: "trivy-results.sarif"
66+
severity: "CRITICAL,HIGH"
67+
68+
- name: Upload Trivy scan results to GitHub Security tab
69+
uses: github/codeql-action/upload-sarif@v3
70+
with:
71+
sarif_file: "trivy-results.sarif"
72+
category: "Trivy-Filesystem"
73+
74+
trivy-image:
75+
name: Trivy Docker Image Scan
76+
runs-on: ubuntu-latest
77+
permissions:
78+
security-events: write
79+
contents: read
80+
steps:
81+
- name: Checkout repository
82+
uses: actions/checkout@v4
83+
84+
- name: Run Trivy vulnerability scanner on latest image
85+
uses: aquasecurity/trivy-action@0.28.0
86+
with:
87+
image-ref: "ghcr.io/coder/code-marketplace:latest"
88+
format: "sarif"
89+
output: "trivy-image-results.sarif"
90+
severity: "CRITICAL,HIGH"
91+
92+
- name: Upload Trivy scan results to GitHub Security tab
93+
uses: github/codeql-action/upload-sarif@v3
94+
with:
95+
sarif_file: "trivy-image-results.sarif"
96+
category: "Trivy-Docker"

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
### Added
11+
12+
- Automated security scanning workflows for improved supply chain security:
13+
- CodeQL analysis for Go code vulnerability scanning
14+
- Trivy scanning for Go dependencies and Docker images
15+
- OpenSSF Scorecard for security best practices assessment
16+
- Results uploaded to GitHub Security tab for centralized monitoring
17+
18+
### Changed
19+
20+
- Enhanced Dependabot configuration with commit message prefixes and patch update
21+
filtering to reduce PR noise while maintaining security update coverage.
1022
- Update the Kubernetes Deployment `spec.strategy.type` field to be of type `Recreate`
1123
in order to properly handle upgrades/restarts as the default deployment creates a PVC
1224
of type `ReadWriteOnce` and could only be assigned to one replica.

0 commit comments

Comments
 (0)