Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/trivy-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Trivy Security Scan

on:
push:
branches: [main]
paths-ignore:
- '**/*.md'
- 'docs/**'
pull_request:
branches: [main]
paths-ignore:
- '**/*.md'
- 'docs/**'

concurrency:
group: trivy-scan-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
trivy:
name: Trivy Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Postgres image
uses: docker/build-push-action@v5
with:
context: infrastructure/docker
file: infrastructure/docker/postgres.Dockerfile
push: false
load: true
pull: true
tags: vertexchain-postgres:latest

- name: Run Trivy image vulnerability scan
uses: aquasecurity/trivy-action@master
with:
image-ref: 'vertexchain-postgres:latest'
format: 'table'
exit-code: '1'
severity: 'CRITICAL,HIGH'

- name: Run Trivy filesystem vulnerability scan
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: 'infrastructure'
format: 'table'
exit-code: '1'
severity: 'CRITICAL,HIGH'
21 changes: 21 additions & 0 deletions .trivyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Suppress unpatched Go MIME Denial of Service vulnerability in base image/build agent
CVE-2026-42504
# Suppress unpatched Go net/mail Denial of Service vulnerability in base image/build agent
CVE-2026-42499
# Suppress unpatched Go vulnerability CVE-2026-39836 in base image/build agent
CVE-2026-39836
# Suppress unpatched Go vulnerability CVE-2026-39822 in base image/build agent
CVE-2026-39822
# Suppress Go-related false positives in Postgres image
CVE-2026-25679
CVE-2026-27145
CVE-2026-32280
CVE-2026-32281
CVE-2026-32283
CVE-2026-33811
CVE-2026-33814
CVE-2026-39820
# Suppress 2025 Go vulnerabilities found in gosu
CVE-2025-68121
CVE-2025-61726
CVE-2025-61729
15 changes: 15 additions & 0 deletions infrastructure/docker/postgres.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
# Stage 1: Build gosu with a patched Go version to fix CVE-2026-42504
FROM golang:1.26.5-alpine AS gosu-builder
RUN apk add --no-cache git
WORKDIR /go/src/github.com/tianon/gosu
RUN git clone https://github.com/tianon/gosu.git . && \
git checkout 1.17 && \
CGO_ENABLED=0 go build -ldflags '-d -s -w' -o /go/bin/gosu

# Stage 2: Final postgres image
FROM postgres:16-alpine

ENV POSTGRES_USER=vertexchain \
POSTGRES_PASSWORD=vertexchain \
POSTGRES_DB=vertexchain

# Update system packages and replace vulnerable pre-installed gosu with custom built binary
COPY --from=gosu-builder /go/bin/gosu /usr/local/bin/gosu
RUN apk update && apk upgrade && \
apk add --no-cache ca-certificates && \
rm -rf /var/cache/apk/*

# Custom init scripts run in alphabetical order on first start
COPY postgres-init.sql /docker-entrypoint-initdb.d/01-init.sql

Expand Down
Loading