Skip to content

Commit e71563e

Browse files
author
Stephan Brandauer
committed
Java: Automodel fr mode: remove superfluous module
1 parent 2be5b19 commit e71563e

File tree

1 file changed

+9
-27
lines changed

1 file changed

+9
-27
lines changed

java/ql/automodel/src/AutomodelFrameworkModeCharacteristics.qll

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ module FrameworkCandidatesImpl implements SharedCharacteristics::CandidateSig {
247247
additional predicate sinkSpec(
248248
Endpoint e, string package, string type, string name, string signature, string ext, string input
249249
) {
250-
FrameworkModeGetCallable::getCallable(e).hasQualifiedName(package, type, name) and
251-
signature = ExternalFlow::paramsString(FrameworkModeGetCallable::getCallable(e)) and
250+
e.getEnclosingCallable().hasQualifiedName(package, type, name) and
251+
signature = ExternalFlow::paramsString(e.getEnclosingCallable()) and
252252
ext = "" and
253253
input = e.getMaDInput()
254254
}
@@ -270,28 +270,13 @@ module FrameworkCandidatesImpl implements SharedCharacteristics::CandidateSig {
270270
*/
271271
RelatedLocation getRelatedLocation(Endpoint e, RelatedLocationType type) {
272272
type = MethodDoc() and
273-
result = FrameworkModeGetCallable::getCallable(e).(Documentable).getJavadoc()
273+
result = e.getEnclosingCallable().(Documentable).getJavadoc()
274274
or
275275
type = ClassDoc() and
276-
result = FrameworkModeGetCallable::getCallable(e).getDeclaringType().(Documentable).getJavadoc()
276+
result = e.getEnclosingCallable().getDeclaringType().(Documentable).getJavadoc()
277277
}
278278
}
279279

280-
private class JavaCallable = Callable;
281-
282-
private module FrameworkModeGetCallable implements AutomodelSharedGetCallable::GetCallableSig {
283-
class Callable = JavaCallable;
284-
285-
class Endpoint = FrameworkCandidatesImpl::Endpoint;
286-
287-
/**
288-
* Returns the callable that contains the given endpoint.
289-
*
290-
* Each Java mode should implement this predicate.
291-
*/
292-
Callable getCallable(Endpoint e) { result = e.getEnclosingCallable() }
293-
}
294-
295280
module CharacteristicsImpl = SharedCharacteristics::SharedCharacteristics<FrameworkCandidatesImpl>;
296281

297282
class EndpointCharacteristic = CharacteristicsImpl::EndpointCharacteristic;
@@ -341,8 +326,8 @@ private class UnexploitableIsCharacteristic extends CharacteristicsImpl::NotASin
341326

342327
override predicate appliesToEndpoint(Endpoint e) {
343328
not FrameworkCandidatesImpl::isSink(e, _, _) and
344-
FrameworkModeGetCallable::getCallable(e).getName().matches("is%") and
345-
FrameworkModeGetCallable::getCallable(e).getReturnType() instanceof BooleanType
329+
e.getEnclosingCallable().getName().matches("is%") and
330+
e.getEnclosingCallable().getReturnType() instanceof BooleanType
346331
}
347332
}
348333

@@ -360,7 +345,7 @@ private class UnexploitableExistsCharacteristic extends CharacteristicsImpl::Not
360345
override predicate appliesToEndpoint(Endpoint e) {
361346
not FrameworkCandidatesImpl::isSink(e, _, _) and
362347
exists(Callable callable |
363-
callable = FrameworkModeGetCallable::getCallable(e) and
348+
callable = e.getEnclosingCallable() and
364349
callable.getName().toLowerCase() = ["exists", "notexists"] and
365350
callable.getReturnType() instanceof BooleanType
366351
)
@@ -374,8 +359,7 @@ private class ExceptionCharacteristic extends CharacteristicsImpl::NotASinkChara
374359
ExceptionCharacteristic() { this = "exception" }
375360

376361
override predicate appliesToEndpoint(Endpoint e) {
377-
FrameworkModeGetCallable::getCallable(e).getDeclaringType().getASupertype*() instanceof
378-
TypeThrowable
362+
e.getEnclosingCallable().getDeclaringType().getASupertype*() instanceof TypeThrowable
379363
}
380364
}
381365

@@ -399,9 +383,7 @@ private class NonPublicMethodCharacteristic extends CharacteristicsImpl::Uninter
399383
{
400384
NonPublicMethodCharacteristic() { this = "non-public method" }
401385

402-
override predicate appliesToEndpoint(Endpoint e) {
403-
not FrameworkModeGetCallable::getCallable(e).isPublic()
404-
}
386+
override predicate appliesToEndpoint(Endpoint e) { not e.getEnclosingCallable().isPublic() }
405387
}
406388

407389
/**

0 commit comments

Comments
 (0)