@@ -729,41 +729,39 @@ private predicate exprToDefinitionByReferenceStep(Expr exprIn, Expr argOut) {
729
729
730
730
private module FieldFlow {
731
731
private import DataFlowImplCommon
732
- private import DataFlowImplLocal
733
732
private import DataFlowPrivate
733
+ private import semmle.code.cpp.dataflow.DataFlow
734
734
735
735
/**
736
- * A configuration for finding local-only flow through fields. This uses the
737
- * `Configuration` class in the dedicated `DataFlowImplLocal` copy of the
738
- * shared library that's not user-exposed directly.
736
+ * A configuration for finding local-only flow through fields.
739
737
*
740
738
* To keep the flow local to a single function, we put barriers on parameters
741
739
* and return statements. Sources and sinks are the values that go into and
742
740
* out of fields, respectively.
743
741
*/
744
- private class FieldConfiguration extends Configuration {
745
- FieldConfiguration ( ) { this = "FieldConfiguration" }
746
-
747
- override predicate isSource ( Node source ) {
742
+ private module FieldConfig implements DataFlow:: ConfigSig {
743
+ predicate isSource ( Node source ) {
748
744
storeStep ( source , _, _)
749
745
or
750
746
// Also mark `foo(a.b);` as a source when `a.b` may be overwritten by `foo`.
751
747
readStep ( _, _, any ( Node node | node .asExpr ( ) = source .asDefiningArgument ( ) ) )
752
748
}
753
749
754
- override predicate isSink ( Node sink ) { readStep ( _, _, sink ) }
750
+ predicate isSink ( Node sink ) { readStep ( _, _, sink ) }
755
751
756
- override predicate isBarrier ( Node node ) { node instanceof ParameterNode }
752
+ predicate isBarrier ( Node node ) { node instanceof ParameterNode }
757
753
758
- override predicate isBarrierOut ( Node node ) {
754
+ predicate isBarrierOut ( Node node ) {
759
755
node .asExpr ( ) .getParent ( ) instanceof ReturnStmt
760
756
or
761
757
node .asExpr ( ) .getParent ( ) instanceof ThrowExpr
762
758
}
763
759
}
764
760
761
+ private module Flow = DataFlow:: Global< FieldConfig > ;
762
+
765
763
predicate fieldFlow ( Node node1 , Node node2 ) {
766
- exists ( FieldConfiguration cfg | cfg . hasFlow ( node1 , node2 ) ) and
764
+ Flow :: flow ( node1 , node2 ) and
767
765
// This configuration should not be able to cross function boundaries, but
768
766
// we double-check here just to be sure.
769
767
getNodeEnclosingCallable ( node1 ) = getNodeEnclosingCallable ( node2 )
0 commit comments