File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed
lib/codeql/ruby/frameworks
test/library-tests/frameworks/active_support Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -24,14 +24,17 @@ module ActiveSupport {
24
24
*/
25
25
module String {
26
26
/**
27
- * A call to `String#constantize`, which tries to find a declared constant with the given name.
28
- * Passing user input to this method may result in instantiation of arbitrary Ruby classes.
27
+ * A call to `String#constantize` or `String#safe_constantize`, which
28
+ * tries to find a declared constant with the given name.
29
+ * Passing user input to this method may result in instantiation of
30
+ * arbitrary Ruby classes.
29
31
*/
30
32
class Constantize extends CodeExecution:: Range , DataFlow:: CallNode {
31
33
// We treat this an `UnknownMethodCall` in order to match every call to `constantize` that isn't overridden.
32
34
// We can't (yet) rely on API Graphs or dataflow to tell us that the receiver is a String.
33
35
Constantize ( ) {
34
- this .asExpr ( ) .getExpr ( ) .( UnknownMethodCall ) .getMethodName ( ) = "constantize"
36
+ this .asExpr ( ) .getExpr ( ) .( UnknownMethodCall ) .getMethodName ( ) =
37
+ [ "constantize" , "safe_constantize" ]
35
38
}
36
39
37
40
override DataFlow:: Node getCode ( ) { result = this .getReceiver ( ) }
Original file line number Diff line number Diff line change 1
1
constantizeCalls
2
2
| active_support.rb:1:1:1:22 | call to constantize | active_support.rb:1:1:1:10 | "Foo::Bar" |
3
3
| active_support.rb:3:1:3:13 | call to constantize | active_support.rb:3:1:3:1 | call to a |
4
+ | active_support.rb:4:1:4:18 | call to safe_constantize | active_support.rb:4:1:4:1 | call to a |
4
5
loggerInstantiations
5
- | active_support.rb:5 :1:5 :33 | call to new |
6
- | active_support.rb:6 :1:6 :40 | call to new |
6
+ | active_support.rb:6 :1:6 :33 | call to new |
7
+ | active_support.rb:7 :1:7 :40 | call to new |
Original file line number Diff line number Diff line change 1
1
"Foo::Bar" . constantize
2
2
3
3
a . constantize
4
+ a . safe_constantize
4
5
5
6
ActiveSupport ::Logger . new ( STDOUT )
6
7
ActiveSupport ::TaggedLogging . new ( STDOUT )
You can’t perform that action at this time.
0 commit comments