Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5b05e72

Browse files
committed
Ruby: switch to local dataflow when dealing with Kernel/IO
1 parent 0110610 commit 5b05e72

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

ruby/ql/lib/codeql/ruby/frameworks/core/Kernel.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ module Kernel {
1919
*/
2020
class KernelMethodCall extends DataFlow::CallNode {
2121
KernelMethodCall() {
22-
this = API::getTopLevelMember("Kernel").getAMethodCall(_)
22+
// Match Kernel calls using local flow, to avoid finding singleton calls on subclasses
23+
this = DataFlow::getConstant("Kernel").getAMethodCall(_)
2324
or
2425
this.asExpr().getExpr() instanceof UnknownMethodCall and
2526
(

ruby/ql/lib/codeql/ruby/security/KernelOpenQuery.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class AmbiguousPathCall extends DataFlow::CallNode {
5555
}
5656

5757
private predicate methodCallOnlyOnIO(DataFlow::CallNode node, string methodName) {
58-
node = API::getTopLevelMember("IO").getAMethodCall(methodName) and
58+
// Use local flow to find calls to 'IO' without subclasses
59+
node = DataFlow::getConstant("IO").getAMethodCall(methodName) and
5960
not node = API::getTopLevelMember("File").getAMethodCall(methodName) // needed in e.g. opal/opal, where some calls have both paths (opal implements an own corelib)
6061
}
6162

0 commit comments

Comments
 (0)