-
Notifications
You must be signed in to change notification settings - Fork 627
90 lines (79 loc) · 2.58 KB
/
docker-scan.yml
File metadata and controls
90 lines (79 loc) · 2.58 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
# ===============================================================
# Docker Security Scan Workflow
# ===============================================================
#
# This workflow builds the container image locally and generates an SBOM
# artifact for review:
# 1. Build image locally (no push required)
# 2. Generate SBOM with Syft
# 3. Upload SBOM artifact
#
# Runs on both PRs and pushes to catch issues early.
#
# ===============================================================
name: Docker Security Scan
on:
push:
branches: ["main"]
paths:
- 'Containerfile.lite'
- 'mcpgateway/**'
- 'plugins/**'
- 'pyproject.toml'
- '.github/workflows/docker-scan.yml'
pull_request:
types: [opened, synchronize, ready_for_review]
branches: ["main"]
paths:
- 'Containerfile.lite'
- 'mcpgateway/**'
- 'plugins/**'
- 'pyproject.toml'
- '.github/workflows/docker-scan.yml'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
IMAGE_NAME: mcp-context-forge-scan
jobs:
# ---------------------------------------------------------------
# Build image and generate SBOM
# ---------------------------------------------------------------
scan:
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
name: Security Scan
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
with:
persist-credentials: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
- name: Build image locally
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
with:
context: .
file: Containerfile.lite
platforms: linux/amd64
push: false
load: true
tags: ${{ env.IMAGE_NAME }}:scan
cache-from: type=gha,scope=scan-build-amd64
cache-to: type=gha,mode=max,scope=scan-build-amd64
- name: Generate SBOM (Syft)
uses: anchore/sbom-action@e22c389904149dbc22b58101806040fa8d37a610 # v0
with:
image: ${{ env.IMAGE_NAME }}:scan
output-file: sbom.spdx.json
upload-artifact: false
- name: Upload SBOM
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: sbom
path: sbom.spdx.json
retention-days: 30