Skip to content

Commit fd306ed

Browse files
committed
Exclude constant names from sources to avoid duplicate results
1 parent 8962307 commit fd306ed

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

go/ql/src/Security/CWE-020/IncompleteHostnameRegexp.ql

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,12 @@ predicate regexpGuardsError(RegexpPattern regexp) {
8181

8282
module IncompleteHostNameRegexpConfig implements DataFlow::ConfigSig {
8383
additional predicate isSourceString(DataFlow::Node source, string hostPart) {
84-
exists(Expr e |
85-
e = source.asExpr() and
86-
isIncompleteHostNameRegexpPattern(e.getStringValue(), hostPart)
84+
exists(Expr e | e = source.asExpr() |
85+
isIncompleteHostNameRegexpPattern(e.getStringValue(), hostPart) and
86+
// Exclude constant names to avoid duplicate results, because the string
87+
// literals which they are initialised with are also considered as
88+
// sources.
89+
not e instanceof ConstantName
8790
)
8891
}
8992

0 commit comments

Comments
 (0)