Skip to content

Commit 6e78aac

Browse files
committed
Java: Rename CallableMethod to Endpoint
1 parent fee9640 commit 6e78aac

File tree

3 files changed

+36
-34
lines changed

3 files changed

+36
-34
lines changed

java/ql/src/utils/modeleditor/ApplicationModeEndpoints.ql

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,22 @@
1010
private import java
1111
private import ModelEditor
1212

13-
class ExternalApi extends CallableMethod {
14-
ExternalApi() { not this.fromSource() }
13+
class ExternalEndpoint extends Endpoint {
14+
ExternalEndpoint() { not this.fromSource() }
1515
}
1616

17-
private Call aUsage(ExternalApi api) { result.getCallee().getSourceDeclaration() = api }
17+
private Call aUsage(ExternalEndpoint endpoint) {
18+
result.getCallee().getSourceDeclaration() = endpoint
19+
}
1820

1921
from
20-
ExternalApi externalApi, string apiName, boolean supported, Call usage, string type,
22+
ExternalEndpoint endpoint, string apiName, boolean supported, Call usage, string type,
2123
string classification
2224
where
23-
apiName = externalApi.getApiName() and
24-
supported = isSupported(externalApi) and
25-
usage = aUsage(externalApi) and
26-
type = supportedType(externalApi) and
27-
classification = methodClassification(usage)
28-
select usage, apiName, supported.toString(), "supported", externalApi.jarContainer(),
29-
externalApi.jarVersion(), type, "type", classification, "classification"
25+
apiName = endpoint.getApiName() and
26+
supported = isSupported(endpoint) and
27+
usage = aUsage(endpoint) and
28+
type = supportedType(endpoint) and
29+
classification = usageClassification(usage)
30+
select usage, apiName, supported.toString(), "supported", endpoint.jarContainer(),
31+
endpoint.jarVersion(), type, "type", classification, "classification"

java/ql/src/utils/modeleditor/FrameworkModeEndpoints.ql

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ private import java
1111
private import semmle.code.java.dataflow.internal.ModelExclusions
1212
private import ModelEditor
1313

14-
class PublicMethodFromSource extends CallableMethod, ModelApi { }
14+
class PublicEndpointFromSource extends Endpoint, ModelApi { }
1515

16-
from PublicMethodFromSource publicMethod, string apiName, boolean supported, string type
16+
from PublicEndpointFromSource endpoint, string apiName, boolean supported, string type
1717
where
18-
apiName = publicMethod.getApiName() and
19-
supported = isSupported(publicMethod) and
20-
type = supportedType(publicMethod)
21-
select publicMethod, apiName, supported.toString(), "supported",
22-
publicMethod.getCompilationUnit().getParentContainer().getBaseName(), "library", type, "type",
18+
apiName = endpoint.getApiName() and
19+
supported = isSupported(endpoint) and
20+
type = supportedType(endpoint)
21+
select endpoint, apiName, supported.toString(), "supported",
22+
endpoint.getCompilationUnit().getParentContainer().getBaseName(), "library", type, "type",
2323
"unknown", "classification"

java/ql/src/utils/modeleditor/ModelEditor.qll

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ private predicate isUninteresting(Callable c) {
2020
/**
2121
* A callable method from either the Standard Library, a 3rd party library or from the source.
2222
*/
23-
class CallableMethod extends Callable {
24-
CallableMethod() { not isUninteresting(this) }
23+
class Endpoint extends Callable {
24+
Endpoint() { not isUninteresting(this) }
2525

2626
/**
2727
* Gets information about the external API in the form expected by the MaD modeling framework.
@@ -108,30 +108,30 @@ class CallableMethod extends Callable {
108108
}
109109
}
110110

111-
boolean isSupported(CallableMethod method) {
112-
method.isSupported() and result = true
111+
boolean isSupported(Endpoint endpoint) {
112+
endpoint.isSupported() and result = true
113113
or
114-
not method.isSupported() and result = false
114+
not endpoint.isSupported() and result = false
115115
}
116116

117-
string supportedType(CallableMethod method) {
118-
method.isSink() and result = "sink"
117+
string supportedType(Endpoint endpoint) {
118+
endpoint.isSink() and result = "sink"
119119
or
120-
method.isSource() and result = "source"
120+
endpoint.isSource() and result = "source"
121121
or
122-
method.hasSummary() and result = "summary"
122+
endpoint.hasSummary() and result = "summary"
123123
or
124-
method.isNeutral() and result = "neutral"
124+
endpoint.isNeutral() and result = "neutral"
125125
or
126-
not method.isSupported() and result = ""
126+
not endpoint.isSupported() and result = ""
127127
}
128128

129-
string methodClassification(Call method) {
130-
isInTestFile(method.getLocation().getFile()) and result = "test"
129+
string usageClassification(Call usage) {
130+
isInTestFile(usage.getLocation().getFile()) and result = "test"
131131
or
132-
method.getFile() instanceof GeneratedFile and result = "generated"
132+
usage.getFile() instanceof GeneratedFile and result = "generated"
133133
or
134-
not isInTestFile(method.getLocation().getFile()) and
135-
not method.getFile() instanceof GeneratedFile and
134+
not isInTestFile(usage.getLocation().getFile()) and
135+
not usage.getFile() instanceof GeneratedFile and
136136
result = "source"
137137
}

0 commit comments

Comments
 (0)