Skip to content

Standalone tool with .sln don't start scanning #261

@matteo-tosi

Description

@matteo-tosi

Environment:

  • Version: 5.6.6
  • Branch:
    • vs2019
    • vs2017
    • vs2015
  • Installation/Running method:
    • Visual Studio Extension
    • NuGet package
    • Standalone tool
      • DotNet Core Tool from NuGet
      • security-scan4x.zip from GitHub Release section
  • Operating System:
    • Windows
    • Linux
    • Mac

Describe the bug
DotNet Core Tool, with .sln file input build, elaborate but don't analyze projects.
In this point of Program.cs, in foreach body the add in the list of valid projects has been omitted:

List<Project> projects;
if (parsedOptions.solutionPath.EndsWith(".sln"))
{
Console.WriteLine($"Loading solution '{parsedOptions.solutionPath}'");
// Attach progress reporter so we print projects as they are loaded.
var solution = await workspace.OpenSolutionAsync(parsedOptions.solutionPath, new ConsoleProgressReporter(parsedOptions.verbose)).ConfigureAwait(false);
projects = new List<Project>(solution.Projects.Count());
foreach (var project in solution.Projects)
{
if (project.FilePath.EndsWith(".shproj") || project.FilePath.EndsWith(".sqlproj") || project.FilePath.EndsWith(".fsproj"))
{
Console.WriteLine($"Skipped: {project.FilePath} excluded from analysis");
continue;
}
var path = project.FilePath;
if (path.StartsWith(solutionDirectory))
path = path.Remove(0, solutionDirectory.Length);
if ((parsedOptions.includeProjects.Any() && !parsedOptions.includeProjects.Any(x => x.IsMatch(path))) ||
parsedOptions.excludeProjects.Any(x => x.IsMatch(path)))
{
Console.WriteLine($"Skipped: {project.FilePath} excluded from analysis");
continue;
}
}
}

Repro
Run tool with always .sln project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions