Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions SecurityCodeScan.Tool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ internal class ParsedOptions
public bool ignoreMsBuildErrors = false;
public bool showBanner = true;
public bool cwe = false;
public bool failOnWarning = false;
public HashSet<string> excludeWarnings = new HashSet<string>();
public HashSet<string> includeWarnings = new HashSet<string>();
public List<Glob> excludeProjects = new List<Glob>();
Expand Down Expand Up @@ -184,6 +185,7 @@ public void Parse(string[] args)
{ "n|no-banner", "(Optional) don't show the banner", r => { showBanner = r == null; } },
{ "v|verbose", "(Optional) more diagnostic messages", r => { verbose = r != null; } },
{ "ignore-msbuild-errors", "(Optional) Don't stop on MSBuild errors", r => { ignoreMsBuildErrors = r != null; } },
{ "f|fail-any-warn","(Optional) fail on any warnings with non-zero exit code", r => { failOnWarning = r != null; } },
{ "h|?|help", "show this message and exit", h => shouldShowHelp = h != null },
};

Expand Down Expand Up @@ -305,6 +307,13 @@ private static async Task<int> Main(string[] args)
Console.WriteLine($@"Completed in {elapsed:hh\:mm\:ss}");
Console.WriteLine($@"{count} warnings");

if (parsedOptions.failOnWarning && count > 0)
{
const int exitCode = 1;
Console.WriteLine($@"Exiting with {exitCode} due to warnings.");
return exitCode;
}

return 0;
}
}
Expand Down