Skip to content

Commit

Permalink
Fixes #35979 - dnscmd nil string error
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernhard authored and ekohl committed Jan 23, 2023
1 parent 1357f39 commit 2d9cdce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions modules/dns_dnscmd/dns_dnscmd_main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def match_zone(record, zone_list)

def enum_zones
zones = []
response = execute '/EnumZones', error_only: true
response = execute '/EnumZones', msg: 'EnumZones', error_only: true
response.each do |line|
next unless line =~ / Primary /
zones << line.sub(/^ +/, '').sub(/ +.*$/, '').chomp("\n")
Expand All @@ -109,7 +109,7 @@ def enum_zones

def enum_records(zone_name, node_name, type)
records = []
response = execute "/EnumRecords", zone_name, "#{node_name}.", "/Type", type, error_only: true
response = execute "/EnumRecords", zone_name, "#{node_name}.", "/Type", type, msg: 'EnumRecords', error_only: true
response.each do |line|
line.chomp!
logger.debug "Extracting record from dnscmd output '#{line}'"
Expand Down
14 changes: 7 additions & 7 deletions test/dns_dnscmd/dnscmd_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_dnscmd_enum_zones_parses_primary_zones_only
domain.com Secondary File
TrustAnchors Primary AD-Forest
Command completed successfully.'.split("\n")
Proxy::Dns::Dnscmd::Record.any_instance.expects(:execute).with('/EnumZones', error_only: true).returns(to_parse)
Proxy::Dns::Dnscmd::Record.any_instance.expects(:execute).with('/EnumZones', msg: 'EnumZones', error_only: true).returns(to_parse)
assert_equal [
"_msdcs.bar.domain.local",
"168.192.in-addr.arpa",
Expand All @@ -126,7 +126,7 @@ def test_enum_a_records
Command completed successfully.
'.split("\n")
Proxy::Dns::Dnscmd::Record.any_instance.expects(:execute).with('/EnumRecords', "domain.local", "host.domain.local.", '/Type', 'A', error_only: true).returns(to_parse)
Proxy::Dns::Dnscmd::Record.any_instance.expects(:execute).with('/EnumRecords', "domain.local", "host.domain.local.", '/Type', 'A', msg: 'EnumRecords', error_only: true).returns(to_parse)
assert_equal ['192.168.33.33', '192.168.33.34'], Proxy::Dns::Dnscmd::Record.new('server', 999).enum_records('domain.local', 'host.domain.local', 'A')
end

Expand All @@ -138,7 +138,7 @@ def test_enum_aaaa_records
Command completed successfully.
'.split("\n")
Proxy::Dns::Dnscmd::Record.any_instance.expects(:execute).with('/EnumRecords', "domain.local", "host.domain.local.", '/Type', 'AAAA', error_only: true).returns(to_parse)
Proxy::Dns::Dnscmd::Record.any_instance.expects(:execute).with('/EnumRecords', "domain.local", "host.domain.local.", '/Type', 'AAAA', msg: 'EnumRecords', error_only: true).returns(to_parse)
assert_equal ['2001:db8:85a3::8a2e:370:7335', '2001:db8:85a3::8a2e:370:7334'], Proxy::Dns::Dnscmd::Record.new('server', 999).enum_records('domain.local', 'host.domain.local', 'AAAA')
end

Expand All @@ -149,7 +149,7 @@ def test_enum_cname_records
Command completed successfully.
'.split("\n")
Proxy::Dns::Dnscmd::Record.any_instance.expects(:execute).with('/EnumRecords', 'example.com', "alias.example.com.", '/Type', 'CNAME', error_only: true).returns(to_parse)
Proxy::Dns::Dnscmd::Record.any_instance.expects(:execute).with('/EnumRecords', 'example.com', "alias.example.com.", '/Type', 'CNAME', msg: 'EnumRecords', error_only: true).returns(to_parse)
assert_equal ['alias.example.com.'], Proxy::Dns::Dnscmd::Record.new('server', 999).enum_records('example.com', 'alias.example.com', 'CNAME')
end

Expand All @@ -160,7 +160,7 @@ def test_enum_ptr_records
Command completed successfully.
'.split("\n")
Proxy::Dns::Dnscmd::Record.any_instance.expects(:execute).with('/EnumRecords', '33.168.192.in-addr.arpa', "33.33.168.192.in-addr.arpa.", '/Type', 'PTR', error_only: true).returns(to_parse)
Proxy::Dns::Dnscmd::Record.any_instance.expects(:execute).with('/EnumRecords', '33.168.192.in-addr.arpa', "33.33.168.192.in-addr.arpa.", '/Type', 'PTR', msg: 'EnumRecords', error_only: true).returns(to_parse)
assert_equal ['host.domain.local.'], Proxy::Dns::Dnscmd::Record.new('server', 999).enum_records('33.168.192.in-addr.arpa', '33.33.168.192.in-addr.arpa', 'PTR')
end

Expand All @@ -172,7 +172,7 @@ def test_enum_ptr_records_when_multiple
Command completed successfully.
'.split("\n")
Proxy::Dns::Dnscmd::Record.any_instance.expects(:execute).with('/EnumRecords', '33.168.192.in-addr.arpa', "33.33.168.192.in-addr.arpa.", '/Type', 'PTR', error_only: true).returns(to_parse)
Proxy::Dns::Dnscmd::Record.any_instance.expects(:execute).with('/EnumRecords', '33.168.192.in-addr.arpa', "33.33.168.192.in-addr.arpa.", '/Type', 'PTR', msg: 'EnumRecords', error_only: true).returns(to_parse)
assert_equal ['host.domain.local.', 'host2.domain.local.'], Proxy::Dns::Dnscmd::Record.new('server', 999).enum_records('33.168.192.in-addr.arpa', '33.33.168.192.in-addr.arpa', 'PTR')
end

Expand All @@ -182,7 +182,7 @@ def test_enum_ptr_records_when_none
Status = 9714 (0x000025f2)
Command failed: DNS_ERROR_NAME_DOES_NOT_EXIST 9714 0x25F2
'.split("\n")
Proxy::Dns::Dnscmd::Record.any_instance.expects(:execute).with('/EnumRecords', '33.168.192.in-addr.arpa', "33.33.168.192.in-addr.arpa.", '/Type', 'PTR', error_only: true).returns(to_parse)
Proxy::Dns::Dnscmd::Record.any_instance.expects(:execute).with('/EnumRecords', '33.168.192.in-addr.arpa', "33.33.168.192.in-addr.arpa.", '/Type', 'PTR', msg: 'EnumRecords', error_only: true).returns(to_parse)
assert_equal [], Proxy::Dns::Dnscmd::Record.new('server', 999).enum_records('33.168.192.in-addr.arpa', '33.33.168.192.in-addr.arpa', 'PTR')
end
end

0 comments on commit 2d9cdce

Please sign in to comment.