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 +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/record_store.rb +1 -0
- data/lib/record_store/provider.rb +1 -0
- data/lib/record_store/provider/dnsimple.rb +12 -2
- data/lib/record_store/provider/dynect.rb +1 -1
- data/lib/record_store/provider/google_cloud_dns.rb +9 -1
- data/lib/record_store/record.rb +18 -0
- data/lib/record_store/record/caa.rb +46 -0
- data/lib/record_store/record/txt.rb +1 -19
- data/lib/record_store/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec61dfda8810f6c7a7d3aa736c92b7a1250e61b0af34b26eda31b328c8f64c95
|
4
|
+
data.tar.gz: 532ee30e67c3b9c5913c2b070d9e3d6e0b0b02439bd79fa2c1a1f68cef540b8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cbfd744fba3f8e9e6f6af89078bcc462e333b66ab73b76f6047fa8765f340ee20d6aa355ba5407b171494705c7425e49ae5beae2d1821efa6c76c4c5a275bea
|
7
|
+
data.tar.gz: aa35fb706234433c77f13c5e19a43c888c31c17c4da73dd78962506049758fb94ac6057a91e26fe4d2d80801b6dd7b95993ff7b18022d0360070ba14fe104cdf
|
data/CHANGELOG.md
CHANGED
data/lib/record_store.rb
CHANGED
@@ -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'
|
@@ -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
|
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
|
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
|
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
|
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(' ')
|
data/lib/record_store/record.rb
CHANGED
@@ -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
|
18
|
+
Record.quote(txtdata)
|
37
19
|
end
|
38
20
|
|
39
21
|
private
|
data/lib/record_store/version.rb
CHANGED
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.
|
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-
|
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
|