Skip to content

Commit 9a45949

Browse files
authored
Merge pull request github#9044 from michaelnebel/csharp/flowsummariestest
C#: Flow summaries test should print, whether a summary is generated or not.
2 parents 1401e7d + 76fd424 commit 9a45949

File tree

3 files changed

+39
-6
lines changed

3 files changed

+39
-6
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ module Public {
219219
*/
220220
pragma[nomagic]
221221
predicate clearsContent(ParameterPosition pos, ContentSet content) { none() }
222+
223+
/**
224+
* Holds if the summary is auto generated.
225+
*/
226+
predicate isAutoGenerated() { none() }
222227
}
223228
}
224229

@@ -898,6 +903,8 @@ module Private {
898903
kind = "taint" and preservesValue = false
899904
)
900905
}
906+
907+
override predicate isAutoGenerated() { summaryElement(this, _, _, _, true) }
901908
}
902909

903910
/** Holds if component `c` of specification `spec` cannot be parsed. */
@@ -1052,9 +1059,13 @@ module Private {
10521059
preservesValue = false and result = "taint"
10531060
}
10541061

1062+
private string renderGenerated(RelevantSummarizedCallable c) {
1063+
if c.isAutoGenerated() then result = "generated:" else result = ""
1064+
}
1065+
10551066
/**
10561067
* A query predicate for outputting flow summaries in semi-colon separated format in QL tests.
1057-
* The syntax is: "namespace;type;overrides;name;signature;ext;inputspec;outputspec;kind",
1068+
* The syntax is: "namespace;type;overrides;name;signature;ext;inputspec;outputspec;(generated:)?kind",
10581069
* ext is hardcoded to empty.
10591070
*/
10601071
query predicate summary(string csv) {
@@ -1065,7 +1076,7 @@ module Private {
10651076
c.relevantSummary(input, output, preservesValue) and
10661077
csv =
10671078
c.getCallableCsv() + getComponentStackCsv(input) + ";" + getComponentStackCsv(output) +
1068-
";" + renderKind(preservesValue)
1079+
";" + renderGenerated(c) + renderKind(preservesValue)
10691080
)
10701081
}
10711082
}

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ module Public {
219219
*/
220220
pragma[nomagic]
221221
predicate clearsContent(ParameterPosition pos, ContentSet content) { none() }
222+
223+
/**
224+
* Holds if the summary is auto generated.
225+
*/
226+
predicate isAutoGenerated() { none() }
222227
}
223228
}
224229

@@ -898,6 +903,8 @@ module Private {
898903
kind = "taint" and preservesValue = false
899904
)
900905
}
906+
907+
override predicate isAutoGenerated() { summaryElement(this, _, _, _, true) }
901908
}
902909

903910
/** Holds if component `c` of specification `spec` cannot be parsed. */
@@ -1052,9 +1059,13 @@ module Private {
10521059
preservesValue = false and result = "taint"
10531060
}
10541061

1062+
private string renderGenerated(RelevantSummarizedCallable c) {
1063+
if c.isAutoGenerated() then result = "generated:" else result = ""
1064+
}
1065+
10551066
/**
10561067
* A query predicate for outputting flow summaries in semi-colon separated format in QL tests.
1057-
* The syntax is: "namespace;type;overrides;name;signature;ext;inputspec;outputspec;kind",
1068+
* The syntax is: "namespace;type;overrides;name;signature;ext;inputspec;outputspec;(generated:)?kind",
10581069
* ext is hardcoded to empty.
10591070
*/
10601071
query predicate summary(string csv) {
@@ -1065,7 +1076,7 @@ module Private {
10651076
c.relevantSummary(input, output, preservesValue) and
10661077
csv =
10671078
c.getCallableCsv() + getComponentStackCsv(input) + ";" + getComponentStackCsv(output) +
1068-
";" + renderKind(preservesValue)
1079+
";" + renderGenerated(c) + renderKind(preservesValue)
10691080
)
10701081
}
10711082
}

ruby/ql/lib/codeql/ruby/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ module Public {
219219
*/
220220
pragma[nomagic]
221221
predicate clearsContent(ParameterPosition pos, ContentSet content) { none() }
222+
223+
/**
224+
* Holds if the summary is auto generated.
225+
*/
226+
predicate isAutoGenerated() { none() }
222227
}
223228
}
224229

@@ -898,6 +903,8 @@ module Private {
898903
kind = "taint" and preservesValue = false
899904
)
900905
}
906+
907+
override predicate isAutoGenerated() { summaryElement(this, _, _, _, true) }
901908
}
902909

903910
/** Holds if component `c` of specification `spec` cannot be parsed. */
@@ -1052,9 +1059,13 @@ module Private {
10521059
preservesValue = false and result = "taint"
10531060
}
10541061

1062+
private string renderGenerated(RelevantSummarizedCallable c) {
1063+
if c.isAutoGenerated() then result = "generated:" else result = ""
1064+
}
1065+
10551066
/**
10561067
* A query predicate for outputting flow summaries in semi-colon separated format in QL tests.
1057-
* The syntax is: "namespace;type;overrides;name;signature;ext;inputspec;outputspec;kind",
1068+
* The syntax is: "namespace;type;overrides;name;signature;ext;inputspec;outputspec;(generated:)?kind",
10581069
* ext is hardcoded to empty.
10591070
*/
10601071
query predicate summary(string csv) {
@@ -1065,7 +1076,7 @@ module Private {
10651076
c.relevantSummary(input, output, preservesValue) and
10661077
csv =
10671078
c.getCallableCsv() + getComponentStackCsv(input) + ";" + getComponentStackCsv(output) +
1068-
";" + renderKind(preservesValue)
1079+
";" + renderGenerated(c) + renderKind(preservesValue)
10691080
)
10701081
}
10711082
}

0 commit comments

Comments
 (0)