auth_dns_check 0.3.1 → 0.4.0

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: 694aa2030b2a1849a624a23471174281a7e9ad75489c985124d7cb987c640ec7
4
- data.tar.gz: 3df4dd5171e5979c261ed0b227797dd8ffa4b5a8909a4254f1fd9195dc82ef36
3
+ metadata.gz: d338d45de300e876947fadfa4d22ecf87425725afdd04319b88be77561acd16f
4
+ data.tar.gz: eedb01a8bd545c05dc46b5a4d75e58ca45b68e9d0c79d01c4c45395f27fc6a4d
5
5
  SHA512:
6
- metadata.gz: 3a6f8f88f72d3c6afc4f6d5dafe228ed91001f4e8880bb2a5f9520e2c90b33c3dd87b340cbeccfc21dc243405b3cf54d5544df0bf2258a090dbb1381697b9c1f
7
- data.tar.gz: c5cbd271edf11b44f33d2a4f32a8f363c7872f8b0052f3aa8d9f37c697d1097659aeea58c2c941483b682aa14487932060dae1eb8fae63d550c557fe283326b2
6
+ metadata.gz: 35938d0b0510dc6e2122fb30b164f28144758374aaa407f38f71e24319a7d058d5cdca4bcb3a0ad5c933252670ef9d67e6a613320439a8dae29270c3bb47c999
7
+ data.tar.gz: 284e37fcf048fff46f974c1c3f648553a6b4b5d93d398b7333dfbb21a1d7973e23c11437a457ee30700d541b5b15be74efe37df3ccaed3c533716d4351d8fc43
@@ -1,7 +1,6 @@
1
1
  ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.5.3
7
- before_install: gem install bundler -v 2.0.1
2
+ language: minimal
3
+ services:
4
+ - docker
5
+ before_install: docker-compose build
6
+ script: docker-compose run test
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  [![Gem](https://img.shields.io/gem/v/auth_dns_check.svg?style=flat)](https://rubygems.org/gems/auth_dns_check "View this project in Rubygems")
2
+ [![CI](https://travis-ci.org/starjuice/auth_dns_check.svg?branch=master)](https://travis-ci.org/github/starjuice/auth_dns_check "View this project in Travis CI")
2
3
 
3
4
  # AuthDnsCheck
4
5
 
@@ -25,3 +25,9 @@ multi-different IN A 127.0.0.1
25
25
  multi-different IN A 127.0.0.3
26
26
  ;
27
27
  same.dotted IN A 127.0.0.1
28
+ ;
29
+ mixed-same IN A 127.0.0.1
30
+ mixed-same IN TXT "some text"
31
+ ;
32
+ mixed-different IN A 127.0.0.1
33
+ mixed-different IN TXT "some text"
@@ -25,3 +25,9 @@ multi-different IN A 127.0.0.3
25
25
  multi-different IN A 127.0.0.2
26
26
  ;
27
27
  same.dotted IN A 127.0.0.1
28
+ ;
29
+ mixed-same IN A 127.0.0.1
30
+ mixed-same IN TXT "some text"
31
+ ;
32
+ mixed-different IN A 127.0.0.1
33
+ mixed-different IN TXT "other text"
@@ -5,6 +5,9 @@ module AuthDnsCheck
5
5
  # @todo IPv6 not supported
6
6
  class Client
7
7
 
8
+ # Default record types for checks like +all?+
9
+ DEFAULT_TYPES = ["A"] unless defined?(DEFAULT_TYPES)
10
+
8
11
  # authoritative name server overrides
9
12
  attr_reader :overrides
10
13
 
@@ -29,9 +32,15 @@ module AuthDnsCheck
29
32
  # @return [Boolean] whether all authoritative agree that +fqdn+ has the same non-empty set of records
30
33
  # @raise [Error] if authoritative name servers could not be found
31
34
  # @todo Records of types other than A not yet supported
32
- def all?(fqdn)
33
- answers = get_addresses(fqdn)
34
- answers.all? { |x| x.any? and x == answers.first }
35
+ def all?(fqdn, types: DEFAULT_TYPES)
36
+ non_empty_set = false
37
+ types.all? { |type|
38
+ resources = get_resources(fqdn, type: type)
39
+ resources.all? do |x|
40
+ non_empty_set = true unless x.empty?
41
+ x == resources.first
42
+ end
43
+ } && non_empty_set
35
44
  end
36
45
 
37
46
  # Check authoritative agreement for the specific address for a name
@@ -49,6 +58,24 @@ module AuthDnsCheck
49
58
 
50
59
  private
51
60
 
61
+ def get_resources(fqdn, type:)
62
+ type_class = Resolv::DNS::Resource::IN::const_get(type)
63
+ get_authoritatives(fqdn).
64
+ map { |x| x.getresources(fqdn, type_class) }.
65
+ map { |x| x.collect { |r| resource_to_s(r, type) }.sort }
66
+ end
67
+
68
+ def resource_to_s(r, type)
69
+ case type
70
+ when "A"
71
+ r.address.to_s
72
+ when "TXT"
73
+ r.data
74
+ else
75
+ raise "unsupported record type #{type}"
76
+ end
77
+ end
78
+
52
79
  def get_addresses(fqdn)
53
80
  get_authoritatives(fqdn).
54
81
  map { |x| x.getaddresses(fqdn) }.
@@ -1,4 +1,4 @@
1
1
  module AuthDnsCheck
2
2
  # The version of the auth_dns_check gem
3
- VERSION = "0.3.1"
3
+ VERSION = "0.4.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auth_dns_check
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sheldon Hearn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-15 00:00:00.000000000 Z
11
+ date: 2020-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler