@@ -5,7 +5,14 @@ private import semmle.code.java.dataflow.TaintTracking
5
5
private import semmle.code.java.security.SensitiveActions
6
6
7
7
/** A sink representing persistent storage that saves data in clear text. */
8
- abstract class CleartextStorageSink extends DataFlow:: Node { }
8
+ abstract class CleartextStorageSink extends DataFlow:: Node {
9
+ /**
10
+ * Gets a location that will be selected in the diff-informed query where
11
+ * this sink is found. If this has no results for any sink, that's taken to
12
+ * mean the query is not diff-informed.
13
+ */
14
+ Location getASelectedLocation ( ) { none ( ) }
15
+ }
9
16
10
17
/** A sanitizer for flows tracking sensitive data being stored in persistent storage. */
11
18
abstract class CleartextStorageSanitizer extends DataFlow:: Node { }
@@ -46,6 +53,17 @@ private module SensitiveSourceFlowConfig implements DataFlow::ConfigSig {
46
53
predicate isAdditionalFlowStep ( DataFlow:: Node n1 , DataFlow:: Node n2 ) {
47
54
any ( CleartextStorageAdditionalTaintStep c ) .step ( n1 , n2 )
48
55
}
56
+
57
+ predicate observeDiffInformedIncrementalMode ( ) {
58
+ // This configuration is used by several queries. A query can opt in to
59
+ // diff-informed mode by implementing `getASelectedLocation` on its sinks,
60
+ // indicating that it has considered which sinks are selected.
61
+ exists ( CleartextStorageSink sink | exists ( sink .getASelectedLocation ( ) ) )
62
+ }
63
+
64
+ Location getASelectedSinkLocation ( DataFlow:: Node sink ) {
65
+ result = sink .( CleartextStorageSink ) .getASelectedLocation ( )
66
+ }
49
67
}
50
68
51
69
private module SensitiveSourceFlow = TaintTracking:: Global< SensitiveSourceFlowConfig > ;
0 commit comments