Skip to content

Commit f7f6f10

Browse files
author
Stephan Brandauer
committed
use NegativeEndpointType class; replace link to slack discussion
1 parent bd3aaf0 commit f7f6f10

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

java/ql/src/Telemetry/AutomodelEndpointCharacteristics.qll

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ module CandidatesImpl implements SharedCharacteristics::CandidateSig {
2121

2222
class EndpointType = AutomodelEndpointTypes::EndpointType;
2323

24-
predicate isNegative(AutomodelEndpointTypes::EndpointType t) {
25-
t instanceof AutomodelEndpointTypes::NegativeSinkType
26-
}
24+
class NegativeEndpointType = AutomodelEndpointTypes::NegativeSinkType;
2725

2826
// Sanitizers are currently not modeled in MaD. TODO: check if this has large negative impact.
2927
predicate isSanitizer(Endpoint e, EndpointType t) { none() }
@@ -95,7 +93,13 @@ module CandidatesImpl implements SharedCharacteristics::CandidateSig {
9593
hasMetadata(e, package, type, name, signature, input, isFinal, isStatic, isPublic,
9694
calleeJavaDoc) and
9795
(if isFinal = true or isStatic = true then subtypes = false else subtypes = true) and
98-
ext = "" and // see https://github.slack.com/archives/CP9127VUK/p1673979477496069
96+
ext = "" and
97+
/*
98+
* "ext" will always be empty for automodeling; it's a mechanism for
99+
* specifying that the model should apply for parameters that have
100+
* a certain annotation.
101+
*/
102+
99103
provenance = "ai-generated" and
100104
metadata =
101105
"{" //

java/ql/src/Telemetry/AutomodelSharedCharacteristics.qll

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/
7069
module 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

Comments
 (0)