Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CAA Record lookups and tests. #240

Merged
merged 3 commits into from
Jul 1, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add CAA Record lookups and tests.
  • Loading branch information
pysysops committed May 31, 2017
commit ece9923c867007705da71c948c04990460125b15
1 change: 1 addition & 0 deletions docs/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,7 @@ With the server attribute set, it is possible to validate the following types of

- A
- AAAA
- CAA
- CNAME
- MX
- NS
Expand Down
4 changes: 4 additions & 0 deletions integration-tests/goss/alpine3/goss-expected-q.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ command:
stderr: []
timeout: 10000
dns:
CAA:dnstest.io:
resolveable: true
timeout: 1000
server: 8.8.8.8
CNAME:c.dnstest.io:
resolveable: true
timeout: 1000
Expand Down
8 changes: 8 additions & 0 deletions integration-tests/goss/alpine3/goss-expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ command:
- 'sh: foobar: not found'
timeout: 10000
dns:
CAA:dnstest.io:
resolveable: true
addrs:
- 0 issue comodoca.com
- 0 issue letsencrypt.org
- 0 issuewild ;
timeout: 1000
server: 8.8.8.8
CNAME:c.dnstest.io:
resolveable: true
addrs:
Expand Down
4 changes: 4 additions & 0 deletions integration-tests/goss/centos7/goss-expected-q.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ command:
stderr: []
timeout: 10000
dns:
CAA:dnstest.io:
resolveable: true
timeout: 1000
server: 8.8.8.8
CNAME:c.dnstest.io:
resolveable: true
timeout: 1000
Expand Down
8 changes: 8 additions & 0 deletions integration-tests/goss/centos7/goss-expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ command:
- 'sh: foobar: command not found'
timeout: 10000
dns:
CAA:dnstest.io:
resolveable: true
addrs:
- 0 issue comodoca.com
- 0 issue letsencrypt.org
- 0 issuewild ;
timeout: 1000
server: 8.8.8.8
CNAME:c.dnstest.io:
resolveable: true
addrs:
Expand Down
2 changes: 2 additions & 0 deletions integration-tests/goss/generate_goss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ goss a "${args[@]}" dns --timeout 1s --server 8.8.8.8 SRV:_https._tcp.dnstest.io

goss a "${args[@]}" dns --timeout 1s --server 8.8.8.8 TXT:txt._test.dnstest.io

goss a "${args[@]}" dns --timeout 1s --server 8.8.8.8 CAA:dnstest.io

goss a "${args[@]}" dns --timeout 1s --server 8.8.8.8 ip6.dnstest.io

goss a "${args[@]}" dns --timeout 1s localhost
Expand Down
8 changes: 8 additions & 0 deletions integration-tests/goss/goss-shared.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ group:
foobar:
exists: false
dns:
CAA:dnstest.io:
resolveable: true
addrs:
- 0 issue comodoca.com
- 0 issue letsencrypt.org
- 0 issuewild ;
timeout: 2000
server: 8.8.8.8
CNAME:c.dnstest.io:
resolveable: true
addrs:
Expand Down
4 changes: 4 additions & 0 deletions integration-tests/goss/precise/goss-expected-q.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ command:
stderr: []
timeout: 10000
dns:
CAA:dnstest.io:
resolveable: true
timeout: 1000
server: 8.8.8.8
CNAME:c.dnstest.io:
resolveable: true
timeout: 1000
Expand Down
8 changes: 8 additions & 0 deletions integration-tests/goss/precise/goss-expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ command:
- 'sh: 1: foobar: not found'
timeout: 10000
dns:
CAA:dnstest.io:
resolveable: true
addrs:
- 0 issue comodoca.com
- 0 issue letsencrypt.org
- 0 issuewild ;
timeout: 1000
server: 8.8.8.8
CNAME:c.dnstest.io:
resolveable: true
addrs:
Expand Down
4 changes: 4 additions & 0 deletions integration-tests/goss/wheezy/goss-expected-q.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ command:
stderr: []
timeout: 10000
dns:
CAA:dnstest.io:
resolveable: true
timeout: 1000
server: 8.8.8.8
CNAME:c.dnstest.io:
resolveable: true
timeout: 1000
Expand Down
8 changes: 8 additions & 0 deletions integration-tests/goss/wheezy/goss-expected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ command:
- 'sh: 1: foobar: not found'
timeout: 10000
dns:
CAA:dnstest.io:
resolveable: true
addrs:
- 0 issue comodoca.com
- 0 issue letsencrypt.org
- 0 issuewild ;
timeout: 1000
server: 8.8.8.8
CNAME:c.dnstest.io:
resolveable: true
addrs:
Expand Down
21 changes: 21 additions & 0 deletions system/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ func DNSlookup(host string, server string, qtype string, timeout int) ([]string,
addrs, err = LookupSRV(host, server, c, m)
case "TXT":
addrs, err = LookupTXT(host, server, c, m)
case "CAA":
addrs, err = LookupCAA(host, server, c, m)
default:
addrs, err = LookupHost(host, server, c, m)
}
Expand Down Expand Up @@ -310,3 +312,22 @@ func LookupPTR(addr string, server string, c *dns.Client, m *dns.Msg) (name []st

return
}

// CAA record lookup
func LookupCAA(host string, server string, c *dns.Client, m *dns.Msg) (addrs []string, err error) {
m.SetQuestion(dns.Fqdn(host), dns.TypeCAA)
r, _, err := c.Exchange(m, net.JoinHostPort(server, "53"))
if err != nil {
return nil, err
}

for _, ans := range r.Answer {
if t, ok := ans.(*dns.CAA); ok {
flag := strconv.Itoa(int(t.Flag))
caarec := strings.Join([]string{flag, t.Tag, t.Value}, " ")
addrs = append(addrs, caarec)
}
}

return
}