Skip to content

Commit 8e429bd

Browse files
author
Max Schaefer
committed
Rename isSinkCandidate (and a related predicate) to isCandidate.
This reflects the fact that these predicates also deal with source candidates.
1 parent 9b7cfd8 commit 8e429bd

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

java/ql/automodel/src/AutomodelApplicationModeExtractCandidates.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ where
6363
not exists(CharacteristicsImpl::UninterestingToModelCharacteristic u |
6464
u.appliesToEndpoint(endpoint)
6565
) and
66-
CharacteristicsImpl::isSinkCandidate(endpoint, _) and
66+
CharacteristicsImpl::isCandidate(endpoint, _) and
6767
endpoint =
6868
getSampleForSignature(9, package, type, subtypes, name, signature, input, output,
6969
isVarargsArray, extensibleType) and

java/ql/automodel/src/AutomodelFrameworkModeExtractCandidates.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ where
2525
not exists(CharacteristicsImpl::UninterestingToModelCharacteristic u |
2626
u.appliesToEndpoint(endpoint)
2727
) and
28-
CharacteristicsImpl::isSinkCandidate(endpoint, _) and
28+
CharacteristicsImpl::isCandidate(endpoint, _) and
2929
// If a node is already a known sink for any of our existing ATM queries and is already modeled as a MaD sink, we
3030
// don't include it as a candidate. Otherwise, we might include it as a candidate for query A, but the model will
3131
// label it as a sink for one of the sink types of query B, for which it's already a known sink. This would result in

java/ql/automodel/src/AutomodelSharedCharacteristics.qll

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,14 @@ module SharedCharacteristics<CandidateSig Candidate> {
117117
}
118118

119119
/**
120-
* Holds if the candidate sink `candidateSink` should be considered as a possible sink of type `sinkType`, and
121-
* classified by the ML model. A candidate sink is a node that cannot be excluded from `sinkType` based on its
122-
* characteristics.
120+
* Holds if the given `endpoint` should be considered as a candidate for type `endpointType`,
121+
* and classified by the ML model.
122+
*
123+
* A candidate is an endpoint that cannot be excluded from `endpointType` based on its characteristics.
123124
*/
124-
predicate isSinkCandidate(Candidate::Endpoint candidateSink, Candidate::EndpointType sinkType) {
125+
predicate isCandidate(Candidate::Endpoint candidateSink, Candidate::EndpointType sinkType) {
125126
not sinkType instanceof Candidate::NegativeEndpointType and
126-
not exists(getAReasonSinkExcluded(candidateSink, sinkType))
127+
not exists(getAnExcludingCharacteristic(candidateSink, sinkType))
127128
}
128129

129130
/**
@@ -139,15 +140,14 @@ module SharedCharacteristics<CandidateSig Candidate> {
139140
}
140141

141142
/**
142-
* Gets the list of characteristics that cause `candidateSink` to be excluded as an effective sink for a given sink
143-
* type.
143+
* Gets a characteristics that disbar `endpoint` from being a candidate for `endpointType`.
144144
*/
145-
EndpointCharacteristic getAReasonSinkExcluded(
146-
Candidate::Endpoint candidateSink, Candidate::EndpointType sinkType
145+
EndpointCharacteristic getAnExcludingCharacteristic(
146+
Candidate::Endpoint endpoint, Candidate::EndpointType endpointType
147147
) {
148148
// An endpoint is a sink candidate if none of its characteristics give much indication whether or not it is a sink.
149-
not sinkType instanceof Candidate::NegativeEndpointType and
150-
result.appliesToEndpoint(candidateSink) and
149+
not endpointType instanceof Candidate::NegativeEndpointType and
150+
result.appliesToEndpoint(endpoint) and
151151
(
152152
// Exclude endpoints that have a characteristic that implies they're not sinks for _any_ sink type.
153153
exists(float confidence |
@@ -158,7 +158,7 @@ module SharedCharacteristics<CandidateSig Candidate> {
158158
// Exclude endpoints that have a characteristic that implies they're not sinks for _this particular_ sink type.
159159
exists(float confidence |
160160
confidence >= mediumConfidence() and
161-
result.hasImplications(sinkType, false, confidence)
161+
result.hasImplications(endpointType, false, confidence)
162162
)
163163
)
164164
}

0 commit comments

Comments
 (0)