mirror of
https://github.com/github/codeql.git
synced 2026-04-25 08:45:14 +02:00
Shared: Move 'getEnclosingCallable' and 'getAsExprEnclosingCallable' out of the class signature.
This commit is contained in:
@@ -44,16 +44,15 @@ signature module ModelGeneratorInputSig<LocationSig Location, InputSig<Location>
|
||||
* Gets the type of this node.
|
||||
*/
|
||||
Type getType();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the enclosing callable of this node.
|
||||
*/
|
||||
Callable getEnclosingCallable();
|
||||
/** Gets the enclosing callable of `node`. */
|
||||
Callable getEnclosingCallable(NodeExtended node);
|
||||
|
||||
/**
|
||||
* Gets the enclosing callable of this node, when considered as an expression.
|
||||
*/
|
||||
Callable getAsExprEnclosingCallable();
|
||||
/**
|
||||
* Gets the enclosing callable of `node`, when considered as an expression.
|
||||
*/
|
||||
Callable getAsExprEnclosingCallable(NodeExtended node);
|
||||
|
||||
/** Gets the parameter corresponding to this node, if any. */
|
||||
Parameter asParameter(NodeExtended n);
|
||||
@@ -462,7 +461,7 @@ module MakeModelGenerator<
|
||||
predicate isSource(DataFlow::Node source, FlowState state) {
|
||||
source instanceof DataFlow::ParameterNode and
|
||||
exists(Callable c |
|
||||
c = source.(NodeExtended).getEnclosingCallable() and
|
||||
c = getEnclosingCallable(source) and
|
||||
c instanceof DataFlowSummaryTargetApi and
|
||||
not isUninterestingForHeuristicDataFlowModels(c)
|
||||
) and
|
||||
@@ -472,7 +471,7 @@ module MakeModelGenerator<
|
||||
predicate isSink(DataFlow::Node sink, FlowState state) {
|
||||
sink instanceof ReturnNodeExt and
|
||||
not isOwnInstanceAccessNode(sink) and
|
||||
not exists(captureQualifierFlow(sink.(NodeExtended).getAsExprEnclosingCallable())) and
|
||||
not exists(captureQualifierFlow(getAsExprEnclosingCallable(sink))) and
|
||||
(state instanceof TaintRead or state instanceof TaintStore)
|
||||
}
|
||||
|
||||
@@ -516,8 +515,8 @@ module MakeModelGenerator<
|
||||
DataFlowSummaryTargetApi api, DataFlow::ParameterNode p, ReturnNodeExt returnNodeExt
|
||||
) {
|
||||
exists(string input, string output |
|
||||
p.(NodeExtended).getEnclosingCallable() = api and
|
||||
returnNodeExt.getEnclosingCallable() = api and
|
||||
getEnclosingCallable(p) = api and
|
||||
getEnclosingCallable(returnNodeExt) = api and
|
||||
input = parameterNodeAsInput(p) and
|
||||
output = getOutput(returnNodeExt) and
|
||||
input != output and
|
||||
@@ -567,11 +566,12 @@ module MakeModelGenerator<
|
||||
private module PropagateContentFlowConfig implements ContentDataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node source) {
|
||||
source instanceof DataFlow::ParameterNode and
|
||||
source.(NodeExtended).getEnclosingCallable() instanceof DataFlowSummaryTargetApi
|
||||
getEnclosingCallable(source) instanceof DataFlowSummaryTargetApi
|
||||
}
|
||||
|
||||
predicate isSink(DataFlow::Node sink) {
|
||||
sink.(ReturnNodeExt).getEnclosingCallable() instanceof DataFlowSummaryTargetApi
|
||||
sink instanceof ReturnNodeExt and
|
||||
getEnclosingCallable(sink) instanceof DataFlowSummaryTargetApi
|
||||
}
|
||||
|
||||
predicate isAdditionalFlowStep = isAdditionalContentFlowStep/2;
|
||||
@@ -664,8 +664,8 @@ module MakeModelGenerator<
|
||||
PropagateContentFlow::AccessPath stores, boolean preservesValue
|
||||
) {
|
||||
PropagateContentFlow::flow(p, reads, returnNodeExt, stores, preservesValue) and
|
||||
returnNodeExt.getEnclosingCallable() = api and
|
||||
p.(NodeExtended).getEnclosingCallable() = api
|
||||
getEnclosingCallable(returnNodeExt) = api and
|
||||
getEnclosingCallable(p) = api
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -709,8 +709,8 @@ module MakeModelGenerator<
|
||||
PropagateContentFlow::AccessPath stores, boolean preservesValue
|
||||
) {
|
||||
PropagateContentFlow::flow(p, reads, returnNodeExt, stores, preservesValue) and
|
||||
returnNodeExt.getEnclosingCallable() = api and
|
||||
p.(NodeExtended).getEnclosingCallable() = api and
|
||||
getEnclosingCallable(returnNodeExt) = api and
|
||||
getEnclosingCallable(p) = api and
|
||||
p = api.getARelevantParameterNode()
|
||||
}
|
||||
|
||||
@@ -982,7 +982,8 @@ module MakeModelGenerator<
|
||||
}
|
||||
|
||||
predicate isSink(DataFlow::Node sink) {
|
||||
sink.(ReturnNodeExt).getEnclosingCallable() instanceof DataFlowSourceTargetApi
|
||||
sink instanceof ReturnNodeExt and
|
||||
getEnclosingCallable(sink) instanceof DataFlowSourceTargetApi
|
||||
}
|
||||
|
||||
DataFlow::FlowFeature getAFeature() { result instanceof DataFlow::FeatureHasSinkCallContext }
|
||||
@@ -1005,8 +1006,8 @@ module MakeModelGenerator<
|
||||
exists(NodeExtended source, ReturnNodeExt sink, string kind |
|
||||
PropagateFromSource::flow(source, sink) and
|
||||
sourceNode(source, kind) and
|
||||
api = sink.getEnclosingCallable() and
|
||||
not irrelevantSourceSinkApi(source.getEnclosingCallable(), api) and
|
||||
api = getEnclosingCallable(sink) and
|
||||
not irrelevantSourceSinkApi(getEnclosingCallable(source), api) and
|
||||
result = ModelPrinting::asSourceModel(api, getOutput(sink), kind)
|
||||
)
|
||||
}
|
||||
@@ -1021,7 +1022,7 @@ module MakeModelGenerator<
|
||||
module PropagateToSinkConfig implements DataFlow::ConfigSig {
|
||||
predicate isSource(DataFlow::Node source) {
|
||||
apiSource(source) and
|
||||
source.(NodeExtended).getEnclosingCallable() instanceof DataFlowSinkTargetApi
|
||||
getEnclosingCallable(source) instanceof DataFlowSinkTargetApi
|
||||
}
|
||||
|
||||
predicate isSink(DataFlow::Node sink) {
|
||||
@@ -1050,7 +1051,7 @@ module MakeModelGenerator<
|
||||
exists(NodeExtended src, NodeExtended sink, string kind |
|
||||
PropagateToSink::flow(src, sink) and
|
||||
sinkNode(sink, kind) and
|
||||
api = src.getEnclosingCallable() and
|
||||
api = getEnclosingCallable(src) and
|
||||
result = ModelPrinting::asSinkModel(api, asInputArgument(src), kind)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user