private void CompleteTask([NotNull] Tasks task, [NotNull] TaskProcessingResult result) { var lowResults = 0; var mediumResults = 0; var highResults = 0; var vulnerabilities = result.Todo.Concat(result.Reopen).Select(x => x.VulnerabilityInfo); foreach (var vulnerabilityInfo in vulnerabilities) { var severity = _vulnerabilitySeverityResolver.Resolve(vulnerabilityInfo.Type); switch (severity) { case VulnerabilitySeverityType.Low: lowResults++; break; case VulnerabilitySeverityType.Medium: mediumResults++; break; case VulnerabilitySeverityType.High: highResults++; break; case VulnerabilitySeverityType.Unknown: // TODO log severities of such type because they are new for us lowResults++; break; default: throw new ArgumentOutOfRangeException(); } var typeShort = _vulnerabilityShortTypeResolver.Resolve(vulnerabilityInfo.Type); typeShort = typeShort.Substring(0, Math.Min(10, typeShort.Length)); _taskResultRepository.Insert( new TaskResults { AdditionalExploitConditions = vulnerabilityInfo.AdditionalExploitConditions, Description = vulnerabilityInfo.Description, ExploitGraph = vulnerabilityInfo.Exploit, File = vulnerabilityInfo.File, Function = vulnerabilityInfo.Function, LineNumber = vulnerabilityInfo.NumberLine, Message = vulnerabilityInfo.Message, Place = vulnerabilityInfo.Place, RawLine = vulnerabilityInfo.RawLine, SeverityTypeInfo = severity == VulnerabilitySeverityType.Unknown ? VulnerabilitySeverityType.Low : severity, SourceFile = vulnerabilityInfo.SourceFile, TaskId = task.Id, Type = vulnerabilityInfo.Type, TypeShort = typeShort, LinePosition = vulnerabilityInfo.Position, IssueNumber = vulnerabilityInfo.IssueNumber, IssueUrl = vulnerabilityInfo.IssueUrl }); } task.FinishPostProcessing(_timeService.GetUtc()); task.LowSeverityVulns = lowResults; task.MediumSeverityVulns = mediumResults; task.HighSeverityVulns = highResults; task.FP = result.FalsePositiveAnnotations.Length + result.FalsePositivePairs.Length; task.Todo = result.Todo.Length; task.Reopen = result.Reopen.Length; task.Fixed = result.Fixed.Length; var previousTask = _taskRepository.GetPrevious(task); if (previousTask == null) { return; } task.IncrementFP = task.FP - previousTask.FP; task.IncrementFixed = task.Fixed - previousTask.Fixed; task.IncrementReopen = task.Reopen - previousTask.Reopen; task.IncrementTodo = task.Todo - previousTask.Todo; }
public void ShouldReturnUnknownVulnerabilityType() { var result = _target.Resolve("Halo"); result.ShouldBeEquivalentTo(VulnerabilitySeverityType.Unknown); }