Skip to content

Commit 6f5bdfb

Browse files
committed
Java: Do not lift neutrals and only generate for public endpoints.
1 parent 1e54422 commit 6f5bdfb

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

java/ql/src/utils/modelgenerator/internal/CaptureModelsSpecific.qll

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,11 @@ predicate isUninterestingForDataFlowModels(Callable api) {
8080
predicate isUninterestingForTypeBasedFlowModels(Callable api) { none() }
8181

8282
/**
83-
* A class of Callables that are relevant for generating summary, source and sinks models for.
83+
* A class of callables that are potentially relevant for generating summary, source, sink
84+
* and neutral models.
8485
*
85-
* In the Standard library and 3rd party libraries it the Callables that can be called
86-
* from outside the library itself.
86+
* In the Standard library and 3rd party libraries it is the callables (or callables that have a
87+
* super implementation) that can be called from outside the library itself.
8788
*/
8889
class TargetApiSpecific extends Callable {
8990
private Callable lift;
@@ -97,6 +98,11 @@ class TargetApiSpecific extends Callable {
9798
* Gets the callable that a model will be lifted to.
9899
*/
99100
Callable lift() { result = lift }
101+
102+
/**
103+
* Holds if this callable is relevant in terms of generating models.
104+
*/
105+
predicate isRelevant() { relevant(this) }
100106
}
101107

102108
private string isExtensible(Callable c) {
@@ -114,23 +120,21 @@ private string typeAsModel(Callable c) {
114120
)
115121
}
116122

117-
private predicate partialLiftedModel(
118-
TargetApiSpecific api, string type, string extensible, string name, string parameters
123+
private predicate partialModel(
124+
Callable api, string type, string extensible, string name, string parameters
119125
) {
120-
exists(Callable c | c = api.lift() |
121-
type = typeAsModel(c) and
122-
extensible = isExtensible(c) and
123-
name = c.getName() and
124-
parameters = ExternalFlow::paramsString(c)
125-
)
126+
type = typeAsModel(api) and
127+
extensible = isExtensible(api) and
128+
name = api.getName() and
129+
parameters = ExternalFlow::paramsString(api)
126130
}
127131

128132
/**
129133
* Computes the first 6 columns for MaD rows.
130134
*/
131135
string asPartialModel(TargetApiSpecific api) {
132136
exists(string type, string extensible, string name, string parameters |
133-
partialLiftedModel(api, type, extensible, name, parameters) and
137+
partialModel(api.lift(), type, extensible, name, parameters) and
134138
result =
135139
type + ";" //
136140
+ extensible + ";" //
@@ -145,7 +149,7 @@ string asPartialModel(TargetApiSpecific api) {
145149
*/
146150
string asPartialNeutralModel(TargetApiSpecific api) {
147151
exists(string type, string name, string parameters |
148-
partialLiftedModel(api, type, _, name, parameters) and
152+
partialModel(api, type, _, name, parameters) and
149153
result =
150154
type + ";" //
151155
+ name + ";" //

java/ql/src/utils/modelgenerator/internal/CaptureSummaryFlowQuery.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,6 @@ string captureFlow(DataFlowTargetApi api) {
7979
*/
8080
string captureNoFlow(DataFlowTargetApi api) {
8181
not exists(DataFlowTargetApi api0 | exists(captureFlow(api0)) and api0.lift() = api.lift()) and
82+
api.isRelevant() and
8283
result = ModelPrinting::asNeutralSummaryModel(api)
8384
}

0 commit comments

Comments
 (0)