{"action":"created","comment":{"url":"https://api.github.com/repos/mozilla/tls-observatory/pulls/comments/172518373","pull_request_review_id":101542452,"id":172518373,"diff_hunk":"@@ -0,0 +1,164 @@\n+package caaWorker\n+\n+import (\n+\t\"encoding/json\"\n+\t\"fmt\"\n+\t\"strings\"\n+\n+\t\"github.com/miekg/dns\"\n+\t\"github.com/mozilla/tls-observatory/worker\"\n+)\n+\n+var (\n+\tworkerName = \"caaWorker\"\n+\tworkerDesc = \"Checks domains DNS records for a CAA record and reports it.\"\n+)\n+\n+func init() {\n+\tworker.RegisterWorker(workerName, worker.Info{Runner: new(eval), Description: workerDesc})\n+}\n+\n+// Result describes the result produced by CAAWorker\n+type Result struct {\n+\tHasCAA       bool     `json:\"has_caa\"`\n+\tHost         string   `json:\"host\"`\n+\tIssueCAs     []string `json:\"issue_cas\"`\n+\tIssueWildCAs []string `json:\"issuewild_cas\"`\n+}\n+\n+type eval struct{}\n+\n+// Run implements the worker interface.It is called to get the worker results.\n+func (e eval) Run(in worker.Input, resChan chan worker.Result) {\n+\tresult := worker.Result{WorkerName: workerName, Success: true}\n+\tcaaRes := Result{}\n+\n+\thostPieces := strings.Split(in.Target, \".\")\n+\tfor i := 0; i < len(hostPieces); i++ {\n+\t\thost := strings.Join(hostPieces[i:], \".\")\n+\n+\t\tmsg := new(dns.Msg)\n+\t\tmsg.SetQuestion(dns.Fqdn(host), dns.TypeCAA)\n+\n+\t\tclient := dns.Client{}\n+\t\tres, _, err := client.Exchange(msg, \"8.8.8.8:53\")\n+\t\tif err != nil {\n+\t\t\tresult.Errors = append(result.Errors, fmt.Sprintf(\"CAA lookup failed for %s: %v\", host, err))\n+\t\t\tcontinue\n+\t\t}\n+\n+\t\tif res.Rcode != dns.RcodeSuccess {\n+\t\t\tresult.Errors = append(result.Errors, fmt.Sprintf(\"CAA lookup failed for %s with %s\", host, dns.RcodeToString[res.Rcode]))\n+\t\t\tcontinue\n+\t\t}\n+\n+\t\tfor _, rr := range res.Answer {\n+\t\t\tif caa, ok := rr.(*dns.CAA); ok {\n+\t\t\t\tcaaRes.HasCAA = true\n+\t\t\t\tif caa.Tag == \"issue\" {\n+\t\t\t\t\tcaaRes.IssueCAs = append(caaRes.IssueCAs, caa.Value)\n+\t\t\t\t} else if caa.Tag == \"issuewild\" {\n+\t\t\t\t\tcaaRes.IssueWildCAs = append(caaRes.IssueWildCAs, caa.Value)\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}\n+\n+\t\tif caaRes.HasCAA {\n+\t\t\tcaaRes.Host = host\n+\t\t\tbreak\n+\t\t}\n+\t}\n+\n+\tres, err := json.Marshal(caaRes)\n+\tif err != nil {\n+\t\tresult.Errors = append(result.Errors, err.Error())\n+\t\tresult.Success = false\n+\t} else {\n+\t\tresult.Success = true\n+\t\tresult.Result = res\n+\t}\n+\n+\tresChan <- result\n+}\n+\n+// Assertor compares 2 caaResults and reports differences.\n+func (e eval) Assertor(caaResult, assertresults []byte) (pass bool, body []byte, err error) {","path":"worker/caaWorker/caaWorker.go","position":85,"original_position":85,"commit_id":"88216d8d8f94eeefd0e39efdf03de380732ff0e9","original_commit_id":"88216d8d8f94eeefd0e39efdf03de380732ff0e9","user":{"login":"jvehent","id":415617,"avatar_url":"https://avatars1.githubusercontent.com/u/415617?v=4","gravatar_id":"","url":"https://api.github.com/users/jvehent","html_url":"https://github.com/jvehent","followers_url":"https://api.github.com/users/jvehent/followers","following_url":"https://api.github.com/users/jvehent/following{/other_user}","gists_url":"https://api.github.com/users/jvehent/gists{/gist_id}","starred_url":"https://api.github.com/users/jvehent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jvehent/subscriptions","organizations_url":"https://api.github.com/users/jvehent/orgs","repos_url":"https://api.github.com/users/jvehent/repos","events_url":"https://api.github.com/users/jvehent/events{/privacy}","received_events_url":"https://api.github.com/users/jvehent/received_events","type":"User","site_admin":false},"body":"`tls-observatory.services.mozilla.com` has caa under `services.mozilla.com`. How about adding that to runner.yaml as an example of using this assertor?","created_at":"2018-03-06T13:43:05Z","updated_at":"2018-03-06T13:49:02Z","html_url":"https://github.com/mozilla/tls-observatory/pull/304#discussion_r172518373","pull_request_url":"https://api.github.com/repos/mozilla/tls-observatory/pulls/304","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/mozilla/tls-observatory/pulls/comments/172518373"},"html":{"href":"https://github.com/mozilla/tls-observatory/pull/304#discussion_r172518373"},"pull_request":{"href":"https://api.github.com/repos/mozilla/tls-observatory/pulls/304"}}},"pull_request":{"url":"https://api.github.com/repos/mozilla/tls-observatory/pulls/304","id":172724176,"html_url":"https://github.com/mozilla/tls-observatory/pull/304","diff_url":"https://github.com/mozilla/tls-observatory/pull/304.diff","patch_url":"https://github.com/mozilla/tls-observatory/pull/304.patch","issue_url":"https://api.github.com/repos/mozilla/tls-observatory/issues/304","number":304,"state":"open","locked":false,"title":"Introduce CAA worker","user":{"login":"0xdiba","id":5148180,"avatar_url":"https://avatars3.githubusercontent.com/u/5148180?v=4","gravatar_id":"","url":"https://api.github.com/users/0xdiba","html_url":"https://github.com/0xdiba","followers_url":"https://api.github.com/users/0xdiba/followers","following_url":"https://api.github.com/users/0xdiba/following{/other_user}","gists_url":"https://api.github.com/users/0xdiba/gists{/gist_id}","starred_url":"https://api.github.com/users/0xdiba/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/0xdiba/subscriptions","organizations_url":"https://api.github.com/users/0xdiba/orgs","repos_url":"https://api.github.com/users/0xdiba/repos","events_url":"https://api.github.com/users/0xdiba/events{/privacy}","received_events_url":"https://api.github.com/users/0xdiba/received_events","type":"User","site_admin":false},"body":"The worker checks the domain's DNS records for CAA and reports CAs permitted to issue standard and wildcard certs ( if any ). ","created_at":"2018-03-04T15:14:15Z","updated_at":"2018-03-06T13:49:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cd8bd2255c12651c81a06bb08c543167474cc2bd","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/mozilla/tls-observatory/pulls/304/commits","review_comments_url":"https://api.github.com/repos/mozilla/tls-observatory/pulls/304/comments","review_comment_url":"https://api.github.com/repos/mozilla/tls-observatory/pulls/comments{/number}","comments_url":"https://api.github.com/repos/mozilla/tls-observatory/issues/304/comments","statuses_url":"https://api.github.com/repos/mozilla/tls-observatory/statuses/88216d8d8f94eeefd0e39efdf03de380732ff0e9","head":{"label":"mozilla:caa_worker","ref":"caa_worker","sha":"88216d8d8f94eeefd0e39efdf03de380732ff0e9","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars2.githubusercontent.com/u/131524?v=4","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":23923847,"name":"tls-observatory","full_name":"mozilla/tls-observatory","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars2.githubusercontent.com/u/131524?v=4","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/tls-observatory","description":"An observatory for TLS configurations, X509 certificates, and more.","fork":false,"url":"https://api.github.com/repos/mozilla/tls-observatory","forks_url":"https://api.github.com/repos/mozilla/tls-observatory/forks","keys_url":"https://api.github.com/repos/mozilla/tls-observatory/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/tls-observatory/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/tls-observatory/teams","hooks_url":"https://api.github.com/repos/mozilla/tls-observatory/hooks","issue_events_url":"https://api.github.com/repos/mozilla/tls-observatory/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/tls-observatory/events","assignees_url":"https://api.github.com/repos/mozilla/tls-observatory/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/tls-observatory/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/tls-observatory/tags","blobs_url":"https://api.github.com/repos/mozilla/tls-observatory/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/tls-observatory/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/tls-observatory/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/tls-observatory/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/tls-observatory/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/tls-observatory/languages","stargazers_url":"https://api.github.com/repos/mozilla/tls-observatory/stargazers","contributors_url":"https://api.github.com/repos/mozilla/tls-observatory/contributors","subscribers_url":"https://api.github.com/repos/mozilla/tls-observatory/subscribers","subscription_url":"https://api.github.com/repos/mozilla/tls-observatory/subscription","commits_url":"https://api.github.com/repos/mozilla/tls-observatory/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/tls-observatory/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/tls-observatory/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/tls-observatory/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/tls-observatory/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/tls-observatory/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/tls-observatory/merges","archive_url":"https://api.github.com/repos/mozilla/tls-observatory/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/tls-observatory/downloads","issues_url":"https://api.github.com/repos/mozilla/tls-observatory/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/tls-observatory/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/tls-observatory/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/tls-observatory/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/tls-observatory/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/tls-observatory/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/tls-observatory/deployments","created_at":"2014-09-11T15:23:25Z","updated_at":"2018-03-05T16:03:47Z","pushed_at":"2018-03-04T15:22:30Z","git_url":"git://github.com/mozilla/tls-observatory.git","ssh_url":"git@github.com:mozilla/tls-observatory.git","clone_url":"https://github.com/mozilla/tls-observatory.git","svn_url":"https://github.com/mozilla/tls-observatory","homepage":"","size":111645,"stargazers_count":319,"watchers_count":319,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":58,"mirror_url":null,"archived":false,"open_issues_count":49,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0"},"forks":58,"open_issues":49,"watchers":319,"default_branch":"master"}},"base":{"label":"mozilla:master","ref":"master","sha":"a64118f715c77ff1bf88bca1694fcacf442e0839","user":{"login":"mozilla","id":131524,"avatar_url":"https://avatars2.githubusercontent.com/u/131524?v=4","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"repo":{"id":23923847,"name":"tls-observatory","full_name":"mozilla/tls-observatory","owner":{"login":"mozilla","id":131524,"avatar_url":"https://avatars2.githubusercontent.com/u/131524?v=4","gravatar_id":"","url":"https://api.github.com/users/mozilla","html_url":"https://github.com/mozilla","followers_url":"https://api.github.com/users/mozilla/followers","following_url":"https://api.github.com/users/mozilla/following{/other_user}","gists_url":"https://api.github.com/users/mozilla/gists{/gist_id}","starred_url":"https://api.github.com/users/mozilla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mozilla/subscriptions","organizations_url":"https://api.github.com/users/mozilla/orgs","repos_url":"https://api.github.com/users/mozilla/repos","events_url":"https://api.github.com/users/mozilla/events{/privacy}","received_events_url":"https://api.github.com/users/mozilla/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/mozilla/tls-observatory","description":"An observatory for TLS configurations, X509 certificates, and more.","fork":false,"url":"https://api.github.com/repos/mozilla/tls-observatory","forks_url":"https://api.github.com/repos/mozilla/tls-observatory/forks","keys_url":"https://api.github.com/repos/mozilla/tls-observatory/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mozilla/tls-observatory/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mozilla/tls-observatory/teams","hooks_url":"https://api.github.com/repos/mozilla/tls-observatory/hooks","issue_events_url":"https://api.github.com/repos/mozilla/tls-observatory/issues/events{/number}","events_url":"https://api.github.com/repos/mozilla/tls-observatory/events","assignees_url":"https://api.github.com/repos/mozilla/tls-observatory/assignees{/user}","branches_url":"https://api.github.com/repos/mozilla/tls-observatory/branches{/branch}","tags_url":"https://api.github.com/repos/mozilla/tls-observatory/tags","blobs_url":"https://api.github.com/repos/mozilla/tls-observatory/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mozilla/tls-observatory/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mozilla/tls-observatory/git/refs{/sha}","trees_url":"https://api.github.com/repos/mozilla/tls-observatory/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mozilla/tls-observatory/statuses/{sha}","languages_url":"https://api.github.com/repos/mozilla/tls-observatory/languages","stargazers_url":"https://api.github.com/repos/mozilla/tls-observatory/stargazers","contributors_url":"https://api.github.com/repos/mozilla/tls-observatory/contributors","subscribers_url":"https://api.github.com/repos/mozilla/tls-observatory/subscribers","subscription_url":"https://api.github.com/repos/mozilla/tls-observatory/subscription","commits_url":"https://api.github.com/repos/mozilla/tls-observatory/commits{/sha}","git_commits_url":"https://api.github.com/repos/mozilla/tls-observatory/git/commits{/sha}","comments_url":"https://api.github.com/repos/mozilla/tls-observatory/comments{/number}","issue_comment_url":"https://api.github.com/repos/mozilla/tls-observatory/issues/comments{/number}","contents_url":"https://api.github.com/repos/mozilla/tls-observatory/contents/{+path}","compare_url":"https://api.github.com/repos/mozilla/tls-observatory/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mozilla/tls-observatory/merges","archive_url":"https://api.github.com/repos/mozilla/tls-observatory/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mozilla/tls-observatory/downloads","issues_url":"https://api.github.com/repos/mozilla/tls-observatory/issues{/number}","pulls_url":"https://api.github.com/repos/mozilla/tls-observatory/pulls{/number}","milestones_url":"https://api.github.com/repos/mozilla/tls-observatory/milestones{/number}","notifications_url":"https://api.github.com/repos/mozilla/tls-observatory/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mozilla/tls-observatory/labels{/name}","releases_url":"https://api.github.com/repos/mozilla/tls-observatory/releases{/id}","deployments_url":"https://api.github.com/repos/mozilla/tls-observatory/deployments","created_at":"2014-09-11T15:23:25Z","updated_at":"2018-03-05T16:03:47Z","pushed_at":"2018-03-04T15:22:30Z","git_url":"git://github.com/mozilla/tls-observatory.git","ssh_url":"git@github.com:mozilla/tls-observatory.git","clone_url":"https://github.com/mozilla/tls-observatory.git","svn_url":"https://github.com/mozilla/tls-observatory","homepage":"","size":111645,"stargazers_count":319,"watchers_count":319,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":58,"mirror_url":null,"archived":false,"open_issues_count":49,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0"},"forks":58,"open_issues":49,"watchers":319,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/mozilla/tls-observatory/pulls/304"},"html":{"href":"https://github.com/mozilla/tls-observatory/pull/304"},"issue":{"href":"https://api.github.com/repos/mozilla/tls-observatory/issues/304"},"comments":{"href":"https://api.github.com/repos/mozilla/tls-observatory/issues/304/comments"},"review_comments":{"href":"https://api.github.com/repos/mozilla/tls-observatory/pulls/304/comments"},"review_comment":{"href":"https://api.github.com/repos/mozilla/tls-observatory/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/mozilla/tls-observatory/pulls/304/commits"},"statuses":{"href":"https://api.github.com/repos/mozilla/tls-observatory/statuses/88216d8d8f94eeefd0e39efdf03de380732ff0e9"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"jvehent"}}