mirror of
https://github.com/github/codeql.git
synced 2026-04-26 09:15:12 +02:00
Ruby: Include self parameters in type tracking flow-through logic
This commit is contained in:
@@ -940,6 +940,12 @@ private class NewCall extends DataFlowCall {
|
||||
abstract class ReturningNode extends Node {
|
||||
/** Gets the kind of this return node. */
|
||||
abstract ReturnKind getKind();
|
||||
|
||||
pragma[nomagic]
|
||||
predicate hasKind(ReturnKind kind, CfgScope scope) {
|
||||
kind = this.getKind() and
|
||||
scope = this.(NodeImpl).getCfgScope()
|
||||
}
|
||||
}
|
||||
|
||||
/** A data-flow node that represents a value returned by a callable. */
|
||||
@@ -1060,10 +1066,8 @@ private module ReturnNodes {
|
||||
SynthReturnNode() { this = TSynthReturnNode(scope, kind) }
|
||||
|
||||
/** Gets a syntactic return node that flows into this synthetic node. */
|
||||
ReturningNode getAnInput() {
|
||||
result.(NodeImpl).getCfgScope() = scope and
|
||||
result.getKind() = kind
|
||||
}
|
||||
pragma[nomagic]
|
||||
ReturningNode getAnInput() { result.hasKind(kind, scope) }
|
||||
|
||||
override ReturnKind getKind() { result = kind }
|
||||
|
||||
|
||||
@@ -80,10 +80,8 @@ predicate jumpStep = DataFlowPrivate::jumpStep/2;
|
||||
pragma[nomagic]
|
||||
private predicate flowThrough(DataFlowPublic::ParameterNode param) {
|
||||
exists(DataFlowPrivate::ReturningNode returnNode, DataFlowDispatch::ReturnKind rk |
|
||||
DataFlowPrivate::LocalFlow::getParameterDefNode(param.getParameter())
|
||||
.(TypeTrackingNode)
|
||||
.flowsTo(returnNode) and
|
||||
rk = returnNode.getKind()
|
||||
param.flowsTo(returnNode) and
|
||||
returnNode.hasKind(rk, param.(DataFlowPrivate::NodeImpl).getCfgScope())
|
||||
|
|
||||
rk instanceof DataFlowDispatch::NormalReturnKind
|
||||
or
|
||||
|
||||
@@ -153,6 +153,7 @@ getTarget
|
||||
| calls.rb:383:1:383:23 | call to instance | calls.rb:326:5:328:7 | instance |
|
||||
| calls.rb:383:1:383:23 | call to instance | calls.rb:336:5:338:7 | instance |
|
||||
| calls.rb:383:1:383:23 | call to instance | calls.rb:342:5:344:7 | instance |
|
||||
| calls.rb:383:1:383:23 | call to instance | calls.rb:375:5:377:7 | instance |
|
||||
| calls.rb:388:13:388:48 | call to puts | calls.rb:102:5:102:30 | puts |
|
||||
| calls.rb:392:13:392:22 | call to singleton1 | calls.rb:387:9:389:11 | singleton1 |
|
||||
| calls.rb:392:13:392:22 | call to singleton1 | calls.rb:422:9:424:11 | singleton1 |
|
||||
|
||||
Reference in New Issue
Block a user