Skip to content

Commit eb8b255

Browse files
committed
Add types of lambdas and methods
1 parent e787d99 commit eb8b255

5 files changed

Lines changed: 17 additions & 1 deletion

File tree

ql/src/codeql_ruby/ast/internal/Module.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ private string builtin() {
1212
result =
1313
[
1414
"Object", "Kernel", "BasicObject", "Class", "Module", "NilClass", "FalseClass", "TrueClass",
15-
"Numeric", "Integer", "Float", "Rational", "Complex", "Array", "Hash"
15+
"Numeric", "Integer", "Float", "Rational", "Complex", "Array", "Hash", "Symbol", "Proc"
1616
]
1717
}
1818

ql/src/codeql_ruby/dataflow/internal/DataFlowDispatch.qll

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ private DataFlow::LocalSourceNode trackInstance(Module tp, TypeTracker t) {
125125
or
126126
result.asExpr().getExpr() instanceof HashLiteral and tp = TResolved("Hash")
127127
or
128+
result.asExpr().getExpr() instanceof MethodBase and tp = TResolved("Symbol")
129+
or
130+
result.asParameter() instanceof BlockParameter and tp = TResolved("Proc")
131+
or
132+
result.asExpr().getExpr() instanceof Lambda and tp = TResolved("Proc")
133+
or
128134
exists(CfgNodes::ExprNodes::CallCfgNode call, DataFlow::Node nodeTo |
129135
call.getExpr().(MethodCall).getMethodName() = "new" and
130136
nodeTo.asExpr() = call.getReceiver() and

ql/test/library-tests/modules/ancestors.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,13 @@ calls.rb:
3737
#-----| Numeric
3838
#-----| super -> Object
3939

40+
#-----| Proc
41+
4042
#-----| Rational
4143
#-----| super -> Numeric
4244

45+
#-----| Symbol
46+
4347
#-----| TrueClass
4448
#-----| super -> Object
4549

ql/test/library-tests/modules/modules.expected

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ getModule
1919
| file://:0:0:0:0 | Float |
2020
| file://:0:0:0:0 | NilClass |
2121
| file://:0:0:0:0 | Numeric |
22+
| file://:0:0:0:0 | Proc |
2223
| file://:0:0:0:0 | Rational |
24+
| file://:0:0:0:0 | Symbol |
2325
| file://:0:0:0:0 | TrueClass |
2426
| hello.rb:1:1:8:3 | EnglishWords |
2527
| hello.rb:11:1:16:3 | Greeting |

ql/test/library-tests/modules/superclasses.expected

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,13 @@ calls.rb:
3636
#-----| Numeric
3737
#-----| -> Object
3838

39+
#-----| Proc
40+
3941
#-----| Rational
4042
#-----| -> Numeric
4143

44+
#-----| Symbol
45+
4246
#-----| TrueClass
4347
#-----| -> Object
4448

0 commit comments

Comments
 (0)