-
Notifications
You must be signed in to change notification settings - Fork 2
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
fix(sl): warn ops regarding CAA records #1076
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -22,6 +22,7 @@ import { | |||||||||||
getDNSRecordsEmailBody, | ||||||||||||
getErrorEmailBody, | ||||||||||||
} from "@root/services/utilServices/SendDNSRecordEmailClient" | ||||||||||||
import TRUSTED_AMPLIFY_CAA_RECORDS from "@root/types/caaAmplify" | ||||||||||||
import { DigResponse, DigType } from "@root/types/dig" | ||||||||||||
import UsersService from "@services/identity/UsersService" | ||||||||||||
import InfraService from "@services/infra/InfraService" | ||||||||||||
|
@@ -231,7 +232,7 @@ export class FormsgSiteLaunchRouter { | |||||||||||
await mailer.sendMail(email, subject, html) | ||||||||||||
} | ||||||||||||
|
||||||||||||
private digDomainForQuadARecords = async ( | ||||||||||||
digDomainRecords = async ( | ||||||||||||
domain: string, | ||||||||||||
digType: DigType | ||||||||||||
): Promise<DigResponse | null> => | ||||||||||||
|
@@ -332,13 +333,18 @@ export class FormsgSiteLaunchRouter { | |||||||||||
for (const launchResult of launchResults) { | ||||||||||||
if (launchResult.isOk()) { | ||||||||||||
// check for AAAA records | ||||||||||||
const digResponse = await this.digDomainForQuadARecords( | ||||||||||||
const quadADigResponse = await this.digDomainRecords( | ||||||||||||
launchResult.value.primaryDomainSource, | ||||||||||||
"AAAA" | ||||||||||||
) | ||||||||||||
const caaDigResponse = await this.digDomainRecords( | ||||||||||||
launchResult.value.primaryDomainSource, | ||||||||||||
"CAA" | ||||||||||||
) | ||||||||||||
|
||||||||||||
const successResult: DnsRecordsEmailProps = launchResult.value | ||||||||||||
if (digResponse && digResponse.answer) { | ||||||||||||
const quadARecords = digResponse.answer | ||||||||||||
if (quadADigResponse && quadADigResponse.answer) { | ||||||||||||
const quadARecords = quadADigResponse.answer | ||||||||||||
successResult.quadARecords = quadARecords.map((record) => ({ | ||||||||||||
domain: record.domain, | ||||||||||||
class: record.class, | ||||||||||||
|
@@ -350,6 +356,35 @@ export class FormsgSiteLaunchRouter { | |||||||||||
`Unable to get dig response for domain: ${launchResult.value.primaryDomainSource}. Skipping check for AAAA records` | ||||||||||||
) | ||||||||||||
} | ||||||||||||
|
||||||||||||
if (!caaDigResponse) { | ||||||||||||
logger.info( | ||||||||||||
`Unable to get dig response for domain: ${launchResult.value.primaryDomainSource}. Skipping check for CAA records` | ||||||||||||
) | ||||||||||||
} else if (caaDigResponse.answer) { | ||||||||||||
const caaRecords = caaDigResponse.answer | ||||||||||||
|
||||||||||||
/** | ||||||||||||
* NOTE: If there exists more than one CAA Record, we need to | ||||||||||||
* 1. check if they have whitelisted Amazon CAA | ||||||||||||
* 2. if not, send email to inform them to whitelist Amazon CAA | ||||||||||||
*/ | ||||||||||||
const hasAmazonCAAWhitelisted = caaRecords.some((record) => { | ||||||||||||
const isAmazonCAA = TRUSTED_AMPLIFY_CAA_RECORDS.some( | ||||||||||||
(trustedCAA) => trustedCAA === record.value | ||||||||||||
) | ||||||||||||
return isAmazonCAA | ||||||||||||
}) | ||||||||||||
if (caaRecords.length > 0 && !hasAmazonCAAWhitelisted) { | ||||||||||||
successResult.addCAARecord = true | ||||||||||||
} else { | ||||||||||||
successResult.addCAARecord = false | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't we need the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh my conidtion is wrong i think that caused the confusion ps There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed, hopefully this clearer
Comment on lines
+378
to
+381
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
} | ||||||||||||
} else { | ||||||||||||
logger.info( | ||||||||||||
`${launchResult.value.primaryDomainSource} Domain does not have any CAA records.` | ||||||||||||
) | ||||||||||||
} | ||||||||||||
// Create better uptime monitor | ||||||||||||
await this.createMonitor(launchResult.value.primaryDomainSource) | ||||||||||||
successResults.push(successResult) | ||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* This is taken from https://docs.aws.amazon.com/acm/latest/userguide/setup-caa.html | ||
*/ | ||
const TRUSTED_AMPLIFY_CAA_RECORDS = [ | ||
"amazon.com", | ||
"amazontrust.com", | ||
"awstrust.com", | ||
"amazonaws.com", | ||
] | ||
|
||
export default TRUSTED_AMPLIFY_CAA_RECORDS |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,4 @@ export type DigType = | |
| "SOA" | ||
| "SRV" | ||
| "TXT" | ||
| "CAA" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the assumption we're making here is that if there's only one CAA record, it's the whitelisted amazon one right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not really, the condition to check here is: if it has any CAA record, at least one has to be the amazon one
in the case where there is no CAA record, actually all this is ok already