Skip to content

Commit a53d86d

Browse files
authored
Add job trivy (#5)
1 parent 500d970 commit a53d86d

1 file changed

Lines changed: 70 additions & 3 deletions

File tree

.github/workflows/main.yml

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,78 @@ jobs:
8989
run: |
9090
cd "${APP_DIR}"
9191
docker build -t ${IMAGE_NAME}:${IMAGE_TAG} .
92-
echo ${IMAGE_NAME}
93-
echo ${IMAGE_TAG}
9492
- name: SBOM (Syft)
9593
uses: anchore/sbom-action@v0
9694
with:
9795
image: demo-app:local
9896
artifact-name: sbom.spdx.json # queda como artefacto del job
99-
97+
# ──────────────────────────────────────────────────────────────────────────────
98+
# Trivy + Firma/Verify (cosign)
99+
# ──────────────────────────────────────────────────────────────────────────────
100+
container_scan:
101+
name: Container & deps scan (Trivy)
102+
runs-on: self-hosted
103+
needs: [build]
104+
steps:
105+
# - name: Trivy image (CRITICAL,HIGH)
106+
# uses: aquasecurity/trivy-action@0.28.0
107+
# with:
108+
# scan-type: fs
109+
# image-ref: demo-app:local
110+
# format: sarif
111+
# output: trivy-image.sarif
112+
# ignore-unfixed: true
113+
# severity: CRITICAL,HIGH
114+
# - uses: github/codeql-action/upload-sarif@v3
115+
# with: { sarif_file: trivy-image.sarif }
116+
117+
- name: Trivy fs (SCA sobre el repo)
118+
uses: aquasecurity/trivy-action@0.28.0
119+
with:
120+
scan-type: fs
121+
scan-ref: .
122+
format: sarif
123+
output: trivy-fs.sarif
124+
ignore-unfixed: true
125+
severity: CRITICAL,HIGH
126+
- uses: github/codeql-action/upload-sarif@v3
127+
with: { sarif_file: trivy-fs.sarif }
128+
129+
# sign:
130+
# name: Supply chain gate (cosign sobre SBOM)
131+
# runs-on: self-hosted
132+
# needs: [container_scan]
133+
# env:
134+
# COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
135+
# steps:
136+
# - uses: actions/checkout@v4
137+
# - name: Instalar cosign
138+
# run: |
139+
# COSIGN_URL="https://github.com/sigstore/cosign/releases/latest/download/cosign-linux-amd64"
140+
# curl -sSLf "$COSIGN_URL" -o /usr/local/bin/cosign
141+
# chmod +x /usr/local/bin/cosign
142+
# - name: Generar claves (si no existen)
143+
# run: |
144+
# test -f cosign.key || cosign generate-key-pair
145+
# - name: Descargar SBOM del job anterior
146+
# uses: actions/download-artifact@v4
147+
# with:
148+
# name: sbom.spdx.json
149+
# path: .
150+
# - name: Firmar SBOM (sign-blob)
151+
# run: cosign sign-blob --yes --key cosign.key sbom.spdx.json <<< "$COSIGN_PASSWORD"
152+
# - name: Verificar firma del SBOM (gate)
153+
# run: cosign verify-blob --key cosign.pub --signature sbom.spdx.json.sig sbom.spdx.json
154+
155+
# ── Alternativa (comentada) si publicas la imagen en GHCR y quieres firmar la imagen:
156+
# - name: Login GHCR
157+
# run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
158+
# - name: Push a GHCR
159+
# run: |
160+
# export IMG="ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }}"
161+
# docker tag ${IMAGE_NAME}:${IMAGE_TAG} "$IMG"
162+
# docker push "$IMG"
163+
# - name: Sign imagen en GHCR
164+
# run: cosign sign --yes --key cosign.key "ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }}" <<< "$COSIGN_PASSWORD"
165+
# - name: Verify imagen (gate)
166+
# run: cosign verify --key cosign.pub "ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.sha }}"

0 commit comments

Comments
 (0)