datahaven/.github/workflows/task-moonwall-tests.yml
Steve Degosserie 746fce9328
security: 🛡️ Harden GitHub Actions workflows (#349)
## 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>
2025-12-12 09:52:50 +00:00

77 lines
2.1 KiB
YAML

name: Moonwall Tests
on:
workflow_dispatch:
workflow_call:
inputs:
binary-hash:
description: "Hash of the built operator binary uploaded as artifact"
required: true
type: string
# Explicit minimal permissions
permissions:
contents: read
actions: write # Required for uploading artifacts
jobs:
moonwall:
runs-on: ubuntu-latest
defaults:
run:
working-directory: test
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Download operator binary artifact
uses: actions/download-artifact@v4
with:
name: datahaven-node-${{ inputs.binary-hash }}
path: operator/target/x86_64-unknown-linux-gnu/release
- name: Prepare operator binary in expected path
run: |
mkdir -p ../operator/target/release
cp ../operator/target/x86_64-unknown-linux-gnu/release/datahaven-node ../operator/target/release/datahaven-node
chmod +x ../operator/target/release/datahaven-node
timeout 20 ../operator/target/release/datahaven-node \
--dev \
--no-telemetry \
--unsafe-force-node-key-generation \
--reserved-only \
--no-grandpa \
--no-prometheus \
--sealing=manual 2>&1 | head -50 || echo "Node startup test completed"
- uses: oven-sh/setup-bun@v2
with:
bun-version-file: test/.bun-version
- uses: actions/setup-node@v4
with:
node-version: 22
- uses: actions/cache@v4
with:
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lock') }}
restore-keys: |
${{ runner.os }}-bun-
- name: Install dependencies
run: bun install
- name: Run Moonwall tests
run: bun run moonwall:test
- name: Upload Moonwall reports
if: always()
uses: actions/upload-artifact@v4
with:
name: moonwall-reports
path: |
test/tmp/testResults.json
test/reports/**
test/**/*.log
retention-days: 1