NuGetDefense icon indicating copy to clipboard operation
NuGetDefense copied to clipboard

NuGetDefence.lib: scanning twice does not report the vulnerabilities on secound scan

Open chiluap opened this issue 1 year ago • 0 comments

Describe the bug When we scan twice, the vulnerable packages only get reported on the first scan.

To Reproduce Steps to reproduce the behavior:

  1. scan a project or solution (I used nuke)
using Nuke.Common;
using Nuke.Common.IO;
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using NuGetDefense;


[SuppressMessage("ReSharper", "InconsistentNaming")]
[SuppressMessage("ReSharper", "UnusedMember.Local")]
[SuppressMessage("ReSharper", "MissingAnnotation")]
partial class Build

{
    Target DependencyCheck => _ => _
        .DependsOn(Compile)
        .Executes(() =>
        {
            ScanOptions options = new ScanOptions()
            {
                ProjectFile = new FileInfo("./path/to/some.csproj"),
                CheckTransitiveDependencies = true,
                WarnOnly = false,    
            };
            Scanner scanner = new Scanner();
            int retVal = scanner.Scan(options);
            Console.WriteLine($"depcheck returned {retVal}");

            if (retVal != 0)
            {
                throw new Exception($"Dependency check failed, vulnarable packages detected {retVal}");
            }
        });
}
  1. run this twice

Expected behavior vulnarable packages get reported both times

Tools (please complete the following information):

  • IDE: [Rider 2023.2, VS2022, NUKE]
  • OS: [Windows 10 Latest Patch]

chiluap avatar Aug 28 '23 08:08 chiluap