record_store 8.0.4 → 8.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 077fdafcb637ff49252d1e8aba5af4803cc4c458dee23465354ca77df48b9f7f
4
- data.tar.gz: 4fe82c6141e811289c9cdd7d978e53d68693a3e22a564b846252a585ec25115b
3
+ metadata.gz: 6c527f647483b3ba25a8795bd1de0eebc8db895263dcaa836b36ba61d6937ede
4
+ data.tar.gz: 89aa174d951809d032d50defe287e53f348a363c68b0eadb759ee15589915b1c
5
5
  SHA512:
6
- metadata.gz: 8c82a2c86d3ed27449b231695bd3edfba7b5d9b0c2e21f64c11cf52af89ad76e6c2364eb957022fc7743e90ecd3818c46c409f0332234ea16a41ea7e5c935ca6
7
- data.tar.gz: 4d144671d258a63f11e8684efe80f2119a9bcc2a4a3786253eba28ba8adf1a648fc0439c2b22ef8d0b508cc52c4453c1300e7a74d4ffce23088e0fdfcb1c6248
6
+ metadata.gz: a5deb741718100321c6c96bdb789cb73120a1d91a24baeec672da5633805f11cc91c310d32a8bc41aead7f0c5a825bd57544272a0d1a6d1a61041896edd8f265
7
+ data.tar.gz: c041100480d8f986c5e2c5a3eb4edebc91e30759f3299c12420d9fe263e22fd359912ff3ad88936c3edb3202d5170cecd2adb3defd4213933b65e0e1214250e9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 8.0.5
4
+ - Add IPv6 PTR record validation
5
+
3
6
  ## 8.0.4
4
7
  - Normalize (compress) addresses in A and AAAA records
5
8
 
@@ -11,35 +11,30 @@ module Cloudflare
11
11
 
12
12
  def get(endpoint, params = {})
13
13
  uri = build_uri(endpoint, params)
14
-
15
14
  response = request(:get, uri)
16
15
  Cloudflare::Response.new(response)
17
16
  end
18
17
 
19
18
  def post(endpoint, body = nil)
20
19
  uri = build_uri(endpoint)
21
-
22
20
  response = request(:post, uri, body: body)
23
21
  Cloudflare::Response.new(response)
24
22
  end
25
23
 
26
24
  def put(endpoint, body = nil)
27
25
  uri = build_uri(endpoint)
28
-
29
26
  response = request(:put, uri, body: body)
30
27
  Cloudflare::Response.new(response)
31
28
  end
32
29
 
33
30
  def patch(endpoint, body = nil)
34
31
  uri = build_uri(endpoint)
35
-
36
32
  response = request(:patch, uri, body: body)
37
33
  Cloudflare::Response.new(response)
38
34
  end
39
35
 
40
36
  def delete(endpoint)
41
37
  uri = build_uri(endpoint)
42
-
43
38
  response = request(:delete, uri)
44
39
  Cloudflare::Response.new(response)
45
40
  end
@@ -72,6 +67,12 @@ module Cloudflare
72
67
  rescue StandardError => e
73
68
  raise "HTTP error: #{e.message}"
74
69
  end
70
+
71
+ if response.code.to_i >= 300
72
+ raise RecordStore::Provider::Error,
73
+ "HTTP response code: #{response.code} - #{response.message}; #{response.body}"
74
+ end
75
+
75
76
  response
76
77
  end
77
78
  end
@@ -2,11 +2,19 @@ module RecordStore
2
2
  class Record::PTR < Record
3
3
  attr_accessor :ptrdname
4
4
 
5
- OCTET_LABEL_SEQUENCE_REGEX = /\A(?:([0-9]|[1-9][0-9]|[1-9][0-9][0-9])\.){1,4}/
6
- IN_ADDR_ARPA_SUFFIX_REGEX = /in-addr\.arpa\.\z/
7
- FQDN_FORMAT_REGEX = Regexp.new(OCTET_LABEL_SEQUENCE_REGEX.source + IN_ADDR_ARPA_SUFFIX_REGEX.source)
5
+ # IPv4: 1-3 digits (0-255) followed by dots, 1-4 times
6
+ IPV4_LABEL_SEQUENCE_REGEX = /\A(?:([0-9]|[1-9][0-9]|[1-9][0-9][0-9])\.){1,4}/
8
7
 
9
- validates_format_of :fqdn, with: FQDN_FORMAT_REGEX
8
+ # IPv6: single hex digit followed by dots, exactly 32 times
9
+ IPV6_LABEL_SEQUENCE_REGEX = /\A(?:[0-9a-f]\.){32}/i
10
+
11
+ IN_ADDR_ARPA_SUFFIX_REGEX = /(in-addr|ip6)\.arpa\.\z/
12
+
13
+ # Combine with suffix for full validation
14
+ IPV4_FORMAT_REGEX = Regexp.new(IPV4_LABEL_SEQUENCE_REGEX.source + 'in-addr\.arpa\.\z')
15
+ IPV6_FORMAT_REGEX = Regexp.new(IPV6_LABEL_SEQUENCE_REGEX.source + 'ip6\.arpa\.\z')
16
+
17
+ validates_format_of :fqdn, with: Regexp.union(IPV4_FORMAT_REGEX, IPV6_FORMAT_REGEX)
10
18
 
11
19
  validate :validate_fqdn_octets_in_range
12
20
  validate :validate_fqdn_is_in_addr_arpa_subzone
@@ -26,9 +34,20 @@ module RecordStore
26
34
  end
27
35
 
28
36
  def validate_fqdn_octets_in_range
29
- OCTET_LABEL_SEQUENCE_REGEX.match(fqdn) do |m|
30
- unless m.captures.all? { |o| o.to_d.between?(0, 255) }
31
- errors.add(:fqdn, 'octet labels must be within the range 0-255')
37
+ if fqdn.end_with?('in-addr.arpa.')
38
+ # IPv4 validation: each octet must be 0-255
39
+ IPV4_LABEL_SEQUENCE_REGEX.match(fqdn) do |m|
40
+ unless m.captures.all? { |o| o.to_i.between?(0, 255) }
41
+ errors.add(:fqdn, 'IPv4 octet labels must be within the range 0-255')
42
+ end
43
+ end
44
+ elsif fqdn.end_with?('ip6.arpa.')
45
+ # IPv6 validation: each nibble must be a valid hex digit
46
+ IPV6_LABEL_SEQUENCE_REGEX.match(fqdn) do |m|
47
+ nibbles = m[0].split('.').reject(&:empty?)
48
+ unless nibbles.all? { |n| n.match?(/\A[0-9a-f]\z/i) }
49
+ errors.add(:fqdn, 'IPv6 labels must be single hexadecimal digits (0-9, a-f)')
50
+ end
32
51
  end
33
52
  end
34
53
  end
@@ -1,3 +1,3 @@
1
1
  module RecordStore
2
- VERSION = '8.0.4'.freeze
2
+ VERSION = '8.0.5'.freeze
3
3
  end
data/record_store.gemspec CHANGED
@@ -46,7 +46,7 @@ Gem::Specification.new do |spec|
46
46
  spec.add_development_dependency 'mocha'
47
47
  spec.add_development_dependency 'pry'
48
48
  spec.add_development_dependency 'rake'
49
- spec.add_development_dependency 'rubocop', '~> 1.67.0'
49
+ spec.add_development_dependency 'rubocop', '~> 1.69.0'
50
50
  spec.add_development_dependency 'rubocop-shopify', '~> 2.15.1'
51
51
  spec.add_development_dependency 'vcr'
52
52
  spec.add_development_dependency 'webmock'
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: record_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.4
4
+ version: 8.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Willem van Bergen
8
8
  - Emil Stolarsky
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2024-11-07 00:00:00.000000000 Z
11
+ date: 2025-01-09 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activemodel
@@ -305,14 +304,14 @@ dependencies:
305
304
  requirements:
306
305
  - - "~>"
307
306
  - !ruby/object:Gem::Version
308
- version: 1.67.0
307
+ version: 1.69.0
309
308
  type: :development
310
309
  prerelease: false
311
310
  version_requirements: !ruby/object:Gem::Requirement
312
311
  requirements:
313
312
  - - "~>"
314
313
  - !ruby/object:Gem::Version
315
- version: 1.67.0
314
+ version: 1.69.0
316
315
  - !ruby/object:Gem::Dependency
317
316
  name: rubocop-shopify
318
317
  requirement: !ruby/object:Gem::Requirement
@@ -440,7 +439,6 @@ licenses:
440
439
  - MIT
441
440
  metadata:
442
441
  allowed_push_host: https://rubygems.org
443
- post_install_message:
444
442
  rdoc_options: []
445
443
  require_paths:
446
444
  - lib
@@ -455,8 +453,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
455
453
  - !ruby/object:Gem::Version
456
454
  version: '0'
457
455
  requirements: []
458
- rubygems_version: 3.5.23
459
- signing_key:
456
+ rubygems_version: 3.6.2
460
457
  specification_version: 4
461
458
  summary: Manage DNS using git
462
459
  test_files: []