コード例 #1
0
 public MethodFacts()
 {
     PackageVulnerabilityServiceMock = new Mock <IPackageVulnerabilityService>();
     GitHubVersionRangeParserMock    = new Mock <IGitHubVersionRangeParser>();
     Ingestor = new AdvisoryIngestor(
         PackageVulnerabilityServiceMock.Object,
         GitHubVersionRangeParserMock.Object);
 }
コード例 #2
0
        public override async Task Run()
        {
            Console.Write("Fetching vulnerabilities from GitHub...");
            var advisoryQueryService = _serviceProvider.GetRequiredService <IAdvisoryQueryService>();
            var advisories           = await advisoryQueryService.GetAdvisoriesSinceAsync(DateTimeOffset.MinValue, CancellationToken.None);

            Console.WriteLine($" FOUND {advisories.Count} advisories.");

            Console.WriteLine("Fetching vulnerabilities from DB...");
            var verifier = new PackageVulnerabilityServiceVerifier(_serviceProvider.GetRequiredService <IEntitiesContext>());
            var ingestor = new AdvisoryIngestor(verifier, new GitHubVersionRangeParser());
            await ingestor.IngestAsync(advisories);

            Console.WriteLine(verifier.HasErrors ?
                              "DB does not match GitHub API - see stderr output for details" :
                              "DB matches GitHub API!");
        }