Skip to content

Commit 0b51555

Browse files
authored
Merge pull request DeusData#2194 from DeusData/fix/security-caller-permissions
fix(ci): grant the security permissions in dry-run.yml, and derive the caller list
2 parents 7d74337 + 09c0e88 commit 0b51555

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

‎.github/workflows/dry-run.yml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ jobs:
5858
# ── Security (independent island — does not block main pipeline) ──
5959
security:
6060
uses: ./.github/workflows/_security.yml
61+
# The called job requests security-events:read to count code-scanning
62+
# alerts; a reusable workflow cannot request more than its caller grants,
63+
# so withholding this here fails the whole run at startup.
64+
permissions:
65+
contents: read
66+
security-events: read
67+
actions: read
6168
secrets: inherit
6269

6370
# ── Lint (cppcheck + clang-format) ────────────────────────────

‎tests/test_security_gate_fail_closed.sh‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,25 @@ require(
9898
# downgrade, it fails the entire run with a startup_failure before a single
9999
# job executes. Checking only the called workflow is how this test passed
100100
# while the PR pipeline never started.
101-
for caller_name in ("pr.yml", "release.yml"):
102-
caller = (root / ".github" / "workflows" / caller_name).read_text(encoding="utf-8")
101+
# The caller list is DERIVED, never hardcoded. An earlier revision listed
102+
# ("pr.yml", "release.yml") by hand and stayed green while dry-run.yml -- a
103+
# third caller nobody had listed -- failed every run at startup. A test that
104+
# only checks the callers you remembered cannot catch the one you forgot.
105+
workflow_dir = root / ".github" / "workflows"
106+
callers = sorted(
107+
path.name
108+
for path in workflow_dir.glob("*.yml")
109+
if "uses: ./.github/workflows/_security.yml" in path.read_text(encoding="utf-8")
110+
)
111+
require(
112+
len(callers) >= 3,
113+
"expected at least 3 callers of _security.yml, found: "
114+
+ (", ".join(callers) or "none")
115+
+ " -- if a caller was deliberately removed, lower this floor on purpose",
116+
)
117+
118+
for caller_name in callers:
119+
caller = (workflow_dir / caller_name).read_text(encoding="utf-8")
103120
# The next sibling may be a comment line, not a key, so the lookahead has to
104121
# accept any 2-space-indented non-space -- matching only ` \w` silently
105122
# failed to find release.yml's job at all.

0 commit comments

Comments
 (0)