nightly-tests: read quoted flow keys, and state the signer-environment prerequisite

The trust-closure flow-mapping reader split its masked copy, so a quoted key (`{"environment":
release}`, `{'uses': ...}`) became `''` and the scan accepted a route it must refuse. It now splits
the original bracket-free mapping and keeps the mask only for the shape check. New cases cover a
double- and single-quoted `environment` key, a quoted `uses` key, and a harmless quoted key that
must still be read rather than masked.

The activation notes and the signer caller said the `release` environment already trusts
`nightly-signer`. It admits only `release` today, so both now state that the environment must
admit `nightly-signer` before the first dispatch.
This commit is contained in:
skylartaylor
2026-11-26 03:02:44 +01:00
parent a44003437e
commit 1872d0e52f
3 changed files with 27 additions and 13 deletions
+2 -2
View File
@@ -41,5 +41,5 @@ jobs:
producer_run_id: ${{ inputs.producer_run_id }}
producer_run_attempt: ${{ inputs.producer_run_attempt }}
# No secrets: inherit or raw platform values in this caller. Only the isolated native
# callee job may bind the existing release environment (which trusts release and
# nightly-signer) and export keys in its signing step.
# callee job may bind the release environment and export its keys; that environment must
# admit nightly-signer alongside release before the first dispatch.
+9 -7
View File
@@ -38,14 +38,16 @@ branch, so nightly signer files never need a stable release sync. The policy's `
names it and the signer's guard requires it; this app has no automatic dispatch transport, so
nothing else targets the branch. The branch only fast-forwards to reviewed main commits, through the
settings script's `advance` (no queued signer run, a trust-closure scan, then the full diff of
`.github/` and `packaging/`), and the existing `release` environment trusts it alongside `release`.
`.github/` and `packaging/`), and the existing `release` environment must admit `nightly-signer`
alongside `release` before the first dispatch (a repository settings change, not a workflow one).
Its trust closure is all of `.github/` and `packaging/`, including `packaging/common.sh` (this app
ships no `packaging/env.sh`), which `import-cert.sh` sources with the Apple keys. On that branch only the pinned `nightly-sign.yml`
caller may reach an environment: no app workflow binds one, and the only caller of the shared stable
`release.yml` is `release.yml`, whose callee must carry the stable-only environment guard. The
contract tests check the in-repo part on every main PR; the settings scan also resolves the callee.
Stable releases still come only from `refs/heads/release`. History does not carry over a switch
between `release` and `nightly-signer`, so the switch happens before the first publication.
ships no `packaging/env.sh`), which `import-cert.sh` sources with the Apple keys. On that branch
only the pinned `nightly-sign.yml` caller may reach an environment: no app workflow binds one, and
the only caller of the shared stable `release.yml` is `release.yml`, whose callee must carry the
stable-only environment guard. The contract tests check the in-repo part on every main PR; the
settings scan also resolves the callee. Stable releases still come only from `refs/heads/release`.
History does not carry over a switch between `release` and `nightly-signer`, so the switch happens
before the first publication.
**Manual actors.** `bflatastic`, `dylanmtaylor`, `echelon`, `FredApps` and `skylartaylor`, in the
producer's `manual-actors` and the policy's `manual_actors`. The list mirrors the release-managers
+16 -4
View File
@@ -528,14 +528,15 @@ def workflow_entries(source):
entries.append((number, key, _workflow_value(value),
is_block or ((value == "" or not is_block) and continues(index, indent))))
if "{" in bare and bare != "{}":
flow = re.fullmatch(r"\{([^{}\[\]]*)\}", FLOW_QUOTED.sub("''", value.strip()))
masked = re.fullmatch(r"\{([^{}\[\]]*)\}", FLOW_QUOTED.sub("''", value.strip()))
flow = re.fullmatch(r"\{([^{}\[\]]*)\}", value.strip())
if any(set(scalar[1:-1]) & set("#{}[],") for scalar in FLOW_QUOTED.findall(value)):
refused.append(f"line {number}: flow mapping quoted scalar with # or flow punctuation")
elif flow is None:
refused.append(f"line {number}: nested or multi-line flow mapping")
elif not re.fullmatch(r"\{([^{}\[\]]*)\}", value.strip()):
elif masked is None or flow is None:
refused.append(f"line {number}: nested or multi-line flow mapping")
else:
# The masked text only proves the shape: a quoted key ("uses", 'environment') keeps
# its identity, so the entries are read from the original mapping text, never ''.
for item in flow.group(1).split(","):
entry = WORKFLOW_KEY.match(item.strip())
key = _workflow_key(entry.group(1)) if entry else None
@@ -632,6 +633,9 @@ class NightlySignerBranchTrustClosure(unittest.TestCase):
"a bracket inside a quoted flow scalar": {**tree, "extra.yml": 'jobs:\n x: {name: "[a]", runs-on: ubuntu-latest}\n'},
"an unterminated quote": {**tree, "extra.yml": 'jobs:\n x:\n name: "a\n b"\n runs-on: ubuntu-latest\n'},
"environment in any flow mapping": {**tree, "extra.yml": "jobs:\n x:\n runs-on: ubuntu-latest\n with: {environment: release}\n"},
"a double-quoted environment key in a flow mapping": {**tree, "extra.yml": 'jobs:\n x:\n runs-on: ubuntu-latest\n with: {"environment": release}\n'},
"a single-quoted environment key in a flow mapping": {**tree, "extra.yml": "jobs:\n x:\n runs-on: ubuntu-latest\n with: {'environment': release}\n"},
"a double-quoted uses key in a flow mapping": {**tree, "extra.yml": 'jobs:\n x: {"uses": ' + SHARED + "nightly-release.yml@" + "a" * 40 + "}\n"},
"uses in any flow mapping": {**tree, "extra.yml": "jobs:\n x:\n steps:\n - {uses: actions/checkout@v4}\n"},
"another caller of the signer": {**tree, "extra.yml": "jobs:\n x:\n uses: " + SHARED + "nightly-release.yml@" + "a" * 40 + "\n"},
"a mutable signer pin": {**tree, "nightly-sign.yml": re.sub(r"nightly-release\.yml@[0-9a-f]{40}", "nightly-release.yml@main", tree["nightly-sign.yml"])},
@@ -642,6 +646,14 @@ class NightlySignerBranchTrustClosure(unittest.TestCase):
with self.subTest(case=label):
self.assertTrue(trust_closure_problems(workflows))
def test_quoted_keys_in_a_flow_mapping_are_read_not_masked(self):
entries, refused = workflow_entries('jobs:\n x: {runs-on: ubuntu-latest, "name": build}\n')
self.assertEqual(refused, [])
self.assertIn((2, "name", "build", False), entries, "a quoted key keeps its identity")
self.assertIn((2, "runs-on", "ubuntu-latest", False), entries)
_, refused = workflow_entries("jobs:\n x: {runs-on: ubuntu-latest, 'environment': release}\n")
self.assertEqual(refused, ["line 2: environment in a flow mapping (must be block style)"])
def test_signer_guard_and_policy_name_the_same_branch(self):
app = json.loads(INSTALLED_POLICY.read_text())["repository"].split("/", 1)[1]
sign = (ROOT / ".github/workflows/nightly-sign.yml").read_text()