Skip to content

Commit 777874b

Browse files
committed
Merge branch 'CFP-2401' of https://github.com/sap-contributions/cloud_controller_ng into CFP-2401
2 parents 46e808d + ad392f4 commit 777874b

File tree

21 files changed

+533
-244
lines changed

21 files changed

+533
-244
lines changed

.github/workflows/bump_bbs_protos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
update-protos:
1010
runs-on: ubuntu-latest
1111
permissions:
12-
contents: read
12+
contents: write
1313
pull-requests: write
1414
steps:
1515
- uses: hmarr/debug-action@v3

.github/workflows/docs_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ permissions:
2121
jobs:
2222
Test-Docs:
2323
runs-on: ubuntu-latest
24-
timeout-minutes: 30
24+
timeout-minutes: 60
2525
steps:
2626
- uses: hmarr/debug-action@v3
2727
- uses: actions/checkout@v4

.github/workflows/unit_tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939

4040
Test-Postgres:
4141
runs-on: ubuntu-latest
42-
timeout-minutes: 30
42+
timeout-minutes: 60
4343
strategy:
4444
fail-fast: false
4545
matrix:
@@ -72,7 +72,7 @@ jobs:
7272

7373
Test-Mysql:
7474
runs-on: ubuntu-latest
75-
timeout-minutes: 30
75+
timeout-minutes: 60
7676
strategy:
7777
fail-fast: false
7878
matrix:

.github/workflows/unit_tests_backwards_compatibility.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ permissions:
2828
jobs:
2929
Test-Postgres-Backwards-Compatibillity:
3030
runs-on: ubuntu-latest
31-
timeout-minutes: 30
31+
timeout-minutes: 60
3232
strategy:
3333
fail-fast: false
3434
max-parallel: 3
@@ -80,7 +80,7 @@ jobs:
8080

8181
Test-Mysql-Backwards-Compatibillity:
8282
runs-on: ubuntu-latest
83-
timeout-minutes: 30
83+
timeout-minutes: 60
8484
strategy:
8585
fail-fast: false
8686
max-parallel: 3

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ gem 'puma'
3232
gem 'rake'
3333
gem 'redis'
3434
gem 'rubyzip', '>= 1.3.0'
35-
gem 'sequel', '~> 5.93'
35+
gem 'sequel', '~> 5.94'
3636
gem 'sequel_pg', require: 'sequel'
3737
gem 'sinatra', '~> 3.2'
3838
gem 'sinatra-contrib'
@@ -82,7 +82,7 @@ group :test do
8282
gem 'rspec-collection_matchers'
8383
gem 'rspec-instafail'
8484
gem 'rspec-its'
85-
gem 'rspec-rails', '~> 8.0.0'
85+
gem 'rspec-rails', '~> 8.0.1'
8686
gem 'rspec-wait'
8787
gem 'rubocop', '~> 1.75.8'
8888
gem 'rubocop-capybara'

Gemfile.lock

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ GEM
106106
base64 (0.2.0)
107107
beefcake (1.0.0)
108108
benchmark (0.4.1)
109-
bigdecimal (3.2.1)
109+
bigdecimal (3.2.2)
110110
bit-struct (0.17)
111111
builder (3.3.0)
112112
byebug (12.0.0)
@@ -141,7 +141,7 @@ GEM
141141
digest-xxhash (0.2.9)
142142
docile (1.1.5)
143143
domain_name (0.6.20240107)
144-
drb (2.2.1)
144+
drb (2.2.3)
145145
erb (5.0.1)
146146
erubi (1.13.1)
147147
eventmachine (1.2.7)
@@ -281,7 +281,7 @@ GEM
281281
jaro_winkler (1.6.1)
282282
json (2.12.2)
283283
json-diff (0.4.1)
284-
json-schema (5.1.1)
284+
json-schema (5.2.1)
285285
addressable (~> 2.8)
286286
bigdecimal (~> 3.1)
287287
json_pure (2.8.1)
@@ -306,7 +306,7 @@ GEM
306306
logger (1.7.0)
307307
loggregator_emitter (5.2.0)
308308
beefcake (~> 1.0.0)
309-
loofah (2.24.0)
309+
loofah (2.24.1)
310310
crass (~> 1.0.2)
311311
nokogiri (>= 1.12.0)
312312
machinist (1.0.6)
@@ -370,7 +370,7 @@ GEM
370370
prettyprint
371371
prettyprint (0.2.0)
372372
prism (1.4.0)
373-
prometheus-client (4.2.4)
373+
prometheus-client (4.2.5)
374374
base64
375375
pry (0.14.1)
376376
coderay (~> 1.1)
@@ -396,7 +396,7 @@ GEM
396396
rackup (1.0.1)
397397
rack (< 3)
398398
webrick
399-
rails-dom-testing (2.2.0)
399+
rails-dom-testing (2.3.0)
400400
activesupport (>= 5.0.0)
401401
minitest
402402
nokogiri (>= 1.6)
@@ -449,7 +449,7 @@ GEM
449449
rspec-mocks (~> 3.13.0)
450450
rspec-collection_matchers (1.2.1)
451451
rspec-expectations (>= 2.99.0.beta1)
452-
rspec-core (3.13.4)
452+
rspec-core (3.13.5)
453453
rspec-support (~> 3.13.0)
454454
rspec-expectations (3.13.5)
455455
diff-lcs (>= 1.2.0, < 2.0)
@@ -462,7 +462,7 @@ GEM
462462
rspec-mocks (3.13.5)
463463
diff-lcs (>= 1.2.0, < 2.0)
464464
rspec-support (~> 3.13.0)
465-
rspec-rails (8.0.0)
465+
rspec-rails (8.0.1)
466466
actionpack (>= 7.2)
467467
activesupport (>= 7.2)
468468
railties (>= 7.2)
@@ -519,7 +519,7 @@ GEM
519519
sexp_processor (~> 4.1)
520520
rubyzip (2.4.1)
521521
securerandom (0.4.1)
522-
sequel (5.93.0)
522+
sequel (5.94.0)
523523
bigdecimal
524524
sequel_pg (1.17.2)
525525
pg (>= 0.18.0, != 1.2.0)
@@ -546,7 +546,7 @@ GEM
546546
rack-protection (= 3.2.0)
547547
sinatra (= 3.2.0)
548548
tilt (~> 2.0)
549-
solargraph (0.55.4)
549+
solargraph (0.56.0)
550550
backport (~> 1.2)
551551
benchmark (~> 0.4)
552552
bundler (~> 2.0)
@@ -558,6 +558,7 @@ GEM
558558
observer (~> 0.1)
559559
ostruct (~> 0.6)
560560
parser (~> 3.0)
561+
prism (~> 1.4)
561562
rbs (~> 3.3)
562563
reverse_markdown (~> 3.0)
563564
rubocop (~> 1.38)
@@ -610,7 +611,7 @@ GEM
610611
yard (0.9.37)
611612
yard-solargraph (0.1.0)
612613
yard (~> 0.9)
613-
zeitwerk (2.7.2)
614+
zeitwerk (2.7.3)
614615

615616
PLATFORMS
616617
ruby
@@ -678,7 +679,7 @@ DEPENDENCIES
678679
rspec-collection_matchers
679680
rspec-instafail
680681
rspec-its
681-
rspec-rails (~> 8.0.0)
682+
rspec-rails (~> 8.0.1)
682683
rspec-wait
683684
rspec_api_documentation (>= 6.1.0)
684685
rubocop (~> 1.75.8)
@@ -689,7 +690,7 @@ DEPENDENCIES
689690
rubocop-rspec_rails
690691
rubocop-sequel (~> 0.4.1)
691692
rubyzip (>= 1.3.0)
692-
sequel (~> 5.93)
693+
sequel (~> 5.94)
693694
sequel_pg
694695
sinatra (~> 3.2)
695696
sinatra-contrib

app/messages/validators/security_group_rule_validator.rb

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,28 @@ def validate(record)
2626
end
2727

2828
validate_allowed_keys(rule, record, index)
29-
30-
add_rule_error("protocol must be 'tcp', 'udp', 'icmp', or 'all'", record, index) unless valid_protocol(rule[:protocol])
29+
add_rule_error("protocol must be 'tcp', 'udp', 'icmp', 'icmpv6' or 'all'", record, index) unless valid_protocol(rule[:protocol])
3130

3231
if valid_destination_type(rule[:destination], record, index)
3332
destinations = rule[:destination].split(',', -1)
3433
add_rule_error("maximum destinations per rule exceeded - must be under #{MAX_DESTINATIONS_PER_RULE}", record, index) unless destinations.length <= MAX_DESTINATIONS_PER_RULE
3534

3635
destinations.each do |d|
37-
validate_destination(d, record, index)
36+
validate_destination(d, rule[:protocol], get_allowed_ip_version(rule), record, index)
3837
end
3938
end
4039

4140
validate_description(rule, record, index)
4241
validate_log(rule, record, index)
42+
validate_protocol(rule, record, index)
43+
end
44+
end
4345

44-
case rule[:protocol]
45-
when 'tcp', 'udp'
46-
validate_tcp_udp_protocol(rule, record, index)
47-
when 'icmp'
48-
validate_icmp_protocol(rule, record, index)
49-
when 'all'
50-
add_rule_error('ports are not allowed for protocols of type all', record, index) if rule[:ports]
51-
end
46+
def get_allowed_ip_version(rule)
47+
if rule[:protocol] == 'icmp'
48+
4
49+
elsif rule[:protocol] == 'icmpv6'
50+
6
5251
end
5352
end
5453

@@ -57,7 +56,7 @@ def boolean?(value)
5756
end
5857

5958
def valid_protocol(protocol)
60-
protocol.is_a?(String) && %w[tcp udp icmp all].include?(protocol)
59+
protocol.is_a?(String) && %w[tcp udp icmp icmpv6 all].include?(protocol)
6160
end
6261

6362
def validate_allowed_keys(rule, record, index)
@@ -73,6 +72,20 @@ def validate_log(rule, record, index)
7372
add_rule_error('log must be a boolean', record, index) if rule[:log] && !boolean?(rule[:log])
7473
end
7574

75+
def validate_protocol(rule, record, index)
76+
case rule[:protocol]
77+
when 'tcp', 'udp'
78+
validate_tcp_udp_protocol(rule, record, index)
79+
when 'icmp'
80+
validate_icmp_protocol(rule, record, index)
81+
when 'icmpv6'
82+
add_rule_error('icmpv6 cannot be used if enable_ipv6 is false', record, index) unless CloudController::RuleValidator.ipv6_enabled?
83+
validate_icmp_protocol(rule, record, index)
84+
when 'all'
85+
add_rule_error('ports are not allowed for protocols of type all', record, index) if rule[:ports]
86+
end
87+
end
88+
7689
def validate_tcp_udp_protocol(rule, record, index)
7790
add_rule_error('ports are required for protocols of type TCP and UDP', record, index) unless rule[:ports]
7891

@@ -128,7 +141,7 @@ def valid_destination_type(destination, record, index)
128141
true
129142
end
130143

131-
def validate_destination(destination, record, index)
144+
def validate_destination(destination, protocol, allowed_ip_version, record, index)
132145
error_message = 'destination must be a valid CIDR, IP address, or IP address range'
133146
error_message = 'destination must contain valid CIDR(s), IP address(es), or IP address range(s)' if CloudController::RuleValidator.comma_delimited_destinations_enabled?
134147
add_rule_error('empty destination specified in comma-delimited list', record, index) if destination.empty?
@@ -137,12 +150,14 @@ def validate_destination(destination, record, index)
137150

138151
zeros_error_message = 'destination octets cannot contain leading zeros'
139152
add_rule_error(zeros_error_message, record, index) unless CloudController::RuleValidator.no_leading_zeros(address_list)
140-
141153
if address_list.length == 1
142-
add_rule_error(error_message, record, index) unless CloudController::RuleValidator.parse_ip(address_list.first)
143-
154+
parsed_ip = CloudController::RuleValidator.parse_ip(address_list.first)
155+
add_rule_error(error_message, record, index) unless parsed_ip
156+
add_rule_error("for protocol \"#{protocol}\" you cannot use IPv#{parsed_ip.version} addresses", record, index) \
157+
unless valid_ip_version?(allowed_ip_version, parsed_ip)
144158
elsif address_list.length == 2
145159
ips = CloudController::RuleValidator.parse_ip(address_list)
160+
146161
return add_rule_error('destination IP address range is invalid', record, index) unless ips
147162

148163
sorted_ips = if ips.first.is_a?(NetAddr::IPv4)
@@ -153,12 +168,17 @@ def validate_destination(destination, record, index)
153168

154169
reversed_range_error = 'beginning of IP address range is numerically greater than the end of its range (range endpoints are inverted)'
155170
add_rule_error(reversed_range_error, record, index) unless ips.first == sorted_ips.first
156-
171+
add_rule_error("for protocol \"#{protocol}\" you cannot use IPv#{ips.first.version} addresses", record, index) \
172+
unless valid_ip_version?(allowed_ip_version, sorted_ips.first)
157173
else
158174
add_rule_error(error_message, record, index)
159175
end
160176
end
161177

178+
def valid_ip_version?(allowed_ip_version, parsed_ip)
179+
parsed_ip.nil? || allowed_ip_version.nil? || parsed_ip.version == allowed_ip_version
180+
end
181+
162182
def add_rule_error(message, record, index)
163183
record.errors.add("Rules[#{index}]:", message)
164184
end

app/models/helpers/metadata_error.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def self.none
99
end
1010

1111
def to_s
12-
"#<MetadataError is_valid:#{is_valid?} message:#{message}"
12+
"#<MetadataError is_valid:#{is_valid?} message:#{message}>"
1313
end
1414
end
1515
end

app/models/runtime/security_group.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def validate_rules
7171
validation_errors = case protocol
7272
when 'tcp', 'udp'
7373
CloudController::TransportRuleValidator.validate(stringified_rule)
74-
when 'icmp'
74+
when 'icmp', 'icmpv6'
7575
CloudController::ICMPRuleValidator.validate(stringified_rule)
7676
when 'all'
7777
CloudController::RuleValidator.validate(stringified_rule)

config/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.197.0
1+
3.198.0

0 commit comments

Comments
 (0)