Skip to content

Rust: Add support for defining barriers and barrier guards using models-as-data - #21475

Merged
owen-mc merged 17 commits into
github:mainfrom
owen-mc:rust/mad-barriers
Mar 24, 2026
Merged

Rust: Add support for defining barriers and barrier guards using models-as-data#21475
owen-mc merged 17 commits into
github:mainfrom
owen-mc:rust/mad-barriers

Conversation

@owen-mc

Copy link
Copy Markdown
Contributor

No description provided.

@github-actionsgithub-actionsBot added Rust Pull requests that update Rust code DataFlow Library labels Mar 15, 2026
Comment threadrust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qll Fixed
* `branch` is either `true` or `false`, indicating which branch of the guard
* is protecting the parameter.
*/
extensible predicate barrierGuardModel(
@hvitved

Copy link
Copy Markdown
Contributor

I have opened owen-mc#6 against this branch.

@hvitved

Copy link
Copy Markdown
Contributor

Fix for barrier guards: owen-mc#7

@owen-mc
owen-mc marked this pull request as ready for review March 20, 2026 14:23
@owen-mc
owen-mc requested review from a team as code ownersMarch 20, 2026 14:23
CopilotAI review requested due to automatic review settings March 20, 2026 14:23
@owen-mc

owen-mc commented Mar 20, 2026

Copy link
Copy Markdown
ContributorAuthor
Rerun has been triggered.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds Rust dataflow support for defining flow barriers and barrier guards via models-as-data, wiring them through the shared flow summary infrastructure and exposing a small Rust-facing API plus tests.

Changes:

  • Introduces shared and Rust-specific flow-summary support for barrier and barrier-guard elements/specs.
  • Adds Rust models-as-data extensibles (barrierModel, barrierGuardModel) and a public FlowBarrier library API to consume them.
  • Updates Rust library tests to exercise barrier and barrier-guard behavior using an .ext.yml MaD extension.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
shared/dataflow/codeql/dataflow/internal/FlowSummaryImpl.qllAdds barrier/barrier-guard element/spec plumbing to shared flow-summary implementation.
rust/ql/test/library-tests/dataflow/barrier/main.rsExtends the Rust test program with barrier and barrier-guard scenarios.
rust/ql/test/library-tests/dataflow/barrier/inline-flow.qlUpdates inline flow test configuration to use the new barrier API.
rust/ql/test/library-tests/dataflow/barrier/inline-flow.ext.ymlAdds MaD extension rows for a barrier and a barrier guard used by the test.
rust/ql/test/library-tests/dataflow/barrier/inline-flow.expectedUpdates expected results for the inline flow test.
rust/ql/lib/codeql/rust/dataflow/internal/empty.model.ymlEnsures barrier/barrier-guard extensibles have at least one definition (empty) in the pack.
rust/ql/lib/codeql/rust/dataflow/internal/SsaImpl.qllAdds internal support for parameterized barrier guards.
rust/ql/lib/codeql/rust/dataflow/internal/Node.qllFixes typos in source/sink node documentation comments.
rust/ql/lib/codeql/rust/dataflow/internal/ModelsAsData.qllDefines MaD extensible predicates and model pretty-printing for barriers and barrier guards.
rust/ql/lib/codeql/rust/dataflow/internal/FlowSummaryImpl.qllAdjusts Rust flow-summary integration to support barrier node extraction details.
rust/ql/lib/codeql/rust/dataflow/internal/DataFlowImpl.qllWires barriers/barrier-guards into Rust dataflow via barrier nodes and guard checks.
rust/ql/lib/codeql/rust/dataflow/FlowBarrier.qllAdds a public Rust library entry point for barriers and barrier guards (and barrierNode).

Comment on lines +115 to +118
* the value referred to by `input` is assumed to lead to a parameter of a call
* (possibly `self`), and the call is guarding the parameter.
* `branch` is either `true` or `false`, indicating which branch of the guard
* is protecting the parameter.

CopilotAIMar 20, 2026

Copy link

Choose a reason for hiding this comment

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

The barrierGuardModel doc comment has a couple issues: the sentence at line 115 starts with a lowercase "the", and branch is documented as boolean (true/false) even though the predicate parameter is a string. Please adjust the wording to be grammatically consistent and clarify the expected string values (for example, literal strings "true"/"false").

Suggested change
*thevaluereferredtoby `input` isassumedtoleadtoaparameterofa call
*(possibly `self`),andthecallisguardingthe parameter.
* `branch` iseither `true` or `false`,indicatingwhichbranchofthe guard
*isprotectingthe parameter.
*Thevalue referred to by `input` is assumed to lead to a parameter of a call
*(possibly `self`),andthecallisguardingthe parameter.
* `branch` iseither `"true"` or `"false"` (asastringliteral), indicating which
*branchoftheguardisprotectingthe parameter.

Copilot uses AI. Check for mistakes.
Comment threadrust/ql/lib/codeql/rust/dataflow/FlowBarrier.qll Outdated
@owen-mcowen-mc added the no-change-note-required This PR does not need a change note label Mar 20, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@owen-mc

owen-mc commented Mar 20, 2026

Copy link
Copy Markdown
ContributorAuthor
Rerun has been triggered.

@hvitvedhvitved left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, just some QL doc nits. I have triggered a DCA run.

Comment threadrust/ql/lib/codeql/rust/dataflow/internal/ModelsAsData.qll Outdated
Comment threadrust/ql/lib/codeql/rust/dataflow/FlowBarrier.qll
@owen-mc

Copy link
Copy Markdown
ContributorAuthor

Thanks. I've addressed those comments.

I meant to ask if you think there should be a QueryBarrier class, that different queries can extend?

@hvitved

Copy link
Copy Markdown
Contributor

I meant to ask if you think there should be a QueryBarrier class, that different queries can extend?

Not sure, doesn't look like other languages have it?

@owen-mc

owen-mc commented Mar 23, 2026

Copy link
Copy Markdown
ContributorAuthor

@owen-mc
owen-mc merged commit fd8821f into github:mainMar 24, 2026
136 checks passed
@owen-mc
owen-mc deleted the rust/mad-barriers branch March 24, 2026 09:31
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DataFlow Libraryno-change-note-requiredThis PR does not need a change noteRustPull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@owen-mc@hvitved@github-advanced-security