-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rust: Make current MaD predicates deprecated #19502
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,9 @@ private import codeql.rust.dataflow.FlowSource | |
private import codeql.rust.dataflow.FlowSink | ||
|
||
/** | ||
* DEPRECATED: This predicate will be replaced by an alternative implementation | ||
* in the future, which uses a slightly different format. | ||
* | ||
* Holds if in a call to the function with canonical path `path`, defined in the | ||
* crate `crate`, the value referred to by `output` is a flow source of the given | ||
* `kind`. | ||
|
@@ -58,12 +61,15 @@ private import codeql.rust.dataflow.FlowSink | |
* For more information on the `kind` parameter, see | ||
* https://github.com/github/codeql/blob/main/docs/codeql/reusables/threat-model-description.rst. | ||
*/ | ||
extensible predicate sourceModel( | ||
extensible predicate sourceModelDeprecated( | ||
string crate, string path, string output, string kind, string provenance, | ||
QlBuiltins::ExtensionId madId | ||
); | ||
|
||
/** | ||
* DEPRECATED: This predicate will be replaced by an alternative implementation | ||
* in the future, which uses a slightly different format. | ||
* | ||
* Holds if in a call to the function with canonical path `path`, defined in the | ||
* crate `crate`, the value referred to by `input` is a flow sink of the given | ||
* `kind`. | ||
|
@@ -74,20 +80,23 @@ extensible predicate sourceModel( | |
* | ||
* - `sql-injection`: a flow sink for SQL injection. | ||
*/ | ||
extensible predicate sinkModel( | ||
extensible predicate sinkModelDeprecated( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably explain what's going on in the qldoc here, i.e. that a new format is coming soon but is not available yet (usually we would link to replacing predicate, but I understand these don't yet exist). |
||
string crate, string path, string input, string kind, string provenance, | ||
QlBuiltins::ExtensionId madId | ||
); | ||
|
||
/** | ||
* DEPRECATED: This predicate will be replaced by an alternative implementation | ||
* in the future, which uses a slightly different format. | ||
* | ||
* Holds if in a call to the function with canonical path `path`, defined in the | ||
* crate `crate`, the value referred to by `input` can flow to the value referred | ||
* to by `output`. | ||
* | ||
* `kind` should be either `value` or `taint`, for value-preserving or taint-preserving | ||
* steps, respectively. | ||
*/ | ||
extensible predicate summaryModel( | ||
extensible predicate summaryModelDeprecated( | ||
string crate, string path, string input, string output, string kind, string provenance, | ||
QlBuiltins::ExtensionId madId | ||
); | ||
|
@@ -99,17 +108,17 @@ extensible predicate summaryModel( | |
*/ | ||
predicate interpretModelForTest(QlBuiltins::ExtensionId madId, string model) { | ||
exists(string crate, string path, string output, string kind | | ||
sourceModel(crate, path, kind, output, _, madId) and | ||
sourceModelDeprecated(crate, path, kind, output, _, madId) and | ||
model = "Source: " + crate + "; " + path + "; " + output + "; " + kind | ||
) | ||
or | ||
exists(string crate, string path, string input, string kind | | ||
sinkModel(crate, path, kind, input, _, madId) and | ||
sinkModelDeprecated(crate, path, kind, input, _, madId) and | ||
model = "Sink: " + crate + "; " + path + "; " + input + "; " + kind | ||
) | ||
or | ||
exists(string type, string path, string input, string output, string kind | | ||
summaryModel(type, path, input, output, kind, _, madId) and | ||
summaryModelDeprecated(type, path, input, output, kind, _, madId) and | ||
model = "Summary: " + type + "; " + path + "; " + input + "; " + output + "; " + kind | ||
) | ||
} | ||
|
@@ -119,15 +128,15 @@ private class SummarizedCallableFromModel extends SummarizedCallable::Range { | |
private string path; | ||
|
||
SummarizedCallableFromModel() { | ||
summaryModel(crate, path, _, _, _, _, _) and | ||
summaryModelDeprecated(crate, path, _, _, _, _, _) and | ||
this = crate + "::_::" + path | ||
} | ||
|
||
override predicate propagatesFlow( | ||
string input, string output, boolean preservesValue, string model | ||
) { | ||
exists(string kind, QlBuiltins::ExtensionId madId | | ||
summaryModel(crate, path, input, output, kind, _, madId) and | ||
summaryModelDeprecated(crate, path, input, output, kind, _, madId) and | ||
model = "MaD:" + madId.toString() | ||
| | ||
kind = "value" and | ||
|
@@ -144,13 +153,13 @@ private class FlowSourceFromModel extends FlowSource::Range { | |
private string path; | ||
|
||
FlowSourceFromModel() { | ||
sourceModel(crate, path, _, _, _, _) and | ||
sourceModelDeprecated(crate, path, _, _, _, _) and | ||
this.callResolvesTo(crate, path) | ||
} | ||
|
||
override predicate isSource(string output, string kind, Provenance provenance, string model) { | ||
exists(QlBuiltins::ExtensionId madId | | ||
sourceModel(crate, path, output, kind, provenance, madId) and | ||
sourceModelDeprecated(crate, path, output, kind, provenance, madId) and | ||
model = "MaD:" + madId.toString() | ||
) | ||
} | ||
|
@@ -161,13 +170,13 @@ private class FlowSinkFromModel extends FlowSink::Range { | |
private string path; | ||
|
||
FlowSinkFromModel() { | ||
sinkModel(crate, path, _, _, _, _) and | ||
sinkModelDeprecated(crate, path, _, _, _, _) and | ||
this.callResolvesTo(crate, path) | ||
} | ||
|
||
override predicate isSink(string input, string kind, Provenance provenance, string model) { | ||
exists(QlBuiltins::ExtensionId madId | | ||
sinkModel(crate, path, input, kind, provenance, madId) and | ||
sinkModelDeprecated(crate, path, input, kind, provenance, madId) and | ||
model = "MaD:" + madId.toString() | ||
) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
extensions: | ||
- addsTo: | ||
pack: codeql/rust-all | ||
extensible: summaryModel | ||
extensible: summaryModelDeprecated | ||
data: | ||
- ["repo:https://github.com/rust-lang/futures-rs:futures-executor", "crate::local_pool::block_on", "Argument[0]", "ReturnValue", "value", "manual"] |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -2,6 +2,6 @@ | |||||||
extensions: | ||||||||
- addsTo: | ||||||||
pack: codeql/rust-all | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] Add a comment above this line (e.g.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||
extensible: summaryModel | ||||||||
extensible: summaryModelDeprecated | ||||||||
data: | ||||||||
- ["repo:https://github.com/servo/rust-url:url", "<crate::Url>::parse", "Argument[0].Reference", "ReturnValue.Field[crate::result::Result::Ok(0)]", "taint", "manual"] |
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.
To preserve backward compatibility during the transition, consider leaving the original
sourceModel
(and its sink/summary counterparts) as wrapper predicates that forward tosourceModelDeprecated
, so existing models won’t break immediately.Copilot uses AI. Check for mistakes.