Exemple #1
0
        private string TemplateReplace(string template)
        {
            //If account metadata does not exist create an empty account model
            if (model.Data.AccountModel == null)
            {
                model.Data.AccountModel = new AccountModel();
            }

            StringBuilder sb = new StringBuilder(template);

            return(sb.Replace("{{Severity}}", model.Data.SeverityName)
                   .Replace("{{DetectionDescription}}", model.Data.DetectDescription)
                   .Replace("{{DetectionName}}", model.Data.DetectName)
                   .Replace("{{Hostname}}", model.Data.ComputerName)
                   .Replace("{{IPAddress}}", model.Data.IPAddress ?? string.Empty)
                   .Replace("{{Username}}", model.Data.UserName)
                   .Replace("{{ProcessStartTime}}", model.Data.FormattedProcessStartTime.Value.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture))
                   .Replace("{{ProcessEndTime}}", model.Data.FormattedProcessEndTime.Value.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture))
                   .Replace("{{FileName}}", model.Data.FileName)
                   .Replace("{{DetectionName}}", model.Data.DetectName)
                   .Replace("{{FalconOrchestratorLink}}", config.FALCON_ORCHESTRATOR_URL + "/detection/edit/" + DatabaseHelpers.GetNextDetectionID() ?? string.Empty)
                   .Replace("{{FalconHostLink}}", model.Data.FalconHostLink)
                   .Replace("{{FilePath}}", model.Data.FilePath)
                   .Replace("{{FirstName}}", model.Data.AccountModel.FirstName ?? string.Empty)
                   .Replace("{{LastName}}", model.Data.AccountModel.LastName ?? string.Empty)
                   .Replace("{{Department}}", model.Data.AccountModel.Department ?? string.Empty)
                   .Replace("{{JobTitle}}", model.Data.AccountModel.JobTitle ?? string.Empty)
                   .Replace("{{EmailAddress}}", model.Data.AccountModel.EmailAddress ?? string.Empty)
                   .Replace("{{Manager}}", model.Data.AccountModel.Manager ?? string.Empty)
                   .Replace("{{Country}}", model.Data.AccountModel.Country ?? string.Empty)
                   .Replace("{{City}}", model.Data.AccountModel.City ?? string.Empty)
                   .Replace("{{PhoneNumber}}", model.Data.AccountModel.PhoneNumber ?? string.Empty)
                   .Replace("{{StateProvince}}", model.Data.AccountModel.StateProvince ?? string.Empty)
                   .Replace("{{StreetAddress}}", model.Data.AccountModel.StreetAddress ?? string.Empty)
                   .Replace("{{FalconOrchestratorLink}}", config.FALCON_ORCHESTRATOR_URL != null ? config.FALCON_ORCHESTRATOR_URL + "/detection/edit/" + DatabaseHelpers.GetNextDetectionID() : string.Empty)
                   .Replace("{{FalconHostLink}}", model.Data.FalconHostLink).ToString());
        }