Skip to content

Commit e916ce8

Browse files
committed
Exclude test directories of typical build tools
1 parent 5e36eed commit e916ce8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

java/ql/src/experimental/Security/CWE/CWE-489/ServletMain.ql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class ServletMainMethod extends Method {
4242
this.getNumberOfParameters() = 1 and
4343
this.getParameter(0).getType() instanceof Array and
4444
not this.getDeclaringType().getName().toLowerCase().matches("%test%") and // Simple check to exclude test classes to reduce FPs
45-
not this.getDeclaringType().getPackage().getName().toLowerCase().matches("%test%") // Simple check to exclude classes in test packages to reduce FPs
45+
not this.getDeclaringType().getPackage().getName().toLowerCase().matches("%test%") and // Simple check to exclude classes in test packages to reduce FPs
46+
not exists(this.getLocation().getFile().getAbsolutePath().indexOf("/src/test/java")) // Match test directory structure of build tools like maven
4647
}
4748
}
4849

0 commit comments

Comments
 (0)