Skip to content

Commit f9599da

Browse files
committed
Java/C#: Move a couple of flow summary tweaks to the shared implementation.
1 parent 9362ae0 commit f9599da

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,19 @@ module Private {
446446
summary(c, inputContents, outputContents, preservesValue) and
447447
pred = summaryNodeInputState(c, inputContents) and
448448
succ = summaryNodeOutputState(c, outputContents)
449+
|
450+
preservesValue = true
451+
or
452+
preservesValue = false and not summary(c, inputContents, outputContents, true)
449453
)
454+
or
455+
// If flow through a method updates a parameter from some input A, and that
456+
// parameter also is returned through B, then we'd like a combined flow from A
457+
// to B as well. As an example, this simplifies modeling of fluent methods:
458+
// for `StringBuilder.append(x)` with a specified value flow from qualifier to
459+
// return value and taint flow from argument 0 to the qualifier, then this
460+
// allows us to infer taint flow from argument 0 to the return value.
461+
summaryPostUpdateNode(pred, succ) and preservesValue = true
450462
}
451463

452464
/**

java/ql/src/semmle/code/java/dataflow/internal/DataFlowUtil.qll

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,6 @@ predicate simpleLocalFlowStep(Node node1, Node node2) {
150150
)
151151
or
152152
FlowSummaryImpl::Private::Steps::summaryLocalStep(node1, node2, true)
153-
or
154-
// If flow through a method updates a parameter from some input A, and that
155-
// parameter also is returned through B, then we'd like a combined flow from A
156-
// to B as well. As an example, this simplifies modeling of fluent methods:
157-
// for `StringBuilder.append(x)` with a specified value flow from qualifier to
158-
// return value and taint flow from argument 0 to the qualifier, then this
159-
// allows us to infer taint flow from argument 0 to the return value.
160-
node1.(SummaryNode).(PostUpdateNode).getPreUpdateNode().(ParameterNode) = node2
161153
}
162154

163155
/**

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,19 @@ module Private {
446446
summary(c, inputContents, outputContents, preservesValue) and
447447
pred = summaryNodeInputState(c, inputContents) and
448448
succ = summaryNodeOutputState(c, outputContents)
449+
|
450+
preservesValue = true
451+
or
452+
preservesValue = false and not summary(c, inputContents, outputContents, true)
449453
)
454+
or
455+
// If flow through a method updates a parameter from some input A, and that
456+
// parameter also is returned through B, then we'd like a combined flow from A
457+
// to B as well. As an example, this simplifies modeling of fluent methods:
458+
// for `StringBuilder.append(x)` with a specified value flow from qualifier to
459+
// return value and taint flow from argument 0 to the qualifier, then this
460+
// allows us to infer taint flow from argument 0 to the return value.
461+
summaryPostUpdateNode(pred, succ) and preservesValue = true
450462
}
451463

452464
/**

java/ql/src/semmle/code/java/dataflow/internal/TaintTrackingUtil.qll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ predicate localAdditionalTaintStep(DataFlow::Node src, DataFlow::Node sink) {
5757
sink.(DataFlow::ImplicitVarargsArray).getCall() = arg.getCall()
5858
)
5959
or
60-
FlowSummaryImpl::Private::Steps::summaryLocalStep(src, sink, false) and
61-
not FlowSummaryImpl::Private::Steps::summaryLocalStep(src, sink, true)
60+
FlowSummaryImpl::Private::Steps::summaryLocalStep(src, sink, false)
6261
}
6362

6463
/**

0 commit comments

Comments
 (0)