BUG/MINOR: annotations: skip empty elements in allow-list and deny-list - #849
Open
locker95 wants to merge 1 commit into
Open
BUG/MINOR: annotations: skip empty elements in allow-list and deny-list#849locker95 wants to merge 1 commit into
locker95 wants to merge 1 commit into
Conversation
A trailing comma in an allow-list annotation makes strings.Split
produce an empty element, net.ParseCIDR("") fails and the whole
annotation is discarded, leaving the ingress open to all traffic.
Skip elements that are empty after trimming instead. A value with no
valid element at all is still rejected: adding the rule with an empty
map would flip an allow-list into denying everyone.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A trailing comma in the allow-list annotation, e.g.
haproxy.org/allow-list: "10.0.0.0/16,", makesstrings.Splitproduce an empty element.net.ParseCIDR("")then fails and the whole annotation is discarded withincorrect address '' in allow-list annotation, so the ingress silently ends up open to all traffic instead of being restricted. The same applies to deny-list and the deprecated whitelist/blacklist names.This patch skips elements that are empty after trimming, so trailing commas, consecutive commas or stray whitespace no longer invalidate the list. A value with no valid element at all is still rejected as before: adding the rule with an empty map would flip an allow-list into denying everyone, which is just as surprising as allowing everyone.
Added a table-driven test for AccessControl.Process covering trailing/consecutive commas, whitespace-only elements, the deprecated whitelist name, deny-list, pattern files and the existing error paths.
Fixes #848