Skip to content

Commit a4939b9

Browse files
committed
Generalize the definition of a known sink:
If the list of reasons includes positive indicators with maximal confidence for this class, it's a known sink for the class. This negates the need for each query config to define the isKnownSink predicate individually.
1 parent 08bbe59 commit a4939b9

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/ATMConfig.qll

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
private import javascript as JS
88
import EndpointTypes
9+
import ClassificationReasons
910

1011
/**
1112
* EXPERIMENTAL. This API may change in the future.
@@ -44,7 +45,14 @@ abstract class AtmConfig extends string {
4445
*
4546
* Holds if `sink` is a known sink of flow.
4647
*/
47-
predicate isKnownSink(JS::DataFlow::Node sink) { none() }
48+
predicate isKnownSink(JS::DataFlow::Node sink) {
49+
// If the list of reasons includes positive indicators with maximal confidence for this class, it's a known sink for
50+
// the class.
51+
exists(ClassificationReason reason |
52+
reason.getEndpoints(sink) and
53+
reason.getImplications(this.getASinkEndpointType(), true, 1.0)
54+
)
55+
}
4856

4957
/**
5058
* EXPERIMENTAL. This API may change in the future.

javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/NosqlInjectionATM.qll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ class NosqlInjectionAtmConfig extends AtmConfig {
9393
source instanceof NosqlInjection::Source or TaintedObject::isSource(source, _)
9494
}
9595

96-
override predicate isKnownSink(DataFlow::Node sink) { sink instanceof NosqlInjection::Sink }
97-
9896
override predicate isEffectiveSink(DataFlow::Node sinkCandidate) {
9997
not exists(SinkEndpointFilter::getAReasonSinkExcluded(sinkCandidate))
10098
}

javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/SqlInjectionATM.qll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ class SqlInjectionAtmConfig extends AtmConfig {
6565

6666
override predicate isKnownSource(DataFlow::Node source) { source instanceof SqlInjection::Source }
6767

68-
override predicate isKnownSink(DataFlow::Node sink) { sink instanceof SqlInjection::Sink }
69-
7068
override predicate isEffectiveSink(DataFlow::Node sinkCandidate) {
7169
not exists(SinkEndpointFilter::getAReasonSinkExcluded(sinkCandidate))
7270
}

javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/TaintedPathATM.qll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ class TaintedPathAtmConfig extends AtmConfig {
6464

6565
override predicate isKnownSource(DataFlow::Node source) { source instanceof TaintedPath::Source }
6666

67-
override predicate isKnownSink(DataFlow::Node sink) { sink instanceof TaintedPath::Sink }
68-
6967
override predicate isEffectiveSink(DataFlow::Node sinkCandidate) {
7068
not exists(SinkEndpointFilter::getAReasonSinkExcluded(sinkCandidate))
7169
}

javascript/ql/experimental/adaptivethreatmodeling/lib/experimental/adaptivethreatmodeling/XssATM.qll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ class DomBasedXssAtmConfig extends AtmConfig {
6565

6666
override predicate isKnownSource(DataFlow::Node source) { source instanceof DomBasedXss::Source }
6767

68-
override predicate isKnownSink(DataFlow::Node sink) { sink instanceof DomBasedXss::Sink }
69-
7068
override predicate isEffectiveSink(DataFlow::Node sinkCandidate) {
7169
not exists(SinkEndpointFilter::getAReasonSinkExcluded(sinkCandidate))
7270
}

0 commit comments

Comments
 (0)