Skip to content

G4: A pull request that brings a new severe code-scanning alert cannot merge #308

Closed

Description

@FlexOr2

G4: A pull request that brings a new severe code-scanning alert cannot merge

Caller: lines 4 and 5 of #10's card, both ruled A by the operator on 09.11.2026. Behind them stands marketplace#484, row S4 (security settings differ across the fleet).

Ruled

The operator, 09.11.2026, on #10's line 4, answer A ("Neue schwere Warnung sperrt"). The contract, as #10's body holds it:

In src/opentofu/github (module organization/): a code-scanning rule (provider required_code_scanning, tool CodeQL, security_alerts_threshold = "high_or_higher", alerts_threshold = "none") reaching repositories through quality_gate=true, with prevent_destroy and destroy = false like the other rulesets; applied only by scripts/apply_github_settings.sh --apply from a clean origin/main. Verified at the pull, else this card returns: provider 6.13.0 carries the rule, every quality_gate=true repository runs CodeQL through quality's codeql.yml, and the rule judges only alerts a pull request introduces.

The operator, 09.11.2026, on #10's line 5, answer A ("Geheimnis-Repo ausnehmen"). The contract, as #10's body holds it:

G4 as drafted (a new organisation ruleset with the rule required_code_scanning: tool CodeQL, security_alerts_threshold high_or_higher, alerts_threshold none; prevent_destroy and destroy = false) targets quality_gate=true and excludes platform-secrets: by a repository-name exclusion if the provider and GitHub's API allow it beside the property condition, else by a second custom property declared in src/opentofu/github/organization whose excluded value only platform-secrets carries; verified at the pull. Condition 3 (only alerts a pull request introduces) is proven by a throwaway pull request after the apply; if it fails, this line returns.

Settled at the pull (09.11.2026, main e375b80)

  1. Provider 6.13.0 carries the rule: holds. github/resource_github_organization_ruleset.go:640-680 declares rules.required_code_scanning with required_code_scanning_tool (tool, alerts_threshold, security_alerts_threshold); github/util_rules.go:573-593,818-835 expands and flattens it.
  2. A name exclusion beside the property condition: neither GitHub nor the provider allows it.
    • GitHub's REST description (github/rest-api-description, schema org-ruleset-conditions) makes the conditions a oneOf of repository_name_and_ref_name, repository_id_and_ref_name and repository_property_and_ref_name, and says: "The branch and tag rulesets conditions object should contain both repository_name and ref_name properties, or both repository_id and ref_name properties, or both repository_property and ref_name properties." docs.github.com, "Create an organization repository ruleset", carries the same sentence.
    • Provider 6.13.0: repository_property has ConflictsWith: ["conditions.0.repository_id", "conditions.0.repository_name"] (resource_github_organization_ruleset.go:130), repository_name the converse (:202), and expandConditions sends only the first of name, id or property it finds (util_rules.go:223,247,257). tofu validate on a scratch copy with both blocks fails with "conditions.0.repository_name": conflicts with conditions.0.repository_property.
    • So the contract's second branch applies: a second custom property. Its exclude is one GitHub documents: "The repository properties and values to exclude. The condition will not pass if any of these properties match." (schema repository-ruleset-conditions-repository-property-target; provider resource_github_organization_ruleset.go:169).
  3. Every targeted repository but platform-secrets runs CodeQL through quality's codeql.yml: holds. quality_gate=true holds for 16 repositories (gh api orgs/overnightworks/properties/values). The 14 that are not archived, all public, run quality's codeql.yml (quality through its own code-scanning.yml, the other 13 at 2d2b68b, v0.10.0) on every pull request to main without a paths filter, and each has a CodeQL analysis of 09.11.2026. claudebot is archived and takes no pull request, so the rule is inert there. platform-secrets answers the code-scanning API with 403 ("Code Security must be enabled for this repository to use code scanning") and is the one exclusion.
  4. The rule judges only alerts a pull request introduces: still not documented. It is matrix row 6, after the apply, as line 5 orders. hal holds 5 open high alerts on main since 06.11.2026 (py/weak-sensitive-data-hashing, py/insecure-protocol, py/clear-text-logging-sensitive-data twice, py/polynomial-redos), so its first pull request after the apply shows whether a base alert blocks.

What it builds

All in src/opentofu/github/organization/main.tf, beside quality_gate and the three rulesets:

  1. The property github_organization_custom_properties.code_scanning_exempt: value_type = "true_false", required = false, no default, values_editable_by = "org_actors", a description that names the ruleset, lifecycle { destroy = false }. A repository without a value does not match the exclusion, so no default is needed. Only organisation actors set a value, so no repository admin can exempt a repository.
  2. The one value github_repository_custom_property.platform_secrets_code_scanning_exempt: repository = "platform-secrets", property_name and property_type from the property, property_value = ["true"], lifecycle { destroy = false }.
  3. The ruleset github_organization_ruleset.code_scanning_required: name code scanning: high or higher blocks the merge, target branch, enforcement active, ref_name include ~DEFAULT_BRANCH, repository_property include quality_gate/custom/["true"] from the property (as quality / verdict required does) and exclude the name and values of item 2, no bypass actor, one required_code_scanning_tool (tool = "CodeQL", security_alerts_threshold = "high_or_higher", alerts_threshold = "none"), prevent_destroy = true, destroy = false. The exclusion references the value, not the schema, so the apply creates the ruleset only after platform-secrets carries the value; a failed create of the value stops it before the ruleset exists.
  4. The mocked test in src/opentofu/github/tests/organization_rulesets.tftest.hcl: one run asserts the tool and both thresholds; the property inclusion equal to the quality ruleset's; exactly one exclusion, the property and values of the one declared value; that value's repository platform-secrets; the property's values_editable_by = "org_actors". The bypass and enforcement runs list the fourth ruleset. The file's header cites The gate fails on legacy Sonar findings now that main is analysed #7.
  5. docs/github-settings.md: Platform on k3s and Flux: from an empty PC to every app live, with hal archived #1 names four rulesets, the schemas of quality_gate and code_scanning_exempt and platform-secrets' one value. A new The gate fails on legacy Sonar findings now that main is analysed #7 states the ruled reach: the ruleset requires CodeQL at high_or_higher and alerts_threshold none on the default branch of every quality_gate=true repository except one whose code_scanning_exempt is true, which only platform-secrets carries. The commit names lines 4 and 5 of Every fleet repository's GitHub settings and the organisation rulesets live as code in platform #10 as the rulings.
  6. After the apply, a follow-up item, cut at this item's landing, adds to src/opentofu/github/organization.tf the import blocks of the three new objects by the ids the read-back shows. An import of an id that does not exist fails the plan, so they cannot come first. Until they land, a lost state would plan the three as creates. The property and value creates are idempotent PUTs. The ruleset would come back as a second ruleset or a refusal.

No import block in the first pull request: none of the three objects exists yet.

Alternatives weighed, for the exclusion:

  • (a) A name exclusion beside the property condition is refused by GitHub's schema and the provider (point 2).
  • (b) A name or id condition instead of the property would leave the property and reach repositories by a list that quality_gate's values no longer steer (six repositories have quality_gate=false today). It also breaks "targets quality_gate=true".
  • (c) A new value of the existing role property needs role declared here, which P0: the skeleton and the fleet's quality gate, from the first pull request #2 keeps as set on GitHub. It also mixes a scanning exemption into a repository's role.
  • (d) A system property such as visibility would exempt every private repository, a later one included. Line 5's own notice says such a repository needs a new decision. GitHub's REST description does not document the name either.
  • (e) A second property, chosen. It is true_false like quality_gate, since the exemption is yes or no. A single_select or string property would add allowed values or free text, and the provider would still send an empty default at its create.

Alternatives weighed, for where the value lives:

  • repositories.tf beside the managed repositories: tofu test cannot plan a resource that depends on one an import block names, so no mocked run could judge it there.
  • The module beside its schema and the ruleset that excludes it, chosen: the one exemption has one owner, and the mocked run judges all three together. The root declares no repository's property value today, since P0: the skeleton and the fleet's quality gate, from the first pull request #2 leaves quality_gate's values to quality's merge command. This value is the first, and that command's PATCH sends only quality_gate (quality/src/quality/merge.py:378), so the two never touch.

Alternatives weighed, for the rule itself: the rule inside quality / verdict required would mean one resource fewer. But that ruleset is quality's contract, so its import id and rollback would carry two unrelated gates. A separate ruleset lets each one apply, fail and roll back alone. Chosen: a separate ruleset.

Size: one production file, 67 added lines. Later, 15 lines of import blocks in a second production file. About 45 test lines and 8 doc lines. A scratch copy of origin/main e375b80 with this design passed tofu fmt -check -recursive, tofu init -backend=false -lockfile=readonly, tofu validate and tofu test (14 passed). A mutation of the exclusion's value failed the new run.

Proof

  • mise run github:test in CI's opentofu job is green: format, init against the lock, validate, the mocked tests and tests/github/plan_with_a_delete_is_refused.sh.
  • The head's apply. First scripts/apply_github_settings.sh, whose plan holds exactly three creates (code_scanning_exempt, its value, the ruleset) and no other action. The three existing rulesets and quality_gate keep an unchanged configuration, and the command refuses any delete. Then scripts/apply_github_settings.sh --apply from a clean origin/main. The plan output goes into the item's journal before the apply.
  • A read-back:
    • gh api orgs/overnightworks/rulesets/<id> shows the one code_scanning rule with tool: CodeQL, security_alerts_threshold: high_or_higher and alerts_threshold: none, the property include and exclude, enforcement active and an empty bypass list.
    • gh api orgs/overnightworks/properties/schema/code_scanning_exempt shows true_false and org_actors.
    • gh api repos/overnightworks/platform-secrets/properties/values shows code_scanning_exempt=true.

Trace (main e375b80)

Risk

Material: security and rights.

  • The rule gates the merge of 14 active repositories, so a wrong condition blocks their pull requests. A missing exclusion blocks platform-secrets for good.
  • A new property's value is an exemption from a security gate.
  • quality's merge command switches quality_gate off for its merge and back on, so it lifts this ruleset too, but only for a pull request whose other checks are green: it stops on any red check but quality / verdict and the Sonar check (quality/src/quality/merge.py:538-558, the gate's reading at 29cfee6). So it is no way past a pull request this rule alone holds back. quality's head is told.
  • GitHub's answer to the empty default_value that provider 6.13.0 sends at the property's create is unknown (Unknowns).

The lane gets an Opus review at high effort and a Codex gpt-6-astra gate. The first review drives this matrix:

# Sentence Cell Driven by
1 The rule reaches repositories only through quality_gate=true the mocked run (inclusion equal to the quality ruleset's); after the apply, gh api repos/overnightworks/kiln/rules/branches/main (quality_gate=false) lists no code_scanning rule CI, head
2 Tool CodeQL, high_or_higher, alerts_threshold = "none" the mocked run; read-back CI, head
3 prevent_destroy, destroy = false, no bypass actor, enforcement active the mocked runs; the delete-refusing test CI
4 The apply plan holds three creates and no delete or change of another ruleset or of quality_gate scripts/apply_github_settings.sh plan in the journal head
5 Every targeted repository but platform-secrets runs CodeQL on each pull request to main before the apply, gh api repos/overnightworks/<r>/code-scanning/analyses?ref=refs/heads/main returns a CodeQL analysis for each of the 14 active quality_gate=true repositories (claudebot archived); after it, each one's rules/branches/main lists code_scanning head
6 A pull request that introduces a high alert cannot merge; one that adds none can, though the base holds a high alert a throwaway pull request in platform (CodeQL analyses python and actions there) planting one high Python alert, closed unmerged with its branch deleted; the first hal pull request after the apply (5 high alerts on main). If the second half fails, line 5 returns. head, after the apply
7 A pull request whose CodeQL run is still in progress cannot merge until it ends the throwaway pull request of row 6 head, after the apply
8 quality's merge command still merges: with quality_gate off the ruleset does not reach the repository row 1's read of a quality_gate=false repository head
9 platform-secrets is not reached, and only its value exempts the mocked run (one exclusion, the value's repository platform-secrets); after the apply, gh api repos/overnightworks/platform-secrets/rules/branches/main lists required_status_checks (it still has quality_gate=true) and no code_scanning, and gh api orgs/overnightworks/properties/values shows code_scanning_exempt=true on platform-secrets alone CI, head
10 Only organisation actors set the exemption the mocked run; gh api orgs/overnightworks/properties/schema/code_scanning_exempt shows org_actors CI, head

Before the apply: the root's plan fails today, before any create. The repository agents was renamed personas: gh api repos/overnightworks/agents answers overnightworks/personas, and the property listing names personas. Meanwhile local.managed and the listing test still name agents. Read from the code, not run here: the output's preconditions then fail, and the repository resource would plan a rename back to agents. #307 holds the fix. G4's apply waits for its landing and apply. The build and CI do not.

Unknowns:

  • Whether GitHub accepts default_value: "" on creating a non-required true_false property. Provider 6.13.0 always sends it (resource_github_organization_custom_properties.go:83,95; go-github v88 sends a non-nil DefaultValue). A refusal fails the apply at the property's create, before the value and the ruleset that depend on it, so nothing reaches a repository. The item then returns to the head with the error.
  • Whether the rule wants an analysis of the base commit as well; rows 6 and 7 show it.
  • A second repository set to code_scanning_exempt=true by hand is not in any plan. Only organisation actors can do it, and G3's targeting check (effective rules against property values) is where it shows. Named on Every fleet repository's GitHub settings and the organisation rulesets live as code in platform #10 for G3, with the fourth ruleset and the second schema.

Rollback:

  • At once, by hand, only with the operator's word given before the apply: gh api -X PUT orgs/overnightworks/rulesets/<id> with enforcement disabled opens the merge again across the fleet. Through the command it is not at once: --apply needs the change on origin/main, platform is quality_gate=true, so this ruleset gates that pull request too, and disabled contradicts Platform on k3s and Flux: from an empty PC to every app live, with hal archived #1's active and the enforcement test. The hand containment is then followed by that pull request, which brings the code to the hand state, and the operator's word on Platform on k3s and Flux: from an empty PC to every app live, with hal archived #1. This is also the containment if row 6's base half fails, while line 5 returns.
  • Final: a revert of the code carries removed blocks with lifecycle { destroy = false } for the three addresses, since the command refuses a delete. First the ruleset, then the property: a property deleted first could drop the exclusion while the ruleset stays active and block platform-secrets. The head deletes the ruleset by gh api -X DELETE orgs/overnightworks/rulesets/<id> and the property by gh api -X DELETE orgs/overnightworks/properties/schema/code_scanning_exempt on the operator's word.

Done when

  • The property code_scanning_exempt, platform-secrets' one value and the ruleset code scanning: high or higher blocks the merge are declared in organization/main.tf. A mocked run judges them, docs/github-settings.md states Platform on k3s and Flux: from an empty PC to every app live, with hal archived #1 and The gate fails on legacy Sonar findings now that main is analysed #7, and mise run github:test is green in CI.
  • The head applied them through scripts/apply_github_settings.sh --apply from a clean origin/main, with the plan of three creates in the journal, and the gh api read-back equals the contract.
  • The follow-up item that adds the three import blocks to organization.tf by the read-back ids is cut and named here.
  • Matrix rows 4 to 10 are driven and reported. Row 6's failure returns line 5 to the operator, with the ruleset disabled.
  • Predecessor: none. CodeQL default setup is configured nowhere, and the merge gate has no code-scanning rule today.
version = 1
now = "Lines 4 and 5 of #10 are ruled A (09.11.2026). The pull at e375b80 settled it: GitHub's schema and provider 6.13.0 refuse a name exclusion beside the property condition, so a second true_false property code_scanning_exempt, set on platform-secrets alone, is excluded; the design passed fmt, validate and the mocked tests in a scratch copy."
next = "Claim with aco start and build the property, its one value, the ruleset, the test and GH-1/GH-7; the apply waits for #307, which declares personas in place of the renamed agents, since the root's plan fails until then."
done_when = "code_scanning_exempt, platform-secrets' value and the ruleset code scanning: high or higher blocks the merge are declared in organization/main.tf, judged by a mocked run and stated as GH-1 and GH-7; applied by apply_github_settings.sh --apply from a clean origin/main with a plan of three creates in the journal and read back by gh api; the follow-up item for their import blocks is cut; matrix rows 4 to 10 are driven."
scope = ["src/opentofu/github/organization/main.tf", "src/opentofu/github/tests/organization_rulesets.tftest.hcl", "docs/github-settings.md"]
whole = "One exempting ruleset: the property, platform-secrets' value and the ruleset that excludes it apply together or the rule blocks platform-secrets for good; the test and GH-1/GH-7 judge and state them, and their import blocks follow the apply in an item of their own."

Activity

  1. added theissue type on Nov 9, 2026
  2. FlexOr2 commented on Nov 9, 2026

    @FlexOr2
    MemberAuthor

    The operator's word for the hand containment, in platform's head session on 09.11.2026. Asked „Darf ich die neue Sperre im Notfall sofort von Hand abschalten? … falls sie wider Erwarten Merges in allen Repos blockiert … Ich setze sie per gh api auf „disabled“ und ziehe den Code danach per PR nach.“, he answered „ja“.

    So the "At once" rollback in this body holds: if the ruleset blocks merges across the fleet, the head (or an agent on its order) sets its enforcement to disabled with gh api -X PUT orgs/overnightworks/rulesets/<id>, then brings the code to that state by pull request.

    Follow-ups from the gate (29cfee6), with owners: the ruleset's target and the create order are not pinned by the test (F4), for the follow-up item that adds the import blocks; aco's landing check and lane-ci read no code-scanning rule, so a pull request whose CodeQL still runs may be reported ready and refused at merge (F5), for aco's board.

  3. added a commit that references this issue on Nov 9, 2026
    e0d3586
  4. FlexOr2 commented on Nov 9, 2026

    @FlexOr2
    MemberAuthor

    The head's plan at e0d3586, before the apply, from clean origin/main: "Plan: 3 to add, 0 to change, 0 to destroy."

    • module.organization.github_organization_custom_properties.code_scanning_exempt will be created
    • module.organization.github_organization_ruleset.code_scanning_required will be created
    • module.organization.github_repository_custom_property.platform_secrets_code_scanning_exempt will be created

    Row 5, read before the apply: code-scanning/analyses?ref=refs/heads/main returns a CodeQL analysis for each of the 14 active quality_gate=true repositories: aco, agents, design, hal, hopin, marketplace, personas, platform, presentator, quality, skat, songmaker, speech, webauth. claudebot is archived, and platform-secrets is exempt.

  5. FlexOr2 commented on Nov 9, 2026

    @FlexOr2
    MemberAuthor

    Applied from clean main at e0d3586 by scripts/apply_github_settings.sh --apply: 3 added, 0 changed, 0 destroyed. The plan afterwards exits 0, "No changes".

    Read back:

    • Ruleset 26872357: active, bypass list empty, one rule code_scanning, CodeQL/high_or_higher/none, include quality_gate=true, exclude code_scanning_exempt=true.
    • code_scanning_exempt: true_false, org_actors. platform-secrets holds code_scanning_exempt=true.
    • rules/branches/main lists code_scanning on aco, agents, design, hal, hopin, marketplace, personas, platform, presentator, quality, skat, songmaker, speech and webauth, and not on platform-secrets.

    Rows 1, 2, 4, 5, 9 and 10 hold. Rows 6 and 7, the throwaway pull request, and row 8 follow here.

  6. FlexOr2 commented on Nov 9, 2026

    @FlexOr2
    MemberAuthor

    Row 8 holds: quality_gate is false on overnightworks/kiln, and gh api repos/overnightworks/kiln/rules/branches/main lists only deletion, non_fast_forward and pull_request, so neither the quality ruleset nor the code-scanning rule reaches a repository outside the property.

  7. FlexOr2 commented on Nov 9, 2026

    @FlexOr2
    MemberAuthor

    The follow-up of this item's point 6 is cut: #335 (import blocks, and F4's target pin). Rows 6 and 7 are not driven yet: the throwaway pull request's merge attempt was refused by the session's safety check and is with the operator. quality's head confirmed the reading of its merge command at quality main 896030a; that a high alert leaves CodeQL's own check red stays to be proven by row 6.

  8. FlexOr2 commented on Nov 9, 2026

    @FlexOr2
    MemberAuthor

    aco's head, asked live on this item's rows 6 and 7 (its finding F5 of the gate on #310): a clear refusal is enough, aco opens no item, and aco's own reading of land answers the worry.

    • aco land reads every check run on the head, CodeQL and codeql / Analyze (...) included. While CodeQL runs it refuses and names the check (LANDCMD-05); a CodeQL check that ended without success refuses too (LANDCMD-06); a mergeable_state other than clean refuses (LANDCMD-03). So "CodeQL still runs, reported ready, then 405" does not reach the merge in aco land; aco check <pr> never claimed readiness. lane-ci is marketplace's to answer.
    • One window is undriven: after codeql / Analyze ended and before GitHub posts the CodeQL check run, no check is pending. Either LANDCMD-03 refuses not mergeable (blocked), or the merge gets a 405 and LANDCMD-37 refuses with GitHub's message. Nothing merges either way and the claim stays.
    • Its request: when row 7 is driven, read mergeable_state and the merge answer in that window and send it the exact refusal text; a sentence that does not say what to do, or a 405, becomes an item on aco's board with that incident as caller.
  9. FlexOr2 commented on Nov 9, 2026

    @FlexOr2
    MemberAuthor

    Rows 6 and 7, read under #10 line 6 (A: read state only, no merge call), on throwaway PR #343 (closed unmerged, branch deleted, lane released):

    • The rule on main: org ruleset 26872357 "code scanning: high or higher blocks the merge", active, ~DEFAULT_BRANCH, tool CodeQL, security_alerts_threshold: high_or_higher, alerts_threshold: none, for quality_gate=true and not code_scanning_exempt=true.
    • Row 7: mergeStateStatus was BLOCKED at 19:24, 19:25 and 19:26 UTC while CodeQL ran, but cluster also ran the whole time, so the read does not single out the code-scanning rule. Not proven.
    • Row 6: not driven. The planted requests.get(url, verify=False) raised no alert: the CodeQL check run concluded success, "No new alerts in code changed by this pull request", and the PR ref lists no alert.

    A second read waits until CI is quiet (after songmaker's go), with a finding the default suite raises without a data flow (for example py/insecure-protocol, an ssl context at TLS 1.0), and reads mergeStateStatus once every other check is green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions