Skip to content

Commit 3d11fc1

Browse files
authored
Add sast job
1 parent e11e91a commit 3d11fc1

4 files changed

Lines changed: 69 additions & 24 deletions

File tree

.github/workflows/main.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: devsecops-pipeline
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: ["main"]
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
security-events: write
12+
packages: write # útil si luego publicas en GHCR
13+
14+
concurrency:
15+
group: devsecops-${{ github.ref }}
16+
cancel-in-progress: true
17+
18+
env:
19+
# 🔁 Cambia esto para probar cada escenario (apps/10-secrets-leak, 20-sast-bugs, etc.)
20+
APP_DIR: apps/10-secrets-leak
21+
# Parámetros de despliegue local
22+
IMAGE_NAME: demo-app
23+
IMAGE_TAG: local
24+
KIND_CLUSTER: kind-devsecops
25+
SERVICE_RELEASE_NAME: demo
26+
27+
jobs:
28+
# ──────────────────────────────────────────────────────────────────────────────
29+
# Secrets + SAST
30+
# ──────────────────────────────────────────────────────────────────────────────
31+
secrets:
32+
name: Secrets scanning (Gitleaks)
33+
runs-on: self-hosted
34+
steps:
35+
- uses: actions/checkout@v4
36+
with: { fetch-depth: 0 } # para análisis que miran historial
37+
- name: Gitleaks
38+
uses: gitleaks/gitleaks-action@v2
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
# Si usas un gitleaks.toml propio, añade inputs/vars según la acción
42+
43+
sast:
44+
name: SAST (Semgrep)
45+
runs-on: self-hosted
46+
needs: [secrets]
47+
steps:
48+
- uses: actions/checkout@v4
49+
- name: Semgrep (bloqueante)
50+
run: |
51+
docker run --rm -v "$PWD:/src" returntocorp/semgrep:latest \
52+
semgrep scan --config p/ci --config .semgrep
53+
- name: Export SARIF (para pestaña Security)
54+
run: |
55+
docker run --rm -v "$PWD:/src" returntocorp/semgrep:latest \
56+
semgrep scan --config p/ci --config .semgrep --sarif -o semgrep.sarif || true
57+
- uses: github/codeql-action/upload-sarif@v3
58+
with: { sarif_file: semgrep.sarif }

.github/workflows/test-self-hosted-runner.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
actions-runner/

.semgrep

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# .semgrep
2+
rules:
3+
- id: hardcoded-password
4+
pattern: password = "$PASS"
5+
message: "Hardcoded password detected. Use environment variables or a secrets manager instead."
6+
languages: [python]
7+
severity: ERROR
8+
metadata:
9+
cwe: "CWE-798: Use of Hard-coded Credentials"
10+
owasp: "A2: Broken Authentication"

0 commit comments

Comments
 (0)