@@ -5,7 +5,14 @@ private import semmle.code.java.dataflow.TaintTracking
55private import semmle.code.java.security.SensitiveActions
66
77/** 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+ }
916
1017/** A sanitizer for flows tracking sensitive data being stored in persistent storage. */
1118abstract class CleartextStorageSanitizer extends DataFlow:: Node { }
@@ -46,6 +53,17 @@ private module SensitiveSourceFlowConfig implements DataFlow::ConfigSig {
4653 predicate isAdditionalFlowStep ( DataFlow:: Node n1 , DataFlow:: Node n2 ) {
4754 any ( CleartextStorageAdditionalTaintStep c ) .step ( n1 , n2 )
4855 }
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+ }
4967}
5068
5169private module SensitiveSourceFlow = TaintTracking:: Global< SensitiveSourceFlowConfig > ;
0 commit comments