Skip to content

Commit 5b77e0e

Browse files
shahidhkclaude
andauthored
Switch to Ubuntu Noble base image and non root user (#17)
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 11fa372 commit 5b77e0e

File tree

3 files changed

+109
-16
lines changed

3 files changed

+109
-16
lines changed

.github/workflows/ndc-python-lambda-connector.yaml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,55 @@ jobs:
8585
path: ./connector-definition/dist
8686
compression-level: 0 # Already compressed
8787

88+
security-scan:
89+
name: Build and scan Docker image
90+
runs-on: ubuntu-latest
91+
steps:
92+
- uses: actions/checkout@v4
93+
94+
- name: Set up Docker Buildx
95+
uses: docker/setup-buildx-action@v3
96+
97+
- name: Build Docker image
98+
uses: docker/build-push-action@v6
99+
with:
100+
context: .
101+
load: true
102+
tags: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ github.sha }}
103+
104+
- name: Run Trivy vulnerability scanner (json output)
105+
uses: aquasecurity/trivy-action@0.32.0
106+
with:
107+
image-ref: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ github.sha }}
108+
format: json
109+
output: trivy-results.json
110+
scanners: vuln
111+
112+
- name: Upload Trivy scan results to Security Agent
113+
uses: hasura/security-agent-tools/upload-file@v1
114+
with:
115+
file_path: trivy-results.json
116+
security_agent_api_key: ${{ secrets.SECURITY_AGENT_API_KEY }}
117+
tags: |
118+
service=ndc-python-lambda
119+
source_code_path=.
120+
docker_file_path=Dockerfile
121+
scanner=trivy
122+
image_name=${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ github.sha }}
123+
product_domain=hasura-ddn-data-plane,promptql-data-plane
124+
team=engine
125+
126+
- name: Fail build on High/Critical Vulnerabilities
127+
uses: aquasecurity/trivy-action@0.32.0
128+
with:
129+
skip-setup-trivy: true
130+
image-ref: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${{ github.sha }}
131+
format: table
132+
severity: CRITICAL,HIGH
133+
scanners: vuln
134+
ignore-unfixed: true
135+
exit-code: 1
136+
88137
build-and-push-docker:
89138
name: Build and push Docker image
90139
needs: build-connector
@@ -121,6 +170,45 @@ jobs:
121170
tags: ${{ steps.docker-metadata.outputs.tags }}
122171
labels: ${{ steps.docker-metadata.outputs.labels }}
123172

173+
- name: Get image tag for scanning
174+
id: get-image-tag
175+
run: |
176+
IMAGE_TAG="${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE_NAME }}:${GITHUB_REF#refs/tags/}"
177+
echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT
178+
179+
- name: Run Trivy vulnerability scanner (json output)
180+
uses: aquasecurity/trivy-action@0.32.0
181+
with:
182+
image-ref: ${{ steps.get-image-tag.outputs.image_tag }}
183+
format: json
184+
output: trivy-results.json
185+
scanners: vuln
186+
187+
- name: Upload Trivy scan results to Security Agent
188+
uses: hasura/security-agent-tools/upload-file@v1
189+
with:
190+
file_path: trivy-results.json
191+
security_agent_api_key: ${{ secrets.SECURITY_AGENT_API_KEY }}
192+
tags: |
193+
service=ndc-python-lambda
194+
source_code_path=.
195+
docker_file_path=Dockerfile
196+
scanner=trivy
197+
image_name=${{ steps.get-image-tag.outputs.image_tag }}
198+
product_domain=hasura-ddn-data-plane,promptql-data-plane
199+
team=engine
200+
201+
- name: Fail build on High/Critical Vulnerabilities
202+
uses: aquasecurity/trivy-action@0.32.0
203+
with:
204+
skip-setup-trivy: true
205+
image-ref: ${{ steps.get-image-tag.outputs.image_tag }}
206+
format: table
207+
severity: CRITICAL,HIGH
208+
scanners: vuln
209+
ignore-unfixed: true
210+
exit-code: 1
211+
124212
release-connector:
125213
name: Release connector
126214
runs-on: ubuntu-latest

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ This changelog documents the changes between release versions.
66

77
Changes to be included in the next upcoming release
88

9+
## [0.2.7] - 2026.02.04
10+
11+
* Switch to `ubuntu:noble-20260113` base image with Python 3.12
12+
* Run container as non-root user for improved security
13+
914
## [0.2.6] - 2025.12.12
1015

1116
* Use pip 25.3 or greater

Dockerfile

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
1-
FROM python:3.12-slim
1+
FROM ubuntu:noble-20260113
22

3-
RUN python -m pip install --no-cache-dir --upgrade "pip>=25.3"
4-
5-
# Install curl for healthcheck
6-
RUN apt-get update && \
7-
apt-get install -y curl git && \
8-
rm -rf /var/lib/apt/lists/*
9-
10-
# Security updates for CVE-2024-56406 (Perl), CVE-2025-7709 (SQLite)
11-
# Upgrade vulnerable system packages to their fixed versions
3+
# Install Python 3.12 (Ubuntu Noble default), venv, curl, and git
124
RUN apt-get update && \
13-
apt-get upgrade -y \
14-
libperl5.40 \
15-
perl \
16-
perl-modules-5.40 \
17-
perl-base \
18-
libsqlite3-0 && \
5+
apt-get install -y --no-install-recommends \
6+
python3 \
7+
python3-venv \
8+
curl \
9+
git && \
1910
apt-get clean && \
2011
rm -rf /var/lib/apt/lists/*
2112

13+
# Create python symlink for compatibility
14+
RUN ln -sf /usr/bin/python3 /usr/bin/python
15+
2216
COPY /docker /scripts
2317
COPY /functions /functions
2418

@@ -28,6 +22,12 @@ RUN chmod +x /scripts/package-restore.sh /scripts/start.sh
2822
# Run the package-restore script
2923
RUN /scripts/package-restore.sh
3024

25+
# Create non-root user
26+
RUN useradd -m python && \
27+
chown -R python:python /scripts /functions
28+
29+
USER python
30+
3131
EXPOSE 8080
3232

3333
HEALTHCHECK --interval=5s --timeout=10s --start-period=1s --retries=3 \

0 commit comments

Comments
 (0)