public async Task <List <IAlert> > GetSystemAlertsAsync() { List <SystemSecurityAlert> alerts = await _authDbContext.SystemSecurityAlerts.ToListAsync(); List <IAlert> alertList = new List <IAlert>(); foreach (SystemSecurityAlert alert in alerts) { switch (alert.AlertType) { case AlertTypeEnum.UnencryptedLdapBindAlert: LdapUnencryptedConnectionAlert ldapUnencryptedConnectionAlert = new LdapUnencryptedConnectionAlert(alert.KeyValueStore); ldapUnencryptedConnectionAlert.Id = alert.Id; alertList.Add(ldapUnencryptedConnectionAlert); break; case AlertTypeEnum.BruteforceIpAddressAlert: BruteforceIpAddressAlert bruteforceIpAddressAlert = new BruteforceIpAddressAlert(alert.KeyValueStore); bruteforceIpAddressAlert.Id = alert.Id; alertList.Add(bruteforceIpAddressAlert); break; } } return(alertList); }
private async Task IssueAlertIfIpIsNowBlocked(IPAddress ipAddress) { if (await IsIpBlockedAsync(ipAddress)) { BruteforceIpAddressAlert alert = new BruteforceIpAddressAlert(ipAddress); await _alertManager.AddAlertAsync(alert); } }