Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d9444d8

Browse files
committed
Python: update synced file FlowSummaryImpl.qll
1 parent 0b5d4c5 commit d9444d8

3 files changed

Lines changed: 50 additions & 6 deletions

File tree

config/identical-files.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"ruby/ql/lib/codeql/ruby/dataflow/internal/DataFlowImplConsistency.qll",
7373
"swift/ql/lib/codeql/swift/dataflow/internal/DataFlowImplConsistency.qll"
7474
],
75-
"DataFlow Java/C# Flow Summaries": [
75+
"DataFlow Java/C#/Ruby/Python/Swift Flow Summaries": [
7676
"java/ql/lib/semmle/code/java/dataflow/internal/FlowSummaryImpl.qll",
7777
"csharp/ql/lib/semmle/code/csharp/dataflow/internal/FlowSummaryImpl.qll",
7878
"ruby/ql/lib/codeql/ruby/dataflow/internal/FlowSummaryImpl.qll",

python/ql/lib/semmle/python/dataflow/new/internal/FlowSummaryImpl.qll

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,16 @@ module Public {
240240
*/
241241
predicate isAutoGenerated() { none() }
242242
}
243+
244+
/** A callable with a flow summary stating there is no flow via the callable. */
245+
class NegativeSummarizedCallable extends SummarizedCallableBase {
246+
NegativeSummarizedCallable() { negativeSummaryElement(this, _) }
247+
248+
/**
249+
* Holds if the negative summary is auto generated.
250+
*/
251+
predicate isAutoGenerated() { negativeSummaryElement(this, true) }
252+
}
243253
}
244254

245255
/**
@@ -1094,7 +1104,7 @@ module Private {
10941104

10951105
/** Provides a query predicate for outputting a set of relevant flow summaries. */
10961106
module TestOutput {
1097-
/** A flow summary to include in the `summary/3` query predicate. */
1107+
/** A flow summary to include in the `summary/1` query predicate. */
10981108
abstract class RelevantSummarizedCallable instanceof SummarizedCallable {
10991109
/** Gets the string representation of this callable used by `summary/1`. */
11001110
abstract string getCallableCsv();
@@ -1109,15 +1119,27 @@ module Private {
11091119
string toString() { result = super.toString() }
11101120
}
11111121

1122+
/** A flow summary to include in the `negativeSummary/1` query predicate. */
1123+
abstract class RelevantNegativeSummarizedCallable instanceof NegativeSummarizedCallable {
1124+
/** Gets the string representation of this callable used by `summary/1`. */
1125+
abstract string getCallableCsv();
1126+
1127+
string toString() { result = super.toString() }
1128+
}
1129+
11121130
/** Render the kind in the format used in flow summaries. */
11131131
private string renderKind(boolean preservesValue) {
11141132
preservesValue = true and result = "value"
11151133
or
11161134
preservesValue = false and result = "taint"
11171135
}
11181136

1119-
private string renderProvenance(RelevantSummarizedCallable c) {
1120-
if c.(SummarizedCallable).isAutoGenerated() then result = "generated" else result = "manual"
1137+
private string renderProvenance(SummarizedCallable c) {
1138+
if c.isAutoGenerated() then result = "generated" else result = "manual"
1139+
}
1140+
1141+
private string renderProvenanceNegative(NegativeSummarizedCallable c) {
1142+
if c.isAutoGenerated() then result = "generated" else result = "manual"
11211143
}
11221144

11231145
/**
@@ -1132,8 +1154,23 @@ module Private {
11321154
|
11331155
c.relevantSummary(input, output, preservesValue) and
11341156
csv =
1135-
c.getCallableCsv() + getComponentStackCsv(input) + ";" + getComponentStackCsv(output) +
1136-
";" + renderKind(preservesValue) + ";" + renderProvenance(c)
1157+
c.getCallableCsv() // Callable information
1158+
+ getComponentStackCsv(input) + ";" // input
1159+
+ getComponentStackCsv(output) + ";" // output
1160+
+ renderKind(preservesValue) + ";" // kind
1161+
+ renderProvenance(c) // provenance
1162+
)
1163+
}
1164+
1165+
/**
1166+
* Holds if a negative flow summary `csv` exists (semi-colon separated format). Used for testing purposes.
1167+
* The syntax is: "namespace;type;name;signature;provenance"",
1168+
*/
1169+
query predicate negativeSummary(string csv) {
1170+
exists(RelevantNegativeSummarizedCallable c |
1171+
csv =
1172+
c.getCallableCsv() // Callable information
1173+
+ renderProvenanceNegative(c) // provenance
11371174
)
11381175
}
11391176
}

python/ql/lib/semmle/python/dataflow/new/internal/FlowSummaryImplSpecific.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,13 @@ predicate summaryElement(
5858
)
5959
}
6060

61+
/**
62+
* Holds if a negative flow summary exists for `c`, which means that there is no
63+
* flow through `c`. The flag `generated` states whether the summary is autogenerated.
64+
* Note. Negative flow summaries has not been implemented for Python.
65+
*/
66+
predicate negativeSummaryElement(FlowSummary::SummarizedCallable c, boolean generated) { none() }
67+
6168
/**
6269
* Gets the summary component for specification component `c`, if any.
6370
*

0 commit comments

Comments
 (0)