Skip to content

Commit 7a3b6f1

Browse files
committed
Ruby: add predicates to DataFlow::ModuleNode to get singleton methods
1 parent 24e8316 commit 7a3b6f1

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowPublic.qll

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,23 @@ class ModuleNode instanceof Module {
10101010
*/
10111011
MethodNode getAnInstanceMethod() { result = this.getInstanceMethod(_) }
10121012

1013+
/**
1014+
* Gets the singleton method named `name` available in this module, including methods inherited from ancestors.
1015+
*
1016+
* Overridden methods are not included.
1017+
*/
1018+
MethodNode getSingletonMethod(string name) {
1019+
result.asCallableAstNode() = super.getAnOwnSingletonMethod() and
1020+
result.getMethodName() = name
1021+
}
1022+
1023+
/**
1024+
* Gets a singleton method available in this module, including methods inherited from ancestors.
1025+
*
1026+
* Overridden methods are not included.
1027+
*/
1028+
MethodNode getASingletonMethod() { result = this.getSingletonMethod(_) }
1029+
10131030
/**
10141031
* Gets the enclosing module, as it appears in the qualified name of this module.
10151032
*

0 commit comments

Comments
 (0)