record_store 8.0.4 → 8.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 077fdafcb637ff49252d1e8aba5af4803cc4c458dee23465354ca77df48b9f7f
4
- data.tar.gz: 4fe82c6141e811289c9cdd7d978e53d68693a3e22a564b846252a585ec25115b
3
+ metadata.gz: 0ea2231f371be0d7bc9f308ccaec17a1b27c410cea7972a8e3e3f7a066ba9042
4
+ data.tar.gz: dbd3fd8c7622660afd23443245c0a350a0bdec1ad2d26bd15951e8db182df751
5
5
  SHA512:
6
- metadata.gz: 8c82a2c86d3ed27449b231695bd3edfba7b5d9b0c2e21f64c11cf52af89ad76e6c2364eb957022fc7743e90ecd3818c46c409f0332234ea16a41ea7e5c935ca6
7
- data.tar.gz: 4d144671d258a63f11e8684efe80f2119a9bcc2a4a3786253eba28ba8adf1a648fc0439c2b22ef8d0b508cc52c4453c1300e7a74d4ffce23088e0fdfcb1c6248
6
+ metadata.gz: ca85b2b49dd23799a9ab95cc60e2e0575b55dc07defb9f6c0b039ff2ef02e5c55b20a7d092aebefedf727e33dd02ca3f2b34ffa5dd758e5d8050b902672caad9
7
+ data.tar.gz: 7435df6101ac759bbf5b980aeb3eaf9b33c8fb4eaf02bccd087c60b74ebae600162fc53a9dc8ecb5eb812e9aa1f50aa37c1f2e91b7fbf3d2fdef9950de1270ce
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 8.0.6
4
+ - Fix quotes around Cloudflare TXT records
5
+
6
+ ## 8.0.5
7
+ - Add IPv6 PTR record validation
8
+
3
9
  ## 8.0.4
4
10
  - Normalize (compress) addresses in A and AAAA records
5
11
 
@@ -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
@@ -128,7 +128,7 @@ module RecordStore
128
128
  api_body[:content] = record.exchange
129
129
  api_body[:priority] = record.preference
130
130
  when Record::TXT, Record::SPF
131
- api_body[:content] = record.txtdata.gsub('\;', ';')
131
+ api_body[:content] = Record.quote(record.txtdata.gsub('\;', ';'))
132
132
  when Record::CAA
133
133
  api_body[:data] = record.rdata
134
134
  when Record::SRV
@@ -166,7 +166,8 @@ module RecordStore
166
166
  record.merge!(cname: api_response['content'])
167
167
  end
168
168
  when 'TXT'
169
- record.merge!(txtdata: Record.unescape(api_response['content']).gsub(';', '\;'))
169
+ content = Record.unquote(api_response['content'])
170
+ record.merge!(txtdata: content.gsub(';', '\;'))
170
171
  when 'MX'
171
172
  record.merge!(preference: api_response['priority'], exchange: api_response['content'])
172
173
  when 'PTR'
@@ -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
@@ -22,7 +22,7 @@ module RecordStore
22
22
 
23
23
  def escaped_semicolons
24
24
  if txtdata =~ /([^\\]|\A);/
25
- errors.add(:txtdata, 'has unescaped semicolons (See RFC 1035).')
25
+ errors.add(:txtdata, 'has unescaped semicolons, which begins comment portion of record per RFC 1035.')
26
26
  end
27
27
  end
28
28
  end
@@ -1,3 +1,3 @@
1
1
  module RecordStore
2
- VERSION = '8.0.4'.freeze
2
+ VERSION = '8.0.6'.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.6
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-02-27 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.3
460
457
  specification_version: 4
461
458
  summary: Manage DNS using git
462
459
  test_files: []