-
Notifications
You must be signed in to change notification settings - Fork 84
Introduce exclude cidrs list from rate-limiting feature #948
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
Merged
b1tamara
merged 7 commits into
cloudfoundry:master
from
sap-contributions:add-nat-exclusion-list
Jul 23, 2026
+261
−119
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6bf7fab
Introduce exclude cidrs list from rate-limiting feature
Mrizwanshaik cd81126
add acceptance test for exclude cidrs list
Mrizwanshaik bb07275
Introduce default exclude_cidrs to empty array
Mrizwanshaik 0f83611
Refactor rate_limit_test opsfiles into reusable helpers
Mrizwanshaik 4c3a04c
Document exclude_cidrs for connection rate limiting
Mrizwanshaik f5e21eb
Adress review comments
Mrizwanshaik 1d917c6
add hard coded values for window size and table size
Mrizwanshaik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # generated from rate_limit_exclusion_cidrs.txt.erb | ||
| <% | ||
| require "base64" | ||
| require 'zlib' | ||
| require 'stringio' | ||
|
|
||
| if_p("ha_proxy.connections_rate_limit.exclude_cidrs") do |cidrs| | ||
| uncompressed = '' | ||
| if cidrs.is_a?(Array) | ||
| uncompressed << "\# detected cidrs provided as array in cleartext format\n" | ||
| cidrs.each do |cidr| | ||
| uncompressed << cidr << "\n" | ||
| end | ||
| else | ||
| gzplain = Base64.decode64(cidrs) | ||
| gz = Zlib::GzipReader.new(StringIO.new(gzplain)) | ||
| uncompressed = gz.read | ||
| end | ||
| %> | ||
| # BEGIN rate limit exclusion cidrs | ||
| <%= uncompressed %> | ||
| # END rate limit exclusion cidrs | ||
| <% | ||
| end | ||
| %> |
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
64 changes: 64 additions & 0 deletions
64
spec/haproxy/templates/rate_limit_exclusion_cidrs.txt_spec.rb
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'rspec' | ||
|
|
||
| describe 'config/rate_limit_exclusion_cidrs.txt' do | ||
| let(:template) { haproxy_job.template('config/rate_limit_exclusion_cidrs.txt') } | ||
|
|
||
| context 'when ha_proxy.connections_rate_limit.exclude_cidrs is provided' do | ||
| context 'when an array of cidrs is provided' do | ||
| it 'has the correct contents' do | ||
| expect(template.render({ | ||
| 'ha_proxy' => { | ||
| 'connections_rate_limit' => { | ||
| 'exclude_cidrs' => [ | ||
| '10.0.0.0/8', | ||
| '192.168.2.0/24' | ||
| ] | ||
| } | ||
| } | ||
| })).to eq(<<~EXPECTED) | ||
| # generated from rate_limit_exclusion_cidrs.txt.erb | ||
|
|
||
| # BEGIN rate limit exclusion cidrs | ||
| # detected cidrs provided as array in cleartext format | ||
| 10.0.0.0/8 | ||
| 192.168.2.0/24 | ||
|
|
||
| # END rate limit exclusion cidrs | ||
|
|
||
| EXPECTED | ||
| end | ||
| end | ||
|
|
||
| context 'when a base64-encoded, gzipped config is provided' do | ||
| it 'has the correct contents' do | ||
| expect(template.render({ | ||
| 'ha_proxy' => { | ||
| 'connections_rate_limit' => { | ||
| 'exclude_cidrs' => gzip_and_b64_encode(<<~INPUT) | ||
| 10.0.0.0/8 | ||
| 192.168.2.0/24 | ||
| INPUT | ||
| } | ||
| } | ||
| })).to eq(<<~EXPECTED) | ||
| # generated from rate_limit_exclusion_cidrs.txt.erb | ||
|
|
||
| # BEGIN rate limit exclusion cidrs | ||
| 10.0.0.0/8 | ||
| 192.168.2.0/24 | ||
|
|
||
| # END rate limit exclusion cidrs | ||
|
|
||
| EXPECTED | ||
| end | ||
| end | ||
| end | ||
|
|
||
| context 'when ha_proxy.connections_rate_limit.exclude_cidrs is not provided' do | ||
| it 'is empty' do | ||
| expect(template.render({})).to be_a_blank_string | ||
| end | ||
| end | ||
| end |
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.
Uh oh!
There was an error while loading. Please reload this page.