-
Notifications
You must be signed in to change notification settings - Fork 404
policy: T5069: large-community-list regex validator disallows whitespace #4482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
policy: T5069: large-community-list regex validator disallows whitespace #4482
Conversation
|
👍 |
dmbaturin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix looks sensible but please use the standard warning mechanism instead of a custom alternative.
098ae39 to
d9455b2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses T5069 by relaxing the regex validator for large-community lists in BGP, allowing whitespace and the common-separator wildcard '_' while still enforcing basic sanity checks and warning on potentially malformed patterns.
- Updated the regex pattern and allowed characters definition to accept underscores and whitespace.
- Added a warning mechanism using Warning() to alert users when the provided regex deviates from the expected form.
- Updated the copyright statement.
d9455b2 to
af2ddd5
Compare
86827d4 to
d49ecca
Compare
|
Unsure why the smoketest failed - it is UserMessage/Warning-related, but I can't get it to fail in local. Comparing a vanilla VyOS with an updated one, manual smoketest runs and direct config sets work as expected. I did muff the previous force-push so I've just tweaked minor Ruff lint fails and some naming that didn't track changes in vyos.base to trigger another smoketest run. Edit: It was a vyos-configd interaction, need to use runtime values of sys.stdout. |
d49ecca to
427cd3f
Compare
…espace * Re-introduce the whitespace/pattern matches ' ' and '_' as allowed * Perform a general Python regex validity check (not 100% 1003.2, but in combination with allowedChars, pretty close) * Introduce a warning against potentially malformed or over-complex patterns, but leave it up to the user to resolve - there are plenty of useful expressions we cannot validate easily
427cd3f to
7c9f908
Compare
|
Updated version: split off the warning-logic into conf verify and dropped output changes for validators. Re-ran smoketests for policy OK. |
|
CI integration ❌ failed! Details
|
sever-sever
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes BGP large-community regex
Smoketest passed. Approved.
dmbaturin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The warning is now in the config scripts. No objections against the logic.
Change summary
NOTE: Potentially hijacking an old ticket with a similar problem.
T5816 improved 1.4/1.5's strict validation to allow full regex on a single large-community tuple. However, it is common to match multiple components of a large-community string via regex in earlier VyOS versions (not to mention Cisco IOS). T5816 is too strict about the form of the regex pattern, does not allow the common-separator wildcard '_' and whitespace, breaking old 1.3 configs and preventing simple pattern logic being used to match multiple communities.
To resolve T5069's concerns and my own, this patch attempts to:
"Well formed" in this case would be one or more community segments roughly fitting the original check, separated by proper whitespace. "1:1:12:2:2" might be a mistake for "1:1:1 2:2:2", but there are still instances of useful patterns not following this form.
Since there's no mechanism for providing warning feedback from a validator and validator output is thrown away unless an error, I've wrapped this in the console_warning() function and it just prints directly to the TTY. If this seems like overkill, if it could be more generally useful, or if there's a suitable mechanism I missed - I imagine validation success/warning/failure feedback could be useful at API level, not just CLI - let me know and I'll update it to match.
If we retain the warning, I'll likely issue a followup patch for the documentation explaining the specific validation logic and what to check when the warning pops up.
Types of changes
Related Task(s)
Related PR(s)
How to test / Smoketest result
I've checked that these compound matches are accepted by FRR and work in a production BGP environment as the older versions of FRR in 1.3 did.
Smoketests, test_policy.py:
test_protocols_bgp.py:
Checklist: