mirror of
https://github.com/github/codeql.git
synced 2026-05-14 11:19:27 +02:00
Add @Pattern annotation test case and javax-validation-constraints stub
Adds a dedicated test verifying that fields annotated with @javax.validation.constraints.Pattern are recognized as sanitized by RegexpCheckBarrier, in addition to the existing String.matches() guard test.
This commit is contained in:
@@ -38,4 +38,12 @@ public class TrustBoundaryViolations extends HttpServlet {
|
||||
request.getSession().setAttribute("input4", input4);
|
||||
}
|
||||
}
|
||||
|
||||
@javax.validation.constraints.Pattern(regexp = "^[a-zA-Z0-9]+$")
|
||||
String validatedField;
|
||||
|
||||
public void doPost(HttpServletRequest request, HttpServletResponse response) {
|
||||
// GOOD: The field is constrained by a @Pattern annotation.
|
||||
request.getSession().setAttribute("validated", validatedField);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
//semmle-extractor-options: --javac-args -cp ${testdir}/../../../stubs/esapi-2.0.1:${testdir}/../../../stubs/javax-servlet-2.5
|
||||
//semmle-extractor-options: --javac-args -cp ${testdir}/../../../stubs/esapi-2.0.1:${testdir}/../../../stubs/javax-servlet-2.5:${testdir}/../../../stubs/javax-validation-constraints
|
||||
|
||||
Reference in New Issue
Block a user