only send risk notif when risks are found

This commit is contained in:
Maidul Islam
2023-07-19 00:05:19 -04:00
parent 1f3f0375b9
commit da9cb70184
@@ -129,16 +129,18 @@ export default async (app: Probot) => {
const adminOrOwnerEmails = userEmails.map(userObject => userObject.email) const adminOrOwnerEmails = userEmails.map(userObject => userObject.email)
const usersToNotify = pusher?.email ? [pusher.email, ...adminOrOwnerEmails] : [...adminOrOwnerEmails] const usersToNotify = pusher?.email ? [pusher.email, ...adminOrOwnerEmails] : [...adminOrOwnerEmails]
await sendMail({ if (Object.keys(allFindingsByFingerprint).length) {
template: "secretLeakIncident.handlebars", await sendMail({
subjectLine: `Incident alert: leaked secrets found in Github repository ${repository.full_name}`, template: "secretLeakIncident.handlebars",
recipients: usersToNotify, subjectLine: `Incident alert: leaked secrets found in Github repository ${repository.full_name}`,
substitutions: { recipients: usersToNotify,
numberOfSecrets: Object.keys(allFindingsByFingerprint).length, substitutions: {
pusher_email: pusher.email, numberOfSecrets: Object.keys(allFindingsByFingerprint).length,
pusher_name: pusher.name pusher_email: pusher.email,
} pusher_name: pusher.name
}); }
});
}
const postHogClient = await TelemetryService.getPostHogClient(); const postHogClient = await TelemetryService.getPostHogClient();
if (postHogClient) { if (postHogClient) {