@@ -16,9 +16,11 @@ module ModificationOfParameterWithDefault {
1616 import ModificationOfParameterWithDefaultCustomizations:: ModificationOfParameterWithDefault
1717
1818 /**
19+ * DEPRECATED: Use `Flow` module instead.
20+ *
1921 * A data-flow configuration for detecting modifications of a parameters default value.
2022 */
21- class Configuration extends DataFlow:: Configuration {
23+ deprecated class Configuration extends DataFlow:: Configuration {
2224 /** Record whether the default value being tracked is non-empty. */
2325 boolean nonEmptyDefault ;
2426
@@ -43,4 +45,33 @@ module ModificationOfParameterWithDefault {
4345 nonEmptyDefault = false and node instanceof MustBeNonEmpty
4446 }
4547 }
48+
49+ private module Config implements DataFlow:: StateConfigSig {
50+ class FlowState = boolean ;
51+
52+ predicate isSource ( DataFlow:: Node source , FlowState state ) {
53+ source .( Source ) .isNonEmpty ( ) = state
54+ }
55+
56+ predicate isSink ( DataFlow:: Node sink ) { sink instanceof Sink }
57+
58+ predicate isSink ( DataFlow:: Node sink , FlowState state ) {
59+ // dummy implementation since this predicate is required, but actual logic is in
60+ // the predicate above.
61+ none ( )
62+ }
63+
64+ predicate isBarrier ( DataFlow:: Node node , FlowState state ) {
65+ // if we are tracking a non-empty default, then it is ok to modify empty values,
66+ // so our tracking ends at those.
67+ state = true and node instanceof MustBeEmpty
68+ or
69+ // if we are tracking a empty default, then it is ok to modify non-empty values,
70+ // so our tracking ends at those.
71+ state = false and node instanceof MustBeNonEmpty
72+ }
73+ }
74+
75+ /** Global data-flow for detecting modifications of a parameters default value. */
76+ module Flow = DataFlow:: GlobalWithState< Config > ;
4677}
0 commit comments