Rb: add Kernel methods as sinks to path-injection#11575
Conversation
…Argument` cannot be mistaken for a method in `CallNode`
a38a043 to
8f0c0f3
Compare
| methodName = super.getMethodName() | ||
| or | ||
| this.asExpr().getExpr() instanceof SuperCall and | ||
| methodName = this.asExpr().getExpr().getEnclosingCallable().(MethodBase).getName() |
There was a problem hiding this comment.
I think it would make sense if super() calls always report the name of its enclosing method as its name. Library models shouldn't have to bother with the kind of code we see here - we should take it as an opportunity to improve the API.
There was a problem hiding this comment.
That sounds like a good idea, I'll try it and see what happens.
There was a problem hiding this comment.
I didn't really have to change the QLDoc for getMethodName() as it already said: Gets the name of the method being called..
And the method being called is not super, so one could say that this new implementation actually fixes a bug.
There was a problem hiding this comment.
Sounds like a good idea to me.
69fae60 to
1a6e16f
Compare
|
A new evaluation is still uneventful. |
|
Thanks! The code LGTM, but could you run an evaluation with meta queries so we can see which sinks get added in practice? |
Evaluation on meta queries: https://github.com/github/codeql-dca-main/blob/data/erik-krogh/pr-11575-e0045d__nightly__code-scanning/reports/alert-meta-comparison.md It keeps crashing, even after I've removed string-constants in |
|
|
||
| override string toString() { result = "call to " + this.getMethodName() } | ||
| override string toString() { | ||
| if this instanceof SuperCall |
There was a problem hiding this comment.
Wouldn't it be better to add a toString method to the SuperCall class instead?
Adds methods like
Kernel.loadas sinks to path-injection.Kernel.loadloads and executes the code referred to by the path.Copilot gave me the list of method names, and I confirmed the list to be correct.
Additionally adds support for
super(..)calls that actually call methods onKernel.Inspired by CVE-2018-3760
Evaluations (nightly, rails) were uneventful.