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 {
2424 */
2525 module String {
2626 /**
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.
2931 */
3032 class Constantize extends CodeExecution:: Range , DataFlow:: CallNode {
3133 // We treat this an `UnknownMethodCall` in order to match every call to `constantize` that isn't overridden.
3234 // We can't (yet) rely on API Graphs or dataflow to tell us that the receiver is a String.
3335 Constantize ( ) {
34- this .asExpr ( ) .getExpr ( ) .( UnknownMethodCall ) .getMethodName ( ) = "constantize"
36+ this .asExpr ( ) .getExpr ( ) .( UnknownMethodCall ) .getMethodName ( ) =
37+ [ "constantize" , "safe_constantize" ]
3538 }
3639
3740 override DataFlow:: Node getCode ( ) { result = this .getReceiver ( ) }
Original file line number Diff line number Diff line change 11constantizeCalls
22| active_support.rb:1:1:1:22 | call to constantize | active_support.rb:1:1:1:10 | "Foo::Bar" |
33| 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 |
45loggerInstantiations
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 11"Foo::Bar" . constantize
22
33a . constantize
4+ a . safe_constantize
45
56ActiveSupport ::Logger . new ( STDOUT )
67ActiveSupport ::TaggedLogging . new ( STDOUT )
You can’t perform that action at this time.
0 commit comments