Skip to content

Commit 2619f3f

Browse files
committed
Ruby: include overridden methods in getAnInstanceSelf
1 parent ab4e341 commit 2619f3f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,8 @@ class ModuleNode instanceof Module {
870870
* including those inherited from ancestors.
871871
*/
872872
ParameterNode getAnInstanceSelf() {
873-
result = TSelfParameterNode(this.getAnInstanceMethod().asMethod())
873+
// Make sure to include the 'self' in overridden instance methods
874+
result = this.getAnAncestor().getAnOwnInstanceSelf()
874875
}
875876

876877
private InstanceVariableAccess getAnOwnInstanceVariableAccess(string name) {
@@ -906,14 +907,18 @@ class ModuleNode instanceof Module {
906907
/**
907908
* Gets the instance method named `name` available in this module, including methods inherited
908909
* from ancestors.
910+
*
911+
* Overridden methods are not included.
909912
*/
910913
MethodNode getInstanceMethod(string name) {
911914
result.asCallableAstNode() = super.getInstanceMethod(name)
912915
}
913916

914917
/**
915-
* Gets an instance method named available in this module, including methods inherited
918+
* Gets an instance method available in this module, including methods inherited
916919
* from ancestors.
920+
*
921+
* Overridden methods are not included.
917922
*/
918923
MethodNode getAnInstanceMethod() { result = this.getInstanceMethod(_) }
919924

0 commit comments

Comments
 (0)