Skip to content

Commit 7af3d22

Browse files
committed
Ruby: simplify Twirp model
1 parent 129e634 commit 7af3d22

File tree

2 files changed

+15
-5
lines changed
  • ruby/ql

2 files changed

+15
-5
lines changed

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module Twirp {
1616
/**
1717
* A Twirp service instantiation
1818
*/
19-
class ServiceInstantiation extends DataFlow::CallNode {
19+
deprecated class ServiceInstantiation extends DataFlow::CallNode {
2020
ServiceInstantiation() {
2121
this = API::getTopLevelMember("Twirp").getMember("Service").getAnInstantiation()
2222
}
@@ -37,23 +37,33 @@ module Twirp {
3737
/**
3838
* A Twirp client
3939
*/
40-
class ClientInstantiation extends DataFlow::CallNode {
40+
deprecated class ClientInstantiation extends DataFlow::CallNode {
4141
ClientInstantiation() {
4242
this = API::getTopLevelMember("Twirp").getMember("Client").getAnInstantiation()
4343
}
4444
}
4545

4646
/** The URL of a Twirp service, considered as a sink. */
4747
class ServiceUrlAsSsrfSink extends ServerSideRequestForgery::Sink {
48-
ServiceUrlAsSsrfSink() { exists(ClientInstantiation c | c.getArgument(0) = this) }
48+
ServiceUrlAsSsrfSink() {
49+
this =
50+
API::getTopLevelMember("Twirp").getMember("Client").getMethod("new").getArgument(0).asSink()
51+
}
4952
}
5053

5154
/** A parameter that will receive parts of the url when handling an incoming request. */
5255
class UnmarshaledParameter extends Http::Server::RequestInputAccess::Range,
5356
DataFlow::ParameterNode
5457
{
5558
UnmarshaledParameter() {
56-
this = any(ServiceInstantiation i).getAHandlerMethodNode().getParameter(0)
59+
this =
60+
API::getTopLevelMember("Twirp")
61+
.getMember("Service")
62+
.getMethod("new")
63+
.getArgument(0)
64+
.getMethod(_)
65+
.getParameter(0)
66+
.asSource()
5767
}
5868

5969
override string getSourceType() { result = "Twirp Unmarhaled Parameter" }

ruby/ql/test/library-tests/frameworks/Twirp/Twirp.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ query predicate sourceTest(Twirp::UnmarshaledParameter source) { any() }
55

66
query predicate ssrfSinkTest(Twirp::ServiceUrlAsSsrfSink sink) { any() }
77

8-
query predicate serviceInstantiationTest(Twirp::ServiceInstantiation si) { any() }
8+
deprecated query predicate serviceInstantiationTest(Twirp::ServiceInstantiation si) { any() }

0 commit comments

Comments
 (0)