@@ -16,6 +16,11 @@ signature module CandidateSig {
1616
1717 class EndpointType ;
1818
19+ /**
20+ * An EndpointType that denotes the absence of any sink.
21+ */
22+ class NegativeEndpointType extends EndpointType ;
23+
1924 /** Gets the string representing the file+range of the endpoint. */
2025 string getLocationString ( Endpoint e ) ;
2126
@@ -24,12 +29,6 @@ signature module CandidateSig {
2429 */
2530 predicate isKnownLabel ( string label , string humanReadableLabel , EndpointType type ) ;
2631
27- /**
28- * EndpointType must have a 'negative' type that denotes the absence of any sink.
29- * This predicate should hold for that type, and that type only.
30- */
31- predicate isNegative ( EndpointType t ) ;
32-
3332 /**
3433 * Should hold for any endpoint that is a flow sanitizer.
3534 */
@@ -68,8 +67,6 @@ signature module CandidateSig {
6867 * implementations of endpoint characteristics exported by this module.
6968 */
7069module SharedCharacteristics< CandidateSig Candidate> {
71- predicate isNegative ( Candidate:: EndpointType e ) { Candidate:: isNegative ( e ) }
72-
7370 predicate isSink ( Candidate:: Endpoint e , string label ) { Candidate:: isSink ( e , label ) }
7471
7572 predicate isNeutral ( Candidate:: Endpoint e ) { Candidate:: isNeutral ( e ) }
@@ -80,7 +77,7 @@ module SharedCharacteristics<CandidateSig Candidate> {
8077 predicate isKnownSink ( Candidate:: Endpoint sink , Candidate:: EndpointType endpointType ) {
8178 // If the list of characteristics includes positive indicators with maximal confidence for this class, then it's a
8279 // known sink for the class.
83- not isNegative ( endpointType ) and
80+ not endpointType instanceof Candidate :: NegativeEndpointType and
8481 exists ( EndpointCharacteristic characteristic |
8582 characteristic .appliesToEndpoint ( sink ) and
8683 characteristic .hasImplications ( endpointType , true , maximalConfidence ( ) )
@@ -93,7 +90,7 @@ module SharedCharacteristics<CandidateSig Candidate> {
9390 * characteristics.
9491 */
9592 predicate isSinkCandidate ( Candidate:: Endpoint candidateSink , Candidate:: EndpointType sinkType ) {
96- not isNegative ( sinkType ) and
93+ not sinkType instanceof Candidate :: NegativeEndpointType and
9794 not exists ( getAReasonSinkExcluded ( candidateSink , sinkType ) )
9895 }
9996
@@ -109,13 +106,13 @@ module SharedCharacteristics<CandidateSig Candidate> {
109106 Candidate:: Endpoint candidateSink , Candidate:: EndpointType sinkType
110107 ) {
111108 // An endpoint is a sink candidate if none of its characteristics give much indication whether or not it is a sink.
112- not isNegative ( sinkType ) and
109+ not sinkType instanceof Candidate :: NegativeEndpointType and
113110 result .appliesToEndpoint ( candidateSink ) and
114111 // Exclude endpoints that have a characteristic that implies they're not sinks for _any_ sink type.
115112 (
116113 exists ( float confidence |
117114 confidence >= mediumConfidence ( ) and
118- result .hasImplications ( any ( Candidate:: EndpointType t | isNegative ( t ) ) , true , confidence )
115+ result .hasImplications ( any ( Candidate:: NegativeEndpointType t ) , true , confidence )
119116 )
120117 or
121118 // Exclude endpoints that have a characteristic that implies they're not sinks for _this particular_ sink type.
@@ -195,7 +192,7 @@ module SharedCharacteristics<CandidateSig Candidate> {
195192 override predicate hasImplications (
196193 Candidate:: EndpointType endpointType , boolean isPositiveIndicator , float confidence
197194 ) {
198- Candidate:: isNegative ( endpointType ) and
195+ endpointType instanceof Candidate:: NegativeEndpointType and
199196 isPositiveIndicator = true and
200197 confidence = highConfidence ( )
201198 }
@@ -214,7 +211,7 @@ module SharedCharacteristics<CandidateSig Candidate> {
214211 override predicate hasImplications (
215212 Candidate:: EndpointType endpointType , boolean isPositiveIndicator , float confidence
216213 ) {
217- Candidate:: isNegative ( endpointType ) and
214+ endpointType instanceof Candidate:: NegativeEndpointType and
218215 isPositiveIndicator = true and
219216 confidence = mediumConfidence ( )
220217 }
@@ -235,7 +232,7 @@ module SharedCharacteristics<CandidateSig Candidate> {
235232 override predicate hasImplications (
236233 Candidate:: EndpointType endpointType , boolean isPositiveIndicator , float confidence
237234 ) {
238- Candidate:: isNegative ( endpointType ) and
235+ endpointType instanceof Candidate:: NegativeEndpointType and
239236 isPositiveIndicator = true and
240237 confidence = mediumConfidence ( )
241238 }
0 commit comments