mirror of
https://github.com/datahaven-xyz/datahaven
synced 2026-05-23 17:28:23 +00:00
## Summary This PR addresses several security vulnerabilities and applies hardening measures to the GitHub Actions workflows: - **Replace `secrets: inherit` with explicit secret passing** - Prevents unnecessary exposure of all repository secrets to called workflows - **Add SHA256 checksum verification for downloaded binaries** - Protects against supply chain attacks via compromised upstream releases - **Add GitHub Environment protections for release workflows** - Requires approval before publishing to Docker Hub or creating releases - **Add explicit minimal permissions to all workflows** - Follows principle of least privilege, removes unnecessary `packages: write` from CI.yml ## Changes by Category ### 1. Explicit Secret Passing | Workflow | Before | After | |----------|--------|-------| | CI.yml → docker-build-ci | `secrets: inherit` | No secrets (GITHUB_TOKEN is automatic) | | CI.yml → docker-build-release | `secrets: inherit` | Explicit `DOCKERHUB_USERNAME`, `DOCKERHUB_TOKEN` | | CI.yml → e2e-tests | `secrets: inherit` | No secrets (GITHUB_TOKEN is automatic) | ### 2. Binary Checksum Verification | Workflow | Binary | SHA256 | |----------|--------|--------| | task-rust-lint.yml | taplo 0.8.1 | `c62baa73c9d7c1572...` | | task-e2e.yml | kurtosis 1.11.99 | `5e88e98c1b255362...` | ### 3. Environment Protections | Workflow | Job | Environment | |----------|-----|-------------| | task-docker-release.yml | build-test-push | `production` | | task-publish-binary.yml | publish-draft-release | `releases` | | task-publish-binary.yml | docker-release-candidate | `production` | | task-publish-runtime.yml | publish-draft-release | `releases` | ### 4. Explicit Permissions All 14 workflow files now have explicit `permissions:` blocks with minimal required access. Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Ahmad Kaouk <56095276+ahmadkaouk@users.noreply.github.com>
87 lines
2.7 KiB
YAML
87 lines
2.7 KiB
YAML
# Build Operator: CI for building the operator binary
|
|
|
|
name: DataHaven Operator Binary Build
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
workflow_call:
|
|
outputs:
|
|
binary-hash:
|
|
description: "The hash of the operator binary"
|
|
value: ${{ jobs.build-node.outputs.binary-hash }}
|
|
|
|
# Explicit minimal permissions
|
|
permissions:
|
|
contents: read
|
|
actions: write # Required for uploading artifacts
|
|
|
|
jobs:
|
|
build-node:
|
|
outputs:
|
|
binary-hash: ${{ steps.hash-binary.outputs.datahaven-node-hash }}
|
|
name: Build operator binary
|
|
runs-on:
|
|
group: DH-runners
|
|
env:
|
|
RUSTC_WRAPPER: "sccache"
|
|
CARGO_INCREMENTAL: "0"
|
|
CARGO_TERM_COLOR: always
|
|
SCCACHE_GHA_ENABLED: "true"
|
|
defaults:
|
|
run:
|
|
working-directory: ./operator
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
submodules: recursive
|
|
fetch-depth: 1
|
|
|
|
# Re-enable if you get GH issues with the runner being full
|
|
# - uses: ./.github/workflows/actions/cleanup-runner
|
|
|
|
- uses: ./.github/workflows/actions/setup-env
|
|
with:
|
|
cache-key: BUILD-RELEASE
|
|
install-deps: false
|
|
|
|
- name: Set build flags
|
|
run: echo "RUSTFLAGS=${{ env.RUSTFLAGS }} -C linker=clang -C link-arg=-fuse-ld=mold" >> $GITHUB_ENV
|
|
|
|
- name: Build node binary
|
|
run: |
|
|
cargo build --release --locked --features fast-runtime
|
|
|
|
- name: Prepare binary
|
|
run: |
|
|
mkdir -p ./target/ci
|
|
mkdir -p ../build
|
|
cp ./target/release/datahaven-node ./target/ci/datahaven-node
|
|
cp ./target/release/datahaven-node ../build/datahaven-node
|
|
|
|
- name: Hash binary
|
|
id: hash-binary
|
|
run: |
|
|
TIMESTAMP=$(date +%s)
|
|
BINARY_PATH=./target/ci/datahaven-node
|
|
HASH=$(echo "$TIMESTAMP" | cat - $BINARY_PATH | sha256sum | awk '{ print $1 }')
|
|
echo "datahaven-node-hash=$HASH" >> $GITHUB_OUTPUT
|
|
echo "Hash of the datahaven-node is: $HASH (with timestamp: $TIMESTAMP)"
|
|
|
|
- name: Upload binary to workflow
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: datahaven-node-${{ steps.hash-binary.outputs.datahaven-node-hash }}
|
|
path: build/datahaven-node
|
|
retention-days: 1
|
|
|
|
- name: Upload WASM to workflow
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: datahaven-wasm-${{ steps.hash-binary.outputs.datahaven-node-hash }}
|
|
path: operator/target/release/wbuild/datahaven-stagenet-runtime/datahaven_stagenet_runtime.wasm
|
|
retention-days: 1
|
|
|
|
- name: Build Stats
|
|
run: |
|
|
sccache --show-stats
|
|
echo "Binary size: $(du -h ./target/ci/datahaven-node | cut -f1)"
|