-
-
Notifications
You must be signed in to change notification settings - Fork 1
120 lines (105 loc) · 4.36 KB
/
Copy pathmcp-docker-build.yml
File metadata and controls
120 lines (105 loc) · 4.36 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
name: Build and Test MCP Server
on:
push:
branches: [ "master" ]
paths:
- 'src/node/**'
- 'src/core/**'
- 'package.json'
- 'package-lock.json'
- 'Dockerfile.mcp'
- '.github/workflows/mcp-docker-build.yml'
pull_request:
branches: [ "master" ]
paths:
- 'src/node/**'
- 'src/core/**'
- 'package.json'
- 'package-lock.json'
- 'Dockerfile.mcp'
- '.github/workflows/mcp-docker-build.yml'
jobs:
build-and-test:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- name: Configure git
run: git config --global init.defaultBranch master
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# =============================================================================
# Build Docker Image for Testing (No Attestations)
# =============================================================================
# Note: This workflow uses `load: true` to load the image into the local
# Docker daemon for testing. Attestations (provenance, SBOM) cannot be
# generated with `load: true` because the local image store doesn't support
# the manifest lists required for attestation attachment.
#
# Attestations are only generated in the mcp-release.yml workflow, which
# pushes to registries (GHCR and Docker Hub) where attestations are supported.
#
# Reference: https://docs.docker.com/build/ci/github-actions/attestations/
# =============================================================================
- name: Build Docker image
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.mcp
push: false
tags: cyberchef-mcp:latest
load: true # Load into local Docker daemon for testing (attestations not supported)
- name: Test MCP Server (List Tools)
run: |
# Run the container detached but interactive
docker run -d -i --name test-mcp cyberchef-mcp:latest
# Send a listTools request and check for "cyberchef_bake" in the output
RESPONSE=$(echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}' | docker exec -i test-mcp node src/node/mcp-server.mjs)
echo "Response: $RESPONSE"
if echo "$RESPONSE" | grep -q "cyberchef_bake"; then
echo "MCP Server is running and responding correctly."
else
echo "MCP Server failed to return expected tools."
exit 1
fi
# Clean up
docker stop test-mcp
docker rm test-mcp
- name: Verify non-root execution
run: |
# Check that the container runs as non-root user (UID 65532 - Chainguard 'nonroot')
# Note: Chainguard distroless has no shell/id command, so we use Node.js process.getuid()
USER_ID=$(docker run --rm --entrypoint node cyberchef-mcp:latest -e "console.log(process.getuid())")
echo "Container user ID: $USER_ID"
if [ "$USER_ID" = "65532" ]; then
echo "Container correctly runs as non-root user (UID 65532 'nonroot')"
else
echo "WARNING: Container is not running as expected user (got $USER_ID, expected 65532)"
exit 1
fi
- name: Run Trivy vulnerability scanner (diagnostic output)
uses: aquasecurity/trivy-action@0.28.0
with:
image-ref: 'cyberchef-mcp:latest'
format: 'table'
severity: 'CRITICAL,HIGH'
vuln-type: 'os,library'
exit-code: '0' # Don't fail - this is diagnostic only
- name: Run Trivy vulnerability scanner (SARIF for code scanning)
uses: aquasecurity/trivy-action@0.28.0
with:
image-ref: 'cyberchef-mcp:latest'
format: 'sarif'
output: 'trivy-results.sarif'
severity: 'CRITICAL,HIGH'
vuln-type: 'os,library'
exit-code: '1' # Fail build on CRITICAL/HIGH vulnerabilities (security hardening)
- name: Upload Trivy scan results
uses: github/codeql-action/upload-sarif@v4
if: always() && hashFiles('trivy-results.sarif') != ''
with:
sarif_file: 'trivy-results.sarif'
category: 'trivy-build-scan'