Skip to content

Commit 0f9ab8a

Browse files
authored
Housekeeping, OSGI start/stop, Parameterized some hardcoded values. (#663)
* Signed key history for MATT SEIL begins here. * Signed key history for MATT SEIL begins here. Fixed email typo. * Revert "Signed key history for MATT SEIL begins here. Fixed email typo." This reverts commit 87c4c4e. * created file on main. * Deleted foo.txt * #661 Added ability to generate OSGi metadata with the command 'mvn org.apache.felix:maven-bundle-plugin:manifest'. * Updated to AntiSamy 1.6.5. * Revert "#661 Added ability to generate OSGi metadata with the command 'mvn org.apache.felix:maven-bundle-plugin:manifest'." This reverts commit 9fa2a53. * #656 --> Parameterized cookie name length and value to correspond with the HTTP maxes defined in esapi.properties. * Adjusted regex to allow for zero-length matches. * Added per review comments for PR #663 Co-authored-by: Matt Seil <xeno6696[at]gmail.com>
1 parent 699291c commit 0f9ab8a

File tree

7 files changed

+9
-8
lines changed

7 files changed

+9
-8
lines changed

configuration/esapi/ESAPI.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ Validator.Redirect=^\\/test.*$
469469
Validator.HTTPScheme=^(http|https)$
470470
Validator.HTTPServerName=^[a-zA-Z0-9_.\\-]*$
471471
Validator.HTTPCookieName=^[a-zA-Z0-9\\-_]{1,32}$
472-
Validator.HTTPCookieValue=^[a-zA-Z0-9\\-\\/+=_ ]*$
472+
Validator.HTTPCookieValue=^[a-zA-Z0-9\\-\\/+=_ ]{0,1024}$
473473
# Note that headerName and Value length is also configured in the HTTPUtilities section
474474
Validator.HTTPHeaderName=^[a-zA-Z0-9\\-_]{1,256}$
475475
Validator.HTTPHeaderValue=^[a-zA-Z0-9()\\-=\\*\\.\\?;,+\\/:&_ ]*$

src/main/java/org/owasp/esapi/reference/DefaultHTTPUtilities.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,9 @@ public void addCookie(HttpServletResponse response, Cookie cookie) {
189189

190190
// validate the name and value
191191
ValidationErrorList errors = new ValidationErrorList();
192-
String cookieName = ESAPI.validator().getValidInput("cookie name", name, "HTTPCookieName", 50, false, errors);
193-
String cookieValue = ESAPI.validator().getValidInput("cookie value", value, "HTTPCookieValue", 5000, false, errors);
192+
SecurityConfiguration sc = ESAPI.securityConfiguration();
193+
String cookieName = ESAPI.validator().getValidInput("cookie name", name, "HTTPCookieName", sc.getIntProp("HttpUtilities.MaxHeaderNameSize"), false, errors);
194+
String cookieValue = ESAPI.validator().getValidInput("cookie value", value, "HTTPCookieValue", sc.getIntProp("HttpUtilities.MaxHeaderValueSize"), false, errors);
194195

195196
// if there are no errors, then set the cookie either with a header or normally
196197
if (errors.size() == 0) {

src/test/resources/esapi/ESAPI-CommaValidatorFileChecker.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ Validator.Redirect=^\\/test.*$
468468
Validator.HTTPScheme=^(http|https)$
469469
Validator.HTTPServerName=^[a-zA-Z0-9_.\\-]*$
470470
Validator.HTTPCookieName=^[a-zA-Z0-9\\-_]{1,32}$
471-
Validator.HTTPCookieValue=^[a-zA-Z0-9\\-\\/+=_ ]*$
471+
Validator.HTTPCookieValue=^[a-zA-Z0-9\\-\\/+=_ ]{0,1024}$
472472
Validator.HTTPHeaderName=^[a-zA-Z0-9\\-_]{1,32}$
473473
Validator.HTTPHeaderValue=^[a-zA-Z0-9()\\-=\\*\\.\\?;,+\\/:&_ ]*$
474474
Validator.HTTPServletPath=^[a-zA-Z0-9.\\-\\/_]*$

src/test/resources/esapi/ESAPI-DualValidatorFileChecker.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ Validator.Redirect=^\\/test.*$
469469
Validator.HTTPScheme=^(http|https)$
470470
Validator.HTTPServerName=^[a-zA-Z0-9_.\\-]*$
471471
Validator.HTTPCookieName=^[a-zA-Z0-9\\-_]{1,32}$
472-
Validator.HTTPCookieValue=^[a-zA-Z0-9\\-\\/+=_ ]*$
472+
Validator.HTTPCookieValue=^[a-zA-Z0-9\\-\\/+=_ ]{0,1024}$
473473
Validator.HTTPHeaderName=^[a-zA-Z0-9\\-_]{1,32}$
474474
Validator.HTTPHeaderValue=^[a-zA-Z0-9()\\-=\\*\\.\\?;,+\\/:&_ ]*$
475475
Validator.HTTPServletPath=^[a-zA-Z0-9.\\-\\/_]*$

src/test/resources/esapi/ESAPI-QuotedValidatorFileChecker.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ Validator.Redirect=^\\/test.*$
467467
Validator.HTTPScheme=^(http|https)$
468468
Validator.HTTPServerName=^[a-zA-Z0-9_.\\-]*$
469469
Validator.HTTPCookieName=^[a-zA-Z0-9\\-_]{1,32}$
470-
Validator.HTTPCookieValue=^[a-zA-Z0-9\\-\\/+=_ ]*$
470+
Validator.HTTPCookieValue=^[a-zA-Z0-9\\-\\/+=_ ]{0,1024}$
471471
Validator.HTTPHeaderName=^[a-zA-Z0-9\\-_]{1,32}$
472472
Validator.HTTPHeaderValue=^[a-zA-Z0-9()\\-=\\*\\.\\?;,+\\/:&_ ]*$
473473
Validator.HTTPServletPath=^[a-zA-Z0-9.\\-\\/_]*$

src/test/resources/esapi/ESAPI-SingleValidatorFileChecker.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ Validator.Redirect=^\\/test.*$
467467
Validator.HTTPScheme=^(http|https)$
468468
Validator.HTTPServerName=^[a-zA-Z0-9_.\\-]*$
469469
Validator.HTTPCookieName=^[a-zA-Z0-9\\-_]{1,32}$
470-
Validator.HTTPCookieValue=^[a-zA-Z0-9\\-\\/+=_ ]*$
470+
Validator.HTTPCookieValue=^[a-zA-Z0-9\\-\\/+=_ ]{0,1024}$
471471
Validator.HTTPHeaderName=^[a-zA-Z0-9\\-_]{1,32}$
472472
Validator.HTTPHeaderValue=^[a-zA-Z0-9()\\-=\\*\\.\\?;,+\\/:&_ ]*$
473473
Validator.HTTPServletPath=^[a-zA-Z0-9.\\-\\/_]*$

src/test/resources/esapi/ESAPI.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ Validator.Redirect=^\\/test.*$
498498
Validator.HTTPScheme=^(http|https)$
499499
Validator.HTTPServerName=^[a-zA-Z0-9_.\\-]*$
500500
Validator.HTTPCookieName=^[a-zA-Z0-9\\-_]{1,32}$
501-
Validator.HTTPCookieValue=^[a-zA-Z0-9\\-\\/+=_ ]*$
501+
Validator.HTTPCookieValue=^[a-zA-Z0-9\\-\\/+=_ ]{0,1024}$
502502
# Note that headerName and Value length is also configured in the HTTPUtilities section
503503
Validator.HTTPHeaderName=^[a-zA-Z0-9\\-_]{1,256}$
504504
Validator.HTTPHeaderValue=^[a-zA-Z0-9()\\-=\\*\\.\\?;,+\\/:&_ ]*$

0 commit comments

Comments
 (0)