Skip to content

Commit 6d29273

Browse files
author
Stephan Brandauer
committed
make framework mode explicit in file/module names
1 parent dfb9d88 commit 6d29273

File tree

2 files changed

+15
-22
lines changed

2 files changed

+15
-22
lines changed

java/ql/src/Telemetry/AutomodelEndpointCharacteristics.qll renamed to java/ql/src/Telemetry/AutomodelFrameworkModeCharacteristics.qll

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ private import semmle.code.java.dataflow.internal.ModelExclusions as ModelExclus
1717
import AutomodelSharedCharacteristics as SharedCharacteristics
1818
import AutomodelEndpointTypes as AutomodelEndpointTypes
1919

20-
module CandidatesImpl implements SharedCharacteristics::CandidateSig {
20+
module FrameworkCandidatesImpl implements SharedCharacteristics::CandidateSig {
2121
class Endpoint = DataFlow::ParameterNode;
2222

2323
class EndpointType = AutomodelEndpointTypes::EndpointType;
@@ -29,7 +29,7 @@ module CandidatesImpl implements SharedCharacteristics::CandidateSig {
2929
// Sanitizers are currently not modeled in MaD. TODO: check if this has large negative impact.
3030
predicate isSanitizer(Endpoint e, EndpointType t) { none() }
3131

32-
RelatedLocation toRelatedLocation(Endpoint e) { result = e.asParameter() }
32+
RelatedLocation asLocation(Endpoint e) { result = e.asParameter() }
3333

3434
predicate isKnownLabel(string label, string humanReadableLabel, EndpointType type) {
3535
label = "read-file" and
@@ -89,18 +89,11 @@ module CandidatesImpl implements SharedCharacteristics::CandidateSig {
8989

9090
predicate hasMetadata(Endpoint e, string metadata) {
9191
exists(
92-
string package, string type, boolean subtypes, string name, string signature, string ext,
93-
int input, boolean isPublic, boolean isFinal, boolean isStatic
92+
string package, string type, boolean subtypes, string name, string signature, int input,
93+
boolean isPublic, boolean isFinal, boolean isStatic
9494
|
9595
hasMetadata(e, package, type, name, signature, input, isFinal, isStatic, isPublic) and
9696
(if isFinal = true or isStatic = true then subtypes = false else subtypes = true) and
97-
ext = "" and
98-
/*
99-
* "ext" will always be empty for automodeling; it's a mechanism for
100-
* specifying that the model should apply for parameters that have
101-
* a certain annotation.
102-
*/
103-
10497
metadata =
10598
"{" //
10699
+ "'Package': '" + package //
@@ -125,11 +118,11 @@ module CandidatesImpl implements SharedCharacteristics::CandidateSig {
125118

126119
Callable getCallable(Endpoint e) { result = e.getEnclosingCallable() }
127120

128-
module CharacteristicsImpl = SharedCharacteristics::SharedCharacteristics<CandidatesImpl>;
121+
module CharacteristicsImpl = SharedCharacteristics::SharedCharacteristics<FrameworkCandidatesImpl>;
129122

130123
class EndpointCharacteristic = CharacteristicsImpl::EndpointCharacteristic;
131124

132-
class Endpoint = CandidatesImpl::Endpoint;
125+
class Endpoint = FrameworkCandidatesImpl::Endpoint;
133126

134127
/*
135128
* Predicates that are used to surface prompt examples and candidates for classification with an ML model.
@@ -181,7 +174,7 @@ private class UnexploitableIsCharacteristic extends CharacteristicsImpl::NotASin
181174
UnexploitableIsCharacteristic() { this = "unexploitable (is-style boolean method)" }
182175

183176
override predicate appliesToEndpoint(Endpoint e) {
184-
not CandidatesImpl::isSink(e, _) and
177+
not FrameworkCandidatesImpl::isSink(e, _) and
185178
getCallable(e).getName().matches("is%") and
186179
getCallable(e).getReturnType() instanceof BooleanType
187180
}
@@ -199,7 +192,7 @@ private class UnexploitableExistsCharacteristic extends CharacteristicsImpl::Not
199192
UnexploitableExistsCharacteristic() { this = "unexploitable (existence-checking boolean method)" }
200193

201194
override predicate appliesToEndpoint(Endpoint e) {
202-
not CandidatesImpl::isSink(e, _) and
195+
not FrameworkCandidatesImpl::isSink(e, _) and
203196
exists(Callable callable |
204197
callable = getCallable(e) and
205198
(

java/ql/src/Telemetry/AutomodelSharedCharacteristics.qll

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ float mediumConfidence() { result = 0.6 }
1313
*/
1414
signature module CandidateSig {
1515
/**
16-
* An endpoint is a potential candidate for modelling. This will typically be bound to the language's
16+
* An endpoint is a potential candidate for modeling. This will typically be bound to the language's
1717
* DataFlow node class, or a subtype thereof.
1818
*/
1919
class Endpoint;
@@ -26,17 +26,17 @@ signature module CandidateSig {
2626
/**
2727
* A class label for an endpoint.
2828
*/
29-
class EndpointType;
29+
class EndpointType extends string;
3030

3131
/**
3232
* An EndpointType that denotes the absence of any sink.
3333
*/
3434
class NegativeEndpointType extends EndpointType;
3535

36-
RelatedLocation toRelatedLocation(Endpoint e);
36+
RelatedLocation asLocation(Endpoint e);
3737

3838
/**
39-
* Defines what labels are known, and what endpoint type they correspond to.
39+
* Defines what MaD labels are known, and what endpoint type they correspond to.
4040
*/
4141
predicate isKnownLabel(string label, string humanReadableLabel, EndpointType type);
4242

@@ -117,7 +117,7 @@ module SharedCharacteristics<CandidateSig Candidate> {
117117
Candidate::RelatedLocation getRelatedLocationOrCandidate(Candidate::Endpoint e, string name) {
118118
if exists(Candidate::getRelatedLocation(e, name))
119119
then result = Candidate::getRelatedLocation(e, name)
120-
else result = Candidate::toRelatedLocation(e)
120+
else result = Candidate::asLocation(e)
121121
}
122122

123123
/**
@@ -152,8 +152,8 @@ module SharedCharacteristics<CandidateSig Candidate> {
152152
*/
153153
abstract class EndpointCharacteristic extends string {
154154
/**
155-
* Holds when the string matches the name of the characteristic, which should describe some characteristic of the
156-
* endpoint that is meaningful for determining whether it's a sink and if so of which type
155+
* The name of the characteristic. This should describe some property of an
156+
* endpoint that is meaningful for determining whether it's a sink, and if so, of which sink type.
157157
*/
158158
bindingset[this]
159159
EndpointCharacteristic() { any() }

0 commit comments

Comments
 (0)