-
Notifications
You must be signed in to change notification settings - Fork 298
Support rfc6598 IP addresses in service subnet #3165
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: abalamanova <[email protected]>
Summary of ChangesHello @balamanova, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the application's network configuration capabilities by integrating support for RFC 6598 Shared Address Space IP ranges within the service subnet validation logic. This change allows for the proper recognition and handling of these specific IP addresses, ensuring broader compatibility and correct data input in the user interface. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request adds support for RFC 6598 IP addresses (Carrier-Grade NAT) to the 'Service Subnet' static workload type. The changes include updating the validation regex and adding a corresponding test case.
My review identifies a bug in the new regex logic that allows invalid CIDR prefixes, and also points out opportunities to improve the regex's maintainability. Additionally, a variable name in the test file has become misleading due to the new address type and should be updated for clarity.
| value: 'SERVICE_SUBNET', | ||
| pattern: | ||
| '^(10(\\.(([0-9]?[0-9])|(1[0-9]?[0-9])|(2[0-4]?[0-9])|(25[0-5]))){3}/([8-9]|(1[0-9])|(2[0-9])|(3[0-1])))|(172\\.((1[6-9])|(2[0-9])|(3[0-1]))(\\.(([0-9]?[0-9])|(1[0-9]?[0-9])|(2[0-4]?[0-9])|(25[0-5]))){2}/((1[2-9])|(2[0-9])|(3[0-1])))|(192\\.168(\\.(([0-9]?[0-9])|(1[0-9]?[0-9])|(2[0-4]?[0-9])|(25[0-5]))){2}/((1[6-9])|(2[0-9])|(3[0-1])))|(127(\\.(([0-9]?[0-9])|(1[0-9]?[0-9])|(2[0-4]?[0-9])|(25[0-5]))){3}/([8-9]|(1[0-9])|(2[0-9])|(3[0-1])))$', | ||
| '^(10(\\.(([0-9]?[0-9])|(1[0-9]?[0-9])|(2[0-4]?[0-9])|(25[0-5]))){3}/([8-9]|(1[0-9])|(2[0-9])|(3[0-1])))|(172\\.((1[6-9])|(2[0-9])|(3[0-1]))(\\.(([0-9]?[0-9])|(1[0-9]?[0-9])|(2[0-4]?[0-9])|(25[0-5]))){2}/((1[2-9])|(2[0-9])|(3[0-1])))|(192\\.168(\\.(([0-9]?[0-9])|(1[0-9]?[0-9])|(2[0-4]?[0-9])|(25[0-5]))){2}/((1[6-9])|(2[0-9])|(3[0-1])))|(127(\\.(([0-9]?[0-9])|(1[0-9]?[0-9])|(2[0-4]?[0-9])|(25[0-5]))){3}/([8-9]|(1[0-9])|(2[0-9])|(3[0-1])))|(100\\.(6[4-9]|[7-9][0-9]|1[01][0-9]|12[0-7])(\\.(([0-9]?[0-9])|(1[0-9]?[0-9])|(2[0-4]?[0-9])|(25[0-5]))){2}/([1-9]|[12][0-9]|3[0-2]))$', |
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.
This regular expression is very complex and hard to maintain. More importantly, the new part for RFC 6598 addresses contains a bug.
- Bug: The CIDR prefix length for the RFC 6598 range (
100.64.0.0/10) should be between 10 and 32. The current regex([1-9]|[12][0-9]|3[0-2])incorrectly allows prefixes from 1 to 9. - Maintainability: The sub-expression for matching an IP octet
(([0-9]?[0-9])|(1[0-9]?[0-9])|(2[0-4]?[0-9])|(25[0-5]))is convoluted and can be simplified to a more standard and efficient form:(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9]).
I suggest refactoring the entire regex to fix the bug and improve readability and performance. Also, please consider updating the comment on line 120, which is now outdated.
| '^(10(\\.(([0-9]?[0-9])|(1[0-9]?[0-9])|(2[0-4]?[0-9])|(25[0-5]))){3}/([8-9]|(1[0-9])|(2[0-9])|(3[0-1])))|(172\\.((1[6-9])|(2[0-9])|(3[0-1]))(\\.(([0-9]?[0-9])|(1[0-9]?[0-9])|(2[0-4]?[0-9])|(25[0-5]))){2}/((1[2-9])|(2[0-9])|(3[0-1])))|(192\\.168(\\.(([0-9]?[0-9])|(1[0-9]?[0-9])|(2[0-4]?[0-9])|(25[0-5]))){2}/((1[6-9])|(2[0-9])|(3[0-1])))|(127(\\.(([0-9]?[0-9])|(1[0-9]?[0-9])|(2[0-4]?[0-9])|(25[0-5]))){3}/([8-9]|(1[0-9])|(2[0-9])|(3[0-1])))|(100\\.(6[4-9]|[7-9][0-9]|1[01][0-9]|12[0-7])(\\.(([0-9]?[0-9])|(1[0-9]?[0-9])|(2[0-4]?[0-9])|(25[0-5]))){2}/([1-9]|[12][0-9]|3[0-2]))$', | |
| '^(10(\\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}/([8-9]|1[0-9]|2[0-9]|3[0-1]))|(172\\.((1[6-9])|2[0-9]|3[0-1])(\\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){2}/(1[2-9]|2[0-9]|3[0-1]))|(192\\.168(\\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){2}/(1[6-9]|2[0-9]|3[0-1]))|(127(\\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}/([8-9]|1[0-9]|2[0-9]|3[0-1]))|(100\\.(6[4-9]|[7-9][0-9]|1[01][0-9]|12[0-7])(\\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){2}/(1[0-9]|2[0-9]|3[0-2]))$' |
| '192.168.2.0/24', | ||
| '192.168.100.0/24', | ||
| '10.255.255.0/24', | ||
| '100.64.0.0/10', |
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 variable name rfc1918CIDR is now misleading as it contains 100.64.0.0/10 which is defined in RFC 6598 (Shared Address Space for Carrier-Grade NAT), not RFC 1918 (Private Internets). To improve clarity and maintainability, consider renaming this variable to something more inclusive, like validServiceSubnetCIDRs, throughout this test case.
Signed-off-by: abalamanova <[email protected]>
Description
Contribution Checklist:
Attach Screenshots (Optional)