Skip to content

Commit a97e7bd

Browse files
committed
Java/C++/C#: Some review fixes.
1 parent 0eacadb commit a97e7bd

File tree

23 files changed

+318
-1406
lines changed

23 files changed

+318
-1406
lines changed

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl.qll

Lines changed: 2 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -460,76 +460,6 @@ private predicate throughFlowNodeCand(Node node, Configuration config) {
460460
not outBarrier(node, config)
461461
}
462462

463-
private newtype TSummary =
464-
TSummaryVal() or
465-
TSummaryTaint() or
466-
TSummaryReadVal(Content f) or
467-
TSummaryReadTaint(Content f) or
468-
TSummaryTaintStore(Content f)
469-
470-
/**
471-
* A summary of flow through a callable. This can either be value-preserving
472-
* if no additional steps are used, taint-flow if at least on additional step
473-
* is used, or any one of those combined with a store or a read. Summaries
474-
* recorded at a return node are restricted to include at least one additional
475-
* step, as the value-based summaries are calculated independent of the
476-
* configuration.
477-
*/
478-
private class Summary extends TSummary {
479-
string toString() {
480-
result = "Val" and this = TSummaryVal()
481-
or
482-
result = "Taint" and this = TSummaryTaint()
483-
or
484-
exists(Content f |
485-
result = "ReadVal " + f.toString() and this = TSummaryReadVal(f)
486-
or
487-
result = "ReadTaint " + f.toString() and this = TSummaryReadTaint(f)
488-
or
489-
result = "TaintStore " + f.toString() and this = TSummaryTaintStore(f)
490-
)
491-
}
492-
493-
/** Gets the summary that results from extending this with an additional step. */
494-
Summary additionalStep() {
495-
this = TSummaryVal() and result = TSummaryTaint()
496-
or
497-
this = TSummaryTaint() and result = TSummaryTaint()
498-
or
499-
exists(Content f | this = TSummaryReadVal(f) and result = TSummaryReadTaint(f))
500-
or
501-
exists(Content f | this = TSummaryReadTaint(f) and result = TSummaryReadTaint(f))
502-
}
503-
504-
/** Gets the summary that results from extending this with a read. */
505-
Summary readStep(Content f) { this = TSummaryVal() and result = TSummaryReadVal(f) }
506-
507-
/** Gets the summary that results from extending this with a store. */
508-
Summary storeStep(Content f) { this = TSummaryTaint() and result = TSummaryTaintStore(f) }
509-
510-
/** Gets the summary that results from extending this with `step`. */
511-
bindingset[this, step]
512-
Summary compose(Summary step) {
513-
this = TSummaryVal() and result = step
514-
or
515-
this = TSummaryTaint() and
516-
(step = TSummaryTaint() or step = TSummaryTaintStore(_)) and
517-
result = step
518-
or
519-
exists(Content f |
520-
this = TSummaryReadVal(f) and step = TSummaryTaint() and result = TSummaryReadTaint(f)
521-
)
522-
or
523-
this = TSummaryReadTaint(_) and step = TSummaryTaint() and result = this
524-
}
525-
526-
/** Holds if this summary does not include any taint steps. */
527-
predicate isPartial() {
528-
this = TSummaryVal() or
529-
this = TSummaryReadVal(_)
530-
}
531-
}
532-
533463
/** Holds if flow may return from `callable`. */
534464
private predicate returnFlowCallableCand(
535465
DataFlowCallable callable, ReturnKindExt kind, Configuration config
@@ -1873,10 +1803,8 @@ private newtype TSummaryCtx =
18731803
TSummaryCtxNil(ParameterNode p) {
18741804
exists(Configuration conf, ReturnNodeExt ret |
18751805
flow(p, true, TNil(_), conf) and
1876-
(
1877-
parameterFlowReturn(p, ret, _, _, _, TSummaryTaint(), conf) or
1878-
parameterFlowReturn(p, ret, _, _, _, TSummaryTaintStore(_), conf)
1879-
) and
1806+
parameterFlowReturn(p, ret, _, _, _,
1807+
any(Summary s | s = TSummaryTaint() or s = TSummaryTaintStore(_)), conf) and
18801808
flow(ret, conf)
18811809
)
18821810
} or

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl2.qll

Lines changed: 2 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -460,76 +460,6 @@ private predicate throughFlowNodeCand(Node node, Configuration config) {
460460
not outBarrier(node, config)
461461
}
462462

463-
private newtype TSummary =
464-
TSummaryVal() or
465-
TSummaryTaint() or
466-
TSummaryReadVal(Content f) or
467-
TSummaryReadTaint(Content f) or
468-
TSummaryTaintStore(Content f)
469-
470-
/**
471-
* A summary of flow through a callable. This can either be value-preserving
472-
* if no additional steps are used, taint-flow if at least on additional step
473-
* is used, or any one of those combined with a store or a read. Summaries
474-
* recorded at a return node are restricted to include at least one additional
475-
* step, as the value-based summaries are calculated independent of the
476-
* configuration.
477-
*/
478-
private class Summary extends TSummary {
479-
string toString() {
480-
result = "Val" and this = TSummaryVal()
481-
or
482-
result = "Taint" and this = TSummaryTaint()
483-
or
484-
exists(Content f |
485-
result = "ReadVal " + f.toString() and this = TSummaryReadVal(f)
486-
or
487-
result = "ReadTaint " + f.toString() and this = TSummaryReadTaint(f)
488-
or
489-
result = "TaintStore " + f.toString() and this = TSummaryTaintStore(f)
490-
)
491-
}
492-
493-
/** Gets the summary that results from extending this with an additional step. */
494-
Summary additionalStep() {
495-
this = TSummaryVal() and result = TSummaryTaint()
496-
or
497-
this = TSummaryTaint() and result = TSummaryTaint()
498-
or
499-
exists(Content f | this = TSummaryReadVal(f) and result = TSummaryReadTaint(f))
500-
or
501-
exists(Content f | this = TSummaryReadTaint(f) and result = TSummaryReadTaint(f))
502-
}
503-
504-
/** Gets the summary that results from extending this with a read. */
505-
Summary readStep(Content f) { this = TSummaryVal() and result = TSummaryReadVal(f) }
506-
507-
/** Gets the summary that results from extending this with a store. */
508-
Summary storeStep(Content f) { this = TSummaryTaint() and result = TSummaryTaintStore(f) }
509-
510-
/** Gets the summary that results from extending this with `step`. */
511-
bindingset[this, step]
512-
Summary compose(Summary step) {
513-
this = TSummaryVal() and result = step
514-
or
515-
this = TSummaryTaint() and
516-
(step = TSummaryTaint() or step = TSummaryTaintStore(_)) and
517-
result = step
518-
or
519-
exists(Content f |
520-
this = TSummaryReadVal(f) and step = TSummaryTaint() and result = TSummaryReadTaint(f)
521-
)
522-
or
523-
this = TSummaryReadTaint(_) and step = TSummaryTaint() and result = this
524-
}
525-
526-
/** Holds if this summary does not include any taint steps. */
527-
predicate isPartial() {
528-
this = TSummaryVal() or
529-
this = TSummaryReadVal(_)
530-
}
531-
}
532-
533463
/** Holds if flow may return from `callable`. */
534464
private predicate returnFlowCallableCand(
535465
DataFlowCallable callable, ReturnKindExt kind, Configuration config
@@ -1873,10 +1803,8 @@ private newtype TSummaryCtx =
18731803
TSummaryCtxNil(ParameterNode p) {
18741804
exists(Configuration conf, ReturnNodeExt ret |
18751805
flow(p, true, TNil(_), conf) and
1876-
(
1877-
parameterFlowReturn(p, ret, _, _, _, TSummaryTaint(), conf) or
1878-
parameterFlowReturn(p, ret, _, _, _, TSummaryTaintStore(_), conf)
1879-
) and
1806+
parameterFlowReturn(p, ret, _, _, _,
1807+
any(Summary s | s = TSummaryTaint() or s = TSummaryTaintStore(_)), conf) and
18801808
flow(ret, conf)
18811809
)
18821810
} or

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl3.qll

Lines changed: 2 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -460,76 +460,6 @@ private predicate throughFlowNodeCand(Node node, Configuration config) {
460460
not outBarrier(node, config)
461461
}
462462

463-
private newtype TSummary =
464-
TSummaryVal() or
465-
TSummaryTaint() or
466-
TSummaryReadVal(Content f) or
467-
TSummaryReadTaint(Content f) or
468-
TSummaryTaintStore(Content f)
469-
470-
/**
471-
* A summary of flow through a callable. This can either be value-preserving
472-
* if no additional steps are used, taint-flow if at least on additional step
473-
* is used, or any one of those combined with a store or a read. Summaries
474-
* recorded at a return node are restricted to include at least one additional
475-
* step, as the value-based summaries are calculated independent of the
476-
* configuration.
477-
*/
478-
private class Summary extends TSummary {
479-
string toString() {
480-
result = "Val" and this = TSummaryVal()
481-
or
482-
result = "Taint" and this = TSummaryTaint()
483-
or
484-
exists(Content f |
485-
result = "ReadVal " + f.toString() and this = TSummaryReadVal(f)
486-
or
487-
result = "ReadTaint " + f.toString() and this = TSummaryReadTaint(f)
488-
or
489-
result = "TaintStore " + f.toString() and this = TSummaryTaintStore(f)
490-
)
491-
}
492-
493-
/** Gets the summary that results from extending this with an additional step. */
494-
Summary additionalStep() {
495-
this = TSummaryVal() and result = TSummaryTaint()
496-
or
497-
this = TSummaryTaint() and result = TSummaryTaint()
498-
or
499-
exists(Content f | this = TSummaryReadVal(f) and result = TSummaryReadTaint(f))
500-
or
501-
exists(Content f | this = TSummaryReadTaint(f) and result = TSummaryReadTaint(f))
502-
}
503-
504-
/** Gets the summary that results from extending this with a read. */
505-
Summary readStep(Content f) { this = TSummaryVal() and result = TSummaryReadVal(f) }
506-
507-
/** Gets the summary that results from extending this with a store. */
508-
Summary storeStep(Content f) { this = TSummaryTaint() and result = TSummaryTaintStore(f) }
509-
510-
/** Gets the summary that results from extending this with `step`. */
511-
bindingset[this, step]
512-
Summary compose(Summary step) {
513-
this = TSummaryVal() and result = step
514-
or
515-
this = TSummaryTaint() and
516-
(step = TSummaryTaint() or step = TSummaryTaintStore(_)) and
517-
result = step
518-
or
519-
exists(Content f |
520-
this = TSummaryReadVal(f) and step = TSummaryTaint() and result = TSummaryReadTaint(f)
521-
)
522-
or
523-
this = TSummaryReadTaint(_) and step = TSummaryTaint() and result = this
524-
}
525-
526-
/** Holds if this summary does not include any taint steps. */
527-
predicate isPartial() {
528-
this = TSummaryVal() or
529-
this = TSummaryReadVal(_)
530-
}
531-
}
532-
533463
/** Holds if flow may return from `callable`. */
534464
private predicate returnFlowCallableCand(
535465
DataFlowCallable callable, ReturnKindExt kind, Configuration config
@@ -1873,10 +1803,8 @@ private newtype TSummaryCtx =
18731803
TSummaryCtxNil(ParameterNode p) {
18741804
exists(Configuration conf, ReturnNodeExt ret |
18751805
flow(p, true, TNil(_), conf) and
1876-
(
1877-
parameterFlowReturn(p, ret, _, _, _, TSummaryTaint(), conf) or
1878-
parameterFlowReturn(p, ret, _, _, _, TSummaryTaintStore(_), conf)
1879-
) and
1806+
parameterFlowReturn(p, ret, _, _, _,
1807+
any(Summary s | s = TSummaryTaint() or s = TSummaryTaintStore(_)), conf) and
18801808
flow(ret, conf)
18811809
)
18821810
} or

cpp/ql/src/semmle/code/cpp/dataflow/internal/DataFlowImpl4.qll

Lines changed: 2 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -460,76 +460,6 @@ private predicate throughFlowNodeCand(Node node, Configuration config) {
460460
not outBarrier(node, config)
461461
}
462462

463-
private newtype TSummary =
464-
TSummaryVal() or
465-
TSummaryTaint() or
466-
TSummaryReadVal(Content f) or
467-
TSummaryReadTaint(Content f) or
468-
TSummaryTaintStore(Content f)
469-
470-
/**
471-
* A summary of flow through a callable. This can either be value-preserving
472-
* if no additional steps are used, taint-flow if at least on additional step
473-
* is used, or any one of those combined with a store or a read. Summaries
474-
* recorded at a return node are restricted to include at least one additional
475-
* step, as the value-based summaries are calculated independent of the
476-
* configuration.
477-
*/
478-
private class Summary extends TSummary {
479-
string toString() {
480-
result = "Val" and this = TSummaryVal()
481-
or
482-
result = "Taint" and this = TSummaryTaint()
483-
or
484-
exists(Content f |
485-
result = "ReadVal " + f.toString() and this = TSummaryReadVal(f)
486-
or
487-
result = "ReadTaint " + f.toString() and this = TSummaryReadTaint(f)
488-
or
489-
result = "TaintStore " + f.toString() and this = TSummaryTaintStore(f)
490-
)
491-
}
492-
493-
/** Gets the summary that results from extending this with an additional step. */
494-
Summary additionalStep() {
495-
this = TSummaryVal() and result = TSummaryTaint()
496-
or
497-
this = TSummaryTaint() and result = TSummaryTaint()
498-
or
499-
exists(Content f | this = TSummaryReadVal(f) and result = TSummaryReadTaint(f))
500-
or
501-
exists(Content f | this = TSummaryReadTaint(f) and result = TSummaryReadTaint(f))
502-
}
503-
504-
/** Gets the summary that results from extending this with a read. */
505-
Summary readStep(Content f) { this = TSummaryVal() and result = TSummaryReadVal(f) }
506-
507-
/** Gets the summary that results from extending this with a store. */
508-
Summary storeStep(Content f) { this = TSummaryTaint() and result = TSummaryTaintStore(f) }
509-
510-
/** Gets the summary that results from extending this with `step`. */
511-
bindingset[this, step]
512-
Summary compose(Summary step) {
513-
this = TSummaryVal() and result = step
514-
or
515-
this = TSummaryTaint() and
516-
(step = TSummaryTaint() or step = TSummaryTaintStore(_)) and
517-
result = step
518-
or
519-
exists(Content f |
520-
this = TSummaryReadVal(f) and step = TSummaryTaint() and result = TSummaryReadTaint(f)
521-
)
522-
or
523-
this = TSummaryReadTaint(_) and step = TSummaryTaint() and result = this
524-
}
525-
526-
/** Holds if this summary does not include any taint steps. */
527-
predicate isPartial() {
528-
this = TSummaryVal() or
529-
this = TSummaryReadVal(_)
530-
}
531-
}
532-
533463
/** Holds if flow may return from `callable`. */
534464
private predicate returnFlowCallableCand(
535465
DataFlowCallable callable, ReturnKindExt kind, Configuration config
@@ -1873,10 +1803,8 @@ private newtype TSummaryCtx =
18731803
TSummaryCtxNil(ParameterNode p) {
18741804
exists(Configuration conf, ReturnNodeExt ret |
18751805
flow(p, true, TNil(_), conf) and
1876-
(
1877-
parameterFlowReturn(p, ret, _, _, _, TSummaryTaint(), conf) or
1878-
parameterFlowReturn(p, ret, _, _, _, TSummaryTaintStore(_), conf)
1879-
) and
1806+
parameterFlowReturn(p, ret, _, _, _,
1807+
any(Summary s | s = TSummaryTaint() or s = TSummaryTaintStore(_)), conf) and
18801808
flow(ret, conf)
18811809
)
18821810
} or

0 commit comments

Comments
 (0)