sprinkle_dns 1.0.2 → 1.0.4

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: 5b3535eda69750742757aa7f7c7bcf14b811e2a596ef14efa626db61de75b69d
4
- data.tar.gz: 0f6e5928450f857ca7b304e1d0482c19e9112f6fa56c65d3716e0c14ec7a3638
3
+ metadata.gz: 2230eba67af9c9645bdee7210e2986e0e8cca62ea616e72365a18006d8e4c453
4
+ data.tar.gz: 908aae7112939f4dfeadb86a316b2de312765c7a73503e58968d62d8d807f072
5
5
  SHA512:
6
- metadata.gz: c613e559b39c52375aad712a395eeb894802dce620adfff24114664f6ecf1519f881e209e3be682a4472369e9d6218642390bcd64dda3f6a5f3f2a0189fce264
7
- data.tar.gz: d3297e82d02cba1b8a07d82323c3dbdf20988e5fa779edd7d4d3e02e90bda5773dd441bbc8c9b8b1f85458fc66598983d183e5af585c6341a683aa6c62eb8df9
6
+ metadata.gz: 052f97f0d06ef878f916823d602f3ca139fc0be038ba3758b09b000665b591e4041e242a705af98fe07c154fba45a1ac48095a5e1bd357b958bdc1c30167907f
7
+ data.tar.gz: 47978d299c2712bf022c6a35a480e4fcc7500819e3d7e0b7823d799cdd6b55e091b6a0b6c7b166b2ce82f7e091e64ec5ee319d64e0423f3c2aa656d81409bd4a
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.2
1
+ 2.6.6
data/CHANGELOG.md CHANGED
@@ -5,6 +5,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ N/A
9
+
10
+ ## [1.0.4] - 2025-11-30
11
+ ### Updated
12
+ - Updated Route53 dependency to 1.127.
13
+
14
+ ## [1.0.3] - 2023-05-26
15
+ ### Added
16
+ - Added an LetsEncrypt guide to the README, including the scripts to communicate with LetsEncrypt.
17
+ - Added support for CAA-records, https://blog.qualys.com/product-tech/2017/03/13/caa-mandated-by-cabrowser-forum
18
+
8
19
  ## [1.0.2] - 2019-05-11
9
20
  ### Fixed
10
21
  - Fixed issue with the non-interactive printer https://github.com/gfish/sprinkle_dns/commit/1e43591c46e056aab9711ccb37eaf91c904969cc
data/Gemfile.lock CHANGED
@@ -1,59 +1,64 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sprinkle_dns (1.0.1)
5
- aws-sdk-route53 (~> 1.21)
4
+ sprinkle_dns (1.0.3)
5
+ aws-sdk-route53 (~> 1.127)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- addressable (2.6.0)
11
- public_suffix (>= 2.0.2, < 4.0)
12
- aws-eventstream (1.0.3)
13
- aws-partitions (1.160.0)
14
- aws-sdk-core (3.50.0)
15
- aws-eventstream (~> 1.0, >= 1.0.2)
16
- aws-partitions (~> 1.0)
17
- aws-sigv4 (~> 1.1)
18
- jmespath (~> 1.0)
19
- aws-sdk-route53 (1.22.0)
20
- aws-sdk-core (~> 3, >= 3.48.2)
21
- aws-sigv4 (~> 1.1)
22
- aws-sigv4 (1.1.0)
23
- aws-eventstream (~> 1.0, >= 1.0.2)
24
- coderay (1.1.2)
10
+ addressable (2.7.0)
11
+ public_suffix (>= 2.0.2, < 5.0)
12
+ aws-eventstream (1.4.0)
13
+ aws-partitions (1.1188.0)
14
+ aws-sdk-core (3.239.2)
15
+ aws-eventstream (~> 1, >= 1.3.0)
16
+ aws-partitions (~> 1, >= 1.992.0)
17
+ aws-sigv4 (~> 1.9)
18
+ base64
19
+ bigdecimal
20
+ jmespath (~> 1, >= 1.6.1)
21
+ logger
22
+ aws-sdk-route53 (1.127.0)
23
+ aws-sdk-core (~> 3, >= 3.239.1)
24
+ aws-sigv4 (~> 1.5)
25
+ aws-sigv4 (1.12.1)
26
+ aws-eventstream (~> 1, >= 1.0.2)
27
+ base64 (0.3.0)
28
+ bigdecimal (3.3.1)
29
+ coderay (1.1.3)
25
30
  crack (0.4.3)
26
31
  safe_yaml (~> 1.0.0)
27
- diff-lcs (1.3)
28
- docile (1.3.1)
29
- hashdiff (0.3.9)
30
- jmespath (1.4.0)
31
- json (2.2.0)
32
- method_source (0.9.2)
33
- pry (0.12.2)
34
- coderay (~> 1.1.0)
35
- method_source (~> 0.9.0)
36
- public_suffix (3.0.3)
37
- rake (12.3.2)
38
- rspec (3.8.0)
39
- rspec-core (~> 3.8.0)
40
- rspec-expectations (~> 3.8.0)
41
- rspec-mocks (~> 3.8.0)
42
- rspec-core (3.8.0)
43
- rspec-support (~> 3.8.0)
44
- rspec-expectations (3.8.3)
32
+ diff-lcs (1.4.4)
33
+ docile (1.3.2)
34
+ hashdiff (1.0.1)
35
+ jmespath (1.6.1)
36
+ logger (1.7.0)
37
+ method_source (1.0.0)
38
+ pry (0.14.2)
39
+ coderay (~> 1.1)
40
+ method_source (~> 1.0)
41
+ public_suffix (4.0.5)
42
+ rake (12.3.3)
43
+ rexml (3.2.5)
44
+ rspec (3.9.0)
45
+ rspec-core (~> 3.9.0)
46
+ rspec-expectations (~> 3.9.0)
47
+ rspec-mocks (~> 3.9.0)
48
+ rspec-core (3.9.2)
49
+ rspec-support (~> 3.9.3)
50
+ rspec-expectations (3.9.2)
45
51
  diff-lcs (>= 1.2.0, < 2.0)
46
- rspec-support (~> 3.8.0)
47
- rspec-mocks (3.8.0)
52
+ rspec-support (~> 3.9.0)
53
+ rspec-mocks (3.9.1)
48
54
  diff-lcs (>= 1.2.0, < 2.0)
49
- rspec-support (~> 3.8.0)
50
- rspec-support (3.8.0)
55
+ rspec-support (~> 3.9.0)
56
+ rspec-support (3.9.3)
51
57
  safe_yaml (1.0.5)
52
- simplecov (0.16.1)
58
+ simplecov (0.18.5)
53
59
  docile (~> 1.1)
54
- json (>= 1.8, < 3)
55
- simplecov-html (~> 0.10.0)
56
- simplecov-html (0.10.2)
60
+ simplecov-html (~> 0.11)
61
+ simplecov-html (0.12.3)
57
62
  vcr (3.0.3)
58
63
  webmock (2.3.2)
59
64
  addressable (>= 2.3.6)
@@ -64,8 +69,9 @@ PLATFORMS
64
69
  ruby
65
70
 
66
71
  DEPENDENCIES
67
- pry (~> 0.12)
72
+ pry (~> 0.14.2)
68
73
  rake (~> 12.3)
74
+ rexml (~> 3.2)
69
75
  rspec (~> 3.8)
70
76
  simplecov (~> 0.16)
71
77
  sprinkle_dns!
@@ -73,4 +79,4 @@ DEPENDENCIES
73
79
  webmock (~> 2.3)
74
80
 
75
81
  BUNDLED WITH
76
- 1.17.2
82
+ 2.4.10
data/README.md CHANGED
@@ -181,3 +181,120 @@ For a more "locked down" policy you can use this (remember to update the `resour
181
181
  ]
182
182
  }
183
183
  ```
184
+
185
+ # Obtain certificates with LetsEncrypt
186
+
187
+ Not everyone is aware of it, but LetsEncrypt allows for a DNS-challenge, this means that if you want to have a certificate for `billetto.com` you can ask certbot to use the DNS-challenge, and run a script:
188
+
189
+ ```bash
190
+ certbot --preferred-challenges dns --manual-auth-hook "bash run_my_dns_script.sh"
191
+ ```
192
+
193
+ The script `run_my_dns_script.sh` will then recieve two ENV-variables, one for `CERTBOT_DOMAIN` which in our example is `billetto.com` and `CERTBOT_VALIDATION` which is a value that needs to be set in the DNS, so in order to prove to LetsEncrypt that we manage the domain we have to set the following:
194
+
195
+ ```
196
+ TXT _acme-challenge.ENV['CERTBOT_DOMAIN'] ENV['CERTBOT_VALIDATION']
197
+ ```
198
+
199
+ Instead of a bash-script, we can use Ruby and SprinkleDNS like so:
200
+
201
+ ```ruby
202
+ #!/usr/bin/env ruby
203
+ require 'sprinkle_dns'
204
+ require_relative '../includes/access_keys'
205
+
206
+ raise 'ENV-variable CERTBOT_DOMAIN is not supplied' if ENV['CERTBOT_DOMAIN'].nil?
207
+ raise 'ENV-variable CERTBOT_VALIDATION is not supplied' if ENV['CERTBOT_VALIDATION'].nil?
208
+
209
+ c = SprinkleDNS::Route53Client.new(ACCESS_KEY_ID, SECRET_ACCESS_KEY)
210
+ s = SprinkleDNS::Client.new(c, interactive_progress: false, diff: false, force: true, delete: false, create_hosted_zones: false)
211
+ s.entry('TXT', "_acme-challenge.#{ENV['CERTBOT_DOMAIN']}", %Q{"#{ENV['CERTBOT_VALIDATION']}"}, 60)
212
+ s.sprinkle!
213
+ ```
214
+
215
+ Save it as `dns_auth.rb`, and remember to chmod it: `chmod +x dns_auth.rb`.
216
+
217
+ Now you can start on the main script `ssl_certbot.rb`:
218
+
219
+ ```ruby
220
+ #!/usr/bin/env ruby
221
+ require 'open3'
222
+ require 'fileutils'
223
+
224
+ EMAIL = 'domains@billetto.com'
225
+ MAIN_DOMAIN = 'billetto.com'
226
+ DOMAINS = ['billetto.dk', 'billetto.co.uk', 'billetto.com']
227
+
228
+ def run_command(command)
229
+ puts("+: #{command}")
230
+
231
+ Open3.popen2e(command) do |stdin, stdout_stderr, wait_thread|
232
+ Thread.new do
233
+ stdout_stderr.each {|l| puts l }
234
+ end
235
+ wait_thread.value
236
+ end
237
+ end
238
+
239
+ def print_guide
240
+ puts "Congratulations, you have a new certificate!"
241
+ puts "----------------------------------------------------------------"
242
+ puts "CERTIFICATE: #{Dir.pwd}/config/live/billetto.com/cert.pem"
243
+ puts "KEY: #{Dir.pwd}/config/live/billetto.com/privkey.pem"
244
+ puts "CHAIN: #{Dir.pwd}/config/live/billetto.com/chain.pem"
245
+ end
246
+
247
+ letsencrypt_dirs = ['config', 'work', 'logs']
248
+ previous_letsencrypt_run = letsencrypt_dirs.all?{|dir| Dir.exist?(dir)}
249
+
250
+ case ARGV[0]
251
+ when 'create'
252
+ certbot_commands = []
253
+ certbot_commands << "certbot certonly"
254
+ certbot_commands << "--manual --manual-public-ip-logging-ok --agree-tos"
255
+ certbot_commands << "--email #{EMAIL} --update-registration --no-eff-email"
256
+ certbot_commands << "--non-interactive --preferred-challenges dns"
257
+ certbot_commands << "--manual-auth-hook \"bundle exec #{Dir.pwd}/dns_auth.rb\""
258
+ certbot_commands << "--config-dir config --work-dir work --logs-dir logs"
259
+ certbot_commands << "--cert-name #{MAIN_DOMAIN}"
260
+ DOMAINS.each do |domain|
261
+ certbot_commands << "-d #{domain} -d www.#{domain}"
262
+ end
263
+ certbot_commands = certbot_commands.join(" ")
264
+
265
+ letsencrypt_dirs.select{|dirname| Dir.exists?(dirname)}.map{|dirname| FileUtils.remove_dir(dirname)}
266
+ run_command("mkdir -p #{letsencrypt_dirs.join(' ')}")
267
+ stdout, stdeerr, status = run_command(certbot_commands)
268
+
269
+ print_guide
270
+ when 'renew'
271
+ if previous_letsencrypt_run
272
+ certbot_commands = []
273
+ certbot_commands << "certbot renew"
274
+ certbot_commands << "--manual --manual-public-ip-logging-ok --agree-tos"
275
+ certbot_commands << "--email #{EMAIL} --update-registration --no-eff-email"
276
+ certbot_commands << "--non-interactive --preferred-challenges dns"
277
+ certbot_commands << "--manual-auth-hook \"bundle exec #{Dir.pwd}/dns_auth.rb\""
278
+ certbot_commands << "--config-dir config --work-dir work --logs-dir logs"
279
+ certbot_commands << "--cert-name #{MAIN_DOMAIN}"
280
+ certbot_commands = certbot_commands.join(" ")
281
+ stdout, stdeerr, status = run_command(certbot_commands)
282
+
283
+ print_guide
284
+ else
285
+ puts "It seems like there are no files from a previous LetsEncrypt run, exiting!"
286
+ exit 1
287
+ end
288
+ else
289
+ puts "Usage:"
290
+ puts "bundle exec ruby ssl_certbot.rb COMMAND"
291
+ puts
292
+ puts "Commands:"
293
+ puts "create - Request a new certificate from LetsEncrypt, should only be used on the first run, or if you have modified the list of domains."
294
+ puts "renew - Renew an already created certificate"
295
+ end
296
+ ```
297
+
298
+ You can update the variables in top of the script, and then you can run `bundle exec ruby ssl_certbot.rb create`, and everytime you need to renew the certificate you can run `bundle exec ruby ssl_certbot.rb renew`.
299
+
300
+ You will need to run the `create` if your list of domains have changed.
@@ -83,7 +83,7 @@ module SprinkleDNS
83
83
  private
84
84
 
85
85
  def valid_record_types
86
- ['SOA','A','TXT','NS','CNAME','MX','NAPTR','PTR','SRV','SPF','AAAA']
86
+ ['SOA','A','TXT','NS','CNAME','MX','NAPTR','PTR','SRV','SPF','AAAA', 'CAA']
87
87
  end
88
88
 
89
89
  end
@@ -90,7 +90,7 @@ module SprinkleDNS
90
90
  private
91
91
 
92
92
  def valid_record_types
93
- ['SOA','A','TXT','NS','CNAME','MX','NAPTR','PTR','SRV','SPF','AAAA']
93
+ ['SOA','A','TXT','NS','CNAME','MX','NAPTR','PTR','SRV','SPF','AAAA', 'CAA']
94
94
  end
95
95
 
96
96
  end
@@ -9,8 +9,6 @@ module SprinkleDNS
9
9
  end
10
10
 
11
11
  def fetch_hosted_zones(filter: [])
12
- hosted_zones = []
13
-
14
12
  if filter.empty?
15
13
  return []
16
14
  end
@@ -1,3 +1,3 @@
1
1
  module SprinkleDNS
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.4"
3
3
  end
data/spec/spec_helper.rb CHANGED
@@ -24,6 +24,7 @@ require 'simplecov'
24
24
  SimpleCov.start
25
25
 
26
26
  require 'vcr'
27
+ require 'pry'
27
28
 
28
29
  require './spec/support/entry_helpers'
29
30
 
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe "CAA-records" do
4
+ it 'should allow for CAA records' do
5
+ hz = SprinkleDNS::HostedZone.new('colourful.com.')
6
+ e1 = SprinkleDNS::HostedZoneEntry.new('A', 'colourful.com.', Array.wrap('80.80.80.80'), 3600, hz.name)
7
+ e1.persisted!
8
+ hz.resource_record_sets << e1
9
+
10
+ client = SprinkleDNS::MockClient.new([hz])
11
+ sdns = SprinkleDNS::Client.new(client, dry_run: false, delete: true, force: true)
12
+
13
+ sdns.entry('A', 'colourful.com', '80.80.80.80', 3600)
14
+ sdns.entry('CAA', 'colourful.com', '0 issue "letsencrypt.org"', 3600)
15
+
16
+ existing_hosted_zones, _ = sdns.sprinkle!
17
+
18
+ shz = client.fetch_hosted_zones(filter: [hz.name]).first
19
+
20
+ rrs = shz.resource_record_sets.select{|rrs| rrs.type == 'CAA' && rrs.name == 'colourful.com.'}.first
21
+ expect(rrs.ttl).to eq 3600
22
+ expect(rrs.value).to eq ['0 issue "letsencrypt.org"']
23
+ end
24
+ end
@@ -269,7 +269,7 @@ RSpec.describe SprinkleDNS::Client do
269
269
 
270
270
  context 'record validation' do
271
271
  it 'should only allow valid string records' do
272
- valid_records = ['SOA','A','TXT','NS','CNAME','MX','NAPTR','PTR','SRV','SPF','AAAA']
272
+ valid_records = ['SOA','A','TXT','NS','CNAME','MX','NAPTR','PTR','SRV','SPF','AAAA', 'CAA']
273
273
 
274
274
  valid_records.each do |record_type|
275
275
  r53c = SprinkleDNS::Route53Client.new('1','2')
@@ -280,7 +280,7 @@ RSpec.describe SprinkleDNS::Client do
280
280
  end
281
281
 
282
282
  it 'should not allow symbols for records' do
283
- invalid_records = [:SOA, :A, :TXT, :NS, :CNAME, :MX, :NAPTR, :PTR, :SRV, :SPF, :AAAA]
283
+ invalid_records = [:SOA, :A, :TXT, :NS, :CNAME, :MX, :NAPTR, :PTR, :SRV, :SPF, :AAAA, :CAA]
284
284
 
285
285
  invalid_records.each do |record_type|
286
286
  r53c = SprinkleDNS::Route53Client.new('1','2')
data/sprinkle_dns.gemspec CHANGED
@@ -18,12 +18,13 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
  gem.required_ruby_version = ">= 2.4.0"
21
- gem.add_runtime_dependency 'aws-sdk-route53', '~> 1.21'
21
+ gem.add_runtime_dependency 'aws-sdk-route53', '~> 1.127'
22
22
 
23
23
  gem.add_development_dependency "rspec", '~> 3.8'
24
24
  gem.add_development_dependency "simplecov", '~> 0.16'
25
- gem.add_development_dependency "pry", '~> 0.12'
25
+ gem.add_development_dependency "pry", '~> 0.14.2'
26
26
  gem.add_development_dependency "rake", '~> 12.3'
27
27
  gem.add_development_dependency "vcr", '~> 3.0'
28
28
  gem.add_development_dependency "webmock", '~> 2.3'
29
+ gem.add_development_dependency "rexml", '~> 3.2'
29
30
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sprinkle_dns
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Grubbe
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2019-05-10 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: aws-sdk-route53
@@ -16,14 +15,14 @@ dependencies:
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: '1.21'
18
+ version: '1.127'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: '1.21'
25
+ version: '1.127'
27
26
  - !ruby/object:Gem::Dependency
28
27
  name: rspec
29
28
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +57,14 @@ dependencies:
58
57
  requirements:
59
58
  - - "~>"
60
59
  - !ruby/object:Gem::Version
61
- version: '0.12'
60
+ version: 0.14.2
62
61
  type: :development
63
62
  prerelease: false
64
63
  version_requirements: !ruby/object:Gem::Requirement
65
64
  requirements:
66
65
  - - "~>"
67
66
  - !ruby/object:Gem::Version
68
- version: '0.12'
67
+ version: 0.14.2
69
68
  - !ruby/object:Gem::Dependency
70
69
  name: rake
71
70
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +107,20 @@ dependencies:
108
107
  - - "~>"
109
108
  - !ruby/object:Gem::Version
110
109
  version: '2.3'
110
+ - !ruby/object:Gem::Dependency
111
+ name: rexml
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '3.2'
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '3.2'
111
124
  description: Make handling DNS easier by using simple Ruby constructs
112
125
  email:
113
126
  - kaspergrubbe@gmail.com
@@ -152,6 +165,7 @@ files:
152
165
  - readme_files/force_false.png
153
166
  - spec/spec_helper.rb
154
167
  - spec/support/entry_helpers.rb
168
+ - spec/unit/caa_record.rb
155
169
  - spec/unit/cli_hosted_zone_diff_spec.rb
156
170
  - spec/unit/hosted_zone_domain_spec.rb
157
171
  - spec/unit/hosted_zone_spec.rb
@@ -164,7 +178,6 @@ licenses:
164
178
  - MIT
165
179
  - GPL-2.0
166
180
  metadata: {}
167
- post_install_message:
168
181
  rdoc_options: []
169
182
  require_paths:
170
183
  - lib
@@ -179,13 +192,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
179
192
  - !ruby/object:Gem::Version
180
193
  version: '0'
181
194
  requirements: []
182
- rubygems_version: 3.0.3
183
- signing_key:
195
+ rubygems_version: 3.6.9
184
196
  specification_version: 4
185
197
  summary: Make handling DNS easier
186
198
  test_files:
187
199
  - spec/spec_helper.rb
188
200
  - spec/support/entry_helpers.rb
201
+ - spec/unit/caa_record.rb
189
202
  - spec/unit/cli_hosted_zone_diff_spec.rb
190
203
  - spec/unit/hosted_zone_domain_spec.rb
191
204
  - spec/unit/hosted_zone_spec.rb