record_store 5.3.0 → 5.4.1

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: 44a86871965b0fa3db8951d4d9f9bdd0fbb2c1c64744508107b96eeb21499101
4
- data.tar.gz: b6e329067a74eb41d277409f5531ff21b49cdcb824c9d5e326257e1adcf17585
3
+ metadata.gz: ec61dfda8810f6c7a7d3aa736c92b7a1250e61b0af34b26eda31b328c8f64c95
4
+ data.tar.gz: 532ee30e67c3b9c5913c2b070d9e3d6e0b0b02439bd79fa2c1a1f68cef540b8c
5
5
  SHA512:
6
- metadata.gz: 57a79a8f04b021985cb19b44393f840e1d3febb4d774136e1ca0ad062cb3a2a6e4255cd13b6929a345a337c85cb36f9461a7c3cae9ec78d905d3c449ae5c15e5
7
- data.tar.gz: 5bd60003b6d11fda8a52a7641a23b7fd3c64a6ae365b3a6d7a650e0dc1f7fd573f8cf0b4e9c4926b2b1763242d3da02a1dbaf184e26d506328fe84509a447d3b
6
+ metadata.gz: 7cbfd744fba3f8e9e6f6af89078bcc462e333b66ab73b76f6047fa8765f340ee20d6aa355ba5407b171494705c7425e49ae5beae2d1821efa6c76c4c5a275bea
7
+ data.tar.gz: aa35fb706234433c77f13c5e19a43c888c31c17c4da73dd78962506049758fb94ac6057a91e26fe4d2d80801b6dd7b95993ff7b18022d0360070ba14fe104cdf
@@ -1,5 +1,11 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 5.4.1
4
+ - case-insensitivity for CAA value validation [FEATURE]
5
+
6
+ ## 5.4.0
7
+ - add support for CAA records [FEATURE]
8
+
3
9
  ## 5.3.0
4
10
  - case insensitivity for fqns (force to lowercsase) [FEATURE]
5
11
 
@@ -15,6 +15,7 @@ require 'record_store/record'
15
15
  require 'record_store/record/a'
16
16
  require 'record_store/record/aaaa'
17
17
  require 'record_store/record/alias'
18
+ require 'record_store/record/caa'
18
19
  require 'record_store/record/cname'
19
20
  require 'record_store/record/mx'
20
21
  require 'record_store/record/ns'
@@ -29,6 +29,7 @@ module RecordStore
29
29
  'A',
30
30
  'AAAA',
31
31
  'ALIAS',
32
+ 'CAA',
32
33
  'CNAME',
33
34
  'MX',
34
35
  'NS',
@@ -81,6 +81,14 @@ module RecordStore
81
81
  record.merge!(address: api_record.content)
82
82
  when 'ALIAS'
83
83
  record.merge!(alias: api_record.content)
84
+ when 'CAA'
85
+ flags, tag, value = api_record.content.split(' ')
86
+
87
+ record.merge!(
88
+ flags: flags.to_i,
89
+ tag: tag,
90
+ value: Record.unquote(value),
91
+ )
84
92
  when 'CNAME'
85
93
  record.merge!(cname: api_record.content)
86
94
  when 'MX'
@@ -88,7 +96,7 @@ module RecordStore
88
96
  when 'NS'
89
97
  record.merge!(nsdname: api_record.content)
90
98
  when 'SPF', 'TXT'
91
- record.merge!(txtdata: Record::TXT.unescape(api_record.content).gsub(';', '\;'))
99
+ record.merge!(txtdata: Record.unescape(api_record.content).gsub(';', '\;'))
92
100
  when 'SRV'
93
101
  weight, port, host = api_record.content.split(' ')
94
102
 
@@ -115,6 +123,8 @@ module RecordStore
115
123
  record_hash[:content] = record.address
116
124
  when 'ALIAS'
117
125
  record_hash[:content] = record.alias.chomp('.')
126
+ when 'CAA'
127
+ record_hash[:content] = "#{record.flags} #{record.tag} \"#{record.value.chomp('.')}\""
118
128
  when 'CNAME'
119
129
  record_hash[:content] = record.cname.chomp('.')
120
130
  when 'MX'
@@ -123,7 +133,7 @@ module RecordStore
123
133
  when 'NS'
124
134
  record_hash[:content] = record.nsdname.chomp('.')
125
135
  when 'SPF', 'TXT'
126
- record_hash[:content] = Record::TXT.escape(record.txtdata).gsub('\;', ';')
136
+ record_hash[:content] = Record.escape(record.txtdata).gsub('\;', ';')
127
137
  when 'SRV'
128
138
  record_hash[:content] = "#{record.weight} #{record.port} #{record.target.chomp('.')}"
129
139
  record_hash[:priority] = record.priority
@@ -102,7 +102,7 @@ module RecordStore
102
102
  type = record.fetch(:record_type)
103
103
  return if type == 'SOA'
104
104
 
105
- record[:txtdata] = Record::TXT.unescape(record[:txtdata]) if %w[SPF TXT].include?(type)
105
+ record[:txtdata] = Record.unescape(record[:txtdata]) if %w[SPF TXT].include?(type)
106
106
 
107
107
  fqdn = record.fetch(:fqdn)
108
108
  fqdn = "#{fqdn}." unless fqdn.ends_with?('.')
@@ -93,6 +93,14 @@ module RecordStore
93
93
  case record.type
94
94
  when 'A', 'AAAA'
95
95
  record_params.merge!(address: record.data[0])
96
+ when 'CAA'
97
+ flags, tag, value = record.data[0].split(' ')
98
+
99
+ record_params.merge!(
100
+ flags: flags.to_i,
101
+ tag: tag,
102
+ value: Record.unquote(value),
103
+ )
96
104
  when 'CNAME'
97
105
  record_params.merge!(cname: record.data[0])
98
106
  when 'MX'
@@ -101,7 +109,7 @@ module RecordStore
101
109
  when 'NS'
102
110
  record_params.merge!(nsdname: record.data[0])
103
111
  when 'SPF', 'TXT'
104
- txtdata = Record::TXT.unquote(record.data[0]).gsub(';', '\;')
112
+ txtdata = Record.unquote(record.data[0]).gsub(';', '\;')
105
113
  record_params.merge!(txtdata: txtdata)
106
114
  when 'SRV'
107
115
  priority, weight, port, target = record.data[0].split(' ')
@@ -11,6 +11,24 @@ module RecordStore
11
11
  validates :fqdn, format: { with: Record::FQDN_REGEX }, length: { maximum: 254 }
12
12
  validate :validate_label_length
13
13
 
14
+ class << self
15
+ def escape(value)
16
+ value.gsub('"', '\"')
17
+ end
18
+
19
+ def quote(value)
20
+ %("#{escape(value)}")
21
+ end
22
+
23
+ def unescape(value)
24
+ value.gsub('\"', '"')
25
+ end
26
+
27
+ def unquote(value)
28
+ unescape(value.sub(/\A"(.*)"\z/, '\1'))
29
+ end
30
+ end
31
+
14
32
  def initialize(record)
15
33
  @fqdn = Record.ensure_ends_with_dot(record.fetch(:fqdn)).downcase
16
34
  @ttl = record.fetch(:ttl)
@@ -0,0 +1,46 @@
1
+ module RecordStore
2
+ class Record::CAA < Record
3
+ attr_accessor :flags, :tag, :value
4
+
5
+ LABEL_REGEX = '[a-z0-9](?:-*[a-z0-9])*'
6
+ DOMAIN_REGEX = /\A#{LABEL_REGEX}(?:\.#{LABEL_REGEX})\z/i
7
+
8
+ validates :flags, numericality: { only_integer: true, greater_than_or_equal_to: 0, less_than_or_equal_to: 255 }, presence: true
9
+ validates :tag, inclusion: { in: %w(issue issuewild iodef) }, presence: true
10
+ validate :validate_uri_value, if: :iodef?
11
+ validates :value, format: { with: DOMAIN_REGEX, message: 'is not a fully qualified domain name'}, unless: :iodef?
12
+
13
+ def initialize(record)
14
+ super
15
+ @flags = Integer(record.fetch(:flags))
16
+ @tag = record.fetch(:tag)
17
+ @value = record.fetch(:value)
18
+ end
19
+
20
+ def rdata
21
+ {
22
+ flags: flags,
23
+ tag: tag,
24
+ value: value,
25
+ }
26
+ end
27
+
28
+ def rdata_txt
29
+ "#{flags} #{tag} \"#{value}\""
30
+ end
31
+
32
+ protected
33
+
34
+ def iodef?
35
+ tag == 'iodef'
36
+ end
37
+
38
+ def validate_uri_value
39
+ uri = URI(value)
40
+ return if uri.kind_of?(URI::MailTo) || uri.kind_of?(URI::HTTP)
41
+ errors.add(:value, "URL scheme should be mailto, http, or https")
42
+ rescue URI::Error
43
+ errors.add(:value, "Value should be a valid URI")
44
+ end
45
+ end
46
+ end
@@ -5,24 +5,6 @@ module RecordStore
5
5
  validates :txtdata, presence: true, length: { maximum: 255 }
6
6
  validate :escaped_semicolons
7
7
 
8
- class << self
9
- def escape(value)
10
- value.gsub('"', '\"')
11
- end
12
-
13
- def quote(value)
14
- %("#{escape(value)}")
15
- end
16
-
17
- def unescape(value)
18
- value.gsub('\"', '"')
19
- end
20
-
21
- def unquote(value)
22
- unescape(value.sub(/\A"(.*)"\z/, '\1'))
23
- end
24
- end
25
-
26
8
  def initialize(record)
27
9
  super
28
10
  @txtdata = record.fetch(:txtdata)
@@ -33,7 +15,7 @@ module RecordStore
33
15
  end
34
16
 
35
17
  def rdata_txt
36
- Record::TXT.quote(txtdata)
18
+ Record.quote(txtdata)
37
19
  end
38
20
 
39
21
  private
@@ -1,3 +1,3 @@
1
1
  module RecordStore
2
- VERSION = '5.3.0'.freeze
2
+ VERSION = '5.4.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: record_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.3.0
4
+ version: 5.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Willem van Bergen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-02-01 00:00:00.000000000 Z
12
+ date: 2019-03-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -288,6 +288,7 @@ files:
288
288
  - lib/record_store/record/a.rb
289
289
  - lib/record_store/record/aaaa.rb
290
290
  - lib/record_store/record/alias.rb
291
+ - lib/record_store/record/caa.rb
291
292
  - lib/record_store/record/cname.rb
292
293
  - lib/record_store/record/mx.rb
293
294
  - lib/record_store/record/ns.rb