Fix Revel template test

We want the controller, which is the type which embeds *Revel.Controller.
We have to skip the implicit field reads to get to the base of the selector
expression.
This commit is contained in:
Owen Mansel-Chan
2021-03-26 10:48:30 +00:00
parent b507c0d584
commit 3e57ea0e75

View File

@@ -279,6 +279,11 @@ module Revel {
override DataFlow::Node getADataArgument() { result = this.getArgumentVariable().getAUse() }
}
private IR::EvalInstruction skipImplicitFieldReads(IR::Instruction insn) {
result = insn or
result = skipImplicitFieldReads(insn.(IR::ImplicitFieldReadInstruction).getBase())
}
/** A call to `Controller.Render`. */
private class ControllerRender extends TemplateRender, DataFlow::MethodCallNode {
ControllerRender() { this.getTarget().hasQualifiedName(packagePath(), "Controller", "Render") }
@@ -286,8 +291,9 @@ module Revel {
override DataFlow::Node getTemplateArgument() { none() }
override File getRenderedFile() {
exists(string controllerRe, string handlerRe, string pathRe |
controllerRe = "\\Q" + this.getReceiver().getType().getName() + "\\E" and
exists(Type controllerType, string controllerRe, string handlerRe, string pathRe |
controllerType = skipImplicitFieldReads(this.getReceiver().asInstruction()).getResultType() and
controllerRe = "\\Q" + controllerType.getName() + "\\E" and
handlerRe = "\\Q" + this.getEnclosingCallable().getName() + "\\E" and
// find a file named '/views/<controller>/<handler>(.<template type>).html
pathRe = "/views/" + controllerRe + "/" + handlerRe + "(\\..*)?\\.html?"