Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/opensecret-eif.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,61 @@ jobs:
changes:
uses: ./.github/workflows/opensecret-change-detection.yml

eif-candidate:
name: EIF candidate build (PR, ${{ matrix.mode }})
needs: changes
# Build measured-input changes before merge without requiring or changing
# PCR approvals. Only same-repository PRs may use the trusted cache.
if: >-
${{
always() && !cancelled() &&
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository &&
needs.changes.result == 'success' &&
needs.changes.outputs.eif == 'true' &&
needs.changes.outputs.pcr_approvals == 'false'
}}
permissions:
contents: read
id-token: write
runs-on: ubuntu-24.04-arm64-8core
timeout-minutes: 180
strategy:
fail-fast: false
matrix:
mode: [dev, prod]
env:
EIF_MODE: ${{ matrix.mode }}
OPENSECRET_DEV_POSTGRES: "0"
OPENSECRET_DEV_ENV: "0"
OPENSECRET_DEV_CONTAINERS: "0"
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false
submodules: recursive
fetch-depth: 0

- name: Install pinned Determinate Nix for FlakeHub authentication
uses: DeterminateSystems/nix-installer-action@ef8a148080ab6020fd15196c2084a2eea5ff2d25 # v22
with:
determinate: true
github-token: ""

- name: Reuse FlakeHub and warm the branch-scoped GitHub cache
uses: DeterminateSystems/flakehub-cache-action@1f9a51a2959d3e26c7838c6f3bf9f48acae525ea # v3
with:
use-gha-cache: enabled
diff-store: true

# No Actions artifact, attestation, signing, or release is produced here.
# The Nix cache is only a build cache, not an approved deployment handoff.
- name: Build PR candidate without signing or publication
shell: bash
run: |
echo 'PR diagnostic only: source_sha is the PR merge ref, not a release source commit. No approved artifact is uploaded.' >> "$GITHUB_STEP_SUMMARY"
bash scripts/ci/build_opensecret_eif.sh "$EIF_MODE" "$RUNNER_TEMP/eif-candidate-$EIF_MODE"

eif:
name: EIF/PCR approval match (${{ matrix.mode }})
needs: changes
Expand Down
12 changes: 7 additions & 5 deletions docs/repository-workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ its table-driven tests when the dependency graph or component layout changes.
The backend has its own root `opensecret-ci.yml` workflow and change selector;
`sdk-integration.yml` tests both SDKs against `services/opensecret/` from the
same checkout. Backend changes do not imply Research or Agent packaging.
The separate `opensecret-eif.yml` compares dev/prod EIF measurements only on PRs
editing approved PCR JSON, relevant master changes, and manual runs. Preserve
ordinary backend PRs without fresh approvals and meaningful master mismatches;
these checks never change approvals, sign, release, or authorize deployment.
Master and same-repository PR EIF checks receive OIDC for FlakeHub caching.
The separate `opensecret-eif.yml` builds dev/prod EIF candidates on
same-repository PRs changing measured inputs without editing PCR approvals;
these diagnostic builds do not publish an artifact. It compares measurements
on PRs editing approved PCR JSON, relevant master changes, and manual runs.
Preserve ordinary backend PRs without fresh approvals and meaningful master
mismatches; these checks never change approvals, sign, release, or authorize
deployment. Master and same-repository PR EIF builds receive OIDC for FlakeHub caching.
Fork PRs and non-master manual runs use GitHub's branch-scoped cache without
OIDC. Preserve that head-repository boundary and verify cache changes on fresh
hosted runners, not just a warm local Nix store. See the [cache policy](../services/opensecret/docs/nitro-deploy.md#binary-caches-and-cold-run-validation).
Expand Down
1 change: 1 addition & 0 deletions scripts/ci/opensecret_change_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
})
EIF_CI_INPUTS = frozenset({
".github/workflows/opensecret-eif.yml",
"scripts/ci/build_opensecret_eif.sh",
"scripts/ci/check_opensecret_eif.sh",
})
# Shell test inputs consumed directly by the component flake, not Cargo.
Expand Down
5 changes: 3 additions & 2 deletions scripts/ci/test_opensecret_change_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ def test_submodules_and_selector_changes_select_all_backend_checks(self):
self.assert_routes([".github/workflows/opensecret-ci.yml"], "rust", "nix", "audit", "eif", "helpers")
self.assert_routes([".github/workflows/sdk-integration.yml"], "integration")

def test_eif_workflow_and_comparison_helper_select_only_master_eif_checks(self):
for path in (".github/workflows/opensecret-eif.yml", "scripts/ci/check_opensecret_eif.sh"):
def test_eif_workflow_and_build_helpers_select_only_eif_checks(self):
for path in (".github/workflows/opensecret-eif.yml", "scripts/ci/build_opensecret_eif.sh",
"scripts/ci/check_opensecret_eif.sh"):
self.assert_routes([path], "eif")
self.assertEqual(research_routes(path), frozenset())
self.assertFalse(affects_agent(path))
Expand Down
41 changes: 32 additions & 9 deletions scripts/ci/test_opensecret_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@


ROOT = Path(__file__).resolve().parents[2]
PR_CANDIDATE_BUILD = (
"echo 'PR diagnostic only: source_sha is the PR merge ref, not a release source commit. "
"No approved artifact is uploaded.' >> \"$GITHUB_STEP_SUMMARY\"\n"
'bash scripts/ci/build_opensecret_eif.sh "$EIF_MODE" '
'"$RUNNER_TEMP/eif-candidate-$EIF_MODE"\n'
)


@functools.cache
Expand Down Expand Up @@ -46,7 +52,7 @@ def test_nix_jobs_fetch_complete_backend_and_submodule_history(self):
# fetcher cannot calculate revCount for a shallow recursive input.
for workflow_name, job_names in (
("opensecret-ci.yml", ("rust", "nix")),
("opensecret-eif.yml", ("eif", "eif-trusted")),
("opensecret-eif.yml", ("eif-candidate", "eif", "eif-trusted")),
("sdk-integration.yml", ("sdk-integration",)),
):
for job_name in job_names:
Expand All @@ -70,7 +76,7 @@ def test_jobs_are_hosted_with_read_only_contents_and_scoped_oidc(self):
self.assertNotRegex(value, r"\bsecrets\b|github\.token|\bGH_TOKEN\b")
for job_name, job in config["jobs"].items():
self.assertNotIn("environment", job)
if (name, job_name) == ("opensecret-eif.yml", "eif-trusted"):
if name == "opensecret-eif.yml" and job_name in ("eif-candidate", "eif-trusted"):
self.assertEqual(job["permissions"], {"contents": "read", "id-token": "write"})
else:
self.assertIn(job.get("permissions"), (None, {"contents": "read"}))
Expand All @@ -83,6 +89,7 @@ def test_jobs_are_hosted_with_read_only_contents_and_scoped_oidc(self):
expected_runner = "ubuntu-latest"
if name == "opensecret-eif.yml":
expected_runner = {
"eif-candidate": "ubuntu-24.04-arm64-8core",
"eif": "ubuntu-24.04-arm",
"eif-trusted": "ubuntu-24.04-arm64-8core",
}[job_name]
Expand Down Expand Up @@ -133,21 +140,27 @@ def test_eif_workflow_preserves_approvals_and_keeps_both_environments_independen
self.assertNotIn("paths", config["on"][event])
self.assertEqual(config["concurrency"]["group"],
"opensecret-eif-${{ github.event_name }}-${{ github.ref }}")
self.assertEqual(set(config["jobs"]), {"changes", "eif", "eif-trusted"})
for job_name in ("eif", "eif-trusted"):
self.assertEqual(set(config["jobs"]), {"changes", "eif-candidate", "eif", "eif-trusted"})
for job_name in ("eif-candidate", "eif", "eif-trusted"):
job = config["jobs"][job_name]
self.assertEqual(job["needs"], "changes")
self.assertEqual(job["strategy"]["matrix"], {"mode": ["dev", "prod"]})
self.assertIs(job["strategy"]["fail-fast"], False)
self.assertEqual(job["env"]["EIF_MODE"], "${{ matrix.mode }}")
self.assertEqual(job["timeout-minutes"], 180 if job_name == "eif-trusted" else 90)
self.assertEqual(job["timeout-minutes"], 90 if job_name == "eif" else 180)
for key in ("OPENSECRET_DEV_POSTGRES", "OPENSECRET_DEV_ENV", "OPENSECRET_DEV_CONTAINERS"):
self.assertEqual(job["env"][key], "0")
commands = [step["run"] for step in job["steps"] if "run" in step]
self.assertEqual(commands, ['bash scripts/ci/check_opensecret_eif.sh "$EIF_MODE"'])
expected_command = PR_CANDIDATE_BUILD if job_name == "eif-candidate" else (
'bash scripts/ci/check_opensecret_eif.sh "$EIF_MODE"')
self.assertEqual(commands, [expected_command])
for value in strings(config["jobs"]):
self.assertNotRegex(value, r"deploy-|stage-|scp-|update-pcr|append-pcr|generate-keys")
self.assertNotRegex(value, r"upload-artifact|download-artifact|gh release")
candidate = config["jobs"]["eif-candidate"]
self.assertNotIn("environment", candidate)
self.assertNotIn("outputs", candidate)
self.assertNotIn("continue-on-error", candidate["steps"][-1])

def test_eif_cache_setup_precedes_build_and_warms_fork_compatible_cache(self):
jobs = workflow("opensecret-eif.yml")["jobs"]
Expand All @@ -162,6 +175,10 @@ def test_eif_cache_setup_precedes_build_and_warms_fork_compatible_cache(self):
"use-gha-cache": "enabled",
"diff-store": True,
}, True),
("eif-candidate", "DeterminateSystems/flakehub-cache-action@1f9a51a2959d3e26c7838c6f3bf9f48acae525ea", {
"use-gha-cache": "enabled",
"diff-store": True,
}, True),
):
with self.subTest(job=job_name):
steps = jobs[job_name]["steps"]
Expand All @@ -173,13 +190,15 @@ def test_eif_cache_setup_precedes_build_and_warms_fork_compatible_cache(self):
self.assertEqual(steps[2]["with"], cache_inputs)
self.assertNotIn("if", steps[2])
self.assertNotIn("continue-on-error", steps[2])
self.assertEqual(steps[3]["run"], 'bash scripts/ci/check_opensecret_eif.sh "$EIF_MODE"')
expected_command = PR_CANDIDATE_BUILD if job_name == "eif-candidate" else (
'bash scripts/ci/check_opensecret_eif.sh "$EIF_MODE"')
self.assertEqual(steps[3]["run"], expected_command)

def test_eif_event_gate_matches_the_approval_policy(self):
# Exercise the actual GitHub boolean expression with a restricted,
# equivalent local representation, not a separately implemented policy.
expressions = {}
for job_name in ("eif", "eif-trusted"):
for job_name in ("eif-candidate", "eif", "eif-trusted"):
expression = workflow("opensecret-eif.yml")["jobs"][job_name]["if"]
expression = expression.strip().removeprefix("${{").removesuffix("}}").strip()
expression = expression.replace("&&", " and ").replace("||", " or ")
Expand Down Expand Up @@ -243,7 +262,11 @@ def test_eif_event_gate_matches_the_approval_policy(self):
condition = condition.replace(key, repr(value))
if eval(condition, {"__builtins__": {}}, {}):
selected.append(job_name)
expected_jobs = ["eif-trusted" if trusted else "eif"] if expected and not cancelled else []
expected_jobs = []
if not cancelled and event == "pull_request" and same_repo and result == "success" and eif == "true" and approvals == "false":
expected_jobs.append("eif-candidate")
if expected and not cancelled:
expected_jobs.append("eif-trusted" if trusted else "eif")
self.assertEqual(selected, expected_jobs)

def test_backend_retains_exact_rust_gates_and_disabled_stateful_shell_hooks(self):
Expand Down
17 changes: 10 additions & 7 deletions services/opensecret/docs/nitro-deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ artifact's `pcr.json`; the deployment verifier rejects anything else.

## CI approval checks

`opensecret-eif.yml` compares generated measurements with the approved JSON
files on Linux ARM64. A PR runs these comparisons only if its own diff edits
`opensecret-eif.yml` builds dev/prod EIF candidates on Linux ARM64 for
same-repository PRs that change measured inputs without editing PCR approvals.
This diagnostic path does not publish an artifact or require an approval match. A PR
runs approval comparisons only if its own diff edits
`pcrDev.json`, `pcrProd.json`, `pcrDevHistory.json`, or `pcrProdHistory.json`
under `services/opensecret/`. Backend code changes alone do not require new
approvals to pass PR CI. The PR's checkout supplies both source and references.
Expand All @@ -99,11 +101,12 @@ rather than writing to `master`.

### Binary caches and cold-run validation

Master push/manual runs and same-repository PR comparisons use the trusted EIF
job, which installs Determinate Nix and uses FlakeHub Cache with job-scoped
`id-token: write`. A PR qualifies only when its head repository's full name
equals `github.repository` and the successful selector reports an approval
JSON edit. This intentionally trusts same-repository PR code to write the
Master push/manual runs and same-repository PR candidate or approval jobs use
the trusted EIF cache setup, which installs Determinate Nix and uses FlakeHub
Cache with job-scoped `id-token: write`. A PR qualifies only when its head
repository's full name equals `github.repository` and the successful selector
reports an EIF input or approval JSON edit, as routed to the respective job.
This intentionally trusts same-repository PR code to write the
FlakeHub cache; it does not grant signing or deployment authority.
Trusted jobs use the organization-configured GitHub-hosted runner
`ubuntu-24.04-arm64-8core` (Ubuntu 24.04 ARM64, 8 CPU, 32 GB RAM) and allow
Expand Down
16 changes: 13 additions & 3 deletions services/opensecret/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@
inherit (kernelUpstream) url hash;
};
kernelStructuredExtraConfig = with pkgs.lib.kernel; {
# Linux 6.12.112 backports the memory-hotplug online-policy choice,
# while this Nixpkgs pin still selects the removed pre-6.14 option.
# Preserve automatic onlining without relaxing config validation.
MEMORY_HOTPLUG_DEFAULT_ONLINE = pkgs.lib.mkForce unset;
MHP_DEFAULT_ONLINE_TYPE_ONLINE_AUTO = yes;
VIRTIO = yes;
VIRTIO_MMIO = yes;
VIRTIO_MENU = yes;
Expand Down Expand Up @@ -347,9 +352,9 @@
tar -xOf ${kernelSource} \
linux-${kernelUpstream.version}/drivers/misc/nsm.c > nsm.c

# 6.12.101 must carry both reviewed NSM fixes: malformed userspace
# pointers return before the mutex is touched, and file operations
# retain module ownership.
# Require both reviewed NSM fixes: malformed userspace pointers
# return before the mutex is touched, and file operations retain
# module ownership.
ioctl_source="$(sed -n \
'/static long nsm_dev_ioctl/,/static int nsm_device_init_vq/p' \
nsm.c)"
Expand All @@ -374,6 +379,10 @@
printf '%s\n' "$fops_source" | grep -Fq '.owner = THIS_MODULE,'
printf '%s\n' "$fops_source" | grep -Fq '.unlocked_ioctl = nsm_dev_ioctl,'

# Bound the NSM device-reported response length before it can be
# copied back to userspace (CVE-2026-89743, fixed in 6.12.109).
grep -Fq 'msg->resp.len = min_t(unsigned int, len, sizeof(msg->resp.data));' nsm.c

{
echo 'branch=${kernelUpstream.branch}'
echo 'version=${kernelUpstream.version}'
Expand All @@ -399,6 +408,7 @@
grep -Fqx 'CONFIG_VIRTIO_VSOCKETS=y' "$config"
grep -Fqx 'CONFIG_HW_RANDOM=y' "$config"
grep -Fqx 'CONFIG_NSM=y' "$config"
grep -Fqx 'CONFIG_MHP_DEFAULT_ONLINE_TYPE_ONLINE_AUTO=y' "$config"
grep -Fqx '# CONFIG_CRYPTO_USER_API_AEAD is not set' "$config"

{
Expand Down
6 changes: 3 additions & 3 deletions services/opensecret/nix/kernel-upstream.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# fields together after reviewing the upstream 6.12 LTS changelog.
{
branch = "6.12";
version = "6.12.101";
url = "https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.12.101.tar.xz";
hash = "sha256-DSHNEZM/SfcVG3ydu4zD/dyMir5QZDS4UP7s9B/CinY=";
version = "6.12.112";
url = "https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.12.112.tar.xz";
hash = "sha256-Fk3J0fbJPGGhXh8HHEg3m0Z/KxfEacznIjRxloII7QM=";
}
Loading