Skip to content

Commit e0f1b38

Browse files
authored
Merge pull request #11580 from michaelnebel/renamenegativemodels
C#/Java: Rename Negative Summary Model to Neutral Model
2 parents 6c8896d + 4835d14 commit e0f1b38

File tree

48 files changed

+193
-269
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+193
-269
lines changed

csharp/ql/lib/ext/generated/dotnet_runtime.model.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10195,7 +10195,7 @@ extensions:
1019510195

1019610196
- addsTo:
1019710197
pack: codeql/csharp-all
10198-
extensible: extNegativeSummaryModel
10198+
extensible: extNeutralModel
1019910199
data:
1020010200
- ["AssemblyStripper", "AssemblyStripper", "StripAssembly", "(System.String,System.String)", "generated"]
1020110201
- ["Generators", "EventSourceGenerator", "Execute", "(Microsoft.CodeAnalysis.GeneratorExecutionContext)", "generated"]

csharp/ql/lib/semmle/code/csharp/dataflow/ExternalFlow.qll

Lines changed: 11 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
* `namespace; type; subtypes; name; signature; ext; input; kind; provenance`
1212
* - Summaries:
1313
* `namespace; type; subtypes; name; signature; ext; input; output; kind; provenance`
14-
* - Negative Summaries:
14+
* - Neutrals:
1515
* `namespace; type; name; signature; provenance`
16-
* A negative summary is used to indicate that there is no flow via a callable.
16+
* A neutral is used to indicate that there is no flow via a callable.
1717
*
1818
* The interpretation of a row is similar to API-graphs with a left-to-right
1919
* reading.
@@ -132,30 +132,12 @@ private class SummaryModelCsvInternal extends Unit {
132132
abstract predicate row(string row);
133133
}
134134

135-
/**
136-
* DEPRECATED: Define negative summary models as data extensions instead.
137-
*
138-
* A unit class for adding additional negative summary model rows.
139-
*
140-
* Extend this class to add additional negative summary definitions.
141-
*/
142-
deprecated class NegativeSummaryModelCsv = NegativeSummaryModelCsvInternal;
143-
144-
private class NegativeSummaryModelCsvInternal extends Unit {
145-
/** Holds if `row` specifies a negative summary definition. */
146-
abstract predicate row(string row);
147-
}
148-
149135
private predicate sourceModelInternal(string row) { any(SourceModelCsvInternal s).row(row) }
150136

151137
private predicate summaryModelInternal(string row) { any(SummaryModelCsvInternal s).row(row) }
152138

153139
private predicate sinkModelInternal(string row) { any(SinkModelCsvInternal s).row(row) }
154140

155-
private predicate negativeSummaryModelInternal(string row) {
156-
any(NegativeSummaryModelCsvInternal s).row(row)
157-
}
158-
159141
/**
160142
* Holds if a source model exists for the given parameters.
161143
*/
@@ -243,25 +225,16 @@ predicate summaryModel(
243225
extSummaryModel(namespace, type, subtypes, name, signature, ext, input, output, kind, provenance)
244226
}
245227

246-
/** Holds if a summary model exists indicating there is no flow for the given parameters. */
247-
extensible predicate extNegativeSummaryModel(
228+
/** Holds if a model exists indicating there is no flow for the given parameters. */
229+
extensible predicate extNeutralModel(
248230
string namespace, string type, string name, string signature, string provenance
249231
);
250232

251-
/** Holds if a summary model exists indicating there is no flow for the given parameters. */
252-
predicate negativeSummaryModel(
233+
/** Holds if a model exists indicating there is no flow for the given parameters. */
234+
predicate neutralModel(
253235
string namespace, string type, string name, string signature, string provenance
254236
) {
255-
exists(string row |
256-
negativeSummaryModelInternal(row) and
257-
row.splitAt(";", 0) = namespace and
258-
row.splitAt(";", 1) = type and
259-
row.splitAt(";", 2) = name and
260-
row.splitAt(";", 3) = signature and
261-
row.splitAt(";", 4) = provenance
262-
)
263-
or
264-
extNegativeSummaryModel(namespace, type, name, signature, provenance)
237+
extNeutralModel(namespace, type, name, signature, provenance)
265238
}
266239

267240
private predicate relevantNamespace(string namespace) {
@@ -393,8 +366,6 @@ module ModelValidation {
393366
sinkModelInternal(row) and expect = 9 and pred = "sink"
394367
or
395368
summaryModelInternal(row) and expect = 10 and pred = "summary"
396-
or
397-
negativeSummaryModelInternal(row) and expect = 5 and pred = "negative summary"
398369
|
399370
exists(int cols |
400371
cols = 1 + max(int n | exists(row.splitAt(";", n))) and
@@ -418,9 +389,9 @@ module ModelValidation {
418389
summaryModel(namespace, type, _, name, signature, ext, _, _, _, provenance) and
419390
pred = "summary"
420391
or
421-
negativeSummaryModel(namespace, type, name, signature, provenance) and
392+
neutralModel(namespace, type, name, signature, provenance) and
422393
ext = "" and
423-
pred = "negative summary"
394+
pred = "neutral"
424395
|
425396
not namespace.regexpMatch("[a-zA-Z0-9_\\.]+") and
426397
result = "Dubious namespace \"" + namespace + "\" in " + pred + " model."
@@ -461,7 +432,7 @@ private predicate elementSpec(
461432
or
462433
summaryModel(namespace, type, subtypes, name, signature, ext, _, _, _, _)
463434
or
464-
negativeSummaryModel(namespace, type, name, signature, _) and ext = "" and subtypes = false
435+
neutralModel(namespace, type, name, signature, _) and ext = "" and subtypes = false
465436
}
466437

467438
private predicate elementSpec(
@@ -595,7 +566,7 @@ private Element interpretElement0(
595566
)
596567
}
597568

598-
/** Gets the source/sink/summary/negativesummary element corresponding to the supplied parameters. */
569+
/** Gets the source/sink/summary/neutral element corresponding to the supplied parameters. */
599570
Element interpretElement(
600571
string namespace, string type, boolean subtypes, string name, string signature, string ext
601572
) {

csharp/ql/lib/semmle/code/csharp/dataflow/internal/DataFlowPrivate.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2321,8 +2321,8 @@ module Csv {
23212321
)
23222322
}
23232323

2324-
/** Computes the first 4 columns for negative CSV rows of `c`. */
2325-
string asPartialNegativeModel(DotNet::Callable c) {
2324+
/** Computes the first 4 columns for neutral CSV rows of `c`. */
2325+
string asPartialNeutralModel(DotNet::Callable c) {
23262326
exists(string namespace, string type, string name, string parameters |
23272327
partialModel(c, namespace, type, name, parameters) and
23282328
result =

csharp/ql/lib/semmle/code/csharp/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,14 @@ module Public {
246246
predicate isAutoGenerated() { none() }
247247
}
248248

249-
/** A callable with a flow summary stating there is no flow via the callable. */
250-
class NegativeSummarizedCallable extends SummarizedCallableBase {
251-
NegativeSummarizedCallable() { negativeSummaryElement(this, _) }
249+
/** A callable where there is no flow via the callable. */
250+
class NeutralCallable extends SummarizedCallableBase {
251+
NeutralCallable() { neutralElement(this, _) }
252252

253253
/**
254-
* Holds if the negative summary is auto generated.
254+
* Holds if the neutral is auto generated.
255255
*/
256-
predicate isAutoGenerated() { negativeSummaryElement(this, true) }
256+
predicate isAutoGenerated() { neutralElement(this, true) }
257257
}
258258
}
259259

@@ -1161,9 +1161,9 @@ module Private {
11611161
string toString() { result = super.toString() }
11621162
}
11631163

1164-
/** A flow summary to include in the `negativeSummary/1` query predicate. */
1165-
abstract class RelevantNegativeSummarizedCallable instanceof NegativeSummarizedCallable {
1166-
/** Gets the string representation of this callable used by `summary/1`. */
1164+
/** A model to include in the `neutral/1` query predicate. */
1165+
abstract class RelevantNeutralCallable instanceof NeutralCallable {
1166+
/** Gets the string representation of this callable used by `neutral/1`. */
11671167
abstract string getCallableCsv();
11681168

11691169
string toString() { result = super.toString() }
@@ -1180,13 +1180,13 @@ module Private {
11801180
if c.isAutoGenerated() then result = "generated" else result = "manual"
11811181
}
11821182

1183-
private string renderProvenanceNegative(NegativeSummarizedCallable c) {
1183+
private string renderProvenanceNeutral(NeutralCallable c) {
11841184
if c.isAutoGenerated() then result = "generated" else result = "manual"
11851185
}
11861186

11871187
/**
11881188
* A query predicate for outputting flow summaries in semi-colon separated format in QL tests.
1189-
* The syntax is: "namespace;type;overrides;name;signature;ext;inputspec;outputspec;kind;provenance"",
1189+
* The syntax is: "namespace;type;overrides;name;signature;ext;inputspec;outputspec;kind;provenance",
11901190
* ext is hardcoded to empty.
11911191
*/
11921192
query predicate summary(string csv) {
@@ -1205,14 +1205,14 @@ module Private {
12051205
}
12061206

12071207
/**
1208-
* Holds if a negative flow summary `csv` exists (semi-colon separated format). Used for testing purposes.
1208+
* Holds if a neutral model `csv` exists (semi-colon separated format). Used for testing purposes.
12091209
* The syntax is: "namespace;type;name;signature;provenance"",
12101210
*/
1211-
query predicate negativeSummary(string csv) {
1212-
exists(RelevantNegativeSummarizedCallable c |
1211+
query predicate neutral(string csv) {
1212+
exists(RelevantNeutralCallable c |
12131213
csv =
12141214
c.getCallableCsv() // Callable information
1215-
+ renderProvenanceNegative(c) // provenance
1215+
+ renderProvenanceNeutral(c) // provenance
12161216
)
12171217
}
12181218
}

csharp/ql/lib/semmle/code/csharp/dataflow/internal/FlowSummaryImplSpecific.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ predicate summaryElement(Callable c, string input, string output, string kind, b
121121
}
122122

123123
/**
124-
* Holds if a negative flow summary exists for `c`, which means that there is no
125-
* flow through `c`. The flag `generated` states whether the summary is autogenerated.
124+
* Holds if a neutral model exists for `c`, which means that there is no
125+
* flow through `c`. The flag `generated` states whether the neutral model is autogenerated.
126126
*/
127-
predicate negativeSummaryElement(Callable c, boolean generated) {
127+
predicate neutralElement(Callable c, boolean generated) {
128128
exists(string namespace, string type, string name, string signature, string provenance |
129-
negativeSummaryModel(namespace, type, name, signature, provenance) and
129+
neutralModel(namespace, type, name, signature, provenance) and
130130
generated = isGenerated(provenance) and
131131
c = interpretElement(namespace, type, false, name, signature, "")
132132
)

csharp/ql/src/Telemetry/SupportedExternalApis.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ private predicate relevant(ExternalApi api) {
1515
not api.isUninteresting() and
1616
(
1717
api.isSupported() or
18-
api instanceof FlowSummaryImpl::Public::NegativeSummarizedCallable
18+
api instanceof FlowSummaryImpl::Public::NeutralCallable
1919
)
2020
}
2121

csharp/ql/src/Telemetry/UnsupportedExternalAPIs.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ private import ExternalApi
1414
private predicate relevant(ExternalApi api) {
1515
not api.isUninteresting() and
1616
not api.isSupported() and
17-
not api instanceof FlowSummaryImpl::Public::NegativeSummarizedCallable
17+
not api instanceof FlowSummaryImpl::Public::NeutralCallable
1818
}
1919

2020
from string info, int usages

csharp/ql/src/meta/frameworks/UnsupportedExternalAPIs.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ where
1818
c.getTarget().getUnboundDeclaration() = api and
1919
not api.isUninteresting() and
2020
not api.isSupported() and
21-
not api instanceof FlowSummaryImpl::Public::NegativeSummarizedCallable
21+
not api instanceof FlowSummaryImpl::Public::NeutralCallable
2222
select c, "Call to unsupported external API $@.", api, api.toString()

csharp/ql/src/utils/model-generator/CaptureNegativeSummaryModels.ql renamed to csharp/ql/src/utils/model-generator/CaptureNeutralModels.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
2-
* @name Capture negative summary models.
3-
* @description Finds negative summary models to be used by other queries.
2+
* @name Capture neutral models.
3+
* @description Finds neutral models to be used by other queries.
44
* @kind diagnostic
5-
* @id cs/utils/model-generator/negative-summary-models
5+
* @id cs/utils/model-generator/neutral-models
66
* @tags model-generator
77
*/
88

Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/**
2-
* @name Extract MaD negative summary model rows.
3-
* @description This extracts the Models as data negative summary model rows.
4-
* @id csharp/utils/modelconverter/generate-data-extensions-negative-summary
2+
* @name Extract MaD neutral model rows.
3+
* @description This extracts the Models as data neutral model rows.
4+
* @id csharp/utils/modelconverter/generate-data-extensions-neutral
55
*/
66

77
import csharp
88
import semmle.code.csharp.dataflow.ExternalFlow
99

1010
from string package, string type, string name, string signature, string provenance
1111
where
12-
negativeSummaryModel(package, type, name, signature, provenance) and
12+
neutralModel(package, type, name, signature, provenance) and
1313
provenance != "generated"
1414
select package, type, name, signature, provenance order by package, type, name, signature

0 commit comments

Comments
 (0)