Пример #1
0
        public List <Alert> GetAlerts(string baseUrl, int start, int count, string riskId)
        {
            List <Alert> alerts   = new List <Alert>();
            IApiResponse response = core.alerts(baseUrl, Convert.ToString(start), Convert.ToString(count), riskId);

            if (response != null && response is ApiResponseList)
            {
                ApiResponseList apiResponseList = (ApiResponseList)response;
                foreach (var alertSet in apiResponseList.List)
                {
                    ApiResponseSet apiResponseSet = (ApiResponseSet)alertSet;
                    alerts.Add(GetNewAlertFromAResponseSet(apiResponseSet));
                }
            }
            return(alerts);
        }
Пример #2
0
 private static Alert GetNewAlertFromAResponseSet(ApiResponseSet apiResponseSet)
 {
     return(new(apiResponseSet.Dictionary.TryGetDictionaryString("alert"), apiResponseSet.Dictionary.TryGetDictionaryString("url"))
     {
         Attack = apiResponseSet.Dictionary.TryGetDictionaryString("attack"),
         Confidence = string.IsNullOrWhiteSpace(apiResponseSet.Dictionary.TryGetDictionaryString("confidence")) ?
                      OWASPZAPDotNetAPI.Alert.ConfidenceLevel.Low :
                      (Alert.ConfidenceLevel)Enum.Parse(typeof(Alert.ConfidenceLevel), apiResponseSet.Dictionary.TryGetDictionaryString("confidence")),
         CweId = int.Parse(apiResponseSet.Dictionary.TryGetDictionaryString("cweid")),
         Description = apiResponseSet.Dictionary.TryGetDictionaryString("description"),
         Evidence = apiResponseSet.Dictionary.TryGetDictionaryString("evidence"),
         Other = apiResponseSet.Dictionary.TryGetDictionaryString("other"),
         Parameter = apiResponseSet.Dictionary.TryGetDictionaryString("param"),
         Reference = apiResponseSet.Dictionary.TryGetDictionaryString("reference"),
         Risk = string.IsNullOrWhiteSpace(apiResponseSet.Dictionary.TryGetDictionaryString("risk")) ?
                OWASPZAPDotNetAPI.Alert.RiskLevel.Low :
                (Alert.RiskLevel)Enum.Parse(typeof(Alert.RiskLevel), apiResponseSet.Dictionary.TryGetDictionaryString("risk")),
         Solution = apiResponseSet.Dictionary.TryGetDictionaryString("solution"),
         WascId = int.Parse(apiResponseSet.Dictionary.TryGetDictionaryString("wascid"))
     });
Пример #3
0
 private static Alert GetNewAlertFromAResponseSet(ApiResponseSet apiResponseSet)
 {
     return new Alert(apiResponseSet.Dictionary.TryGetDictionaryString("alert"), apiResponseSet.Dictionary.TryGetDictionaryString("url"))
     {
         Attack = apiResponseSet.Dictionary.TryGetDictionaryString("attack"),
         Confidence = string.IsNullOrWhiteSpace(apiResponseSet.Dictionary.TryGetDictionaryString("confidence")) ?
             Alert.ConfidenceLevel.Low :
             (Alert.ConfidenceLevel)Enum.Parse(typeof(Alert.ConfidenceLevel), apiResponseSet.Dictionary.TryGetDictionaryString("confidence")),
         CWEId = int.Parse(apiResponseSet.Dictionary.TryGetDictionaryString("cweid")),
         Description = apiResponseSet.Dictionary.TryGetDictionaryString("description"),
         Evidence = apiResponseSet.Dictionary.TryGetDictionaryString("evidence"),
         Other = apiResponseSet.Dictionary.TryGetDictionaryString("other"),
         Parameter = apiResponseSet.Dictionary.TryGetDictionaryString("param"),
         Reference = apiResponseSet.Dictionary.TryGetDictionaryString("reference"),
         Risk = string.IsNullOrWhiteSpace("") ?
             Alert.RiskLevel.Low :
             (Alert.RiskLevel)Enum.Parse(typeof(Alert.RiskLevel), apiResponseSet.Dictionary.TryGetDictionaryString("risk")),
         Solution = apiResponseSet.Dictionary.TryGetDictionaryString("solution"),
         WASCId = int.Parse(apiResponseSet.Dictionary.TryGetDictionaryString("wascid"))
     };
 }