Ruby: simplify some charpreds

This commit is contained in:
Alex Ford
2022-03-10 17:33:31 +00:00
parent 25416babe0
commit 506989ff91
2 changed files with 10 additions and 15 deletions

View File

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

View File

@@ -19,19 +19,14 @@ module Kernel {
*/
class KernelMethodCall extends DataFlow::CallNode {
KernelMethodCall() {
exists(MethodCall methodCall |
methodCall = this.asExpr().getExpr() and
(
this = API::getTopLevelMember("Kernel").getAMethodCall(_)
or
methodCall instanceof UnknownMethodCall and
(
this.getReceiver().asExpr().getExpr() instanceof SelfVariableAccess and
isPrivateKernelMethod(methodCall.getMethodName())
or
isPublicKernelMethod(methodCall.getMethodName())
)
)
this = API::getTopLevelMember("Kernel").getAMethodCall(_)
or
this.asExpr().getExpr() instanceof UnknownMethodCall and
(
this.getReceiver().asExpr().getExpr() instanceof SelfVariableAccess and
isPrivateKernelMethod(this.getMethodName())
or
isPublicKernelMethod(this.getMethodName())
)
}
}