-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Rust: Add support for defining barriers and barrier guards using models-as-data #21475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
owen-mc
wants to merge
14
commits into
github:main
Choose a base branch
from
owen-mc:rust/mad-barriers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+407
−32
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
bceab0b
Add extensible predicates
owen-mc f342bae
Update empty.model.yml
owen-mc f9521e9
Update `interpretModelForTest`
owen-mc f455054
Shared: Add `barrierElement` in FlowSummaryImpl.qll
owen-mc d3177b9
Add FlowBarrier.qll
owen-mc e86ce8f
Instantiate flow barriers from MaD
owen-mc 93c6560
Add test for MaD barriers
owen-mc 2f0d328
Misc: fix typos in QLDocs
owen-mc c5457d3
Add (failing) test for MaD barrier guard
owen-mc 77cb353
Add MaD barrier guard model to make test pass
owen-mc 7d65bac
Add `FlowBarrierGuard` to FlowBarrier.qll
owen-mc 769b3a6
Instantiate flow barrier guards from MaD
owen-mc bde9378
Update MaD barrier guard test output
owen-mc 093c279
Fix incorrect QLDoc
owen-mc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| /** | ||
| * Provides classes and predicates for defining barriers. | ||
| * | ||
| * Flow barriers defined here feed into data flow configurations as follows: | ||
| * | ||
| * ```text | ||
| * data from *.model.yml | QL extensions of FlowBarrier::Range | ||
| * v v | ||
| * FlowBarrier (associated with a models-as-data kind string) | ||
| * v | ||
| * barrierNode predicate | other QL defined barriers, for example using concepts | ||
| * v v | ||
| * various Barrier classes for specific data flow configurations | ||
| * ``` | ||
| * | ||
| * New barriers should be defined using models-as-data, QL extensions of | ||
| * `FlowBarrier::Range`, or concepts. Data flow configurations should use the | ||
| * `barrierNode` predicate and/or concepts to define their barriers. | ||
| */ | ||
|
|
||
| private import rust | ||
| private import internal.FlowSummaryImpl as Impl | ||
| private import internal.DataFlowImpl as DataFlowImpl | ||
|
|
||
| // import all instances below | ||
| private module Barriers { | ||
| private import codeql.rust.Frameworks | ||
| private import codeql.rust.dataflow.internal.ModelsAsData | ||
| } | ||
|
|
||
| /** Provides the `Range` class used to define the extent of `FlowBarrier`. */ | ||
| module FlowBarrier { | ||
| /** A flow barrier. */ | ||
| abstract class Range extends Impl::Public::BarrierElement { | ||
| bindingset[this] | ||
| Range() { any() } | ||
|
|
||
| override predicate isBarrier( | ||
| string output, string kind, Impl::Public::Provenance provenance, string model | ||
| ) { | ||
| this.isBarrier(output, kind) and provenance = "manual" and model = "" | ||
| } | ||
|
|
||
| /** | ||
| * Holds if this element is a flow barrier of kind `kind`, where data | ||
| * flows out as described by `output`. | ||
| */ | ||
| predicate isBarrier(string output, string kind) { none() } | ||
| } | ||
| } | ||
|
|
||
| final class FlowBarrier = FlowBarrier::Range; | ||
|
|
||
| /** Provides the `Range` class used to define the extent of `FlowBarrierGuard`. */ | ||
| module FlowBarrierGuard { | ||
| /** A flow barrier guard. */ | ||
| abstract class Range extends Impl::Public::BarrierGuardElement { | ||
| bindingset[this] | ||
| Range() { any() } | ||
|
|
||
| override predicate isBarrierGuard( | ||
| string input, string branch, string kind, Impl::Public::Provenance provenance, string model | ||
| ) { | ||
| this.isBarrierGuard(input, branch, kind) and provenance = "manual" and model = "" | ||
| } | ||
|
|
||
| /** | ||
| * Holds if this element is a flow barrier guard of kind `kind`, for data | ||
| * flowing in as described by `input`, when `this` evaluates to `branch`. | ||
| */ | ||
| predicate isBarrierGuard(string input, string branch, string kind) { none() } | ||
| } | ||
| } | ||
|
|
||
| final class FlowBarrierGuard = FlowBarrierGuard::Range; | ||
|
|
||
| predicate barrierNode = DataFlowImpl::barrierNode/2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
barrierGuardModeldoc comment has a couple issues: the sentence at line 115 starts with a lowercase "the", andbranchis documented as boolean (true/false) even though the predicate parameter is astring. Please adjust the wording to be grammatically consistent and clarify the expected string values (for example, literal strings "true"/"false").