Add C# 8 nullable annotations and fix null dereference issues (#139)

* Update dependencies.
This commit is contained in:
Gabe Stocco 2020-03-17 12:27:38 -07:00 коммит произвёл GitHub
Родитель 7759bd0876
Коммит 988836cc56
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
43 изменённых файлов: 4252 добавлений и 1159 удалений

Просмотреть файл

@ -56,8 +56,7 @@ namespace Microsoft.DevSkim.CLI
{
foreach(Attribute attr in property.GetCustomAttributes(true))
{
JsonPropertyAttribute jsonAttr = (attr as JsonPropertyAttribute);
if (jsonAttr != null && jsonAttr.PropertyName == propName)
if (attr is JsonPropertyAttribute jsonAttr && jsonAttr.PropertyName == propName)
{
return GetPropertyValue(property, rule);
}
@ -75,23 +74,23 @@ namespace Microsoft.DevSkim.CLI
private string GetPropertyValue(PropertyInfo property, Rule rule)
{
string result = string.Empty;
switch (property.PropertyType.Name)
switch (property.GetValue(rule))
{
case "String":
result = property.GetValue(rule) as string;
case string s:
result = s;
break;
case "String[]":
string[] list = (property.GetValue(rule) as string[]);
result = (list == null) ? string.Empty : string.Join(",", list);
case string[] list:
result = string.Join(",", list);
break;
case "SearchPattern[]":
case "SearchCondition[]":
case "CodeFix[]":
case SearchPattern[] _:
case SearchCondition[] _:
case CodeFix[] _:
result = "#UNSUPPORTED PROPERTY";
break;
default:
result = property.GetValue(rule).ToString();
result = property.GetValue(rule)?.ToString() ?? string.Empty;
break;
}
return result;

Просмотреть файл

@ -105,7 +105,7 @@ namespace Microsoft.DevSkim.CLI.Commands
return (int)ExitCode.CriticalError;
}
Verifier verifier = null;
Verifier? verifier = null;
if (_rulespath.Count() > 0)
{
// Setup the rules
@ -126,13 +126,17 @@ namespace Microsoft.DevSkim.CLI.Commands
if (!_ignoreDefaultRules)
{
Assembly assembly = Assembly.GetAssembly(typeof(Boundary));
Assembly? assembly = Assembly.GetAssembly(typeof(Boundary));
string filePath = "Microsoft.DevSkim.Resources.devskim-rules.json";
Stream resource = assembly.GetManifestResourceStream(filePath);
using (StreamReader file = new StreamReader(resource))
Stream? resource = assembly?.GetManifestResourceStream(filePath);
if (resource is Stream)
{
rules.AddString(file.ReadToEnd(), filePath, null);
}
using (StreamReader file = new StreamReader(resource))
{
rules.AddString(file.ReadToEnd(), filePath, null);
}
}
}
// Initialize the processor
@ -158,8 +162,8 @@ namespace Microsoft.DevSkim.CLI.Commands
}
Writer outputWriter = WriterFactory.GetWriter(_fileFormat,
(string.IsNullOrEmpty(_outputFile)) ? null : "text",
_outputFormat);
_outputFormat,
string.IsNullOrEmpty(_outputFile)?Console.Out: File.CreateText(_outputFile));
if (string.IsNullOrEmpty(_outputFile))
outputWriter.TextWriter = Console.Out;
else
@ -230,13 +234,11 @@ namespace Microsoft.DevSkim.CLI.Commands
issue.Rule.Severity,
issue.Rule.Name);
IssueRecord record = new IssueRecord()
{
Filename = filename,
Filesize = fileText.Length,
TextSample = fileText.Substring(issue.Boundary.Index, issue.Boundary.Length),
Issue = issue
};
IssueRecord record = new IssueRecord(
Filename: filename,
Filesize: fileText.Length,
TextSample: fileText.Substring(issue.Boundary.Index, issue.Boundary.Length),
Issue: issue);
outputWriter.WriteIssue(record);
}

Просмотреть файл

@ -51,7 +51,7 @@ namespace Microsoft.DevSkim.CLI.Commands
JsonSerializerSettings settings = new JsonSerializerSettings();
settings.Formatting = (_indent) ? Formatting.Indented : Formatting.None;
settings.Error = delegate (object sender, Newtonsoft.Json.Serialization.ErrorEventArgs e)
settings.Error = delegate (object? sender, Newtonsoft.Json.Serialization.ErrorEventArgs e)
{
e.ErrorContext.Handled = true;
};

Просмотреть файл

@ -10,17 +10,17 @@ namespace Microsoft.DevSkim.CLI.Commands
{
public static void Configure(CommandLineApplication app)
{
app.FullName = Assembly.GetEntryAssembly()
.GetCustomAttribute<AssemblyProductAttribute>()
app.FullName = Assembly.GetEntryAssembly()?
.GetCustomAttribute<AssemblyProductAttribute>()?
.Product;
app.Name = Assembly.GetEntryAssembly()
.GetCustomAttribute<AssemblyTitleAttribute>()
app.Name = Assembly.GetEntryAssembly()?
.GetCustomAttribute<AssemblyTitleAttribute>()?
.Title;
app.HelpOption("-?|-h|--help");
app.VersionOption("-v|--version", Assembly.GetEntryAssembly()
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
app.VersionOption("-v|--version", Assembly.GetEntryAssembly()?
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?
.InformationalVersion);
app.Command("analyze", AnalyzeCommand.Configure, false);

Просмотреть файл

@ -5,10 +5,19 @@ namespace Microsoft.DevSkim.CLI
{
class ErrorMessage
{
public string File { get; set; }
public string Path { get; set; }
public string? File { get; set; }
public string? Path { get; set; }
public string Message { get; set; }
public string RuleID { get; set; }
public string? RuleID { get; set; }
public bool Warning { get; set; }
public ErrorMessage(string Message, string? File = null, string? RuleID = null, string? Path = null, bool Warning = false)
{
this.File = File;
this.Path = Path;
this.Message = Message;
this.RuleID = RuleID;
this.Warning = Warning;
}
}
}

Просмотреть файл

@ -27,10 +27,10 @@ namespace Microsoft.DevSkim.CLI
Environment.Exit((int)ExitCode.CriticalError);
}
public string WriteRaw(string rawData)
public string? WriteRaw(string? rawData)
{
string fileName = "devskim_exception.log";
FileStream fs = null;
string? fileName = "devskim_exception.log";
FileStream? fs = null;
try
{
fs = new FileStream(fileName, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
@ -68,7 +68,7 @@ namespace Microsoft.DevSkim.CLI
string message = "Message: " + ex.Message + "\r\n";
message += "StackTrace: " + ex.StackTrace;
return WriteRaw(message);
return WriteRaw(message) ?? string.Empty;
}
}
}

Просмотреть файл

@ -5,9 +5,17 @@ namespace Microsoft.DevSkim.CLI
{
public class IssueRecord
{
public string Filename { get; set; }
public int Filesize { get; set; }
public string TextSample { get; set; }
public Issue Issue { get; set; }
public string Filename { get; }
public int Filesize { get; }
public string TextSample { get; }
public Issue Issue { get; }
public IssueRecord(string Filename, int Filesize, string TextSample, Issue Issue)
{
this.Filename = Filename;
this.Filesize = Filesize;
this.TextSample = TextSample;
this.Issue = Issue;
}
}
}

Просмотреть файл

@ -20,6 +20,8 @@
<PackageIcon>devskim-icon-128.png</PackageIcon>
<PackageProjectUrl>https://github.com/Microsoft/DevSkim</PackageProjectUrl>
<PackageVersion>0.0.0</PackageVersion>
<LangVersion>8.0</LangVersion>
<Nullable>Enable</Nullable>
</PropertyGroup>
<ItemGroup>
@ -36,7 +38,7 @@
</ItemGroup>
<ItemGroup>
<None Include="..\Content\LICENSE.txt" Pack="true" PackagePath=""/>
<None Include="..\Content\devskim-icon-128.png" Pack="true" PackagePath=""/>
<None Include="..\Content\LICENSE.txt" Pack="true" PackagePath="" />
<None Include="..\Content\devskim-icon-128.png" Pack="true" PackagePath="" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,17 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.DevSkim.CLI", "Microsoft.DevSkim.CLI.csproj", "{15A5C17C-D5B0-4F90-8DF4-D8C0EBAAC3D5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{15A5C17C-D5B0-4F90-8DF4-D8C0EBAAC3D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{15A5C17C-D5B0-4F90-8DF4-D8C0EBAAC3D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{15A5C17C-D5B0-4F90-8DF4-D8C0EBAAC3D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{15A5C17C-D5B0-4F90-8DF4-D8C0EBAAC3D5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

Просмотреть файл

@ -31,10 +31,11 @@ namespace Microsoft.DevSkim.CLI
{
List<string> missingTest = new List<string>();
foreach (Rule r in _rules)
foreach (Rule? r in _rules)
{
if (!_coverageList.Contains(r.Id))
missingTest.Add(r.Id);
if (r is Rule)
if (!_coverageList.Contains(r.Id))
missingTest.Add(r.Id);
}
if (missingTest.Count > 0)
@ -66,7 +67,7 @@ namespace Microsoft.DevSkim.CLI
// See if file name is a valid rule ID and preload default values
string defaultId = Path.GetFileNameWithoutExtension(fileName);
string[] languages = null;
string[]? languages = null;
Rule fileRule = _rules.FirstOrDefault(x => x.Id == defaultId);
if (fileRule != null)
languages = fileRule.AppliesTo;
@ -140,7 +141,7 @@ namespace Microsoft.DevSkim.CLI
return result;
}
private string[] GetLanguges(string header, string[] defaultLanguages)
private string[] GetLanguges(string header, string[]? defaultLanguages)
{
List<string> result = new List<string>();
@ -166,29 +167,32 @@ namespace Microsoft.DevSkim.CLI
Regex reg = new Regex("^line: *(\\d*)( *expect *)?(.*)", RegexOptions.Multiline);
MatchCollection matches = reg.Matches(header);
foreach(Match match in matches)
foreach(Match? match in matches)
{
int line;
List<string> ids = new List<string>();
if (int.TryParse(match.Groups[1].Value, out line))
if (match is { })
{
// get list of ids or used default one
if (match.Groups[2].Value.Trim() == "expect" && !string.IsNullOrEmpty(match.Groups[3].Value))
int line;
List<string> ids = new List<string>();
if (int.TryParse(match.Groups[1].Value, out line))
{
ids.AddRange(match.Groups[3].Value.Split(',')
.Select(x => x.Trim()));
// get list of ids or used default one
if (match.Groups[2].Value.Trim() == "expect" && !string.IsNullOrEmpty(match.Groups[3].Value))
{
ids.AddRange(match.Groups[3].Value.Split(',')
.Select(x => x.Trim()));
}
else
{
ids.Add(defaultId);
}
// Add line and ids to the result set
if (result.ContainsKey(line))
result[line].AddRange(ids);
else
result.Add(line, ids);
}
else
{
ids.Add(defaultId);
}
// Add line and ids to the result set
if (result.ContainsKey(line))
result[line].AddRange(ids);
else
result.Add(line, ids);
}
}
}
return result;

Просмотреть файл

@ -73,13 +73,7 @@ namespace Microsoft.DevSkim.CLI
// Check for null Id
if (rule.Id == null)
{
_messages.Add(new ErrorMessage()
{
Message = "Rule has empty ID",
Path = rule.Name ?? string.Empty,
File = rule.Source,
Warning = true
});
_messages.Add(new ErrorMessage(Message: "Rule has empty ID", Path: rule.Name, File: rule.Source, Warning: true));
}
else
{
@ -87,21 +81,9 @@ namespace Microsoft.DevSkim.CLI
Rule sameRule = _rules.FirstOrDefault(x => x.Id == rule.Id);
if (sameRule != null && sameRule != rule)
{
_messages.Add(new ErrorMessage()
{
Message = "Two or more rules have a same ID",
RuleID = sameRule.Id,
File = sameRule.Source,
Warning = true
});
_messages.Add(new ErrorMessage(Message: "Two or more rules have a same ID", RuleID: sameRule.Id, File: sameRule.Source, Warning: true));
_messages.Add(new ErrorMessage()
{
Message = "Two or more rules have a same ID",
RuleID = rule.Id,
File = rule.Source,
Warning = true
});
_messages.Add(new ErrorMessage(Message: "Two or more rules have a same ID", RuleID: rule.Id, File: rule.Source, Warning: true));
}
}
@ -112,14 +94,11 @@ namespace Microsoft.DevSkim.CLI
{
if (!languages.Contains(lang))
{
_messages.Add(new ErrorMessage()
{
Message = string.Format("Unknown language '{0}'", lang),
RuleID = rule.Id ?? string.Empty,
Path = "applies_to",
File = rule.Source,
Warning = true
});
_messages.Add(new ErrorMessage(Message: string.Format("Unknown language '{0}'", lang),
RuleID: rule.Id ?? string.Empty,
Path: "applies_to",
File: rule.Source,
Warning: true));
}
}
}
@ -142,14 +121,11 @@ namespace Microsoft.DevSkim.CLI
{
RuleSet rules = new RuleSet();
bool noProblem = true;
rules.OnDeserializationError += delegate (object sender, Newtonsoft.Json.Serialization.ErrorEventArgs e)
rules.OnDeserializationError += delegate (object? sender, Newtonsoft.Json.Serialization.ErrorEventArgs e)
{
ErrorMessage message = new ErrorMessage()
{
File = file,
Message = e.ErrorContext.Error.Message,
Path = e.ErrorContext.Path
};
ErrorMessage message = new ErrorMessage(File: file,
Message: e.ErrorContext.Error.Message,
Path: e.ErrorContext.Path);
if (e.ErrorContext.OriginalObject is Rule r && !string.IsNullOrEmpty(r.Id))
{

Просмотреть файл

@ -2,6 +2,7 @@
// Licensed under the MIT License.
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
@ -9,12 +10,13 @@ namespace Microsoft.DevSkim.CLI.Writers
{
public class JsonWriter : Writer
{
public JsonWriter(string formatString)
public JsonWriter(string formatString, TextWriter output)
{
if (string.IsNullOrEmpty(formatString))
_formatString = "%F%L%C%l%c%m%S%R%N%D";
else
_formatString = formatString;
this.TextWriter = output;
}
public override void WriteIssue(IssueRecord issue)
@ -38,15 +40,15 @@ namespace Microsoft.DevSkim.CLI.Writers
if (_formatString.Contains("%R"))
item.Add("rule_id", issue.Issue.Rule.Id);
if (_formatString.Contains("%N"))
item.Add("rule_name", issue.Issue.Rule.Name);
item.Add("rule_name", issue.Issue.Rule.Name ?? string.Empty);
if (_formatString.Contains("%S"))
item.Add("severity", issue.Issue.Rule.Severity);
if (_formatString.Contains("%D"))
item.Add("description", issue.Issue.Rule.Description);
item.Add("description", issue.Issue.Rule.Description ?? string.Empty);
if (_formatString.Contains("%m"))
item.Add("match", issue.TextSample);
if (_formatString.Contains("%T"))
item.Add("tags", issue.Issue.Rule.Tags);
item.Add("tags", issue.Issue.Rule.Tags ?? Array.Empty<string>());
// Store the result in the result list
jsonResult.Add(item);

Просмотреть файл

@ -3,6 +3,7 @@ using Microsoft.CodeAnalysis.Sarif.Readers;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text;
@ -10,10 +11,12 @@ namespace Microsoft.DevSkim.CLI.Writers
{
public class SarifWriter : Writer
{
public SarifWriter()
public SarifWriter(TextWriter textWriter)
{
_results = new List<Result>();
_rules = new Dictionary<string, CodeAnalysis.Sarif.Rule>();
this.TextWriter = textWriter;
}
public override void WriteIssue(IssueRecord issue)
@ -49,32 +52,34 @@ namespace Microsoft.DevSkim.CLI.Writers
sarifLog.Version = SarifVersion.OneZeroZero;
Run runItem = new Run();
runItem.Tool = new Tool();
Assembly entryAssembly = Assembly.GetEntryAssembly();
runItem.Tool.Name = entryAssembly.GetName()
if (Assembly.GetEntryAssembly() is Assembly entryAssembly)
{
runItem.Tool.Name = entryAssembly.GetName()
.Name;
runItem.Tool.FullName = entryAssembly.GetCustomAttribute<AssemblyProductAttribute>()
.Product;
runItem.Tool.FullName = entryAssembly.GetCustomAttribute<AssemblyProductAttribute>()?
.Product;
runItem.Tool.Version = entryAssembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
.InformationalVersion;
runItem.Results = _results;
runItem.Rules = _rules;
sarifLog.Runs = new List<Run>();
sarifLog.Runs.Add(runItem);
runItem.Tool.Version = entryAssembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?
.InformationalVersion;
runItem.Results = _results;
runItem.Rules = _rules;
sarifLog.Runs = new List<Run>();
sarifLog.Runs.Add(runItem);
JsonSerializerSettings settings = new JsonSerializerSettings()
{
ContractResolver = SarifContractResolver.Instance,
Formatting = Formatting.Indented
};
TextWriter.Write(JsonConvert.SerializeObject(sarifLog, settings));
TextWriter.Flush();
TextWriter.Close();
JsonSerializerSettings settings = new JsonSerializerSettings()
{
ContractResolver = SarifContractResolver.Instance,
Formatting = Formatting.Indented
};
TextWriter.Write(JsonConvert.SerializeObject(sarifLog, settings));
TextWriter.Flush();
TextWriter.Close();
}
}
private void MapRuleToResult(Rule rule, ref Result resultItem)
@ -96,7 +101,7 @@ namespace Microsoft.DevSkim.CLI.Writers
resultItem.RuleId = rule.Id;
resultItem.Message = rule.Name;
foreach (string tag in rule.Tags)
foreach (string tag in rule.Tags ?? Array.Empty<string>())
{
resultItem.Tags.Add(tag);
}

Просмотреть файл

@ -1,6 +1,9 @@
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT License.
using System;
using System.IO;
namespace Microsoft.DevSkim.CLI.Writers
{
/// <summary>
@ -19,12 +22,14 @@ namespace Microsoft.DevSkim.CLI.Writers
/// </summary>
public class SimpleTextWriter : Writer
{
public SimpleTextWriter(string formatString)
public SimpleTextWriter(string formatString, TextWriter writer)
{
if (string.IsNullOrEmpty(formatString))
_formatString = "%F:%L:%C:%l:%c [%S] %R %N";
else
_formatString = formatString;
this.TextWriter = writer;
}
public override void WriteIssue(IssueRecord issue)
@ -41,7 +46,7 @@ namespace Microsoft.DevSkim.CLI.Writers
output = output.Replace("%S", issue.Issue.Rule.Severity.ToString());
output = output.Replace("%D", issue.Issue.Rule.Description);
output = output.Replace("%m", issue.TextSample);
output = output.Replace("%T", string.Join(',',issue.Issue.Rule.Tags));
output = output.Replace("%T", string.Join(',',issue.Issue.Rule.Tags ?? Array.Empty<string>()));
TextWriter.WriteLine(output);
}

Просмотреть файл

@ -7,7 +7,10 @@ namespace Microsoft.DevSkim.CLI.Writers
{
public abstract class Writer
{
#nullable disable
public TextWriter TextWriter { get; set; }
#nullable restore
public abstract void WriteIssue(IssueRecord issue);
public abstract void FlushAndClose();
}

Просмотреть файл

@ -2,16 +2,14 @@
// Licensed under the MIT License.
using System;
using System.IO;
namespace Microsoft.DevSkim.CLI.Writers
{
public class WriterFactory
{
public static Writer GetWriter(string writerName, string defaultWritter, string format = null)
public static Writer GetWriter(string writerName, string format, TextWriter output)
{
if (string.IsNullOrEmpty(writerName))
writerName = defaultWritter;
if (string.IsNullOrEmpty(writerName))
writerName = "_dummy";
@ -20,11 +18,11 @@ namespace Microsoft.DevSkim.CLI.Writers
case "_dummy":
return new DummyWriter();
case "json":
return new JsonWriter(format);
return new JsonWriter(format, output);
case "text":
return new SimpleTextWriter(format);
return new SimpleTextWriter(format, output);
case "sarif":
return new SarifWriter();
return new SarifWriter(output);
default:
throw new Exception("wrong output");
}

Просмотреть файл

@ -32,7 +32,7 @@ namespace Microsoft.DevSkim.Tests
[ExpectedException(typeof(NullReferenceException))]
public void IsMatch_InvalidInputTest()
{
RuleProcessor processor = new RuleProcessor();
RuleProcessor processor = new RuleProcessor(new RuleSet());
// Langugage is null
Issue[] issues = processor.Analyze(null, "");
@ -43,7 +43,7 @@ namespace Microsoft.DevSkim.Tests
[ExpectedException(typeof(NullReferenceException))]
public void IsMatch_InvalidLanguageTest()
{
RuleProcessor processor = new RuleProcessor();
RuleProcessor processor = new RuleProcessor(new RuleSet());
string testString = "this is a test string";
// Langugage is empty

Просмотреть файл

@ -17,8 +17,7 @@ namespace Microsoft.DevSkim.Tests
public void AssignRuleSetTest()
{
RuleSet rules = RuleSet.FromDirectory(Path.Combine("rules","valid"), null);
RuleProcessor proc = new RuleProcessor();
proc.Rules = rules;
RuleProcessor proc = new RuleProcessor(rules);
Assert.AreSame(rules, proc.Rules, "Rulesets needs to match");
}

Просмотреть файл

@ -16,11 +16,8 @@ namespace Microsoft.DevSkim.VSExtension
{
public SkimShim()
{
processor = new RuleProcessor()
{
EnableSuppressions = true
};
ruleset = new RuleSet();
processor = new RuleProcessor(ruleset);
LoadRules();
}
@ -89,8 +86,6 @@ namespace Microsoft.DevSkim.VSExtension
{
Settings set = Settings.GetSettings();
ruleset = new RuleSet();
Assembly assembly = Assembly.GetAssembly(typeof(Boundary));
string filePath = "Microsoft.DevSkim.Resources.devskim-rules.json";
Stream resource = assembly.GetManifestResourceStream(filePath);
@ -116,7 +111,7 @@ namespace Microsoft.DevSkim.VSExtension
if (set.EnableManualReviewRules) processor.SeverityLevel |= Severity.ManualReview;
}
private RuleProcessor processor = new RuleProcessor();
private RuleProcessor processor;
private RuleSet ruleset;
private static SkimShim _instance = new SkimShim();

Просмотреть файл

@ -11,16 +11,16 @@ namespace Microsoft.DevSkim
public class CodeFix
{
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
public string? Name { get; set; }
[JsonProperty(PropertyName = "type")]
[JsonConverter(typeof(FixTypeConverter))]
public FixType FixType { get; set; }
public FixType? FixType { get; set; }
[JsonProperty(PropertyName = "pattern")]
public SearchPattern Pattern { get; set; }
public SearchPattern? Pattern { get; set; }
[JsonProperty(PropertyName = "replacement")]
public string Replacement { get; set; }
public string? Replacement { get; set; }
}
}

Просмотреть файл

@ -11,15 +11,15 @@ namespace Microsoft.DevSkim
class Comment
{
[JsonProperty(PropertyName ="language")]
public string[] Languages { get; set; }
public string[]? Languages { get; set; }
[JsonProperty(PropertyName ="inline")]
public string Inline{ get; set; }
public string? Inline{ get; set; }
[JsonProperty(PropertyName = "preffix")]
public string Preffix { get; set; }
public string? Prefix { get; set; }
[JsonProperty(PropertyName ="suffix")]
public string Suffix { get; set; }
public string? Suffix { get; set; }
}
}

Просмотреть файл

@ -11,9 +11,9 @@ namespace DevSkim
class ContentTypeRecord
{
[JsonProperty(PropertyName ="vs_type")]
public string VSType { get; set; }
public string? VSType { get; set; }
[JsonProperty(PropertyName ="ds_types")]
public string[] DSTypes { get; set; }
public string[]? DSTypes { get; set; }
}
}

Просмотреть файл

@ -20,25 +20,30 @@ namespace Microsoft.DevSkim
/// </summary>
class FixTypeConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
{
FixType svr = (FixType)value;
string svrstr = svr.ToString().ToLower();
switch (svr)
if (value is FixType svr)
{
case FixType.RegexReplace:
svrstr = "regex-replace";
break;
string svrstr = svr.ToString().ToLower();
switch (svr)
{
case FixType.RegexReplace:
svrstr = "regex-replace";
break;
}
writer.WriteValue(svrstr);
}
writer.WriteValue(svrstr);
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
{
var enumString = (string)reader.Value;
enumString = enumString.Replace("-", "");
return Enum.Parse(typeof(FixType), enumString, true);
if (reader.Value is string enumString)
{
enumString = enumString.Replace("-", "");
return Enum.Parse(typeof(FixType), enumString, true);
}
return null;
}
public override bool CanConvert(Type objectType)

Просмотреть файл

@ -9,17 +9,6 @@ namespace Microsoft.DevSkim
/// </summary>
public class Issue
{
/// <summary>
/// Creates new instance of Issue
/// </summary>
public Issue()
{
Rule = null;
Boundary = new Boundary();
StartLocation = new Location();
IsSuppressionInfo = false;
}
/// <summary>
/// Boundary of issue (index, length)
/// </summary>
@ -40,6 +29,14 @@ namespace Microsoft.DevSkim
/// </summary>
public Rule Rule { get; set; }
public Issue(Boundary Boundary, Location StartLocation, Location EndLocation, Rule Rule)
{
this.Boundary = Boundary;
this.StartLocation = StartLocation;
this.EndLocation = EndLocation;
this.Rule = Rule;
}
/// <summary>
/// True if Issue refers to suppression information
/// </summary>

Просмотреть файл

@ -20,15 +20,15 @@ namespace Microsoft.DevSkim
{
Assembly assembly = Assembly.GetExecutingAssembly();
// Load comments
Stream resource = assembly.GetManifestResourceStream("Microsoft.DevSkim.Resources.comments.json");
using (StreamReader file = new StreamReader(resource))
Stream? resource = assembly.GetManifestResourceStream("Microsoft.DevSkim.Resources.comments.json");
using (StreamReader file = new StreamReader(resource ?? new MemoryStream()))
{
Comments = JsonConvert.DeserializeObject<List<Comment>>(file.ReadToEnd());
}
// Load languages
resource = assembly.GetManifestResourceStream("Microsoft.DevSkim.Resources.languages.json");
using (StreamReader file = new StreamReader(resource))
using (StreamReader file = new StreamReader(resource ?? new MemoryStream()))
{
Languages = JsonConvert.DeserializeObject<List<LanguageInfo>>(file.ReadToEnd());
}
@ -50,8 +50,8 @@ namespace Microsoft.DevSkim
// Look for whole filename first
foreach (LanguageInfo item in Instance.Languages)
{
if (Array.Exists(item.Extensions, x => x.EndsWith(file)))
return item.Name;
if (Array.Exists(item.Extensions ?? Array.Empty<string>(), x => x.EndsWith(file)))
return item?.Name ?? string.Empty;
}
// Look for extension only ext is defined
@ -59,8 +59,8 @@ namespace Microsoft.DevSkim
{
foreach (LanguageInfo item in Instance.Languages)
{
if (Array.Exists(item.Extensions, x => x.EndsWith(ext)))
return item.Name;
if (Array.Exists(item.Extensions ?? Array.Empty<string>(), x => x.EndsWith(ext)))
return item.Name ?? string.Empty;
}
}
@ -80,7 +80,7 @@ namespace Microsoft.DevSkim
{
foreach (Comment comment in Instance.Comments)
{
if (comment.Languages.Contains(language.ToLower()))
if (comment.Languages.Contains(language.ToLower()) && comment.Inline is { })
return comment.Inline;
}
}
@ -101,8 +101,8 @@ namespace Microsoft.DevSkim
{
foreach (Comment comment in Instance.Comments)
{
if (comment.Languages.Contains(language.ToLower()))
return comment.Preffix;
if (comment.Languages.Contains(language.ToLower()) && comment.Prefix is { })
return comment.Prefix;
}
}
@ -122,7 +122,7 @@ namespace Microsoft.DevSkim
{
foreach (Comment comment in Instance.Comments)
{
if (comment.Languages.Contains(language.ToLower()))
if (comment.Languages.Contains(language.ToLower()) && comment.Suffix is { })
return comment.Suffix;
}
}
@ -142,7 +142,7 @@ namespace Microsoft.DevSkim
return names.ToArray();
}
private static Language _instance;
private static Language? _instance;
private static Language Instance
{
get

Просмотреть файл

@ -11,9 +11,9 @@ namespace Microsoft.DevSkim
class LanguageInfo
{
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
public string? Name { get; set; }
[JsonProperty(PropertyName = "extensions")]
public string[] Extensions { get; set; }
public string[]? Extensions { get; set; }
}
}

Просмотреть файл

@ -12,6 +12,8 @@
<Description>DevSkim is a framework and language analyzer that provides inline security analysis.</Description>
<PackageIcon>devskim-icon-128.png</PackageIcon>
<PackageProjectUrl>https://github.com/Microsoft/DevSkim</PackageProjectUrl>
<LangVersion>8.0</LangVersion>
<Nullable>Enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />

Просмотреть файл

@ -20,20 +20,26 @@ namespace Microsoft.DevSkim
/// </summary>
class PatternScopeConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
{
PatternScope svr = (PatternScope)value;
string svrstr = svr.ToString().ToLower();
if (value is PatternScope svr)
{
string svrstr = svr.ToString().ToLower();
writer.WriteValue(svrstr);
writer.WriteValue(svr.ToString().ToLower());
writer.WriteValue(svrstr);
writer.WriteValue(svr.ToString().ToLower());
}
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
{
var enumString = (string)reader.Value;
enumString = enumString.Replace("-", "");
return Enum.Parse(typeof(PatternScope), enumString, true);
if (reader.Value is string enumString)
{
enumString = enumString.Replace("-", "");
return Enum.Parse(typeof(PatternScope), enumString, true);
}
// TODO: Should there be a separate enum value for finding a null here?
return null;
}
public override bool CanConvert(Type objectType)

Просмотреть файл

@ -22,26 +22,32 @@ namespace Microsoft.DevSkim
/// </summary>
class PatternTypeConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
{
PatternType svr = (PatternType)value;
string svrstr = svr.ToString().ToLower();
switch (svr)
if (value is PatternType svr)
{
case PatternType.RegexWord:
svrstr = "regex-word";
break;
string svrstr = svr.ToString().ToLower();
switch (svr)
{
case PatternType.RegexWord:
svrstr = "regex-word";
break;
}
writer.WriteValue(svrstr);
writer.WriteValue(svr.ToString().ToLower());
}
writer.WriteValue(svrstr);
writer.WriteValue(svr.ToString().ToLower());
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
{
var enumString = (string)reader.Value;
enumString = enumString.Replace("-", "");
return Enum.Parse(typeof(PatternType), enumString, true);
if (reader.Value is string enumString)
{
enumString = enumString.Replace("-", "");
return Enum.Parse(typeof(PatternType), enumString, true);
}
return null;
}
public override bool CanConvert(Type objectType)

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

Просмотреть файл

@ -15,13 +15,13 @@ namespace Microsoft.DevSkim
/// Typically file, database or other storage.
/// </summary>
[JsonIgnore]
public string Source { get; set; }
public string? Source { get; set; }
/// <summary>
/// Optional tag assigned to the rule during runtime
/// </summary>
[JsonIgnore]
public string RuntimeTag { get; set; }
public string? RuntimeTag { get; set; }
/// <summary>
/// Runtime flag to disable the rule
@ -33,19 +33,19 @@ namespace Microsoft.DevSkim
public string Id { get; set; }
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
public string? Name { get; set; }
[JsonProperty(PropertyName = "overrides")]
public string[] Overrides { get; set; }
public string[]? Overrides { get; set; }
[JsonProperty(PropertyName = "schema_version")]
public int SchemaVersion { get; set; }
[JsonProperty(PropertyName = "tags")]
public string[] Tags { get; set; }
public string[]? Tags { get; set; }
[JsonProperty(PropertyName = "applies_to")]
public string[] AppliesTo { get; set; }
public string[]? AppliesTo { get; set; }
[JsonProperty(PropertyName = "severity")]
[JsonConverter(typeof(SeverityConverter))]
@ -55,21 +55,26 @@ namespace Microsoft.DevSkim
public Confidence Confidence { get; set; }
[JsonProperty(PropertyName = "description")]
public string Description { get; set; }
public string? Description { get; set; }
[JsonProperty(PropertyName = "recommendation")]
public string Recommendation { get; set; }
public string? Recommendation { get; set; }
[JsonProperty(PropertyName = "rule_info")]
public string RuleInfo { get; set; }
public string? RuleInfo { get; set; }
[JsonProperty(PropertyName = "patterns")]
public SearchPattern[] Patterns { get; set; }
public SearchPattern[]? Patterns { get; set; }
[JsonProperty(PropertyName = "conditions")]
public SearchCondition[] Conditions { get; set; }
public SearchCondition[]? Conditions { get; set; }
[JsonProperty(PropertyName = "fix_its")]
public CodeFix[] Fixes { get; set; }
public CodeFix[]? Fixes { get; set; }
public Rule(string Id)
{
this.Id = Id;
}
}
}

Просмотреть файл

@ -18,21 +18,14 @@ namespace Microsoft.DevSkim
/// <summary>
/// Creates instance of RuleProcessor
/// </summary>
public RuleProcessor()
{
public RuleProcessor(RuleSet rules)
{
_ruleset = rules;
_rulesCache = new Dictionary<string, IEnumerable<Rule>>();
EnableSuppressions = false;
EnableCache = true;
SeverityLevel = Severity.Critical | Severity.Important | Severity.Moderate | Severity.BestPractice;
}
/// <summary>
/// Creates instance of RuleProcessor
/// </summary>
public RuleProcessor(RuleSet rules) : this()
{
this.Rules = rules;
}
#region Public Methods
@ -49,9 +42,12 @@ namespace Microsoft.DevSkim
if (fixRecord.FixType == FixType.RegexReplace)
{
//TODO: Better pattern search and modifiers
Regex regex = new Regex(fixRecord.Pattern.Pattern);
result = regex.Replace(text, fixRecord.Replacement);
if (fixRecord.Pattern is { })
{
//TODO: Better pattern search and modifiers
Regex regex = new Regex(fixRecord.Pattern.Pattern);
result = regex.Replace(text, fixRecord.Replacement);
}
}
return result;
@ -97,7 +93,7 @@ namespace Microsoft.DevSkim
continue;
// Go through each matching pattern of the rule
foreach (SearchPattern pattern in rule.Patterns)
foreach (SearchPattern pattern in rule.Patterns ?? Array.Empty<SearchPattern>())
{
// Get all matches for the pattern
List<Boundary> matches = line.MatchPattern(pattern);
@ -123,36 +119,33 @@ namespace Microsoft.DevSkim
}
else
{
foreach (SearchCondition condition in rule.Conditions)
foreach (SearchCondition condition in rule.Conditions.Where(x => x is SearchCondition))
{
bool res = line.MatchPattern(condition.Pattern, match, condition);
if (res && condition.NegateFinding)
if (condition.Pattern is { })
{
passedConditions = false;
break;
}
if (!res && condition.NegateFinding)
{
passedConditions = true;
break;
}
if (!res)
{
passedConditions = false;
break;
bool res = line.MatchPattern(condition.Pattern, match, condition);
if (res && condition.NegateFinding)
{
passedConditions = false;
break;
}
if (!res && condition.NegateFinding)
{
passedConditions = true;
break;
}
if (!res)
{
passedConditions = false;
break;
}
}
}
}
if (passedConditions)
{
Issue issue = new Issue()
{
Boundary = match,
StartLocation = line.GetLocation(match.Index),
EndLocation = line.GetLocation(match.Index + match.Length),
Rule = rule
};
Issue issue = new Issue(Boundary: match, StartLocation: line.GetLocation(match.Index), EndLocation: line.GetLocation(match.Index + match.Length), Rule: rule);
matchList.Add(issue);
}
@ -169,8 +162,8 @@ namespace Microsoft.DevSkim
{
supp = new Suppression(textContainer,(lineNumber > 0)?lineNumber:result.StartLocation.Line);
// If rule is NOT being suppressed then report it
SuppressedIssue supissue = supp.GetSuppressedIssue(result.Rule.Id);
if (supissue == null)
var supissue = supp.GetSuppressedIssue(result.Rule.Id);
if (supissue is null)
{
resultsList.Add(result);
}

Просмотреть файл

@ -21,12 +21,12 @@ namespace Microsoft.DevSkim
/// </summary>
/// <param name="sender">Sender object</param>
/// <param name="e">Error arguments</param>
public delegate void DeserializationError(object sender, Newtonsoft.Json.Serialization.ErrorEventArgs e);
public delegate void DeserializationError(object? sender, Newtonsoft.Json.Serialization.ErrorEventArgs e);
/// <summary>
/// Event raised if deserialization error is encoutered while loading JSON rules
/// </summary>
public event DeserializationError OnDeserializationError;
public event DeserializationError? OnDeserializationError;
/// <summary>
/// Creates instance of Ruleset
@ -42,7 +42,7 @@ namespace Microsoft.DevSkim
/// <param name="path">Path to rules folder</param>
/// <param name="tag">Tag for the rules</param>
/// <returns>Ruleset</returns>
public static RuleSet FromDirectory(string path, string tag = null)
public static RuleSet FromDirectory(string path, string? tag = null)
{
RuleSet result = new RuleSet();
result.AddDirectory(path, tag);
@ -56,7 +56,7 @@ namespace Microsoft.DevSkim
/// <param name="filename">Filename with rules</param>
/// <param name="tag">Tag for the rules</param>
/// <returns>Ruleset</returns>
public static RuleSet FromFile(string filename, string tag = null)
public static RuleSet FromFile(string filename, string? tag = null)
{
RuleSet result = new RuleSet();
result.AddFile(filename, tag);
@ -71,7 +71,7 @@ namespace Microsoft.DevSkim
/// <param name="sourcename">Name of the source (file, stream, etc..)</param>
/// <param name="tag">Tag for the rules</param>
/// <returns>Ruleset</returns>
public static RuleSet FromString(string jsonstring, string sourcename = "string", string tag = null)
public static RuleSet FromString(string jsonstring, string sourcename = "string", string? tag = null)
{
RuleSet result = new RuleSet();
result.AddString(jsonstring, sourcename, tag);
@ -84,7 +84,7 @@ namespace Microsoft.DevSkim
/// </summary>
/// <param name="path">Path to rules folder</param>
/// <param name="tag">Tag for the rules</param>
public void AddDirectory(string path, string tag = null)
public void AddDirectory(string path, string? tag = null)
{
if (path == null)
throw new ArgumentNullException("path");
@ -103,7 +103,7 @@ namespace Microsoft.DevSkim
/// </summary>
/// <param name="filename">Filename with rules</param>
/// <param name="tag">Tag for the rules</param>
public void AddFile(string filename, string tag = null)
public void AddFile(string filename, string? tag = null)
{
if (string.IsNullOrEmpty(filename))
throw new ArgumentException("filename");
@ -123,16 +123,15 @@ namespace Microsoft.DevSkim
/// <param name="jsonstring">JSON string</param>
/// <param name="sourcename">Name of the source (file, stream, etc..)</param>
/// <param name="tag">Tag for the rules</param>
public void AddString(string jsonstring, string sourcename, string tag = null)
public void AddString(string jsonstring, string sourcename, string? tag = null)
{
List<Rule> ruleList = new List<Rule>();
JsonSerializerSettings settings = new JsonSerializerSettings()
{
Error = HandleDeserializationError
};
ruleList = JsonConvert.DeserializeObject<List<Rule>>(jsonstring, settings);
if (ruleList != null)
List<Rule>? ruleList = JsonConvert.DeserializeObject<List<Rule>>(jsonstring, settings);
if (ruleList is List<Rule>)
{
foreach (Rule r in ruleList)
{
@ -151,8 +150,11 @@ namespace Microsoft.DevSkim
r.Conditions = new SearchCondition[] { };
foreach (SearchCondition condition in r.Conditions)
{
SanitizePatternRegex(condition.Pattern);
{
if (condition.Pattern is { })
{
SanitizePatternRegex(condition.Pattern);
}
}
}
@ -233,7 +235,7 @@ namespace Microsoft.DevSkim
/// </summary>
/// <param name="sender">Sender object</param>
/// <param name="errorArgs">Error arguments</param>
private void HandleDeserializationError(object sender, Newtonsoft.Json.Serialization.ErrorEventArgs errorArgs)
private void HandleDeserializationError(object? sender, Newtonsoft.Json.Serialization.ErrorEventArgs errorArgs)
{
OnDeserializationError?.Invoke(sender, errorArgs);
}

Просмотреть файл

@ -8,10 +8,10 @@ namespace Microsoft.DevSkim
public class SearchCondition
{
[JsonProperty(PropertyName = "pattern")]
public SearchPattern Pattern { get; set; }
public SearchPattern? Pattern { get; set; }
[JsonProperty(PropertyName = "search_in")]
public string SearchIn { get; set; }
public string? SearchIn { get; set; }
[JsonProperty(PropertyName = "negate_finding")]
public bool NegateFinding { get; set; }

Просмотреть файл

@ -11,16 +11,16 @@ namespace Microsoft.DevSkim
public class SearchPattern
{
[JsonProperty(PropertyName = "pattern")]
public string Pattern { get; set; }
public string? Pattern { get; set; }
[JsonProperty(PropertyName = "type")]
[JsonConverter(typeof(PatternTypeConverter))]
public PatternType PatternType { get; set; }
public PatternType? PatternType { get; set; }
[JsonProperty(PropertyName = "modifiers")]
public string[] Modifiers { get; set; }
public string[]? Modifiers { get; set; }
[JsonProperty(PropertyName = "scopes")]
public PatternScope[] Scopes { get; set; }
public PatternScope[]? Scopes { get; set; }
}
}

Просмотреть файл

@ -39,29 +39,35 @@ namespace Microsoft.DevSkim
/// </summary>
class SeverityConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
{
Severity svr = (Severity)value;
string svrstr = svr.ToString().ToLower();
switch (svr)
if (value is Severity svr)
{
case Severity.BestPractice:
svrstr = "best-practice";
break;
case Severity.ManualReview:
svrstr = "manual-review";
break;
}
string svrstr = svr.ToString().ToLower();
writer.WriteValue(svrstr);
switch (svr)
{
case Severity.BestPractice:
svrstr = "best-practice";
break;
case Severity.ManualReview:
svrstr = "manual-review";
break;
}
writer.WriteValue(svrstr);
}
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
{
var enumString = (string)reader.Value;
enumString = enumString.Replace("-", "");
return Enum.Parse(typeof(Severity), enumString, true);
if (reader.Value is string enumString)
{
enumString = enumString.Replace("-", "");
return Enum.Parse(typeof(Severity), enumString, true);
}
return null;
}
public override bool CanConvert(Type objectType)

Просмотреть файл

@ -8,7 +8,7 @@ namespace Microsoft.DevSkim
/// </summary>
public class SuppressedIssue
{
public Boundary Boundary { get; set; }
public string ID { get; set; }
public Boundary? Boundary { get; set; }
public string? ID { get; set; }
}
}

Просмотреть файл

@ -20,10 +20,9 @@ namespace Microsoft.DevSkim
public const string pattern = KeywordPrefix + @"\s+" + KeywordIgnore + @"\s([a-zA-Z\d,:]+)(\s+" + KeywordUntil + @"\s\d{4}-\d{2}-\d{2}|)";
Regex reg = new Regex(pattern);
TextContainer _text;
TextContainer? _text;
int _lineNumber;
string _lineText;
Language _language;
/// <summary>
/// Creates new instance of Supressor
@ -31,7 +30,7 @@ namespace Microsoft.DevSkim
/// <param name="text">Text to work with</param>
public Suppression(string text)
{
if (text == null)
if (text is null)
{
throw new ArgumentNullException("text");
}
@ -42,8 +41,13 @@ namespace Microsoft.DevSkim
public Suppression(TextContainer text, int lineNumber)
{
if (text is null)
{
throw new ArgumentNullException("text");
}
_text = text;
_lineNumber = lineNumber;
_lineText = _text.GetLineContent(_lineNumber);
ParseLine();
}
@ -53,14 +57,10 @@ namespace Microsoft.DevSkim
/// </summary>
/// <param name="issueId">Rule ID</param>
/// <returns>True if rule is suppressed</returns>
public SuppressedIssue GetSuppressedIssue(string issueId)
public SuppressedIssue? GetSuppressedIssue(string issueId)
{
bool result = false;
SuppressedIssue issue = _issues.FirstOrDefault(x => x.ID == issueId || x.ID == KeywordAll);
if (issue != null)
result = true;
if (DateTime.Now < _expirationDate && result)
if (DateTime.Now < _expirationDate && issue != null)
return issue;
else
return null;
@ -71,9 +71,9 @@ namespace Microsoft.DevSkim
/// </summary>
private void ParseLine()
{
// If we have multiple lines to look at
if (_text != null)
{
_lineText = _text.GetLineContent(_lineNumber);
// If the line with the issue doesn't contain a suppression check the lines above it
if (!_lineText.Contains(KeywordPrefix))
{

Просмотреть файл

@ -60,7 +60,7 @@ namespace Microsoft.DevSkim
{
bool result = false;
Boundary scope = ParseSearchBoundary(boundary, condition.SearchIn);
Boundary scope = ParseSearchBoundary(boundary, condition.SearchIn ?? "finding-only");
string text = _content.Substring(scope.Index, scope.Length);
List<Boundary> matches = MatchPattern(pattern, text);
@ -181,10 +181,12 @@ namespace Microsoft.DevSkim
MatchCollection matches = patRegx.Matches(text);
if (matches.Count > 0)
{
foreach (Match m in matches)
foreach (Match? m in matches)
{
Boundary bound = new Boundary() { Index = m.Index, Length = m.Length };
matchList.Add(bound);
if (m is { })
{
matchList.Add(new Boundary() { Index = m.Index, Length = m.Length });
}
}
}

79
DevSkim-VSCode-Plugin/client/package-lock.json сгенерированный
Просмотреть файл

@ -461,9 +461,9 @@
}
},
"@types/node": {
"version": "11.15.6",
"resolved": "https://registry.npmjs.org/@types/node/-/node-11.15.6.tgz",
"integrity": "sha512-QylJmcJXqKCOhx1VE29kKA2wDjzVBQuKzoSJPykpelTmNQX/GAlPXgT1ZiIc6+sL81z66vXbrDexGale/JVIsQ==",
"version": "11.15.7",
"resolved": "https://registry.npmjs.org/@types/node/-/node-11.15.7.tgz",
"integrity": "sha512-3c3Kc7VIdE5UpqpmztRy7FU+turZgIurGnwpGFy/fRFOirfPc7ZnoFL83qVoqEDENJENqDhtGyQZ5fkXNQ6Qkw==",
"dev": true
},
"@types/semver": {
@ -500,9 +500,9 @@
"dev": true
},
"acorn": {
"version": "5.7.3",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz",
"integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==",
"version": "5.7.4",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.4.tgz",
"integrity": "sha512-1D++VG7BhrtvQpNbBzovKNc1FLGGEE/oGe7b9xJm/RFHMBeUaUGpluV9RLjZa47YFdPcDAenEYuq9pQPcMdLJg==",
"dev": true
},
"acorn-globals": {
@ -516,9 +516,9 @@
},
"dependencies": {
"acorn": {
"version": "6.4.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.0.tgz",
"integrity": "sha512-gac8OEcQ2Li1dxIEWGZzsp2BitJxwkwcOm0zHAJLcPJaVvm58FRnk6RkuLRpU1EujipU2ZFODv2P9DLMfnV8mw==",
"version": "6.4.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.1.tgz",
"integrity": "sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==",
"dev": true
}
}
@ -1672,7 +1672,8 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"aproba": {
"version": "1.2.0",
@ -1693,12 +1694,14 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -1713,17 +1716,20 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"core-util-is": {
"version": "1.0.2",
@ -1840,7 +1846,8 @@
"inherits": {
"version": "2.0.4",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"ini": {
"version": "1.3.5",
@ -1852,6 +1859,7 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@ -1866,6 +1874,7 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@ -1873,12 +1882,14 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"minipass": {
"version": "2.9.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@ -1897,6 +1908,7 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@ -1986,7 +1998,8 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"object-assign": {
"version": "4.1.1",
@ -1998,6 +2011,7 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@ -2083,7 +2097,8 @@
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"safer-buffer": {
"version": "2.1.2",
@ -2119,6 +2134,7 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@ -2138,6 +2154,7 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@ -2181,12 +2198,14 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"yallist": {
"version": "3.1.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
}
}
},
@ -4915,9 +4934,9 @@
}
},
"typescript": {
"version": "3.7.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.5.tgz",
"integrity": "sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw==",
"version": "3.8.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz",
"integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==",
"dev": true
},
"union-value": {
@ -5069,12 +5088,12 @@
"integrity": "sha512-JvONPptw3GAQGXlVV2utDcHx0BiY34FupW/kI6mZ5x06ER5DdPG/tXWMVHjTNULF5uKPOUUD0SaXg5QaubJL0A=="
},
"vscode-languageclient": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-6.1.0.tgz",
"integrity": "sha512-Tcp0VoOaa0YzxL4nEfK9tsmcy76Eo8jNLvFQZwh2c8oMm02luL8uGYPLQNAiZ3XGgegfcwiQFZMqbW7DNV0vxA==",
"version": "6.1.1",
"resolved": "https://registry.npmjs.org/vscode-languageclient/-/vscode-languageclient-6.1.1.tgz",
"integrity": "sha512-mB6d8Tg+82l8EFUfR+SBu0+lCshyKVgC5E5+MQ0/BJa+9AgeBjtG5npoGaCo4/VvWzK0ZRGm85zU5iRp1RYPIA==",
"requires": {
"semver": "^6.3.0",
"vscode-languageserver-protocol": "^3.15.2"
"vscode-languageserver-protocol": "^3.15.3"
},
"dependencies": {
"semver": {
@ -5085,9 +5104,9 @@
}
},
"vscode-languageserver-protocol": {
"version": "3.15.2",
"resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.15.2.tgz",
"integrity": "sha512-GdL05JKOgZ76RDg3suiGCl9enESM7iQgGw4x93ibTh4sldvZmakHmTeZ4iUApPPGKf6O3OVBtrsksBXnHYaxNg==",
"version": "3.15.3",
"resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.15.3.tgz",
"integrity": "sha512-zrMuwHOAQRhjDSnflWdJG+O2ztMWss8GqUUB8dXLR/FPenwkiBNkMIJJYfSN6sgskvsF0rHAoBowNQfbyZnnvw==",
"requires": {
"vscode-jsonrpc": "^5.0.1",
"vscode-languageserver-types": "3.15.1"

Просмотреть файл

@ -23,18 +23,18 @@
},
"devDependencies": {
"@types/jest": "^24.9.1",
"@types/node": "^11.15.6",
"@types/node": "^11.15.7",
"@types/semver": "^6.2.1",
"jest": "^24.9.0",
"jest-cli": "^24.9.0",
"rimraf": "^2.6.2",
"shx": "^0.3.2",
"ts-loader": "^6.2.1",
"typescript": "^3.7.5",
"vscode": "^1.1.36",
"rimraf": "^2.6.2"
"typescript": "^3.8.3",
"vscode": "^1.1.36"
},
"dependencies": {
"node-dir": "^0.1.17",
"vscode-languageclient": "^6.1"
"vscode-languageclient": "^6.1.1"
}
}

4610
DevSkim-VSCode-Plugin/server/package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -39,12 +39,12 @@
"devDependencies": {
"@types/jest": "^24.9.1",
"@types/node": "^6.14.9",
"jest": "^24.9.0",
"jest": "^25.1.0",
"rimraf": "^2.6.2",
"ts-jest": "^24.3.0",
"ts-loader": "^6.2.1",
"typescript": "^3.7.5",
"webpack": "^4.41.6",
"webpack-cli": "^3.3.11",
"rimraf": "^2.6.2"
"webpack-cli": "^3.3.11"
}
}