Skip to content

Commit 2b5e2ed

Browse files
committed
Ruby: factor out some code into a helper predicate
1 parent cfde7e9 commit 2b5e2ed

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

ruby/ql/lib/codeql/ruby/frameworks/ActionCable.qll

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ module ActionCable {
2929
}
3030
}
3131

32+
private DataFlow::ConstRef getActionCableChannelBase() {
33+
result = DataFlow::getConstant("ActionCable").getConstant("Channel").getConstant("Base")
34+
}
35+
3236
/**
3337
* The data argument in an RPC endpoint method on a subclass of
3438
* `ActionCable::Channel::Base`, considered as a remote flow source.
@@ -38,21 +42,11 @@ module ActionCable {
3842
exists(DataFlow::MethodNode m |
3943
// Any method on a subclass of `ActionCable::Channel::Base`
4044
// automatically becomes an RPC endpoint
41-
m =
42-
DataFlow::getConstant("ActionCable")
43-
.getConstant("Channel")
44-
.getConstant("Base")
45-
.getADescendentModule()
46-
.getAnInstanceMethod() and
45+
m = getActionCableChannelBase().getADescendentModule().getAnInstanceMethod() and
4746
// as long as it's not an instance method of
4847
// `ActionCable::Channel::Base` itself, which might exist in the
4948
// database
50-
not m =
51-
DataFlow::getConstant("ActionCable")
52-
.getConstant("Channel")
53-
.getConstant("Base")
54-
.asModule()
55-
.getAnInstanceMethod() and
49+
not m = getActionCableChannelBase().asModule().getAnInstanceMethod() and
5650
// and as long as it's public
5751
m.asCallableAstNode().isPublic() and
5852
// and is not called `subscribed` or `unsubscribed`.

0 commit comments

Comments
 (0)