Skip to content

Commit 609ed70

Browse files
committed
use GVN to find detect when the alert-location is used as a link
1 parent afdd7b0 commit 609ed70

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

ql/ql/src/queries/style/AlertMessage.ql

+7-3
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,16 @@ String doubleWhitespace(Select sel) {
185185
result.getValue().regexpMatch(".*\\s\\s.*")
186186
}
187187

188+
import codeql.GlobalValueNumbering as GVN
189+
188190
/**
189191
* Gets an expression that repeats the alert-loc as a link.
190192
*/
191-
VarAccess getAlertLocLink(Select sel) {
192-
// TODO: Get this to work with GVN. I got an infinite loop when I tried.
193-
result = sel.getExpr(0).(VarAccess).getDeclaration().getAnAccess() and
193+
AstNode getAlertLocLink(Select sel) {
194+
exists(GVN::ValueNumber vn |
195+
result = vn.getAnExpr() and
196+
sel.getExpr(0) = vn.getAnExpr()
197+
) and
194198
exists(int msgIndex | sel.getExpr(msgIndex) = sel.getMessage() |
195199
result = sel.getExpr(any(int i | i > msgIndex))
196200
)

0 commit comments

Comments
 (0)