-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16110 from hvitved/dataflow/param-flow-no-expects…
…-content Data flow: Block flow at `expectsContents` nodes in `parameterValueFlow`
- Loading branch information
Showing
4 changed files
with
73 additions
and
28 deletions.
There are no files selected for viewing
Empty file.
39 changes: 39 additions & 0 deletions
39
ruby/ql/test/library-tests/dataflow/regressions/Regressions.ql
This file contains 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,39 @@ | ||
private import codeql.ruby.dataflow.FlowSummary | ||
|
||
private class ReverseSummary extends SimpleSummarizedCallable { | ||
ReverseSummary() { this = "reverse" } | ||
|
||
override predicate propagatesFlow(string input, string output, boolean preservesValue) { | ||
input = "Argument[self].WithElement[any]" and | ||
output = "ReturnValue" and | ||
preservesValue = true | ||
} | ||
} | ||
|
||
private module Config implements DataFlow::ConfigSig { | ||
predicate isSource(DataFlow::Node source) { | ||
source | ||
.(DataFlow::PostUpdateNode) | ||
.getPreUpdateNode() | ||
.asExpr() | ||
.getExpr() | ||
.(MethodCall) | ||
.getMethodName() = "reverse" | ||
} | ||
|
||
predicate isSink(DataFlow::Node sink) { | ||
exists(MethodCall mc | | ||
mc.getMethodName() = "sink" and | ||
sink.asExpr().getExpr() = mc.getAnArgument() | ||
) | ||
} | ||
} | ||
|
||
/** | ||
* This predicate should not have a result. We check that the flow summary for | ||
* `reverse` does not get picked up by the `reverseStepThroughInputOutputAlias` | ||
* logic in `DataFlowImplCommon.qll`. | ||
*/ | ||
query predicate noReverseStepThroughInputOutputAlias(DataFlow::Node source, DataFlow::Node sink) { | ||
DataFlow::Global<Config>::flow(source, sink) | ||
} |
3 changes: 3 additions & 0 deletions
3
ruby/ql/test/library-tests/dataflow/regressions/regressions.rb
This file contains 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,3 @@ | ||
x = foo | ||
x.reverse.bar | ||
sink(x) |
This file contains 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