Skip to content

Commit 03ca244

Browse files
author
Max Schaefer
committed
Associate endpoints with their potential endpoint types and check these when determining candidates.
This prevents us from associating a sink candidate with a source type and vice versa. However, this does not fix the problem of negative characteristics for sink types excluding source candidates.
1 parent a6d996b commit 03ca244

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

java/ql/automodel/src/AutomodelApplicationModeCharacteristics.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,18 @@ abstract private class ApplicationModeEndpoint extends TApplicationModeEndpoint
9696
else none() // if both exist, it would be a summaryModel (not yet supported)
9797
}
9898

99+
/**
100+
* Gets a potential type of this endpoint to make sure that sources are
101+
* associated with source types and sinks with sink types.
102+
*/
103+
AutomodelEndpointTypes::EndpointType getAPotentialType() {
104+
this.getExtensibleType() = "sourceModel" and
105+
result instanceof AutomodelEndpointTypes::SourceType
106+
or
107+
this.getExtensibleType() = "sinkModel" and
108+
result instanceof AutomodelEndpointTypes::SinkType
109+
}
110+
99111
abstract string toString();
100112
}
101113

java/ql/automodel/src/AutomodelFrameworkModeCharacteristics.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@ abstract class FrameworkModeEndpoint extends TFrameworkModeEndpoint {
9090

9191
abstract string getExtensibleType();
9292

93+
/**
94+
* Gets a potential type of this endpoint to make sure that sources are
95+
* associated with source types and sinks with sink types.
96+
*/
97+
AutomodelEndpointTypes::EndpointType getAPotentialType() {
98+
this.getExtensibleType() = "sourceModel" and
99+
result instanceof AutomodelEndpointTypes::SourceType
100+
or
101+
this.getExtensibleType() = "sinkModel" and
102+
result instanceof AutomodelEndpointTypes::SinkType
103+
}
104+
93105
string toString() { result = this.asTop().toString() }
94106

95107
Location getLocation() { result = this.asTop().getLocation() }

java/ql/automodel/src/AutomodelSharedCharacteristics.qll

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ signature module CandidateSig {
1616
* 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
*/
19-
class Endpoint;
19+
class Endpoint {
20+
EndpointType getAPotentialType();
21+
}
2022

2123
/**
2224
* A related location for an endpoint. This will typically be bound to the supertype of all AST nodes (eg., `Top`).
@@ -122,9 +124,10 @@ module SharedCharacteristics<CandidateSig Candidate> {
122124
*
123125
* A candidate is an endpoint that cannot be excluded from `endpointType` based on its characteristics.
124126
*/
125-
predicate isCandidate(Candidate::Endpoint candidateSink, Candidate::EndpointType sinkType) {
126-
not sinkType instanceof Candidate::NegativeEndpointType and
127-
not exists(getAnExcludingCharacteristic(candidateSink, sinkType))
127+
predicate isCandidate(Candidate::Endpoint endpoint, Candidate::EndpointType endpointType) {
128+
not endpointType instanceof Candidate::NegativeEndpointType and
129+
endpointType = endpoint.getAPotentialType() and
130+
not exists(getAnExcludingCharacteristic(endpoint, endpointType))
128131
}
129132

130133
/**

0 commit comments

Comments
 (0)