Add methods to augment allowed headers and parameters in StrictHttpFi…#15048
Add methods to augment allowed headers and parameters in StrictHttpFi…#15048jzheaux merged 1 commit intospring-projects:mainfrom baezzys:enhance/strict-http-firewall-flexibility
Conversation
jzheaux
left a comment
There was a problem hiding this comment.
Thanks, @baezzys! There is an issue with having both set and add that I didn't see earlier, which is that it assumes that the application wants to do Predicate#and and not Predicate#or. It doesn't give the developer much more power.
Also, I think that addAllowHeaderValues makes it seem like you are listing additional ways that headers would be allowed, which is the opposite of the implementation.
Instead, please let's introduce public static defaults for each, like so:
public static final Predicate<String> ALLOWED_HEADER_NAMES = ...;
public static final Predicate<String> ALLOWED_HEADER_VALUES = ...;
public static final Predicate<String> ALLOWED_PARAMETER_NAMES = ...;
public static final Predicate<String> ALLOWED_PARAMETER_VALUES = ...;So that an application can do:
firewall.setAllowedHeaderValues(ALLOWED_HEADER_VALUES.and((value) -> !value.contains("\t")))|
Thank you for the review, @jzheaux. However, since the setters are not static, would it be acceptable to change them to public instead of public static? |
|
I think they should be |
|
Thank you for the feedback, @jzheaux I have updated the Please review the changes and let me know if any further adjustments are needed. |
|
Hi @jzheaux, Sorry for the late response. I've made the changes based on your feedback. PTAL. Thanks! |
Introduced public static final Predicates for allowed header names, header values, parameter names, and parameter values for building expressions. Closes gh-13639
|
Thank you, @baezzys, for the PR! This is now merged into |
This pull request introduces new constants in the
StrictHttpFirewallclass that allow for the augmentation of the sets of allowable header names, header values, parameter names, and parameter values.This closes #13639