Skip to content

Commit 81de9d3

Browse files
committed
C#/Java: Don't generate models if there exist a manual summary or neutral summary.
1 parent 87c6a3e commit 81de9d3

File tree

5 files changed

+13
-23
lines changed

5 files changed

+13
-23
lines changed

csharp/ql/src/utils/modelgenerator/CaptureDiscardedSummaryModels.ql

Lines changed: 0 additions & 15 deletions
This file was deleted.

csharp/ql/src/utils/modelgenerator/CaptureNeutralModels.ql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,5 @@ import internal.CaptureModels
1111
import internal.CaptureSummaryFlowQuery
1212

1313
from DataFlowTargetApi api, string noflow
14-
where
15-
noflow = captureNoFlow(api) and
16-
not api.(FlowSummaryImpl::Public::SummarizedCallable).applyManualModel()
14+
where noflow = captureNoFlow(api)
1715
select noflow order by noflow

csharp/ql/src/utils/modelgenerator/CaptureSummaryModels.ql

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,5 @@ import internal.CaptureModels
1111
import internal.CaptureSummaryFlowQuery
1212

1313
from DataFlowTargetApi api, string flow
14-
where
15-
flow = captureFlow(api) and
16-
not api.(FlowSummaryImpl::Public::SummarizedCallable).applyManualModel()
14+
where flow = captureFlow(api)
1715
select flow order by flow

csharp/ql/src/utils/modelgenerator/internal/CaptureModelsSpecific.qll

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ private import dotnet
77
private import semmle.code.csharp.commons.Util as Util
88
private import semmle.code.csharp.commons.Collections as Collections
99
private import semmle.code.csharp.dataflow.internal.DataFlowDispatch
10+
private import semmle.code.csharp.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
1011
private import semmle.code.csharp.frameworks.system.linq.Expressions
1112
import semmle.code.csharp.dataflow.internal.ExternalFlow as ExternalFlow
1213
import semmle.code.csharp.dataflow.internal.DataFlowImplCommon as DataFlowImplCommon
@@ -37,7 +38,10 @@ private predicate isRelevantForModels(CS::Callable api) {
3738
not api instanceof Util::MainMethod and
3839
not api instanceof CS::Destructor and
3940
not api instanceof CS::AnonymousFunctionExpr and
40-
not api.(CS::Constructor).isParameterless()
41+
not api.(CS::Constructor).isParameterless() and
42+
// Disregard all APIs that have a manual model.
43+
not api = any(FlowSummaryImpl::Public::SummarizedCallable sc | sc.applyManualModel()) and
44+
not api = any(FlowSummaryImpl::Public::NeutralSummaryCallable sc | sc.hasManualModel())
4145
}
4246

4347
/**

java/ql/src/utils/modelgenerator/internal/CaptureModelsSpecific.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
private import java as J
66
private import semmle.code.java.dataflow.internal.DataFlowPrivate
77
private import semmle.code.java.dataflow.internal.ContainerFlow as ContainerFlow
8+
private import semmle.code.java.dataflow.internal.FlowSummaryImpl as FlowSummaryImpl
89
private import semmle.code.java.dataflow.internal.ModelExclusions
910
private import semmle.code.java.dataflow.DataFlow as Df
1011
private import semmle.code.java.dataflow.SSA as Ssa
@@ -37,7 +38,11 @@ private predicate isInfrequentlyUsed(J::CompilationUnit cu) {
3738
*/
3839
private predicate isRelevantForModels(J::Callable api) {
3940
not isUninterestingForModels(api) and
40-
not isInfrequentlyUsed(api.getCompilationUnit())
41+
not isInfrequentlyUsed(api.getCompilationUnit()) and
42+
// Disregard all APIs that have a manual model.
43+
not api = any(FlowSummaryImpl::Public::SummarizedCallable sc | sc.applyManualModel()).asCallable() and
44+
not api =
45+
any(FlowSummaryImpl::Public::NeutralSummaryCallable sc | sc.hasManualModel()).asCallable()
4146
}
4247

4348
/**

0 commit comments

Comments
 (0)