-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Rust: Data flow improvements to unlock flow in sqlx test #18291
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
Changes from 1 commit
df03751
aab3428
defbbb2
cad4f39
402d4e1
ee87d4c
d8c301a
c1e2197
049fab4
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 |
|---|---|---|
|
|
@@ -712,6 +712,11 @@ private class CapturedVariableContent extends Content, TCapturedVariableContent | |
| override string toString() { result = "captured " + v } | ||
| } | ||
|
|
||
| /** A value refered to by a reference. */ | ||
|
||
| final class ReferenceContent extends Content, TReferenceContent { | ||
| override string toString() { result = "&ref" } | ||
| } | ||
|
|
||
| /** | ||
| * An element in an array. | ||
| */ | ||
|
|
@@ -1040,6 +1045,13 @@ module RustDataFlow implements InputSig<Location> { | |
| ["crate::option::Option::Some", "crate::result::Result::Ok"] | ||
| ) | ||
| or | ||
| exists(PrefixExprCfgNode deref | | ||
| c instanceof ReferenceContent and | ||
| deref.getOperatorName() = "*" and | ||
| node1.asExpr() = deref.getExpr() and | ||
| node2.asExpr() = deref | ||
| ) | ||
| or | ||
| VariableCapture::readStep(node1, c, node2) | ||
| ) | ||
| or | ||
|
|
@@ -1123,6 +1135,12 @@ module RustDataFlow implements InputSig<Location> { | |
| node2.(PostUpdateNode).getPreUpdateNode().asExpr() = index.getBase() | ||
| ) | ||
| or | ||
| exists(RefExprCfgNode ref | | ||
| c instanceof ReferenceContent and | ||
| node1.asExpr() = ref.getExpr() and | ||
| node2.asExpr() = ref | ||
| ) | ||
| or | ||
| VariableCapture::storeStep(node1, c, node2) | ||
| ) | ||
| or | ||
|
|
@@ -1382,7 +1400,8 @@ private module Cached { | |
| e = | ||
| [ | ||
| any(IndexExprCfgNode i).getBase(), any(FieldExprCfgNode access).getExpr(), | ||
| any(TryExprCfgNode try).getExpr() | ||
| any(TryExprCfgNode try).getExpr(), | ||
| any(PrefixExprCfgNode pe | pe.getOperatorName() = "*").getExpr() | ||
| ] | ||
| } or | ||
| TSsaNode(SsaImpl::DataFlowIntegration::SsaNode node) or | ||
|
|
@@ -1482,7 +1501,8 @@ private module Cached { | |
| TStructFieldContent(StructCanonicalPath s, string field) { | ||
| field = s.getStruct().getFieldList().(RecordFieldList).getAField().getName().getText() | ||
| } or | ||
| TCapturedVariableContent(VariableCapture::CapturedVariable v) | ||
| TCapturedVariableContent(VariableCapture::CapturedVariable v) or | ||
| TReferenceContent() | ||
|
|
||
| cached | ||
| newtype TContentSet = TSingletonContentSet(Content c) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,8 @@ module RustTaintTracking implements InputSig<Location, RustDataFlow> { | |
| RustDataFlow::readStep(pred, cs, succ) and | ||
| cs.getContent() instanceof ArrayElementContent | ||
| ) | ||
| or | ||
| pred.asExpr() = succ.asExpr().(RefExprCfgNode).getExpr() | ||
|
||
| ) | ||
| or | ||
| FlowSummaryImpl::Private::Steps::summaryLocalStep(pred.(Node::FlowSummaryNode).getSummaryNode(), | ||
|
|
@@ -59,7 +61,10 @@ module RustTaintTracking implements InputSig<Location, RustDataFlow> { | |
| bindingset[node] | ||
| predicate defaultImplicitTaintRead(Node::Node node, ContentSet cs) { | ||
| exists(node) and | ||
| cs.(SingletonContentSet).getContent() instanceof ArrayElementContent | ||
| exists(Content c | c = cs.(SingletonContentSet).getContent() | | ||
| c instanceof ArrayElementContent or | ||
| c instanceof ReferenceContent | ||
| ) | ||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -484,7 +484,6 @@ module Impl { | |
| class VariableReadAccess extends VariableAccess { | ||
| VariableReadAccess() { | ||
| not this instanceof VariableWriteAccess and | ||
| not this = any(RefExpr re).getExpr() and | ||
|
Contributor
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. I think it may be better to only consider these reads for the SSA library. Should be enough to change
Contributor
Author
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. Done. I had to also handle |
||
| not this = any(CompoundAssignmentExpr cae).getLhs() | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,23 @@ | ||
| models | ||
| edges | ||
| | main.rs:20:13:20:22 | source(...) | main.rs:21:19:21:25 | s[...] | provenance | | | ||
| | main.rs:20:13:20:22 | source(...) | main.rs:22:16:22:21 | sliced | provenance | | | ||
| | main.rs:21:18:21:25 | &... [&ref] | main.rs:22:16:22:21 | sliced | provenance | | | ||
| | main.rs:21:19:21:25 | s[...] | main.rs:21:18:21:25 | &... [&ref] | provenance | | | ||
| | main.rs:26:14:26:23 | source(...) | main.rs:32:10:32:11 | s4 | provenance | | | ||
| | main.rs:37:14:37:23 | source(...) | main.rs:40:10:40:35 | ... + ... | provenance | | | ||
| nodes | ||
| | main.rs:20:13:20:22 | source(...) | semmle.label | source(...) | | ||
| | main.rs:21:18:21:25 | &... [&ref] | semmle.label | &... [&ref] | | ||
| | main.rs:21:19:21:25 | s[...] | semmle.label | s[...] | | ||
| | main.rs:22:16:22:21 | sliced | semmle.label | sliced | | ||
| | main.rs:26:14:26:23 | source(...) | semmle.label | source(...) | | ||
| | main.rs:32:10:32:11 | s4 | semmle.label | s4 | | ||
| | main.rs:37:14:37:23 | source(...) | semmle.label | source(...) | | ||
| | main.rs:40:10:40:35 | ... + ... | semmle.label | ... + ... | | ||
| subpaths | ||
| testFailures | ||
| #select | ||
| | main.rs:22:16:22:21 | sliced | main.rs:20:13:20:22 | source(...) | main.rs:22:16:22:21 | sliced | $@ | main.rs:20:13:20:22 | source(...) | source(...) | | ||
| | main.rs:32:10:32:11 | s4 | main.rs:26:14:26:23 | source(...) | main.rs:32:10:32:11 | s4 | $@ | main.rs:26:14:26:23 | source(...) | source(...) | | ||
| | main.rs:40:10:40:35 | ... + ... | main.rs:37:14:37:23 | source(...) | main.rs:40:10:40:35 | ... + ... | $@ | main.rs:37:14:37:23 | source(...) | source(...) | |
Uh oh!
There was an error while loading. Please reload this page.