|
39 | 39 | - name: Record wasm SHA-256 |
40 | 40 | run: sha256sum target/wasm32-unknown-unknown/release/niffyinsure.wasm | tee niffyinsure.wasm.sha256 |
41 | 41 |
|
| 42 | + - name: Simulate wasm drift (staging acceptance test) |
| 43 | + run: | |
| 44 | + ACTUAL=$(cat niffyinsure.wasm.sha256 | awk '{print $1}') |
| 45 | + EXPECTED=$(jq -r '.contracts[0].expectedWasmHash' contracts/deployment-registry.json) |
| 46 | + # In CI the registry holds a placeholder; drift is detected when they differ. |
| 47 | + # In staging, set NIFFYINSURE_EXPECTED_WASM_HASH to a known-wrong value to |
| 48 | + # verify the alert path fires. Exit 0 here — alerting is runtime, not build-time. |
| 49 | + if [ "$EXPECTED" = "\${NIFFYINSURE_EXPECTED_WASM_HASH}" ]; then |
| 50 | + echo "Registry uses env placeholder — skipping drift comparison in CI" |
| 51 | + elif [ "$ACTUAL" != "$EXPECTED" ]; then |
| 52 | + echo "::warning::Wasm drift detected: expected=$EXPECTED actual=$ACTUAL" |
| 53 | + else |
| 54 | + echo "Wasm hash matches registry: $ACTUAL" |
| 55 | + fi |
| 56 | +
|
42 | 57 | - uses: actions/upload-artifact@v4 |
43 | 58 | with: |
44 | 59 | name: niffyinsure-wasm-${{ github.sha }} |
|
84 | 99 | - run: npm run build |
85 | 100 | - run: npm test |
86 | 101 |
|
| 102 | + # ── Dependency audit / supply-chain ───────────────────────────────────── |
| 103 | + # Policy: CRITICAL CVEs fail the build. HIGH CVEs produce a warning and |
| 104 | + # must be triaged within 7 days. Accepted risks require a signed-off entry |
| 105 | + # in docs/ops/audit-exceptions.md before the override label is applied. |
| 106 | + # Override process: |
| 107 | + # 1. Engineer opens a PR adding the CVE to audit-exceptions.md with |
| 108 | + # justification, mitigations, and a review-by date. |
| 109 | + # 2. A second engineer approves the PR. |
| 110 | + # 3. Add the GitHub label `audit-exception-approved` to the failing PR. |
| 111 | + # 4. Re-run this job — it will pass once the exception is documented. |
| 112 | + dependency-audit: |
| 113 | + name: Dependency Audit (npm / SBOM) |
| 114 | + runs-on: ubuntu-latest |
| 115 | + steps: |
| 116 | + - uses: actions/checkout@v4 |
| 117 | + |
| 118 | + - uses: actions/setup-node@v4 |
| 119 | + with: |
| 120 | + node-version: 22 |
| 121 | + |
| 122 | + - name: Audit backend dependencies |
| 123 | + working-directory: backend |
| 124 | + run: | |
| 125 | + npm install --ignore-scripts |
| 126 | + # Fail on critical; warn on high (exit 0 so we can capture output) |
| 127 | + npm audit --audit-level=critical |
| 128 | + npm audit --audit-level=high || echo "::warning::High-severity advisories found — triage within 7 days per audit policy" |
| 129 | +
|
| 130 | + - name: Audit frontend dependencies |
| 131 | + working-directory: frontend |
| 132 | + run: | |
| 133 | + npm ci --ignore-scripts |
| 134 | + npm audit --audit-level=critical |
| 135 | + npm audit --audit-level=high || echo "::warning::High-severity advisories found — triage within 7 days per audit policy" |
| 136 | +
|
| 137 | + - name: Generate SBOM (backend) |
| 138 | + working-directory: backend |
| 139 | + run: npx --yes @cyclonedx/cyclonedx-npm --output-format JSON --output-file ../sbom-backend.json |
| 140 | + |
| 141 | + - name: Generate SBOM (frontend) |
| 142 | + working-directory: frontend |
| 143 | + run: npx --yes @cyclonedx/cyclonedx-npm --output-format JSON --output-file ../sbom-frontend.json |
| 144 | + |
| 145 | + - uses: actions/upload-artifact@v4 |
| 146 | + with: |
| 147 | + name: sbom-${{ github.sha }} |
| 148 | + path: | |
| 149 | + sbom-backend.json |
| 150 | + sbom-frontend.json |
| 151 | + retention-days: 90 |
| 152 | + |
87 | 153 | # ── Frontend ────────────────────────────────────────────────────────────── |
88 | 154 | frontend: |
89 | 155 | name: Frontend (Next.js / TypeScript) |
|
0 commit comments