@@ -5,13 +5,44 @@ import semmle.code.java.dataflow.DataFlow
5
5
private import semmle.code.java.dataflow.ExternalFlow
6
6
import semmle.code.java.security.XSS
7
7
8
- /** A sink that represent a method that outputs data to an HTTP response. */
9
- abstract class InformationLeakSink extends DataFlow:: Node { }
8
+ /**
9
+ * A sink that represent a method that outputs data to an HTTP response. Extend
10
+ * this class to add more sinks that should be considered information leak
11
+ * points by every query. To find the full set of information-leak sinks, use
12
+ * `InformationLeakSink` instead.
13
+ */
14
+ abstract class AbstractInformationLeakSink extends DataFlow:: Node { }
15
+
16
+ /**
17
+ * A sink that represent a method that outputs data to an HTTP response. To add
18
+ * more sinks, extend `AbstractInformationLeakSink` rather than this class.
19
+ */
20
+ final class InformationLeakSink extends DataFlow:: Node instanceof InformationLeakDiffInformed< xssNotDiffInformed / 0 > :: InformationLeakSink
21
+ { }
10
22
11
23
/** A default sink representing methods outputing data to an HTTP response. */
12
- private class DefaultInformationLeakSink extends InformationLeakSink {
13
- DefaultInformationLeakSink ( ) {
14
- sinkNode ( this , "information-leak" ) or
15
- this instanceof XssSink
24
+ private class DefaultInformationLeakSink extends AbstractInformationLeakSink {
25
+ DefaultInformationLeakSink ( ) { sinkNode ( this , "information-leak" ) }
26
+ }
27
+
28
+ /**
29
+ * A module for finding information-leak sinks faster in a diff-informed query.
30
+ * The `hasSourceInDiffRange` parameter should hold if the overall data-flow
31
+ * configuration of the query has any sources in the diff range.
32
+ */
33
+ module InformationLeakDiffInformed< xssNullaryPredicate / 0 hasSourceInDiffRange> {
34
+ final private class Node = DataFlow:: Node ;
35
+
36
+ /**
37
+ * A diff-informed replacement for the top-level `InformationLeakSink`,
38
+ * omitting for efficiency some sinks that would never be reported by a
39
+ * diff-informed query.
40
+ */
41
+ final class InformationLeakSink extends Node {
42
+ InformationLeakSink ( ) {
43
+ this instanceof AbstractInformationLeakSink
44
+ or
45
+ this instanceof XssDiffInformed< hasSourceInDiffRange / 0 > :: XssSink
46
+ }
16
47
}
17
48
}
0 commit comments