Skip to content

Commit 40fc299

Browse files
ihor-sokoliukclaude
andcommitted
security(ci): pin action SHAs, add CodeQL workflow, add Trivy scan
Closes SEC-006: Add supply-chain hardening to CI/CD Coverage: 87.36% (unchanged) Phase 1 step 1: pin all floating action tags to full commit SHAs in docker-publish.yml, npm-publish.yml, and scorecard.yml. Phase 1 step 2: add codeql.yml for TypeScript analysis on push/PR/weekly. Phase 1 step 3: add Trivy CRITICAL/HIGH scan + SARIF upload after Docker push. Also logs SEC-011: mcp-publisher binary in npm-publish.yml downloaded without checksum verification. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 1e55f2f commit 40fc299

4 files changed

Lines changed: 78 additions & 23 deletions

File tree

.github/workflows/codeql.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: CodeQL Analysis
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
schedule:
9+
- cron: '0 6 * * 1' # weekly, Monday 06:00 UTC
10+
11+
permissions: read-all
12+
13+
jobs:
14+
analyze:
15+
name: Analyze TypeScript
16+
runs-on: ubuntu-latest
17+
permissions:
18+
security-events: write
19+
actions: read
20+
contents: read
21+
22+
steps:
23+
- name: Checkout code
24+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
25+
26+
- name: Initialize CodeQL
27+
uses: github/codeql-action/init@dd903d2e4f5405488e5ef1422510ee31c8b32357 # v3.36.2
28+
with:
29+
languages: javascript-typescript
30+
queries: security-and-quality
31+
32+
- name: Build TypeScript
33+
run: npm ci && npm run build
34+
35+
- name: Perform CodeQL Analysis
36+
uses: github/codeql-action/analyze@dd903d2e4f5405488e5ef1422510ee31c8b32357 # v3.36.2
37+
with:
38+
category: /language:javascript-typescript

.github/workflows/docker-publish.yml

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,60 @@ on:
66
- 'v*'
77

88
permissions:
9-
contents: read # checkout only; Docker Hub auth uses secrets, not GITHUB_TOKEN
9+
contents: read # checkout only; Docker Hub auth uses secrets, not GITHUB_TOKEN
10+
security-events: write # for Trivy SARIF upload to GitHub Security tab
1011

1112
jobs:
1213
push_to_registry:
1314
name: Push Docker image to Docker Hub
1415
runs-on: ubuntu-latest
1516
steps:
1617
- name: Check out the repo
17-
uses: actions/checkout@v4
18-
18+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
19+
1920
- name: Set up QEMU
20-
uses: docker/setup-qemu-action@v3
21-
21+
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
22+
2223
- name: Set up Docker Buildx
23-
uses: docker/setup-buildx-action@v3
24-
24+
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
25+
2526
- name: Log in to Docker Hub
26-
uses: docker/login-action@v3
27+
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
2728
with:
2829
username: ${{ secrets.DOCKERHUB_USERNAME }}
2930
password: ${{ secrets.DOCKERHUB_TOKEN }}
30-
31+
3132
- name: Extract metadata (tags, labels) for Docker
3233
id: meta
33-
uses: docker/metadata-action@v5
34+
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
3435
with:
3536
images: isokoliuk/mcp-searxng
3637
tags: |
3738
type=semver,pattern={{version}}
3839
type=semver,pattern={{major}}.{{minor}}
3940
type=raw,value=latest
40-
41+
4142
- name: Build and push Docker image
42-
uses: docker/build-push-action@v6
43+
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
4344
with:
4445
context: .
4546
platforms: linux/amd64,linux/arm64
4647
push: true
4748
tags: ${{ steps.meta.outputs.tags }}
48-
labels: ${{ steps.meta.outputs.labels }}
49+
labels: ${{ steps.meta.outputs.labels }}
50+
51+
- name: Scan Docker image for vulnerabilities
52+
uses: aquasecurity/trivy-action@ed142fd0673e97e23eac54620cfb913e5ce36c25 # v0.36.0
53+
with:
54+
image-ref: 'isokoliuk/mcp-searxng:latest'
55+
format: 'sarif'
56+
output: 'trivy-results.sarif'
57+
severity: 'CRITICAL,HIGH'
58+
ignore-unfixed: true
59+
exit-code: '1'
60+
61+
- name: Upload Trivy scan results to Security tab
62+
uses: github/codeql-action/upload-sarif@dd903d2e4f5405488e5ef1422510ee31c8b32357 # v3.36.2
63+
if: always()
64+
with:
65+
sarif_file: 'trivy-results.sarif'

.github/workflows/npm-publish.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,23 @@ jobs:
1515
runs-on: ubuntu-latest # Note: Trusted publishing requires GitHub-hosted runners, not self-hosted
1616
steps:
1717
- name: Checkout code
18-
uses: actions/checkout@v4
19-
18+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
19+
2020
- name: Setup Node.js
21-
uses: actions/setup-node@v4
21+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
2222
with:
2323
node-version: '20'
2424
registry-url: 'https://registry.npmjs.org/'
25-
25+
2626
- name: Update npm to latest version
2727
run: npm install -g npm@latest
28-
28+
2929
- name: Install dependencies
3030
run: npm install --ignore-scripts
31-
31+
3232
- name: Build package
3333
run: npm run build
34-
34+
3535
- name: Publish to npm
3636
run: npm publish --access public
3737

@@ -41,10 +41,10 @@ jobs:
4141
needs: build-and-publish
4242
steps:
4343
- name: Checkout code
44-
uses: actions/checkout@v4
44+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
4545

4646
- name: Setup Node.js
47-
uses: actions/setup-node@v4
47+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
4848
with:
4949
node-version: '20'
5050
registry-url: 'https://registry.npmjs.org/'

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,6 @@ jobs:
7373
# Upload the results to GitHub's code scanning dashboard (optional).
7474
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
7575
- name: "Upload to code-scanning"
76-
uses: github/codeql-action/upload-sarif@v3
76+
uses: github/codeql-action/upload-sarif@dd903d2e4f5405488e5ef1422510ee31c8b32357 # v3.36.2
7777
with:
7878
sarif_file: results.sarif

0 commit comments

Comments
 (0)