Skip to content

Commit 7e9d870

Browse files
committed
Data flow: Sync
1 parent febebed commit 7e9d870

File tree

1 file changed

+20
-29
lines changed

1 file changed

+20
-29
lines changed

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

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
private import FlowSummaryImplSpecific
1010
private import DataFlowImplSpecific::Private
1111
private import DataFlowImplSpecific::Public
12-
private import DataFlowImplCommon as DataFlowImplCommon
12+
private import DataFlowImplCommon
1313

1414
/** Provides classes and predicates for defining flow summaries. */
1515
module Public {
@@ -295,7 +295,7 @@ module Private {
295295
or
296296
exists(int i |
297297
parameterReadState(c, state, i) and
298-
result.(ParameterNode).isParameterOf(c, i)
298+
result.(ParamNode).isParameterOf(c, i)
299299
)
300300
)
301301
}
@@ -421,7 +421,7 @@ module Private {
421421
}
422422

423423
/** Holds if summary node `post` is a post-update node with pre-update node `pre`. */
424-
predicate summaryPostUpdateNode(Node post, ParameterNode pre) {
424+
predicate summaryPostUpdateNode(Node post, ParamNode pre) {
425425
exists(SummarizedCallable c, int i |
426426
isParameterPostUpdate(post, c, i) and
427427
pre.isParameterOf(c, i)
@@ -493,17 +493,15 @@ module Private {
493493
* Holds if values stored inside content `c` are cleared when passed as
494494
* input of type `input` in `call`.
495495
*/
496-
predicate summaryClearsContent(ArgumentNode arg, Content c) {
496+
predicate summaryClearsContent(ArgNode arg, Content c) {
497497
exists(DataFlowCall call, int i |
498498
viableCallable(call).(SummarizedCallable).clearsContent(i, c) and
499499
arg.argumentOf(call, i)
500500
)
501501
}
502502

503503
pragma[nomagic]
504-
private ParameterNode summaryArgParam(
505-
ArgumentNode arg, DataFlowImplCommon::ReturnKindExt rk, DataFlowImplCommon::OutNodeExt out
506-
) {
504+
private ParamNode summaryArgParam(ArgNode arg, ReturnKindExt rk, OutNodeExt out) {
507505
exists(DataFlowCall call, int pos, SummarizedCallable callable |
508506
arg.argumentOf(call, pos) and
509507
viableCallable(call) = callable and
@@ -519,8 +517,8 @@ module Private {
519517
* NOTE: This step should not be used in global data-flow/taint-tracking, but may
520518
* be useful to include in the exposed local data-flow/taint-tracking relations.
521519
*/
522-
predicate summaryThroughStep(ArgumentNode arg, Node out, boolean preservesValue) {
523-
exists(DataFlowImplCommon::ReturnKindExt rk, DataFlowImplCommon::ReturnNodeExt ret |
520+
predicate summaryThroughStep(ArgNode arg, Node out, boolean preservesValue) {
521+
exists(ReturnKindExt rk, ReturnNodeExt ret |
524522
summaryLocalStep(summaryArgParam(arg, rk, out), ret, preservesValue) and
525523
ret.getKind() = rk
526524
)
@@ -533,8 +531,8 @@ module Private {
533531
* NOTE: This step should not be used in global data-flow/taint-tracking, but may
534532
* be useful to include in the exposed local data-flow/taint-tracking relations.
535533
*/
536-
predicate summaryGetterStep(ArgumentNode arg, Content c, Node out) {
537-
exists(DataFlowImplCommon::ReturnKindExt rk, Node mid, DataFlowImplCommon::ReturnNodeExt ret |
534+
predicate summaryGetterStep(ArgNode arg, Content c, Node out) {
535+
exists(ReturnKindExt rk, Node mid, ReturnNodeExt ret |
538536
summaryReadStep(summaryArgParam(arg, rk, out), c, mid) and
539537
summaryLocalStep(mid, ret, _) and
540538
ret.getKind() = rk
@@ -548,8 +546,8 @@ module Private {
548546
* NOTE: This step should not be used in global data-flow/taint-tracking, but may
549547
* be useful to include in the exposed local data-flow/taint-tracking relations.
550548
*/
551-
predicate summarySetterStep(ArgumentNode arg, Content c, Node out) {
552-
exists(DataFlowImplCommon::ReturnKindExt rk, Node mid, DataFlowImplCommon::ReturnNodeExt ret |
549+
predicate summarySetterStep(ArgNode arg, Content c, Node out) {
550+
exists(ReturnKindExt rk, Node mid, ReturnNodeExt ret |
553551
summaryLocalStep(summaryArgParam(arg, rk, out), mid, _) and
554552
summaryStoreStep(mid, c, ret) and
555553
ret.getKind() = rk
@@ -563,12 +561,9 @@ module Private {
563561
* definition of `clearsContent()`.
564562
*/
565563
predicate summaryStoresIntoArg(Content c, Node arg) {
566-
exists(
567-
DataFlowImplCommon::ParamUpdateReturnKind rk, DataFlowImplCommon::ReturnNodeExt ret,
568-
PostUpdateNode out
569-
|
564+
exists(ParamUpdateReturnKind rk, ReturnNodeExt ret, PostUpdateNode out |
570565
exists(DataFlowCall call, SummarizedCallable callable |
571-
DataFlowImplCommon::getNodeEnclosingCallable(ret) = callable and
566+
getNodeEnclosingCallable(ret) = callable and
572567
viableCallable(call) = callable and
573568
summaryStoreStep(_, c, ret) and
574569
ret.getKind() = pragma[only_bind_into](rk) and
@@ -740,21 +735,17 @@ module Private {
740735
specSplit(output, c, idx)
741736
|
742737
exists(int pos |
743-
node.asNode()
744-
.(PostUpdateNode)
745-
.getPreUpdateNode()
746-
.(ArgumentNode)
747-
.argumentOf(mid.asCall(), pos)
738+
node.asNode().(PostUpdateNode).getPreUpdateNode().(ArgNode).argumentOf(mid.asCall(), pos)
748739
|
749740
c = "Argument" or parseArg(c, pos)
750741
)
751742
or
752-
exists(int pos | node.asNode().(ParameterNode).isParameterOf(mid.asCallable(), pos) |
743+
exists(int pos | node.asNode().(ParamNode).isParameterOf(mid.asCallable(), pos) |
753744
c = "Parameter" or parseParam(c, pos)
754745
)
755746
or
756747
c = "ReturnValue" and
757-
node.asNode() = getAnOutNode(mid.asCall(), getReturnValueKind())
748+
node.asNode() = getAnOutNodeExt(mid.asCall(), TValueReturn(getReturnValueKind()))
758749
or
759750
interpretOutputSpecific(c, mid, node)
760751
)
@@ -769,15 +760,15 @@ module Private {
769760
interpretInput(input, idx + 1, ref, mid) and
770761
specSplit(input, c, idx)
771762
|
772-
exists(int pos | node.asNode().(ArgumentNode).argumentOf(mid.asCall(), pos) |
763+
exists(int pos | node.asNode().(ArgNode).argumentOf(mid.asCall(), pos) |
773764
c = "Argument" or parseArg(c, pos)
774765
)
775766
or
776-
exists(ReturnNode ret |
767+
exists(ReturnNodeExt ret |
777768
c = "ReturnValue" and
778769
ret = node.asNode() and
779-
ret.getKind() = getReturnValueKind() and
780-
mid.asCallable() = DataFlowImplCommon::getNodeEnclosingCallable(ret)
770+
ret.getKind().(ValueReturnKind).getKind() = getReturnValueKind() and
771+
mid.asCallable() = getNodeEnclosingCallable(ret)
781772
)
782773
or
783774
interpretInputSpecific(c, mid, node)

0 commit comments

Comments
 (0)