-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Java: Exclude qualifier argument for existing models #13747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Java: Exclude qualifier argument for existing models #13747
Conversation
Excludes candadites for `Argument[this]` where we already have a model that covers a different argument of the containing call.
Reverts the change made in daf2743 With the change in the aforementioned commit, we were extracting candidates for endpoints that had a neutral _summary_ model. These are bad candidates, as they have already been triaged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you :) <3 ✨
Should we merge this or do we need input from @github/codeql-java ? |
Does this exclusion require that the models are |
This comment is 10/10, @atorralba — really well spotted ❤️! I'm taking this PR over, as Taus is 🌴, and just pushed a fix to this. Could you take a look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a small suggestion to further improve OtherArgumentToModeledMethodCharacteristic::appliesToEndpoint
, but otherwise LGTM 👍
c = otherSink.asExpr().(Argument).getCall() and | ||
e.asExpr() in [c.getQualifier(), c.getAnArgument()] and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't going to always work if otherSink
is an instance argument (this
), or if either e
or otherSink
are variadic arguments. I think we could take advantage of ArgumentNode
here:
c = otherSink.asExpr().(Argument).getCall() and | |
e.asExpr() in [c.getQualifier(), c.getAnArgument()] and | |
e.getCall() = otherSink.(ArgumentNode).getCall() |
This implies that Call c
isn't needed at the exists
, and that we add a getCall
predicate to ArgumentNode
. If we also considered ImplicitVarargsArray
as part of the definition of ArgumentNode
it would be the cherry on top:
private class ArgumentNode extends DataFlow::Node {
Call c;
ArgumentNode() {
exists(Argument arg | this.asExpr() = arg and not arg.isVararg() and c = arg.getCall())
or
this.(DataFlow::ImplicitVarargsArray).getCall() = c
or
this = DataFlow::getInstanceArgument(c)
}
Call getCall() { result = c }
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
13027a1 I think this commit implements your suggestion :) thank you :) :)
Excludes candidates for
Argument[this]
where we already have a model that covers a different argument of the containing call.