zonefile 1.04 → 1.06

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 23d7b96f880fc4a87ae278280123e1425b68aa81
4
+ data.tar.gz: 35387ada562d7ae8cee0dbae606788fbc0862240
5
+ SHA512:
6
+ metadata.gz: 352fab59555103484bb27a8594d5fefa49aa12c3d46f53256d846deebd2699db7122661184409e116ee692b76dad9d20428a11a4f6f0c80bba596aec3e8b214b
7
+ data.tar.gz: fa666a85d05633a00cf5ee589919b6ed0ec26f5192ba2bd45ca6a9414e96dc3b8c90b53def3278e2f43f8f0898e6289054bd124d22ddde189279fdce0ed9d27c
data/CHANGELOG CHANGED
@@ -2,3 +2,4 @@
2
2
  1.01 - Fixes
3
3
  1.02 - Fixes
4
4
  1.03 - Fixes TXT records, quotes are not treated anymore
5
+ 1.05 - Adds support for TLSA records
@@ -40,8 +40,12 @@
40
40
  # - :name, :ttl, :class, :algorithm, :flags, :iterations, :salt, :next, :types
41
41
  # * NSEC3PARAM
42
42
  # - :name, :ttl, :class, :algorithm, :flags, :iterations, :salt
43
+ # * TLSA
44
+ # - :name, :ttl, :class, :certificate_usage, :selector, :matching_type, :data
43
45
  # * NAPTR
44
46
  # - :name, :ttl, :class, :order, :preference, :flags, :service, :regexp, :replacement
47
+ # * SPF
48
+ # - :name, :ttl, :class, :text
45
49
  #
46
50
  # == Examples
47
51
  #
@@ -98,7 +102,7 @@
98
102
 
99
103
  class Zonefile
100
104
 
101
- RECORDS = %w{ mx a a4 ns cname txt ptr srv soa ds dnskey rrsig nsec nsec3 nsec3param naptr }
105
+ RECORDS = %w{ mx a a4 ns cname txt ptr srv soa ds dnskey rrsig nsec nsec3 nsec3param tlsa naptr spf }
102
106
  attr :records
103
107
  attr :soa
104
108
  attr :data
@@ -310,6 +314,16 @@ class Zonefile
310
314
  add_record( 'rrsig', :name => $1, :ttl => $2, :class => $3, :type_covered => $4, :algorithm => $5,
311
315
  :labels => $6.to_i, :original_ttl => $7.to_i, :expiration => $8.to_i, :inception => $9.to_i,
312
316
  :key_tag => $10.to_i, :signer => $11, :signature => $12.gsub( /\s/,'') )
317
+ elsif line=~/^(#{valid_name}) \s*
318
+ #{ttl_cls}
319
+ TLSA \s
320
+ (\d+) \s
321
+ (\d+) \s
322
+ (\d+) \s
323
+ #{base64}
324
+ /ix
325
+ add_record( 'tlsa', :name => $1, :ttl => $2, :class => $3, :certificate_usage => $4.to_i,
326
+ :selector => $5.to_i, :matching_type => $6.to_i, :data => $7 )
313
327
  elsif line=~/^(#{valid_name})? \s*
314
328
  #{ttl_cls}
315
329
  NAPTR \s
@@ -353,6 +367,8 @@ class Zonefile
353
367
  add_record('ptr', :name => $1, :class => $3, :ttl => $2, :host => $4)
354
368
  elsif line =~ /^(#{valid_name})? \s* #{ttl_cls} TXT \s+ (.*)$/ix
355
369
  add_record('txt', :name => $1, :ttl => $2, :class => $3, :text => $4.strip)
370
+ elsif line =~ /^(#{valid_name})? \s* #{ttl_cls} SPF \s+ (.*)$/ix
371
+ add_record('spf', :name => $1, :ttl => $2, :class => $3, :text => $4.strip)
356
372
  elsif line =~ /\$TTL\s+(#{rr_ttl})/i
357
373
  @ttl = $1
358
374
  end
@@ -383,9 +399,8 @@ class Zonefile
383
399
 
384
400
  #{@origin ? "$ORIGIN #{@origin}" : ''}
385
401
  #{@ttl ? "$TTL #{@ttl}" : ''}
386
-
387
- ; Zone NS Records
388
402
  ENDH
403
+ out << "\n; Zone NS Records\n" unless self.ns.empty?
389
404
  self.ns.each do |ns|
390
405
  out << "#{ns[:name]} #{ns[:ttl]} #{ns[:class]} NS #{ns[:host]}\n"
391
406
  end
@@ -414,6 +429,11 @@ ENDH
414
429
  out << "#{tx[:name]} #{tx[:ttl]} #{tx[:class]} TXT #{tx[:text]}\n"
415
430
  end
416
431
 
432
+ out << "\n; Zone SPF Records\n" unless self.spf.empty?
433
+ self.spf.each do |spf|
434
+ out << "#{spf[:name]} #{spf[:ttl]} #{spf[:class]} SPF #{spf[:text]}\n"
435
+ end
436
+
417
437
  out << "\n; Zone SRV Records\n" unless self.srv.empty?
418
438
  self.srv.each do |srv|
419
439
  out << "#{srv[:name]} #{srv[:ttl]} #{srv[:class]} SRV #{srv[:pri]} #{srv[:weight]} #{srv[:port]} #{srv[:host]}\n"
@@ -454,6 +474,11 @@ ENDH
454
474
  out << "#{rrsig[:name]} #{rrsig[:ttl]} #{rrsig[:class]} RRSIG #{rrsig[:type_covered]} #{rrsig[:algorithm]} #{rrsig[:labels]} #{rrsig[:original_ttl]} #{rrsig[:expiration]} #{rrsig[:inception]} #{rrsig[:key_tag]} #{rrsig[:signer]} #{rrsig[:signature]}\n"
455
475
  end
456
476
 
477
+ out << "\n; Zone TLSA Records\n" unless self.tlsa.empty?
478
+ self.tlsa.each do |tlsa|
479
+ out << "#{tlsa[:name]} #{tlsa[:ttl]} #{tlsa[:class]} TLSA #{tlsa[:certificate_usage]} #{tlsa[:selector]} #{tlsa[:matching_type]} #{tlsa[:data]}\n"
480
+ end
481
+
457
482
  out << "\n; Zone NAPTR Records\n" unless self.ds.empty?
458
483
  self.naptr.each do |naptr|
459
484
  out << "#{naptr[:name]} #{naptr[:ttl]} #{naptr[:class]} NAPTR #{naptr[:order]} #{naptr[:preference]} #{naptr[:flags]} #{naptr[:service]} #{naptr[:regexp]} #{naptr[:replacement]}\n"
@@ -15,6 +15,7 @@ $ORIGIN test-zone.db
15
15
 
16
16
  @ IN A 127.0.0.1
17
17
  @ IN MX 10 mail
18
+ @ IN SPF "v=spf1 mx ~all"
18
19
  ftp IN CNAME www
19
20
  localhost IN A 127.0.0.1
20
21
  mail IN A 127.0.0.1
@@ -24,11 +25,13 @@ www IN A 127.0.0.1
24
25
  IN MX 10 10.0.0.4
25
26
  A 10.0.0.5
26
27
  TXT "web;server"
28
+ SPF "v=spf1 -all"
27
29
  foo IN A 10.0.0.6
28
30
  mini A 10.0.0.7
29
31
  icarus IN AAAA fe80::0260:83ff:fe7c:3a2a
30
32
  soup IN TXT "This is a text message"
31
33
  txta TXT "t=y; o=-" ; Nasty Comment
34
+ elsewhere IN SPF "v=spf1 mx ?all"
32
35
  _kerberos IN TXT maxnet.ao
33
36
  _sip._tcp.example.com. 86400 IN SRV 0 5 5060 sipserver.example.com.
34
37
  12.23.21.23.in-addr.arpa IN PTR www.myhost.example.com.
@@ -54,4 +57,9 @@ alfa.example.com. 86400 IN NSEC host.example.com. (
54
57
  A MX RRSIG NSEC TYPE1234 )
55
58
  IN NSEC3 1 1 12 aabbccdd ( 2vptu5timamqttgl4luu7kg2leoaor3s A RRSIG )
56
59
  IN NSEC3PARAM 1 0 12 aabbccdd
60
+ _443._tcp.www.example.com. 86400 IN TLSA (
61
+ 1 1 2 92003ba34942dc74152e2f2c408d29ec
62
+ a5a520e7f2e06bb944f4dca346baf63c
63
+ 1b177615d466f6c4b71c216a50292bd5
64
+ 8c9ebdd2f74e38fe51ffd48c43326cbc )
57
65
  urn.example.com. IN NAPTR 100 50 "s" "http+N2L+N2C+N2R" "" www.example.com.
@@ -1,4 +1,4 @@
1
- require 'test/unit'
1
+ require 'minitest/autorun'
2
2
 
3
3
 
4
4
  $: << File.expand_path(File.dirname(__FILE__) + '/../lib')
@@ -9,7 +9,7 @@ require 'zonefile'
9
9
 
10
10
  $zonefile = ARGV[0] || 'test-zone.db'
11
11
 
12
- class TC_Zonefile < Test::Unit::TestCase
12
+ class TC_Zonefile < Minitest::Unit::TestCase
13
13
 
14
14
  def setup
15
15
  @zf = Zonefile.from_file(File.dirname(__FILE__) + '/'+$zonefile, 'test-origin')
@@ -32,7 +32,7 @@ class TC_Zonefile < Test::Unit::TestCase
32
32
  assert_equal 2, @zf.ptr.size
33
33
  assert @zf.ptr[0][:host] == data[0][:host]
34
34
  assert @zf.ptr[1][:name] == data[1][:name]
35
- assert_raise(NoMethodError) do
35
+ assert_raises(NoMethodError) do
36
36
  @zf.dont_exist(123,123,123)
37
37
  end
38
38
  end
@@ -132,6 +132,26 @@ class TC_Zonefile < Test::Unit::TestCase
132
132
  end unless @swap_txt
133
133
  end
134
134
 
135
+ def test_spf
136
+ assert_equal '"v=spf1 mx ~all"', @zf.spf[0][:text]
137
+ assert_equal "IN", @zf.spf[0][:class]
138
+ assert_equal "@", @zf.spf[0][:name]
139
+ assert_equal '"v=spf1 -all"', @zf.spf[1][:text]
140
+ assert_equal 'www', @zf.spf[1][:name]
141
+ assert_nil @zf.spf[1][:class]
142
+ assert_equal "elsewhere", @zf.spf[2][:name]
143
+ assert_equal '"v=spf1 mx ?all"', @zf.spf[2][:text]
144
+
145
+ assert_equal 3, @zf.spf.size
146
+
147
+ begin
148
+ @swap_txt = true
149
+ swap
150
+ test_txt
151
+ end unless @swap_txt
152
+ end
153
+
154
+
135
155
  def test_a4
136
156
  assert_equal 'icarus', @zf.a4[0][:name]
137
157
  assert_equal 'IN', @zf.a4[0][:class]
@@ -302,6 +322,28 @@ SIGNATURE
302
322
  end unless @swap_rrsig
303
323
  end
304
324
 
325
+ def test_tlsa
326
+ assert_equal "_443._tcp.www.example.com.", @zf.tlsa[0][:name]
327
+ assert_equal '86400', @zf.srv[0][:ttl]
328
+ assert_equal 1, @zf.tlsa[0][:certificate_usage]
329
+ assert_equal 1, @zf.tlsa[0][:selector]
330
+ assert_equal 2, @zf.tlsa[0][:matching_type]
331
+
332
+ sig = <<SIGNATURE.gsub( /\s+/,'').strip
333
+ 92003ba34942dc74152e2f2c408d29ec
334
+ a5a520e7f2e06bb944f4dca346baf63c
335
+ 1b177615d466f6c4b71c216a50292bd5
336
+ 8c9ebdd2f74e38fe51ffd48c43326cbc
337
+ SIGNATURE
338
+ assert_equal sig, @zf.tlsa[0][:data].gsub( /\s+/,'')
339
+
340
+ begin
341
+ @swap_tlsa= true
342
+ swap
343
+ test_tlsa
344
+ end unless @swap_tlsa
345
+ end
346
+
305
347
  def test_origin
306
348
  assert_equal 'test-zone.db', @zf.origin
307
349
  swap
metadata CHANGED
@@ -1,71 +1,50 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: zonefile
3
- version: !ruby/object:Gem::Version
4
- hash: 7
5
- prerelease:
6
- segments:
7
- - 1
8
- - 4
9
- version: "1.04"
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.06'
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - Martin Boese
13
8
  autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
-
17
- date: 2013-02-06 00:00:00 Z
11
+ date: 2017-06-15 00:00:00.000000000 Z
18
12
  dependencies: []
19
-
20
- description: |-
21
- A library that can create, read, write, modify BIND compatible Zonefiles (RFC1035).
22
- Warning: It probably works for most cases, but it might not be able to read all files
23
- even if they are valid for bind.
13
+ description: "A library that can create, read, write, modify BIND compatible Zonefiles
14
+ (RFC1035).\nWarning: It probably works for most cases, but it might not be able
15
+ to read all files \neven if they are valid for bind."
24
16
  email: martin@internet.ao
25
17
  executables: []
26
-
27
18
  extensions: []
28
-
29
19
  extra_rdoc_files: []
30
-
31
- files:
32
- - lib/zonefile/zonefile.rb
20
+ files:
21
+ - CHANGELOG
33
22
  - lib/zonefile.rb
23
+ - lib/zonefile/zonefile.rb
34
24
  - tests/test-zone.db
35
25
  - tests/zonefile.rb
36
- - CHANGELOG
37
26
  homepage: http://zonefile.rubyforge.org/
38
- licenses: []
39
-
27
+ licenses:
28
+ - MIT
29
+ metadata: {}
40
30
  post_install_message:
41
31
  rdoc_options: []
42
-
43
- require_paths:
32
+ require_paths:
44
33
  - lib
45
- required_ruby_version: !ruby/object:Gem::Requirement
46
- none: false
47
- requirements:
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
48
36
  - - ">="
49
- - !ruby/object:Gem::Version
50
- hash: 3
51
- segments:
52
- - 0
53
- version: "0"
54
- required_rubygems_version: !ruby/object:Gem::Requirement
55
- none: false
56
- requirements:
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
57
41
  - - ">="
58
- - !ruby/object:Gem::Version
59
- hash: 3
60
- segments:
61
- - 0
62
- version: "0"
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
63
44
  requirements: []
64
-
65
45
  rubyforge_project: zonefile
66
- rubygems_version: 1.8.24
46
+ rubygems_version: 2.4.8
67
47
  signing_key:
68
- specification_version: 3
48
+ specification_version: 4
69
49
  summary: BIND 8/9 Zonefile Reader and Writer
70
50
  test_files: []
71
-