@@ -105,34 +105,45 @@ module Sinatra {
105105 * Gets the template file referred to by `erbCall`.
106106 * This works on the AST level to avoid non-monotonic reecursion in `ErbLocalsHashSyntheticGlobal`.
107107 */
108+ pragma [ nomagic]
108109 private ErbFile getTemplateFile ( MethodCall erbCall ) {
109110 erbCall .getMethodName ( ) = "erb" and
110111 result .getTemplateName ( ) = erbCall .getArgument ( 0 ) .getConstantValue ( ) .getStringlikeValue ( ) and
111112 result .getRelativePath ( ) .matches ( "%views/%" )
112113 }
113114
115+ pragma [ nomagic]
116+ private predicate erbCallAtLocation ( MethodCall erbCall , ErbFile erbFile , Location l ) {
117+ erbCall .getMethodName ( ) = "erb" and
118+ erbFile = getTemplateFile ( erbCall ) and
119+ l = erbCall .getLocation ( )
120+ }
121+
114122 /**
115123 * Like `Location.toString`, but displays the relative path rather than the full path.
116124 */
125+ bindingset [ loc]
126+ pragma [ inline_late]
117127 private string locationRelativePathToString ( Location loc ) {
118128 result =
119129 loc .getFile ( ) .getRelativePath ( ) + "@" + loc .getStartLine ( ) + ":" + loc .getStartColumn ( ) + ":" +
120130 loc .getEndLine ( ) + ":" + loc .getEndColumn ( )
121131 }
122132
123133 /**
124- * A synthetic global representing the hash of local variables passed to an ERB template.
134+ * A synthetic global representing the hash of local variables passed to an ERB template.
125135 */
126136 class ErbLocalsHashSyntheticGlobal extends SummaryComponent:: SyntheticGlobal {
127137 private string id ;
128138 private MethodCall erbCall ;
129139 private ErbFile erbFile ;
130140
131141 ErbLocalsHashSyntheticGlobal ( ) {
132- this = "SinatraErbLocalsHash(" + id + ")" and
133- id = erbFile .getRelativePath ( ) + "," + locationRelativePathToString ( erbCall .getLocation ( ) ) and
134- erbCall .getMethodName ( ) = "erb" and
135- erbFile = getTemplateFile ( erbCall )
142+ exists ( Location l |
143+ erbCallAtLocation ( erbCall , erbFile , l ) and
144+ id = erbFile .getRelativePath ( ) + "," + locationRelativePathToString ( l ) and
145+ this = "SinatraErbLocalsHash(" + id + ")"
146+ )
136147 }
137148
138149 /**
0 commit comments