mirror of
https://github.com/google/nomulus
synced 2026-06-09 16:33:02 +00:00
Add BCC capabilities to the Spec11 reports (#418)
* Add BCC capabilities to the Spec11 reports
This commit is contained in:
@@ -917,6 +917,20 @@ public final class RegistryConfig {
|
||||
return parseEmailAddress(config.misc.spec11OutgoingEmailAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the email addresses to which we will BCC Spec11 emails.
|
||||
*
|
||||
* @see google.registry.reporting.spec11.Spec11EmailUtils
|
||||
*/
|
||||
@Provides
|
||||
@Config("spec11BccEmailAddresses")
|
||||
public static ImmutableList<InternetAddress> provideSpec11BccEmailAddresses(
|
||||
RegistryConfigSettings config) {
|
||||
return config.misc.spec11BccEmailAddresses.stream()
|
||||
.map(RegistryConfig::parseEmailAddress)
|
||||
.collect(toImmutableList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the registry, for use in spec 11 emails.
|
||||
*
|
||||
|
||||
@@ -193,6 +193,7 @@ public class RegistryConfigSettings {
|
||||
public String sheetExportId;
|
||||
public String alertRecipientEmailAddress;
|
||||
public String spec11OutgoingEmailAddress;
|
||||
public List<String> spec11BccEmailAddresses;
|
||||
public int asyncDeleteDelaySeconds;
|
||||
public int transientFailureRetries;
|
||||
}
|
||||
|
||||
@@ -389,6 +389,11 @@ misc:
|
||||
# to be a deliverable email address to handle replies from registrars as well.
|
||||
spec11OutgoingEmailAddress: abuse@example.com
|
||||
|
||||
# Addresses to which we will BCC all Spec11 email reports, in case one
|
||||
# wishes to examine the output.
|
||||
spec11BccEmailAddresses:
|
||||
- abuse@example.com
|
||||
|
||||
# How long to delay processing of asynchronous deletions. This should always
|
||||
# be longer than eppResourceCachingSeconds, to prevent deleted contacts or
|
||||
# hosts from being used on domains.
|
||||
|
||||
@@ -58,6 +58,7 @@ public class Spec11EmailUtils {
|
||||
|
||||
private final SendEmailService emailService;
|
||||
private final InternetAddress outgoingEmailAddress;
|
||||
private final ImmutableList<InternetAddress> spec11BccEmailAddresses;
|
||||
private final InternetAddress alertRecipientAddress;
|
||||
private final ImmutableList<String> spec11WebResources;
|
||||
private final String registryName;
|
||||
@@ -67,10 +68,12 @@ public class Spec11EmailUtils {
|
||||
SendEmailService emailService,
|
||||
@Config("alertRecipientEmailAddress") InternetAddress alertRecipientAddress,
|
||||
@Config("spec11OutgoingEmailAddress") InternetAddress spec11OutgoingEmailAddress,
|
||||
@Config("spec11BccEmailAddresses") ImmutableList<InternetAddress> spec11BccEmailAddresses,
|
||||
@Config("spec11WebResources") ImmutableList<String> spec11WebResources,
|
||||
@Config("registryName") String registryName) {
|
||||
this.emailService = emailService;
|
||||
this.outgoingEmailAddress = spec11OutgoingEmailAddress;
|
||||
this.spec11BccEmailAddresses = spec11BccEmailAddresses;
|
||||
this.alertRecipientAddress = alertRecipientAddress;
|
||||
this.spec11WebResources = spec11WebResources;
|
||||
this.registryName = registryName;
|
||||
@@ -125,11 +128,18 @@ public class Spec11EmailUtils {
|
||||
|
||||
private RegistrarThreatMatches filterOutNonPublishedMatches(
|
||||
RegistrarThreatMatches registrarThreatMatches) {
|
||||
ImmutableList<ThreatMatch> filteredMatches = registrarThreatMatches.threatMatches().stream()
|
||||
.filter(threatMatch ->
|
||||
ofy().load().type(DomainBase.class).filter("fullyQualifiedDomainName",
|
||||
threatMatch.fullyQualifiedDomainName()).first().now().shouldPublishToDns()
|
||||
).collect(toImmutableList());
|
||||
ImmutableList<ThreatMatch> filteredMatches =
|
||||
registrarThreatMatches.threatMatches().stream()
|
||||
.filter(
|
||||
threatMatch ->
|
||||
ofy()
|
||||
.load()
|
||||
.type(DomainBase.class)
|
||||
.filter("fullyQualifiedDomainName", threatMatch.fullyQualifiedDomainName())
|
||||
.first()
|
||||
.now()
|
||||
.shouldPublishToDns())
|
||||
.collect(toImmutableList());
|
||||
return RegistrarThreatMatches.create(registrarThreatMatches.clientId(), filteredMatches);
|
||||
}
|
||||
|
||||
@@ -146,7 +156,7 @@ public class Spec11EmailUtils {
|
||||
.setContentType(MediaType.HTML_UTF_8)
|
||||
.setFrom(outgoingEmailAddress)
|
||||
.addRecipient(getEmailAddressForRegistrar(registrarThreatMatches.clientId()))
|
||||
.setBcc(outgoingEmailAddress)
|
||||
.setBccs(spec11BccEmailAddresses)
|
||||
.build());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user