Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.58] - 2025-06-09
## New Feature
Adds a `vs` output format to leverage the DevSkim CLI as a build task in a csproj.

## [1.0.57] - 2025-05-28
## Fix
Fix an issue handling non-ascii paths when launching LSP in VS Code Extension
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public record BaseAnalyzeCommandOptions : LogOptions
[Option('o', "output-format", HelpText = "Format for output text.", Default = SimpleTextWriter.DefaultFormat)]
public string OutputTextFormat { get; set; } = SimpleTextWriter.DefaultFormat;

[Option('f', "file-format", HelpText = "Format type for output. [text|sarif]", Default = "sarif")]
[Option('f', "file-format", HelpText = "Format type for output. [text|sarif|vs]", Default = "sarif")]
public string OutputFileFormat { get; set; } = "sarif";

[Option('s', "severity", HelpText = "Comma-separated Severities to match", Separator = ',', Default = new[] { Severity.Critical, Severity.Important, Severity.Moderate, Severity.BestPractice, Severity.ManualReview })]
Expand Down
17 changes: 17 additions & 0 deletions DevSkim-DotNet/Microsoft.DevSkim.CLI/Writers/SimpleTextWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

using System;
using System.IO;
using Microsoft.ApplicationInspector.RulesEngine;

namespace Microsoft.DevSkim.CLI.Writers
{
Expand All @@ -16,6 +17,7 @@ namespace Microsoft.DevSkim.CLI.Writers
/// - %R - rule id
/// - %N - rule name
/// - %S - severity (Critical, Important, etc.)
/// - %V - Visual Studio style severity (only warning or error)
/// - %m - string match
/// - %T - tags(comma-separated)
/// </summary>
Expand Down Expand Up @@ -62,12 +64,27 @@ public override void WriteIssue(DevSkim.IssueRecord issue)
output = output.Replace("%R", issue.Issue.Rule.Id);
output = output.Replace("%N", issue.Issue.Rule.Name);
output = output.Replace("%S", issue.Issue.Rule.Severity.ToString());
output = output.Replace("%V", DevSkimSevToVsSev(issue.Issue.Rule.Severity));
output = output.Replace("%D", issue.Issue.Rule.Description);
output = output.Replace("%m", issue.TextSample);
output = output.Replace("%T", string.Join(",", issue.Issue.Rule.Tags ?? Array.Empty<string>()));
TextWriter.WriteLine(output);
}

private string DevSkimSevToVsSev(Severity ruleSeverity)
{
return ruleSeverity switch
{
Severity.Unspecified => "unspecified",
Severity.Critical => "error",
Severity.Important => "warning",
Severity.Moderate => "warning",
Severity.BestPractice => "warning",
Severity.ManualReview => "warning",
_ => "unspecified"
};
}

private string _formatString;
}
}
3 changes: 3 additions & 0 deletions DevSkim-DotNet/Microsoft.DevSkim.CLI/Writers/WriterFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ public static Writer GetWriter(string writerName, string format, TextWriter outp
case "_dummy":
return new DummyWriter();

case "vs":
return new SimpleTextWriter("%F(%L,%l): %V %R: %D", output);

case "json":
return new JsonWriter(format, output);

Expand Down