Java: Rename Negative Summary Model to Neutral Model.

This commit is contained in:
Michael Nebel
2022-12-06 16:33:12 +01:00
parent 079d48c42a
commit 3af00a8f3f
11 changed files with 41 additions and 45 deletions

View File

@@ -14,5 +14,5 @@ extensions:
data: []
- addsTo:
pack: codeql/java-all
extensible: extNegativeSummaryModel
extensible: extNeutralModel
data: []

View File

@@ -1861,7 +1861,7 @@ extensions:
- addsTo:
pack: codeql/java-all
extensible: extNegativeSummaryModel
extensible: extNeutralModel
data:
- ["kotlin.annotation", "AnnotationRetention", "valueOf", "(String)", "generated"]
- ["kotlin.annotation", "AnnotationRetention", "values", "()", "generated"]

View File

@@ -676,7 +676,7 @@ extensions:
- addsTo:
pack: codeql/java-all
extensible: extNegativeSummaryModel
extensible: extNeutralModel
data:
- ["org.apache.commons.io.charset", "CharsetDecoders", "CharsetDecoders", "()", "generated"]
- ["org.apache.commons.io.charset", "CharsetEncoders", "CharsetEncoders", "()", "generated"]

View File

@@ -11,9 +11,9 @@
* `package; type; subtypes; name; signature; ext; input; kind; provenance`
* - Summaries:
* `package; type; subtypes; name; signature; ext; input; output; kind; provenance`
* - Negative Summaries:
* - Neutrals:
* `package; type; name; signature; provenance`
* A negative summary is used to indicate that there is no flow via a callable.
* A neutral is used to indicate that there is no flow via a callable.
*
* The interpretation of a row is similar to API-graphs with a left-to-right
* reading.
@@ -123,16 +123,16 @@ private class SummaryModelCsvInternal extends Unit {
}
/**
* DEPRECATED: Define negative summary models as data extensions instead.
* DEPRECATED: Define neutral models as data extensions instead.
*
* A unit class for adding additional negative summary model rows.
* A unit class for adding additional neutral model rows.
*
* Extend this class to add additional negative summary definitions.
* Extend this class to add additional neutral definitions.
*/
deprecated class NegativeSummaryModelCsv = NegativeSummaryModelCsvInternal;
deprecated class NeutralModelCsv = NeutralModelCsvInternal;
private class NegativeSummaryModelCsvInternal extends Unit {
/** Holds if `row` specifies a negative summary definition. */
private class NeutralModelCsvInternal extends Unit {
/** Holds if `row` specifies a neutral definition. */
abstract predicate row(string row);
}
@@ -142,9 +142,7 @@ private predicate summaryModelInternal(string row) { any(SummaryModelCsvInternal
private predicate sinkModelInternal(string row) { any(SinkModelCsvInternal s).row(row) }
private predicate negativeSummaryModelInternal(string row) {
any(NegativeSummaryModelCsvInternal s).row(row)
}
private predicate neutralModelInternal(string row) { any(NeutralModelCsvInternal s).row(row) }
/**
* Holds if an experimental source model exists for the given parameters.
@@ -313,17 +311,15 @@ predicate summaryModel(
.summaryModel(package, type, subtypes, name, signature, ext, input, output, kind, provenance)
}
/** Holds if a summary model exists indicating there is no flow for the given parameters. */
extensible predicate extNegativeSummaryModel(
/** Holds if a neutral model exists indicating there is no flow for the given parameters. */
extensible predicate extNeutralModel(
string package, string type, string name, string signature, string provenance
);
/** Holds if a summary model exists indicating there is no flow for the given parameters. */
predicate negativeSummaryModel(
string package, string type, string name, string signature, string provenance
) {
/** Holds if a neutral model exists indicating there is no flow for the given parameters. */
predicate neutralModel(string package, string type, string name, string signature, string provenance) {
exists(string row |
negativeSummaryModelInternal(row) and
neutralModelInternal(row) and
row.splitAt(";", 0) = package and
row.splitAt(";", 1) = type and
row.splitAt(";", 2) = name and
@@ -331,7 +327,7 @@ predicate negativeSummaryModel(
row.splitAt(";", 4) = provenance
)
or
extNegativeSummaryModel(package, type, name, signature, provenance)
extNeutralModel(package, type, name, signature, provenance)
}
private predicate relevantPackage(string package) {
@@ -473,7 +469,7 @@ module ModelValidation {
or
summaryModelInternal(row) and expect = 10 and pred = "summary"
or
negativeSummaryModelInternal(row) and expect = 5 and pred = "negative summary"
neutralModelInternal(row) and expect = 5 and pred = "neutral"
|
exists(int cols |
cols = 1 + max(int n | exists(row.splitAt(";", n))) and
@@ -497,9 +493,9 @@ module ModelValidation {
summaryModel(package, type, _, name, signature, ext, _, _, _, provenance) and
pred = "summary"
or
negativeSummaryModel(package, type, name, signature, provenance) and
neutralModel(package, type, name, signature, provenance) and
ext = "" and
pred = "negative summary"
pred = "neutral"
|
not package.regexpMatch("[a-zA-Z0-9_\\.]*") and
result = "Dubious package \"" + package + "\" in " + pred + " model."
@@ -541,7 +537,7 @@ private predicate elementSpec(
or
summaryModel(package, type, subtypes, name, signature, ext, _, _, _, _)
or
negativeSummaryModel(package, type, name, signature, _) and ext = "" and subtypes = false
neutralModel(package, type, name, signature, _) and ext = "" and subtypes = false
}
private string paramsStringPart(Callable c, int i) {
@@ -590,7 +586,7 @@ private Element interpretElement0(
)
}
/** Gets the source/sink/summary/negativesummary element corresponding to the supplied parameters. */
/** Gets the source/sink/summary/neutral element corresponding to the supplied parameters. */
Element interpretElement(
string package, string type, boolean subtypes, string name, string signature, string ext
) {

View File

@@ -160,12 +160,12 @@ predicate summaryElement(
}
/**
* Holds if a negative flow summary exists for `c`, which means that there is no
* flow through `c`. The flag `generated` states whether the summary is autogenerated.
* Holds if a neutral model exists for `c`, which means that there is no
* flow through `c`. The flag `generated` states whether the model is autogenerated.
*/
predicate negativeSummaryElement(SummarizedCallableBase c, boolean generated) {
predicate neutralElement(SummarizedCallableBase c, boolean generated) {
exists(string namespace, string type, string name, string signature, string provenance |
negativeSummaryModel(namespace, type, name, signature, provenance) and
neutralModel(namespace, type, name, signature, provenance) and
generated = isGenerated(provenance) and
c.asCallable() = interpretElement(namespace, type, false, name, signature, "")
)

View File

@@ -14,7 +14,7 @@ private predicate relevant(ExternalApi api) {
not api.isUninteresting() and
(
api.isSupported() or
api = any(FlowSummaryImpl::Public::NegativeSummarizedCallable nsc).asCallable()
api = any(FlowSummaryImpl::Public::NeutralCallable nsc).asCallable()
)
}

View File

@@ -13,7 +13,7 @@ import ExternalApi
private predicate relevant(ExternalApi api) {
not api.isUninteresting() and
not api.isSupported() and
not api = any(FlowSummaryImpl::Public::NegativeSummarizedCallable nsc).asCallable()
not api = any(FlowSummaryImpl::Public::NeutralCallable nsc).asCallable()
}
from string apiName, int usages

View File

@@ -1,8 +1,8 @@
/**
* @name Capture negative summary models.
* @description Finds negative summary models to be used by other queries.
* @name Capture neutral models.
* @description Finds neutral models to be used by other queries.
* @kind diagnostic
* @id java/utils/model-generator/negative-summary-models
* @id java/utils/model-generator/neutral-models
* @tags model-generator
*/

View File

@@ -1,7 +1,7 @@
/**
* @name Extract MaD negative summary model rows.
* @description This extracts the Models as data negative summary model rows.
* @id java/utils/modelconverter/generate-data-extensions-negative-summary
* @name Extract MaD neutral model rows.
* @description This extracts the Models as data neutral model rows.
* @id java/utils/modelconverter/generate-data-extensions-neutral
*/
import java
@@ -9,6 +9,6 @@ import semmle.code.java.dataflow.ExternalFlow
from string package, string type, string name, string signature, string provenance
where
negativeSummaryModel(package, type, name, signature, provenance) and
neutralModel(package, type, name, signature, provenance) and
provenance != "generated"
select package, type, name, signature, provenance order by package, type, name, signature

View File

@@ -131,9 +131,9 @@ string asPartialModel(TargetApiSpecific api) {
}
/**
* Computes the first 4 columns for negative CSV rows.
* Computes the first 4 columns for neutral CSV rows.
*/
string asPartialNegativeModel(TargetApiSpecific api) {
string asPartialNeutralModel(TargetApiSpecific api) {
exists(string type, string name, string parameters |
partialModel(api, type, name, parameters) and
result =

View File

@@ -77,10 +77,10 @@ string captureFlow(DataFlowTargetApi api) {
}
/**
* Gets the negative summary for `api`, if any.
* A negative summary is generated, if there does not exist any positive flow.
* Gets the neutral summary for `api`, if any.
* A neutral model is generated, if there does not exist any summary model.
*/
string captureNoFlow(DataFlowTargetApi api) {
not exists(captureFlow(api)) and
result = asNegativeSummaryModel(api)
result = asNeutralModel(api)
}