|
| 1 | +# SPDX-License-Identifier: PMPL-1.0-or-later |
| 2 | +# Cerro-Terro Build Orchestration |
| 3 | +# Coordinates multi-stage builds with security scanning |
| 4 | + |
| 5 | +version: "1.0" |
| 6 | +project: fireflag |
| 7 | +description: "Firefox/Gecko flag management extension" |
| 8 | + |
| 9 | +# Build stages with dependencies |
| 10 | +stages: |
| 11 | + # Stage 1: Security scanning before build |
| 12 | + pre-build-security: |
| 13 | + description: "Run security scans on source code" |
| 14 | + runs-on: ubuntu-latest |
| 15 | + container: cgr.dev/chainguard/wolfi-base:latest |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + run: git clone ${REPO_URL} /src |
| 19 | + |
| 20 | + - name: Svalin static analysis |
| 21 | + run: | |
| 22 | + cd /src |
| 23 | + # Run svalin security scan |
| 24 | + .github/workflows/svalin-scan.yml |
| 25 | +
|
| 26 | + - name: Selur secrets detection |
| 27 | + run: | |
| 28 | + cd /src |
| 29 | + # Run TruffleHog |
| 30 | + docker run --rm -v /src:/src trufflesecurity/trufflehog:latest \ |
| 31 | + filesystem /src --only-verified |
| 32 | +
|
| 33 | + - name: Vordr runtime verification |
| 34 | + run: | |
| 35 | + cd /src |
| 36 | + # Verify extension structure |
| 37 | + web-ext lint /src/extension |
| 38 | +
|
| 39 | + # Stage 2: Build with Guix for reproducibility |
| 40 | + guix-build: |
| 41 | + description: "Build extension in Guix environment" |
| 42 | + depends-on: [pre-build-security] |
| 43 | + runs-on: ubuntu-latest |
| 44 | + container: |
| 45 | + file: .containerization/Containerfile |
| 46 | + stage: builder |
| 47 | + env: |
| 48 | + GUIX_PROFILE: /var/guix/profiles/per-user/build |
| 49 | + steps: |
| 50 | + - name: Activate Guix environment |
| 51 | + run: | |
| 52 | + export PATH="${GUIX_PROFILE}/bin:$PATH" |
| 53 | + guix environment --pure fireflag |
| 54 | +
|
| 55 | + - name: Build ReScript |
| 56 | + run: rescript build |
| 57 | + |
| 58 | + - name: Verify Idris2 proofs |
| 59 | + run: | |
| 60 | + cd extension/lib/idris |
| 61 | + idris2 --check FlagSafety.idr |
| 62 | + idris2 --check FlagTransaction.idr |
| 63 | + idris2 --check SafeUI.idr |
| 64 | +
|
| 65 | + - name: Package extension |
| 66 | + run: | |
| 67 | + cd extension |
| 68 | + web-ext build --overwrite-dest |
| 69 | +
|
| 70 | + - name: Generate checksums |
| 71 | + run: | |
| 72 | + cd extension/web-ext-artifacts |
| 73 | + sha256sum *.xpi > SHA256SUMS |
| 74 | + gpg --detach-sign --armor SHA256SUMS |
| 75 | +
|
| 76 | + artifacts: |
| 77 | + - extension/web-ext-artifacts/*.xpi |
| 78 | + - extension/web-ext-artifacts/SHA256SUMS* |
| 79 | + |
| 80 | + # Stage 3: Post-build security validation |
| 81 | + post-build-security: |
| 82 | + description: "Scan built artifacts for security issues" |
| 83 | + depends-on: [guix-build] |
| 84 | + runs-on: ubuntu-latest |
| 85 | + steps: |
| 86 | + - name: Unpack .xpi |
| 87 | + run: | |
| 88 | + mkdir /tmp/extension |
| 89 | + unzip extension/web-ext-artifacts/*.xpi -d /tmp/extension |
| 90 | +
|
| 91 | + - name: Scan for secrets in build |
| 92 | + run: | |
| 93 | + docker run --rm -v /tmp/extension:/scan \ |
| 94 | + trufflesecurity/trufflehog:latest filesystem /scan |
| 95 | +
|
| 96 | + - name: Verify manifest integrity |
| 97 | + run: | |
| 98 | + jq empty /tmp/extension/manifest.json |
| 99 | + jq '.manifest_version == 3' /tmp/extension/manifest.json |
| 100 | +
|
| 101 | + - name: Check file permissions |
| 102 | + run: | |
| 103 | + # Ensure no executable permissions on source files |
| 104 | + find /tmp/extension -type f -executable -name "*.js" -o -name "*.html" |
| 105 | +
|
| 106 | + # Stage 4: Sign for Mozilla Add-ons |
| 107 | + sign-extension: |
| 108 | + description: "Sign extension for distribution" |
| 109 | + depends-on: [post-build-security] |
| 110 | + runs-on: ubuntu-latest |
| 111 | + secrets: |
| 112 | + - MOZILLA_API_KEY |
| 113 | + - MOZILLA_API_SECRET |
| 114 | + steps: |
| 115 | + - name: Sign with web-ext |
| 116 | + run: | |
| 117 | + web-ext sign \ |
| 118 | + --api-key=${MOZILLA_API_KEY} \ |
| 119 | + --api-secret=${MOZILLA_API_SECRET} \ |
| 120 | + --channel=listed |
| 121 | +
|
| 122 | + artifacts: |
| 123 | + - extension/web-ext-artifacts/*-signed.xpi |
| 124 | + |
| 125 | +# Outputs |
| 126 | +outputs: |
| 127 | + extension: |
| 128 | + description: "Signed Firefox extension" |
| 129 | + path: extension/web-ext-artifacts/*-signed.xpi |
| 130 | + |
| 131 | + checksums: |
| 132 | + description: "SHA256 checksums with GPG signature" |
| 133 | + path: extension/web-ext-artifacts/SHA256SUMS* |
| 134 | + |
| 135 | + provenance: |
| 136 | + description: "SLSA provenance attestation" |
| 137 | + path: extension/web-ext-artifacts/provenance.json |
| 138 | + |
| 139 | +# Build configuration |
| 140 | +config: |
| 141 | + reproducible: true |
| 142 | + slsa-level: 3 |
| 143 | + sbom: true |
| 144 | + sign-commits: true |
| 145 | + verify-signatures: true |
0 commit comments