Skip to content

ci: run fork PR builds in restricted workflow - #6002

Merged
renecannao merged 11 commits into
v3.0from
ci/fork-pr-builds
Aug 9, 2026
Merged

renecannao merged 11 commits into
v3.0from
ci/fork-pr-builds

Conversation

@renecannao

@renecannao renecannao commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Adds a fork-only pull_request caller that runs the existing four build variants through the shared reusable workflow with trusted: false.

The existing CI-trigger → CI-builds cascade now skips fork heads; its write-capable path remains available for same-repository heads only.

Why

Approved external PR workflows should build the contributor's code without running it in the privileged workflow_run context.

Validation

  • YAML parsing and whitespace checks
  • Cross-branch isolation validator
  • Independent security review

Depends on #6001. Merge #6001 first, then this PR. After both merge, verify a controlled fork PR creates four GitHub-hosted jobs and no privileged CI-builds job.

Summary by CodeRabbit

  • New Features

    • Added secure build support for pull requests originating from forks.
    • Fork builds use read-only access and isolated GitHub-hosted runners.
    • Prevented untrusted fork changes from entering privileged build workflows.
    • Preserved standard build behavior for changes made within the repository.
  • Documentation

    • Added design and implementation documentation for fork pull-request builds.
  • Tests

    • Added automated validation for workflow permissions, trust controls, runner isolation, secrets, and build behavior.

@coderabbitai

coderabbitai Bot commented Aug 9, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The pull request adds a fork-only CI workflow, guards trusted workflow paths, documents isolated build behavior, and adds a validator for workflow security properties.

Changes

Fork pull-request build isolation

Layer / File(s) Summary
Fork build design and rollout plan
docs/superpowers/specs/..., docs/superpowers/plans/...
The design and plan define isolated fork builds, restricted permissions and operations, validation checks, and deployment order.
Fork and workflow-run routing
.github/workflows/CI-builds-fork.yml, .github/workflows/CI-builds.yml, .github/workflows/CI-trigger.yml
The workflows add fork-only pull-request handling and exclude forked or externally triggered events from trusted execution paths.
Workflow security validation
test/infra/control/validate-fork-pr-builds.bash
The validator checks workflow triggers, permissions, repository guards, trusted-mode settings, runners, matrices, privileged steps, and checkout settings.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ForkPullRequest
  participant CIbuildsfork
  participant CIbuilds
  ForkPullRequest->>CIbuildsfork: Trigger pull_request workflow
  CIbuildsfork->>CIbuilds: Invoke reusable workflow with trusted: false
  CIbuilds->>CIbuilds: Exclude external workflow_run execution
Loading

Possibly related PRs

  • sysown/proxysql#5595: Both changes modify the CI workflow chain for fork and workflow_run execution.
  • sysown/proxysql#6001: The main PR uses the trusted: false mode added to the shared CI workflow and updates its callers to isolate fork builds.

Poem

A rabbit checks each workflow gate,
Fork builds run with read-only state.
Trusted paths reject unsafe flow,
Validators check each row.
Hop, hop—isolated builds now go!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: running fork pull request builds in a restricted workflow.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/fork-pr-builds

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/CI-builds-fork.yml:
- Around line 15-17: Derive fork trust from the pull request event rather than
the caller-controlled trusted input, using a predicate such as
github.event.pull_request.head.repo.fork to gate runner selection and privileged
steps. Update .github/workflows/CI-builds-fork.yml:15-17 accordingly; revise
docs/superpowers/plans/2026-08-09-fork-pr-builds.md:160-176 to specify
event-derived trust; and update
test/infra/control/validate-fork-pr-builds.bash:47-64 to validate the
event/actor predicate instead of inputs.trusted.

In @.github/workflows/CI-trigger.yml:
- Line 24: Apply one fail-closed trust predicate across the fork-PR workflow
paths: in .github/workflows/CI-trigger.yml (line 24),
.github/workflows/CI-builds.yml (line 16), and
.github/workflows/CI-builds-fork.yml (line 14), classify Dependabot and other
required untrusted pull-request sources as trusted: false or exclude them from
trusted cascades, including privileged workflow_run paths that inherit secrets.
Update the corresponding trust logic and guidance in
docs/superpowers/plans/2026-08-09-fork-pr-builds.md (lines 216-220) to match;
all listed sites require changes.

In `@docs/superpowers/plans/2026-08-09-fork-pr-builds.md`:
- Around line 145-155: Correct the documented worktree and validation-command
paths so each is resolvable from its stated working directory. Update the
worktree creation instructions near the initial setup and apply the same
relative-path correction at the later references around Steps 180–184 and
280–292. Ensure the validation command locates the primary checkout’s test
script when run from the worktree.

In `@docs/superpowers/specs/2026-08-09-fork-pr-builds-design.md`:
- Around line 22-24: Update the architecture text describing the fork build path
to state that CI-builds-fork.yml invokes the shared ci-builds.yml workflow with
trusted set to false, rather than describing a separate reusable build
implementation. Preserve the documented untrusted-code restrictions and caller
permissions.

In `@test/infra/control/validate-fork-pr-builds.bash`:
- Around line 24-39: Update the validator around the workflow-loading and
routing assertions to load .github/workflows/CI-trigger.yml and validate its
trusted and untrusted paths alongside base, fork, and reusable workflows.
Replace substring include? checks for if expressions with normalized-expression
comparisons against an allowlist covering the exact trusted and untrusted
guards, including both routing cases; retain the existing permission, secret,
trigger, reusable-workflow, and trusted-mode assertions.
- Around line 45-50: Update the reusable workflow input validation near the
existing trusted default assertion to also assert that
inputs.fetch('trusted').fetch('type') equals 'boolean'. Keep the current default
and runs-on checks unchanged.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 092bc8d8-9fa3-40fd-a160-c944420db4ea

📥 Commits

Reviewing files that changed from the base of the PR and between 90d4cc1 and 5d07134.

📒 Files selected for processing (6)
  • .github/workflows/CI-builds-fork.yml
  • .github/workflows/CI-builds.yml
  • .github/workflows/CI-trigger.yml
  • docs/superpowers/plans/2026-08-09-fork-pr-builds.md
  • docs/superpowers/specs/2026-08-09-fork-pr-builds-design.md
  • test/infra/control/validate-fork-pr-builds.bash
📜 Review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: run / trigger
  • GitHub Check: build
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2026-04-11T13:17:55.508Z
Learnt from: renecannao
Repo: sysown/proxysql PR: 5607
File: doc/GH-Actions/README.md:13-18
Timestamp: 2026-04-11T13:17:55.508Z
Learning: When using GitHub-flavored Markdown headings, be aware that an em-dash surrounded by spaces (written as ` — `) affects the generated anchor/slug: GitHub replaces spaces with hyphens and removes non-alphanumeric punctuation, which can produce double hyphens (e.g., `## Foo — bar` → anchor `#foo--bar`, not `#foo-bar`). If you reference these anchors (e.g., internal links), ensure the expected slug matches this behavior.

Applied to files:

  • docs/superpowers/specs/2026-08-09-fork-pr-builds-design.md
  • docs/superpowers/plans/2026-08-09-fork-pr-builds.md
📚 Learning: 2026-04-11T13:17:55.509Z
Learnt from: renecannao
Repo: sysown/proxysql PR: 5607
File: doc/GH-Actions/README.md:13-18
Timestamp: 2026-04-11T13:17:55.509Z
Learning: When reviewing GitHub-flavored Markdown links/anchors, remember that heading-to-anchor slug generation treats spaces as hyphens and removes punctuation. If a heading contains an em-dash surrounded by spaces (e.g. ` — `), the slugs can legitimately include a double hyphen where the two surrounding space-runs become `-` on either side of the removed em-dash (e.g. `...vocabulary--read...`). Do not flag double-hyphens in anchor links for em-dash-containing headings as errors; they reflect GitHub’s correct slug behavior.

Applied to files:

  • docs/superpowers/specs/2026-08-09-fork-pr-builds-design.md
  • docs/superpowers/plans/2026-08-09-fork-pr-builds.md
🪛 LanguageTool
docs/superpowers/plans/2026-08-09-fork-pr-builds.md

[style] ~15-~15: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...rets, and GitHub-hosted runners only. - Fork builds must not use shared cache operat...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[uncategorized] ~205-~205: The official name of this software platform is spelled with a capital “H”.
Context: ...fork.yml **Interfaces:** - Consumes:github.event.workflow_run.head_repository.full...

(GITHUB)


[uncategorized] ~205-~205: The official name of this software platform is spelled with a capital “H”.
Context: ...flow_run.head_repository.full_nameandgithub.event.pull_request.head.repo.fork`. - P...

(GITHUB)


[uncategorized] ~224-~224: The official name of this software platform is spelled with a capital “H”.
Context: ...p 2: Add the fork-only caller** Create .github/workflows/CI-builds-fork.yml: ```yaml...

(GITHUB)

Comment thread .github/workflows/CI-builds-fork.yml Resolved

jobs:
run:
if: ${{ !github.event.pull_request || !github.event.pull_request.head.repo.fork }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Repo files of interest:"
git ls-files | rg '(^\.github/workflows/(CI-trigger|CI-builds|CI-builds-fork)\.yml$|(?i)dependabot|docs/superpowers/plans/2026-08-09-fork-pr-builds\.md$|validate-fork-pr-builds)' || true

echo
echo "Workflow snippets:"
for f in .github/workflows/CI-trigger.yml .github/workflows/CI-builds.yml .github/workflows/CI-builds-fork.yml; do
  if [ -f "$f" ]; then
    echo "--- $f"
    nl -ba "$f" | sed -n '1,80p'
  fi
done

echo
echo "Plan snippet:"
if [ -f docs/superpowers/plans/2026-08-09-fork-pr-builds.md ]; then
  nl -ba docs/superpowers/plans/2026-08-09-fork-pr-builds.md | sed -n '130,240p'
fi

echo
echo "Search for reusable workflow inputs/trust labels:"
rg -n "inputs\.trusted|trusted:|secrets: inherit|pull_request\.head\.repo\.fork|workflow_run|same-repository|dependabot|Dependabot|untrusted" .github workflows docs test -S || true

Repository: sysown/proxysql

Length of output: 477


🌐 Web query:

GitHub Actions Dependabot pull_request workflows untrusted GitHub App pull_request event

💡 Result:

When using GitHub Actions with Dependabot, it is critical to understand that GitHub treats these workflows as originating from a potentially untrusted source to prevent security compromises [1][2]. By default, when Dependabot triggers a workflow via events like pull_request, it is treated as if it were opened from a repository fork [2][3]. Key security restrictions and behaviors include: 1. Restricted Tokens and Secrets: Workflows triggered by Dependabot (github.actor == 'dependabot[bot]') receive a read-only GITHUB_TOKEN by default [1][2]. Furthermore, standard GitHub Actions secrets are not available to these runs; only designated Dependabot secrets can be accessed [1][2][3]. You can increase token permissions using the permissions key in your workflow, but secrets remain limited to Dependabot-configured ones [2][4]. 2. The pull_request_target Trigger: This event is a common source of security vulnerabilities (often called "pwn requests") because it runs with the privileges of the base repository [5][6]. If Dependabot triggers a pull_request_target workflow and the base ref was created by Dependabot, the workflow is automatically restricted to a read-only token and no secrets [1][7]. 3. Protection Against Untrusted Code: GitHub has implemented safeguards to prevent the execution of untrusted code in privileged contexts. For instance, actions/checkout v7 and newer now refuse to fetch fork pull request code in pull_request_target and workflow_run workflows unless explicitly opted out [5]. If your workflow requires checking out code from a fork with elevated trust, you must use the allow-unsafe-pr-checkout input, which is a deliberate security decision that should be carefully reviewed [8][5]. For secure operation, the recommended best practice is to separate tasks: use an unprivileged pull_request workflow to handle untrusted code and artifacts, and then use a separate, privileged workflow triggered by workflow_run to process the results of the first task [9]. Avoid using pull_request_target unless absolutely necessary, and always ensure that any code checked out from an untrusted source is never executed directly in a privileged context [8][9][5].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Repo files of interest:"
git ls-files | rg '(^\.github/workflows/CI-(trigger|builds|builds-fork)\.yml$|docs/superpowers/plans/2026-08-09-fork-pr-builds\.md$|test/infra/control/validate-fork-pr-builds\.bash$)' || true

echo
echo "Workflow snippets:"
for f in .github/workflows/CI-trigger.yml .github/workflows/CI-builds.yml .github/workflows/CI-builds-fork.yml; do
  if [ -f "$f" ]; then
    awk '{ printf "%d\t%s\n", NR, $0 }' "$f" | sed -n '1,120p'
  fi
done

echo
echo "Plan snippets:"
if [ -f docs/superpowers/plans/2026-08-09-fork-pr-builds.md ]; then
  awk '{ printf "%d\t%s\n", NR, $0 }' docs/superpowers/plans/2026-08-09-fork-pr-builds.md | sed -n '130,245p'
fi

echo
echo "Control validation snippets:"
if [ -f test/infra/control/validate-fork-pr-builds.bash ]; then
  awk '{ printf "%d\t%s\n", NR, $0 }' test/infra/control/validate-fork-pr-builds.bash | sed -n '1,130p'
fi

echo
echo "Search for trust inputs/workflow conditions:"
rg -n "inputs\.trusted|trusted:|secrets: inherit|pull_request\.head\.repo\.fork|workflow_run|same-repository|repository|dependabot|Dependabot|untrusted" .github workflows docs test -S || true

Repository: sysown/proxysql

Length of output: 50372


🌐 Web query:

GitHub Actions GitHub Apps pull_request event head.repo.fork false same repository

💡 Result:

In GitHub Actions, the head.repo.fork property available in the pull_request event payload indicates whether the repository itself is a GitHub fork of another repository—not whether the specific pull request originates from a different repository than the base [1][2]. Because this flag reflects the status of the repository, using head.repo.fork == false to identify same-repository pull requests is unreliable [1][2]. A repository that is a fork of an upstream project will have its fork flag set to true, even for internal branches and pull requests created within that same forked repository [1][2]. Consequently, using this flag as a proxy for "same-repo" will cause false positives in forked repositories, as same-repo pull requests will incorrectly report fork: true [2]. To accurately determine if a pull request is from the same repository, you should compare the full names of the base and head repositories instead [1][2]. This check is robust regardless of whether the repository is a fork: if: ${{ github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }} This condition explicitly confirms that the pull request head branch and the base branch reside within the same repository [1][2]. Reliance on head.repo.fork has been explicitly deprecated or removed in some tooling (such as the GitHub CLI) due to this inherent ambiguity [1][2].

Citations:


Apply one fail-closed trust predicate across the fork-PR paths.

The PR workflows classify trust as “not a fork head”, and the workflow_run caller only trusts the same repository. GitHub treats Dependabot pull_request flows as untrusted, while workflow_run with secrets: inherit is privileged. Route Dependabot and similar required untrusted sources to trusted: false, or remove them from the trusted cascades. Do this for .github/workflows/CI-trigger.yml, .github/workflows/CI-builds.yml, .github/workflows/CI-builds-fork.yml, and the matching docs plan.

📍 Affects 4 files
  • .github/workflows/CI-trigger.yml#L24-L24 (this comment)
  • .github/workflows/CI-builds.yml#L16-L16
  • .github/workflows/CI-builds-fork.yml#L14-L14
  • docs/superpowers/plans/2026-08-09-fork-pr-builds.md#L216-L220
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/CI-trigger.yml at line 24, Apply one fail-closed trust
predicate across the fork-PR workflow paths: in .github/workflows/CI-trigger.yml
(line 24), .github/workflows/CI-builds.yml (line 16), and
.github/workflows/CI-builds-fork.yml (line 14), classify Dependabot and other
required untrusted pull-request sources as trusted: false or exclude them from
trusted cascades, including privileged workflow_run paths that inherit secrets.
Update the corresponding trust logic and guidance in
docs/superpowers/plans/2026-08-09-fork-pr-builds.md (lines 216-220) to match;
all listed sites require changes.

Comment on lines +145 to +155
git worktree add .worktrees/ci-fork-pr-builds-actions -b ci/fork-pr-builds-actions origin/GH-Actions
```

Add checks that require `inputs.trusted` to guard the cache restore/save/packing steps, both `LouisBrunner/checks-action` steps, every handoff upload, and the diagnostic artifact upload.

- [ ] **Step 2: Confirm the extended test fails**

Run from `.worktrees/ci-fork-pr-builds-actions`:

```bash
bash ../ci-fork-pr-builds/test/infra/control/validate-fork-pr-builds.bash ci/fork-pr-builds HEAD

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Fix the documented worktree paths.

Line 145 creates the worktree below the primary checkout. From that worktree, ../ci-fork-pr-builds/test/... does not reach the primary checkout. From the primary checkout, ../ci-fork-pr-builds-actions does not reach .worktrees/ci-fork-pr-builds-actions.

Use paths relative to the documented locations.

Proposed path correction
- bash ../ci-fork-pr-builds/test/infra/control/validate-fork-pr-builds.bash ci/fork-pr-builds HEAD
+ bash ../../test/infra/control/validate-fork-pr-builds.bash ci/fork-pr-builds HEAD

- git -C ../ci-fork-pr-builds-actions diff origin/GH-Actions...ci/fork-pr-builds-actions -- .github/workflows/ci-builds.yml
+ git -C .worktrees/ci-fork-pr-builds-actions diff origin/GH-Actions...ci/fork-pr-builds-actions -- .github/workflows/ci-builds.yml

Apply the same correction to Lines 183 and 292.

Also applies to: 180-184, 280-292

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/superpowers/plans/2026-08-09-fork-pr-builds.md` around lines 145 - 155,
Correct the documented worktree and validation-command paths so each is
resolvable from its stated working directory. Update the worktree creation
instructions near the initial setup and apply the same relative-path correction
at the later references around Steps 180–184 and 280–292. Ensure the validation
command locates the primary checkout’s test script when run from the worktree.

Comment on lines +22 to +24
`CI-builds` remains a `workflow_run` workflow. It must skip its privileged reusable build job when the upstream workflow run originates from a fork. This prevents `actions/checkout` from trying to fetch a fork commit while the job has the base repository's write-capable token.

A new direct `pull_request` workflow runs the four build variants for fork heads. It uses a separate reusable build implementation designed for untrusted code. The caller grants only `contents: read`; the reusable workflow does not inherit secrets, use self-hosted runners, publish custom check runs, restore or save shared caches, upload handoff artifacts, or trigger downstream test workflows.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Align the architecture text with the implementation.

Line 24 describes a separate reusable build implementation. .github/workflows/CI-builds-fork.yml calls the shared ci-builds.yml@GH-Actions workflow with trusted: false. Use the shared-workflow wording so the design and deployment contract match.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/superpowers/specs/2026-08-09-fork-pr-builds-design.md` around lines 22 -
24, Update the architecture text describing the fork build path to state that
CI-builds-fork.yml invokes the shared ci-builds.yml workflow with trusted set to
false, rather than describing a separate reusable build implementation. Preserve
the documented untrusted-code restrictions and caller permissions.

Comment on lines +24 to +39
base = workflow(ENV.fetch('BASE_BUILDS'))
fork = workflow(ENV.fetch('FORK_BUILDS'))
reusable = workflow(ENV.fetch('REUSABLE_BUILDS'))

base_run = base.fetch('jobs').fetch('run')
assert(base_run.fetch('if').include?('head_repository.full_name == github.repository'), 'trusted CI-builds lacks same-repository guard')
assert(base_run.fetch('permissions') == 'write-all', 'trusted CI-builds permission changed')
assert(base_run.fetch('secrets') == 'inherit', 'trusted CI-builds secret handoff changed')

fork_event = fork['on'] || fork[true]
fork_run = fork.fetch('jobs').fetch('run')
assert(fork_event.key?('pull_request'), 'fork workflow is not pull_request-triggered')
assert(fork.fetch('permissions') == { 'contents' => 'read' }, 'fork workflow permissions are not exactly contents: read')
assert(fork_run.fetch('if').include?('head.repo.fork'), 'fork workflow is not restricted to fork heads')
assert(fork_run.fetch('uses') == 'sysown/proxysql/.github/workflows/ci-builds.yml@GH-Actions', 'fork workflow uses the wrong reusable workflow')
assert(fork_run.fetch('with').fetch('trusted') == false, 'fork workflow does not select untrusted mode')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

Validate every trusted routing guard.

The validator never loads .github/workflows/CI-trigger.yml, even though the PR changes its fork guard. It also uses include? checks for if expressions. An expression containing the required fragment plus an unconditional || true would pass.

Load CI-trigger.yml and compare normalized expressions against an allowlist for the final trust contract. Test both trusted and untrusted cases.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/infra/control/validate-fork-pr-builds.bash` around lines 24 - 39, Update
the validator around the workflow-loading and routing assertions to load
.github/workflows/CI-trigger.yml and validate its trusted and untrusted paths
alongside base, fork, and reusable workflows. Replace substring include? checks
for if expressions with normalized-expression comparisons against an allowlist
covering the exact trusted and untrusted guards, including both routing cases;
retain the existing permission, secret, trigger, reusable-workflow, and
trusted-mode assertions.

Comment on lines +45 to +50
reusable_event = reusable['on'] || reusable.fetch(true)
inputs = reusable_event.fetch('workflow_call').fetch('inputs')
assert(inputs.fetch('trusted').fetch('default') == true, 'reusable workflow lacks trusted=true default')
builds = reusable.fetch('jobs').fetch('builds')
runs_on = builds.fetch('runs-on')
assert(runs_on.match?(/\A\$\{\{\s*inputs\.trusted\s*&&\s*\(/) && runs_on.match?(/\)\s*\|\|\s*'ubuntu-24\.04'\s*\}\}\z/), 'untrusted mode does not force ubuntu-24.04')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Files matching validate-fork-pr-builds.bash:"
fd -a 'validate-fork-pr-builds\.bash$' . || true

file="$(fd 'validate-fork-pr-builds\.bash$' . | head -n1)"
if [ -n "${file:-}" ]; then
  echo
  echo "File: $file"
  wc -l "$file"
  echo
  echo "Relevant lines:"
  sed -n '1,120p' "$file" | cat -n
fi

echo
echo "Search for reusable workflow/test input assertions:"
rg -n "trusted|workflow_call|inputs\.fetch|assert\(inputs\.fetch|type.*boolean" . --glob '!node_modules' --glob '!dist' --glob '!build' | head -n 200

Repository: sysown/proxysql

Length of output: 50372


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="$(git ls-files | grep -F 'test/infra/control/validate-fork-pr-builds.bash' | head -n1)"
echo "Target file: ${file:-not found}"
if [ -n "${file:-}" ]; then
  wc -l "$file"
  echo
  sed -n '1,120p' "$file" | cat -n
fi

echo
echo "Controlled targeted search:"
git ls-files | grep -F 'validate-fork-pr-builds.bash' | head -n 20
rg -n "validate-fork-pr-builds|trusted|workflow_call|inputs\.fetch|assert\(|\.fetch\(" test infra .github --glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**' --max-count 300 | head -n 350

Repository: sysown/proxysql

Length of output: 12559


🌐 Web query:

GitHub Actions reusable workflows workflow_call inputs type boolean required optional syntax

💡 Result:

To define a boolean input in a GitHub Actions reusable workflow, you must use the on.workflow_call.inputs keyword and specify type: boolean [1][2][3]. When defining inputs for a workflow_call trigger, the type parameter is mandatory and must be one of boolean, number, or string [1][2]. Syntax Example To define a boolean input, use the following structure within your reusable workflow file: on: workflow_call: inputs: my-boolean-input: description: 'An example boolean input' type: boolean required: false default: false Configuration Details - type: Must be set to boolean for this input type [1][3]. - required: A boolean value (true or false) indicating if the input is mandatory. If set to false, you can provide a default value [1][2]. - default: If no default is specified for a boolean input, it defaults to false [1][2]. - Accessing inputs: Within the called (reusable) workflow, you can access the input value using the ${{ inputs.input-id }} context [1][3]. Passing the Input In the caller workflow, you pass the input value using the with keyword within your job configuration [4][3]. The data type provided by the caller must match the type defined in the reusable workflow [4]. jobs: call-my-workflow: uses: octo-org/example-repo/.github/workflows/reusable.yml@main with: my-boolean-input: true

Citations:


🌐 Web query:

site:docs.github.com/reusable-workflows reusable workflow inputs type default required

💡 Result:

In GitHub Actions reusable workflows, the on.workflow_call.inputs configuration allows you to define parameters passed from a caller workflow. Each input requires the type parameter, while required and default are optional [1]. Key configuration details include: Type: The type parameter is required for every input defined in a reusable workflow [1]. Valid values are boolean, number, or string [1]. Required: The required parameter is a boolean that determines if the input must be provided by the caller [2][1]. Default: The default parameter is optional. If it is not specified, the system assigns a default value based on the input's type [1]: - Boolean: false - Number: 0 - String: "" (empty string) Example configuration: on: workflow_call: inputs: username: description: 'A username passed from the caller workflow' default: 'john-doe' required: false type: string

Citations:


Assert that trusted has type: boolean.

workflow_call inputs require an explicit type, and the reusable workflow should only pass boolean logic to ${{ inputs.trusted }}. Add a missing type assertion so a reusable workflow with a non-boolean input does not make this validator pass.

Proposed assertion
 assert(inputs.fetch('trusted').fetch('default') == true, 'reusable workflow lacks trusted=true default')
+assert(inputs.fetch('trusted').fetch('type') == 'boolean', 'trusted input is not boolean')
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
reusable_event = reusable['on'] || reusable.fetch(true)
inputs = reusable_event.fetch('workflow_call').fetch('inputs')
assert(inputs.fetch('trusted').fetch('default') == true, 'reusable workflow lacks trusted=true default')
builds = reusable.fetch('jobs').fetch('builds')
runs_on = builds.fetch('runs-on')
assert(runs_on.match?(/\A\$\{\{\s*inputs\.trusted\s*&&\s*\(/) && runs_on.match?(/\)\s*\|\|\s*'ubuntu-24\.04'\s*\}\}\z/), 'untrusted mode does not force ubuntu-24.04')
reusable_event = reusable['on'] || reusable.fetch(true)
inputs = reusable_event.fetch('workflow_call').fetch('inputs')
assert(inputs.fetch('trusted').fetch('default') == true, 'reusable workflow lacks trusted=true default')
assert(inputs.fetch('trusted').fetch('type') == 'boolean', 'trusted input is not boolean')
builds = reusable.fetch('jobs').fetch('builds')
runs_on = builds.fetch('runs-on')
assert(runs_on.match?(/\A\$\{\{\s*inputs\.trusted\s*&&\s*\(/) && runs_on.match?(/\)\s*\|\|\s*'ubuntu-24\.04'\s*\}\}\z/), 'untrusted mode does not force ubuntu-24.04')
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/infra/control/validate-fork-pr-builds.bash` around lines 45 - 50, Update
the reusable workflow input validation near the existing trusted default
assertion to also assert that inputs.fetch('trusted').fetch('type') equals
'boolean'. Keep the current default and runs-on checks unchanged.

@sonarqubecloud

sonarqubecloud Bot commented Aug 9, 2026

Copy link
Copy Markdown

@renecannao
renecannao marked this pull request as ready for review August 9, 2026 06:52
@renecannao
renecannao merged commit e120e43 into v3.0 Aug 9, 2026
11 of 12 checks passed
@renecannao
renecannao deleted the ci/fork-pr-builds branch August 16, 2026 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant