|
| 1 | +# Secure-by-Default Starter: Architecture Overview |
| 2 | + |
| 3 | +This document describes the architecture, controls, and evidence flow of the Secure-by-Default Starter. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Legend & Assumptions |
| 8 | + |
| 9 | +**Legend** |
| 10 | +- Solid arrow: normal flow |
| 11 | +- Dashed arrow: visibility/evidence |
| 12 | +- 🔒 = security control |
| 13 | +- 📦 = artifact |
| 14 | + |
| 15 | +**Assumptions** |
| 16 | +- GitHub Actions runners (ubuntu-latest) |
| 17 | +- Docker available for local parity (`make scan`, `make sbom`) |
| 18 | +- No GitHub Advanced Security required (works on Free); complements it if enabled |
| 19 | + |
| 20 | +--- |
| 21 | + |
| 22 | +## Flow Overview |
| 23 | + |
| 24 | +```mermaid |
| 25 | +flowchart TD |
| 26 | + Dev[Developer Laptop] -->|git push| Repo[(GitHub Repo)] |
| 27 | + Repo -->|CI Trigger| Actions[GitHub Actions] |
| 28 | + Actions -->|Trivy fs scan| TrivyScanner[Trivy 🔒] |
| 29 | + Actions -->|Generate SBOM| SBOM[SPDX 📦] |
| 30 | + Actions -->|Upload SARIF| SARIF[Code Scanning Alerts 📦] |
| 31 | + Repo -.->|Branch Protection| PR[Pull Request Checks 🔒] |
| 32 | + SBOM -->|Artifact| GHArtifacts[GitHub Artifacts 📦] |
| 33 | +``` |
| 34 | + |
| 35 | +--- |
| 36 | + |
| 37 | +## Sequence View |
| 38 | + |
| 39 | +```mermaid |
| 40 | +sequenceDiagram |
| 41 | + autonumber |
| 42 | + participant Dev as Developer |
| 43 | + participant Repo as GitHub Repo |
| 44 | + participant CI as GitHub Actions |
| 45 | + participant Trivy as Trivy Scanner |
| 46 | + participant GHSec as Code Scanning (SARIF) |
| 47 | + participant Art as Artifacts (SBOM) |
| 48 | +
|
| 49 | + Dev->>Dev: pre-commit (🔒 Gitleaks) blocks secrets |
| 50 | + Dev->>Repo: push branch / open PR |
| 51 | + Repo-->>CI: trigger security workflow |
| 52 | + CI->>Trivy: fs scan (vuln + IaC) with HIGH/CRIT gate |
| 53 | + Trivy-->>CI: results (exit-code 0/1) |
| 54 | + CI->>GHSec: upload SARIF (📦 evidence) |
| 55 | + CI->>Art: publish sbom.spdx.json (📦 evidence) |
| 56 | + CI-->>Repo: status checks (pass/fail gate) |
| 57 | +``` |
| 58 | + |
| 59 | +--- |
| 60 | + |
| 61 | +## Components & Responsibilities |
| 62 | + |
| 63 | +| Component | Responsibility | Evidence Produced | |
| 64 | +|---|---|---| |
| 65 | +| Pre-commit (Gitleaks) 🔒 | Stop hardcoded secrets before push | Local terminal output; blocked commit | |
| 66 | +| Trivy (CI) 🔒 | Vulnerability + IaC misconfig scan; fail on HIGH/CRIT | SARIF uploaded to Code scanning | |
| 67 | +| SBOM step 📦 | Generate SPDX JSON of repo dependencies/assets | `sbom.spdx.json` artifact in Actions | |
| 68 | +| Branch Protection 🔒 | Enforce PR review & passing checks | Protected branch status | |
| 69 | +| Dependabot | Open dependency update PRs | PRs labeled `dependencies` | |
| 70 | +| OpenSSF Scorecard | External hygiene signal | Public score/badge | |
| 71 | +| Trust Page | Single place to find status & evidence | `docs/trust-page.md` | |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +## Threat Model (Starter) |
| 76 | + |
| 77 | +**Assets** |
| 78 | +- Source code (confidentiality/integrity) |
| 79 | +- SBOM + SARIF artifacts (integrity) |
| 80 | +- Secret material (must never enter repo) |
| 81 | + |
| 82 | +**Key Risks & Controls** |
| 83 | +- Secret leakage → 🔒 pre-commit Gitleaks blocks locally |
| 84 | +- Vulnerabilities / misconfigs → 🔒 Trivy CI gate on HIGH/CRIT |
| 85 | +- Unreviewed/unsafe merges → 🔒 Branch protection + required checks |
| 86 | +- Supply-chain drift → Dependabot weekly updates; SBOM per run |
| 87 | +- Lack of evidence for auditors → SARIF in Code scanning + SPDX artifact + Trust page |
| 88 | + |
| 89 | +--- |
| 90 | + |
| 91 | +## Evidence Retention & Privacy |
| 92 | + |
| 93 | +- **Artifacts**: `sbom.spdx.json` retained per Actions retention policy (repo setting). |
| 94 | +- **SARIF alerts**: stored in GitHub Security → Code scanning. |
| 95 | +- **No secrets**: baseline prevents secrets from entering history; rotate immediately if detected locally. |
| 96 | + |
| 97 | +--- |
| 98 | + |
| 99 | +## Extensibility |
| 100 | + |
| 101 | +- **Supply chain**: Cosign/SLSA attestations → after SBOM step. |
| 102 | +- **Kubernetes policy**: Kyverno/Conftest → additional CI job; optional PR annotations. |
| 103 | +- **AI/LLM repos**: add model/package scanners (e.g., known-bad weights/licenses) → new job, same gating model. |
| 104 | +- **GitHub Advanced Security**: enable Push Protection, CodeQL → complements Trivy; keep both. |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +## Controls Matrix (Quick Map) |
| 109 | + |
| 110 | +| Risk | Control | Where | |
| 111 | +|---|---|---| |
| 112 | +| Secrets in commits | 🔒 Gitleaks pre-commit | Developer laptop | |
| 113 | +| Critical CVEs | 🔒 Trivy gate HIGH/CRIT | CI | |
| 114 | +| IaC misconfig | 🔒 Trivy config scanner | CI | |
| 115 | +| Unknown assets | 📦 SPDX SBOM per run | CI Artifacts | |
| 116 | +| Unreviewed merge | 🔒 Branch protection | Repo settings | |
| 117 | +| Stale deps | Dependabot weekly PRs | GitHub PRs | |
0 commit comments