Skip to content

Commit 506989f

Browse files
committed
Ruby: simplify some charpreds
1 parent 25416ba commit 506989f

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ abstract class ParamsCall extends MethodCall {
127127
* ActionController parameters available via the `params` method.
128128
*/
129129
class ParamsSource extends RemoteFlowSource::Range {
130-
ParamsSource() { exists(ParamsCall call | this.asExpr().getExpr() = call) }
130+
ParamsSource() { this.asExpr().getExpr() instanceof ParamsCall }
131131

132132
override string getSourceType() { result = "ActionController::Metal#params" }
133133
}
@@ -144,7 +144,7 @@ abstract class CookiesCall extends MethodCall {
144144
* ActionController parameters available via the `cookies` method.
145145
*/
146146
class CookiesSource extends RemoteFlowSource::Range {
147-
CookiesSource() { exists(CookiesCall call | this.asExpr().getExpr() = call) }
147+
CookiesSource() { this.asExpr().getExpr() instanceof CookiesCall }
148148

149149
override string getSourceType() { result = "ActionController::Metal#cookies" }
150150
}

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,14 @@ module Kernel {
1919
*/
2020
class KernelMethodCall extends DataFlow::CallNode {
2121
KernelMethodCall() {
22-
exists(MethodCall methodCall |
23-
methodCall = this.asExpr().getExpr() and
24-
(
25-
this = API::getTopLevelMember("Kernel").getAMethodCall(_)
26-
or
27-
methodCall instanceof UnknownMethodCall and
28-
(
29-
this.getReceiver().asExpr().getExpr() instanceof SelfVariableAccess and
30-
isPrivateKernelMethod(methodCall.getMethodName())
31-
or
32-
isPublicKernelMethod(methodCall.getMethodName())
33-
)
34-
)
22+
this = API::getTopLevelMember("Kernel").getAMethodCall(_)
23+
or
24+
this.asExpr().getExpr() instanceof UnknownMethodCall and
25+
(
26+
this.getReceiver().asExpr().getExpr() instanceof SelfVariableAccess and
27+
isPrivateKernelMethod(this.getMethodName())
28+
or
29+
isPublicKernelMethod(this.getMethodName())
3530
)
3631
}
3732
}

0 commit comments

Comments
 (0)