6
6
7
7
private import javascript as JS
8
8
import EndpointTypes
9
- import EndpointCharacteristics
9
+ import EndpointCharacteristics as EndpointCharacteristics
10
10
11
11
/**
12
12
* EXPERIMENTAL. This API may change in the future.
@@ -48,7 +48,7 @@ abstract class AtmConfig extends string {
48
48
final predicate isKnownSink ( JS:: DataFlow:: Node sink ) {
49
49
// If the list of characteristics includes positive indicators with maximal confidence for this class, then it's a
50
50
// known sink for the class.
51
- exists ( EndpointCharacteristic characteristic |
51
+ exists ( EndpointCharacteristics :: EndpointCharacteristic characteristic |
52
52
characteristic .getEndpoints ( sink ) and
53
53
characteristic
54
54
.getImplications ( this .getASinkEndpointType ( ) , true , characteristic .maximalConfidence ( ) )
@@ -69,7 +69,38 @@ abstract class AtmConfig extends string {
69
69
* Holds if the candidate sink `candidateSink` predicted by the machine learning model should be
70
70
* an effective sink, i.e. one considered as a possible sink of flow in the boosted query.
71
71
*/
72
- predicate isEffectiveSink ( JS:: DataFlow:: Node candidateSink ) { none ( ) }
72
+ predicate isEffectiveSink ( JS:: DataFlow:: Node candidateSink ) {
73
+ not exists ( this .getAReasonSinkExcluded ( candidateSink ) )
74
+ }
75
+
76
+ /**
77
+ * Gets the list of characteristics that cause `candidateSink` to be excluded as an effective sink.
78
+ */
79
+ final EndpointCharacteristics:: EndpointCharacteristic getAReasonSinkExcluded (
80
+ JS:: DataFlow:: Node candidateSink
81
+ ) {
82
+ // An endpoint is an effective sink (sink candidate) if none of its characteristics give much indication whether or
83
+ // not it is a sink. Historically, we used endpoint filters, and scored endpoints that are filtered out neither by
84
+ // a standard endpoint filter nor by an endpoint filter specific to this sink type. To replicate this behavior, we
85
+ // have given the endpoint filter characteristics medium confidence, and we exclude endpoints that have a
86
+ // medium-confidence characteristic that indicates that they are not sinks, either in general or for this sink type.
87
+ exists ( EndpointCharacteristics:: EndpointCharacteristic filter , float confidence |
88
+ filter .getEndpoints ( candidateSink ) and
89
+ confidence >= filter .mediumConfidence ( ) and
90
+ // TODO: Experiment with excluding all endpoints that have a medium- or high-confidence characteristic that
91
+ // implies they're not sinks, rather than using only medium-confidence characteristics, by deleting the following
92
+ // line.
93
+ confidence < filter .highConfidence ( ) and
94
+ (
95
+ // Exclude endpoints that have a characteristic that implies they're not sinks for _any_ sink type.
96
+ filter .getImplications ( any ( NegativeType negative ) , true , confidence )
97
+ or
98
+ // Exclude endpoints that have a characteristic that implies they're not sinks for _this particular_ sink type.
99
+ filter .getImplications ( this .getASinkEndpointType ( ) , false , confidence )
100
+ ) and
101
+ result = filter
102
+ )
103
+ }
73
104
74
105
/**
75
106
* EXPERIMENTAL. This API may change in the future.
@@ -85,7 +116,7 @@ abstract class AtmConfig extends string {
85
116
* Get an endpoint type for the sinks of this query. A query may have multiple applicable
86
117
* endpoint types for its sinks.
87
118
*/
88
- EndpointType getASinkEndpointType ( ) { none ( ) }
119
+ abstract EndpointType getASinkEndpointType ( ) ;
89
120
90
121
/**
91
122
* EXPERIMENTAL. This API may change in the future.
0 commit comments