/// <summary> /// Run the report. /// </summary> /// <param name="checkmarxApiSession"> /// A <see cref="ICheckmarxApiSession"/> used to run the report. This cannot be null. /// </param> /// <param name="options"> /// Command line options. This cannot be null. /// </param> /// <returns> /// The report results. /// </returns> /// <exception cref="ArgumentNullException"> /// <paramref name="checkmarxApiSession"/> cannot be null. /// </exception> /// <exception cref="CheckmarxErrorException"> /// Checkmarx returned an unexpected result or error. /// </exception> /// <exception cref="CheckmarxCommunicationException"> /// Communication with the Checkmarx server failed. /// </exception> public IList <string> Run(ICheckmarxApiSession checkmarxApiSession, CheckmarxReportOptions options) { if (checkmarxApiSession == null) { throw new ArgumentNullException(nameof(checkmarxApiSession)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } return(checkmarxApiSession.GetProjectScans() .AsParallel() .WithDegreeOfParallelism(ReportRunnerHelper.MaxParallelization) .Where(ReportRunnerHelper.GetProjectPredicate(options)) .Select( project => CheckmarxApiSessionHelper.GenerateLastScanCsvReport(checkmarxApiSession, project).ToString()) .ToList()); }
/// <summary> /// Run the report. /// </summary> /// <param name="checkmarxApiSession"> /// A <see cref="ICheckmarxApiSession"/> used to run the report. This cannot be null. /// </param> /// <param name="options"> /// Command line options. This cannot be null. /// </param> /// <returns> /// The report results. /// </returns> /// <exception cref="ArgumentNullException"> /// <paramref name="checkmarxApiSession"/> cannot be null. /// </exception> /// <exception cref="CheckmarxErrorException"> /// Checkmarx returned an unexpected result or error. /// </exception> /// <exception cref="CheckmarxCommunicationException"> /// Communication with the Checkmarx server failed. /// </exception> public IList <ScanResult> Run(ICheckmarxApiSession checkmarxApiSession, CheckmarxReportOptions options) { if (checkmarxApiSession == null) { throw new ArgumentNullException(nameof(checkmarxApiSession)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } return(checkmarxApiSession.GetProjectScans() .AsParallel() .WithDegreeOfParallelism(ReportRunnerHelper.MaxParallelization) .Where(ReportRunnerHelper.GetProjectPredicate(options)) .SelectMany( project => CheckmarxApiSessionHelper.GenerateLastScanXmlReport(checkmarxApiSession, project) .XPathSelectElements("//Result[@FalsePositive=\"False\"]") .Select(xmlNode => XmlNodeToScanResult(xmlNode, project.ProjectName))) .ToList()); }