66
77private import javascript as JS
88import EndpointTypes
9- import EndpointCharacteristics
9+ import EndpointCharacteristics as EndpointCharacteristics
1010
1111/**
1212 * EXPERIMENTAL. This API may change in the future.
@@ -48,7 +48,7 @@ abstract class AtmConfig extends string {
4848 final predicate isKnownSink ( JS:: DataFlow:: Node sink ) {
4949 // If the list of characteristics includes positive indicators with maximal confidence for this class, then it's a
5050 // known sink for the class.
51- exists ( EndpointCharacteristic characteristic |
51+ exists ( EndpointCharacteristics :: EndpointCharacteristic characteristic |
5252 characteristic .getEndpoints ( sink ) and
5353 characteristic
5454 .getImplications ( this .getASinkEndpointType ( ) , true , characteristic .maximalConfidence ( ) )
@@ -69,7 +69,38 @@ abstract class AtmConfig extends string {
6969 * Holds if the candidate sink `candidateSink` predicted by the machine learning model should be
7070 * an effective sink, i.e. one considered as a possible sink of flow in the boosted query.
7171 */
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+ }
73104
74105 /**
75106 * EXPERIMENTAL. This API may change in the future.
@@ -85,7 +116,7 @@ abstract class AtmConfig extends string {
85116 * Get an endpoint type for the sinks of this query. A query may have multiple applicable
86117 * endpoint types for its sinks.
87118 */
88- EndpointType getASinkEndpointType ( ) { none ( ) }
119+ abstract EndpointType getASinkEndpointType ( ) ;
89120
90121 /**
91122 * EXPERIMENTAL. This API may change in the future.
0 commit comments