Skip to content

Commit 9a6aac1

Browse files
committed
Crypto: To get unreferenced parameters as general sources for Java, I've included the caveat that if a function is called, all the calls appear to be in test files.
1 parent c6174fb commit 9a6aac1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

java/ql/lib/experimental/quantum/Language.qll

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,18 @@ final class DefaultRemoteFlowSource = RemoteFlowSource;
5555

5656
private class GenericUnreferencedParameterSource extends Crypto::GenericUnreferencedParameterSource {
5757
GenericUnreferencedParameterSource() {
58-
exists(Parameter p | this = p and not exists(p.getAnArgument()))
58+
exists(Parameter p |
59+
this = p and
60+
(
61+
not exists(p.getAnArgument())
62+
or
63+
// If all calls to a function occur in a test file, ignore those calls
64+
// and consider the parameter to the function a potential source as well.
65+
forall(Call testCall | testCall.getCallee() = p.getCallable() |
66+
testCall.getFile().getBaseName().toUpperCase().matches("%TEST%")
67+
)
68+
)
69+
)
5970
}
6071

6172
override predicate flowsTo(Crypto::FlowAwareElement other) {

0 commit comments

Comments
 (0)