@@ -16,9 +16,11 @@ module ModificationOfParameterWithDefault {
16
16
import ModificationOfParameterWithDefaultCustomizations:: ModificationOfParameterWithDefault
17
17
18
18
/**
19
+ * DEPRECATED: Use `Flow` module instead.
20
+ *
19
21
* A data-flow configuration for detecting modifications of a parameters default value.
20
22
*/
21
- class Configuration extends DataFlow:: Configuration {
23
+ deprecated class Configuration extends DataFlow:: Configuration {
22
24
/** Record whether the default value being tracked is non-empty. */
23
25
boolean nonEmptyDefault ;
24
26
@@ -43,4 +45,33 @@ module ModificationOfParameterWithDefault {
43
45
nonEmptyDefault = false and node instanceof MustBeNonEmpty
44
46
}
45
47
}
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 > ;
46
77
}
0 commit comments