-
Notifications
You must be signed in to change notification settings - Fork 4k
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
fix(ec2-alpha): do not use string comparison in rangesOverlap
#32269
Conversation
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 pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
rangesOverlap
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
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.
@awsdro Thanks for your contribution. Left some minor comments.
test('Should return true for overlapping IP ranges where the last IP of one range is the first IP of the other', () => { | ||
const testCidr = new CidrBlock('10.0.0.0/16'); | ||
const range1 = ['10.0.0.0', '10.0.15.255'] as [string, string]; | ||
const range2 = ['10.0.15.255', '10.0.255.255'] as [string, string]; |
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.
Ips from 10.0.15.255
to 10.0.255.255
consists of multiple CIDR range blocks such as below and not a single CIDR range block
10.0.15.255/32
10.0.16.0/20
10.0.32.0/19
10.0.64.0/18
10.0.128.0/17
nit: It would be better to have ips that are from a single CIDR range block so it will be easy to understand. I would suggest to provide a single CIDR range block something like below.
Range 1: 10.0.0.0/24 [10.0.0.0 - 10.0.0.255]
Range 2: 10.0.0.255/32 [10.0.0.255 - 10.0.0.255]
Note: In a single CIDR range, usually the last ip can't be first ip of another valid CIDR range except for /32. So for this unit test, testing last ip of one range to another range, we could test only for /32 range ip(range 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.
The IPs used in some of the unit tests are not valid CIDR ranges, I only added them to test the actual comparison logic in the rangesOverlap
method. During actual use, the method would not be called with invalid CIDR ranges, but it might worth having tests around the logic regardless, as was recommended in previous feedback.
Pull request has been modified.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
This pull request has been removed from the queue for the following reason: Pull request #32269 has been dequeued. The pull request could not be merged. This could be related to an activated branch protection or ruleset rule that prevents us from merging. (detail: 4 of 6 required status checks are expected.). You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. If you want to requeue this pull request, you need to post a comment with the text: |
@Mergifyio refresh |
✅ Pull request refreshed |
This pull request has been removed from the queue for the following reason: Pull request #32269 has been dequeued. The pull request could not be merged. This could be related to an activated branch protection or ruleset rule that prevents us from merging. (detail: 4 of 6 required status checks are expected.). You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. If you want to requeue this pull request, you need to post a comment with the text: |
@Mergifyio requeue |
❌ Command disallowed due to command restrictions in the Mergify configuration.
|
Hi @godwingrs22, could you please help with merging this Pull Request? I am seeing the following message: I do not have permissions to requeue the PR. |
@Mergifyio requeue |
✅ The queue state of this pull request has been cleaned. It can be re-embarked automatically |
This pull request has been removed from the queue for the following reason: Pull request #32269 has been dequeued. The pull request could not be merged. This could be related to an activated branch protection or ruleset rule that prevents us from merging. (detail: 4 of 6 required status checks are expected.). You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it. If you want to requeue this pull request, you need to post a comment with the text: |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #32269 +/- ##
=======================================
Coverage 78.85% 78.85%
=======================================
Files 108 108
Lines 7165 7165
Branches 1319 1319
=======================================
Hits 5650 5650
Misses 1330 1330
Partials 185 185
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@Mergifyio refresh |
✅ Pull request refreshed |
Comments on closed issues and PRs are hard for our team to see. |
Issue #32145
Closes #32145.
Reason for this change
The rangesOverlap method was using string comparison to check if IP ranges overlapped.
Description of changes
The rangesOverlap method was updated to compare IP ranges using the ip-num library
Description of how you validated changes
Added two unit tests to verify correct behavior
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license