Skip to content

Autonomous OODA-loop pentesting agent. Hermes brain, Kali + Playwright tools over MCP, ATT&CK as the Orient language.

perf(ci): optimize Trivy Docker scanning

irraz140cbfd84389
diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml
index 674b074..50ff793 100644
--- a/.github/workflows/security.yml
+++ b/.github/workflows/security.yml
@@ -8,6 +8,7 @@ on:
schedule:
# Ejecutar escaneo completo semanalmente (lunes a las 2 AM UTC)
- cron: '0 2 * * 1'
+ workflow_dispatch: # Permitir ejecución manual
jobs:
# ============================================================================
@@ -154,44 +155,58 @@ jobs:
docker-scan:
name: 🐳 Trivy - Escaneo de Imágenes Docker
runs-on: ubuntu-latest
+ # Solo ejecutar en schedule, workflow_dispatch, o PRs (no en push directo)
+ if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request'
+ strategy:
+ matrix:
+ image: [kali, mcp]
steps:
- uses: actions/checkout@v7
- - name: Build Kali image
- run: docker build -t vulnerator-kali:test -f docker/kali/Dockerfile .
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v3
- - name: Run Trivy vulnerability scanner on Kali
- uses: aquasecurity/trivy-action@master
+ - name: Cache Docker layers
+ uses: actions/cache@v4
with:
- image-ref: 'vulnerator-kali:test'
- format: 'sarif'
- output: 'trivy-kali-results.sarif'
- severity: 'CRITICAL,HIGH'
-
- - name: Upload Trivy results to GitHub Security
- uses: github/codeql-action/upload-sarif@v3
- if: always()
+ path: /tmp/.buildx-cache
+ key: ${{ runner.os }}-buildx-${{ matrix.image }}-${{ hashFiles(format('docker/{0}/**', matrix.image)) }}
+ restore-keys: |
+ ${{ runner.os }}-buildx-${{ matrix.image }}-
+ ${{ runner.os }}-buildx-
+
+ - name: Build ${{ matrix.image }} image
+ uses: docker/build-push-action@v6
with:
- sarif_file: 'trivy-kali-results.sarif'
- category: 'trivy-kali'
-
- - name: Build MCP image
- run: docker build -t vulnerator-mcp:test -f docker/mcp/Dockerfile .
-
- - name: Run Trivy vulnerability scanner on MCP
+ context: .
+ file: docker/${{ matrix.image }}/Dockerfile
+ tags: vulnerator-${{ matrix.image }}:test
+ load: true
+ cache-from: type=local,src=/tmp/.buildx-cache
+ cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
+
+ - name: Run Trivy vulnerability scanner on ${{ matrix.image }}
uses: aquasecurity/trivy-action@master
with:
- image-ref: 'vulnerator-mcp:test'
+ image-ref: 'vulnerator-${{ matrix.image }}:test'
format: 'sarif'
- output: 'trivy-mcp-results.sarif'
+ output: 'trivy-${{ matrix.image }}-results.sarif'
severity: 'CRITICAL,HIGH'
+ timeout: '10m'
- name: Upload Trivy results to GitHub Security
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
- sarif_file: 'trivy-mcp-results.sarif'
- category: 'trivy-mcp'
+ sarif_file: 'trivy-${{ matrix.image }}-results.sarif'
+ category: 'trivy-${{ matrix.image }}'
+
+ # Move cache to avoid growing indefinitely
+ - name: Update cache
+ if: always()
+ run: |
+ rm -rf /tmp/.buildx-cache
+ mv /tmp/.buildx-cache-new /tmp/.buildx-cache || true
# ============================================================================
# ESCANEO DE ARCHIVOS DE CONFIGURACIÓN Y SECRETOS