From 7faaf3d1fbbbee51d09e3f16edbe226e798b79cc Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Sun, 21 Aug 2016 17:00:36 -0700 Subject: [PATCH 01/51] Implement smart validation in SarifCli tool --- BuildAndTest.cmd | 6 + src/Everything.sln | 16 +- src/References/Microsoft.Json.Pointer.dll | Bin 0 -> 11776 bytes .../Sarif.FunctionalTests.csproj | 4 +- src/Sarif/ConsoleLogger.cs | 2 +- src/Sarif/Writers/MimeType.cs | 3 + .../Properties/AssemblyInfo.cs | 10 ++ .../DoNotUseFriendlyNameAsRuleIdTests.cs | 23 +++ .../Rules/SkimmerTestsBase.cs | 116 +++++++++++++ .../SarifCli.FunctionalTests.csproj | 101 +++++++++++ .../RuleIdDoesNotMatchFriendlyName.sarif | 25 +++ ...eIdDoesNotMatchFriendlyName_Expected.sarif | 47 ++++++ .../RuleIdMatchesFriendlyName.sarif | 25 +++ .../RuleIdMatchesFriendlyName_Expected.sarif | 83 +++++++++ src/SarifCli.FunctionalTests/packages.config | 12 ++ src/SarifCli/AnalyzeCommand.cs | 159 ++++++++++++++++++ src/SarifCli/AnalyzeOptions.cs | 19 +++ src/{SarifValidator => SarifCli}/App.config | 0 src/SarifCli/ExportRulesMetadataCommand.cs | 24 +++ src/{SarifValidator => SarifCli}/Program.cs | 23 ++- src/SarifCli/Properties/AssemblyInfo.cs | 13 ++ .../Resources.Designer.cs | 22 ++- .../Resources.resx | 6 + .../Rules/DoNotUseFriendlyNameAsRuleId.cs | 64 +++++++ src/SarifCli/Rules/RuleIds.cs | 10 ++ src/SarifCli/Rules/RuleResources.Designer.cs | 81 +++++++++ src/SarifCli/Rules/RuleResources.resx | 126 ++++++++++++++ .../Rules/SarifValidationSkimmerBase.cs | 57 +++++++ src/SarifCli/SarifCli.csproj | 88 ++++++++++ src/SarifCli/SarifValidationContext.cs | 69 ++++++++ .../packages.config | 1 + src/SarifValidator/CommandLineOptions.cs | 16 -- src/SarifValidator/Properties/AssemblyInfo.cs | 10 -- src/SarifValidator/SarifValidator.csproj | 46 ----- 34 files changed, 1216 insertions(+), 91 deletions(-) create mode 100644 src/References/Microsoft.Json.Pointer.dll create mode 100644 src/SarifCli.FunctionalTests/Properties/AssemblyInfo.cs create mode 100644 src/SarifCli.FunctionalTests/Rules/DoNotUseFriendlyNameAsRuleIdTests.cs create mode 100644 src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs create mode 100644 src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj create mode 100644 src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdDoesNotMatchFriendlyName.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdDoesNotMatchFriendlyName_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdMatchesFriendlyName.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdMatchesFriendlyName_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/packages.config create mode 100644 src/SarifCli/AnalyzeCommand.cs create mode 100644 src/SarifCli/AnalyzeOptions.cs rename src/{SarifValidator => SarifCli}/App.config (100%) create mode 100644 src/SarifCli/ExportRulesMetadataCommand.cs rename src/{SarifValidator => SarifCli}/Program.cs (67%) create mode 100644 src/SarifCli/Properties/AssemblyInfo.cs rename src/{SarifValidator => SarifCli}/Resources.Designer.cs (76%) rename src/{SarifValidator => SarifCli}/Resources.resx (94%) create mode 100644 src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs create mode 100644 src/SarifCli/Rules/RuleIds.cs create mode 100644 src/SarifCli/Rules/RuleResources.Designer.cs create mode 100644 src/SarifCli/Rules/RuleResources.resx create mode 100644 src/SarifCli/Rules/SarifValidationSkimmerBase.cs create mode 100644 src/SarifCli/SarifCli.csproj create mode 100644 src/SarifCli/SarifValidationContext.cs rename src/{SarifValidator => SarifCli}/packages.config (66%) delete mode 100644 src/SarifValidator/CommandLineOptions.cs delete mode 100644 src/SarifValidator/Properties/AssemblyInfo.cs delete mode 100644 src/SarifValidator/SarifValidator.csproj diff --git a/BuildAndTest.cmd b/BuildAndTest.cmd index 8a6dd938f..a247a1208 100644 --- a/BuildAndTest.cmd +++ b/BuildAndTest.cmd @@ -114,6 +114,12 @@ if "%ERRORLEVEL%" NEQ "0" ( goto ExitFailed ) +src\packages\xunit.runner.console.2.1.0\tools\xunit.console.x86.exe bld\bin\SarifCli.FunctionalTests\AnyCPU_%Configuration%\Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.dll + +if "%ERRORLEVEL%" NEQ "0" ( +goto ExitFailed +) + goto Exit :ExitFailed diff --git a/src/Everything.sln b/src/Everything.sln index b689ba895..89c14a77d 100644 --- a/src/Everything.sln +++ b/src/Everything.sln @@ -33,7 +33,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sarif.Converters", "Sarif.C EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sarif.Viewer.VisualStudio.UnitTests", "Sarif.Viewer.VisualStudio.UnitTests\Sarif.Viewer.VisualStudio.UnitTests.csproj", "{D0210D4B-32A8-46CA-8BA4-0703517481B4}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SarifValidator", "SarifValidator\SarifValidator.csproj", "{0EBA700D-29E7-4FFF-8EBF-20B8C0EF9A98}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SarifCli", "SarifCli\SarifCli.csproj", "{0EBA700D-29E7-4FFF-8EBF-20B8C0EF9A98}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SarifCli.FunctionalTests", "SarifCli.FunctionalTests\SarifCli.FunctionalTests.csproj", "{859920F3-DB09-4C1D-9EAD-DFB1D7A03A46}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -201,6 +203,18 @@ Global {0EBA700D-29E7-4FFF-8EBF-20B8C0EF9A98}.Release|x64.Build.0 = Release|Any CPU {0EBA700D-29E7-4FFF-8EBF-20B8C0EF9A98}.Release|x86.ActiveCfg = Release|Any CPU {0EBA700D-29E7-4FFF-8EBF-20B8C0EF9A98}.Release|x86.Build.0 = Release|Any CPU + {859920F3-DB09-4C1D-9EAD-DFB1D7A03A46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {859920F3-DB09-4C1D-9EAD-DFB1D7A03A46}.Debug|Any CPU.Build.0 = Debug|Any CPU + {859920F3-DB09-4C1D-9EAD-DFB1D7A03A46}.Debug|x64.ActiveCfg = Debug|Any CPU + {859920F3-DB09-4C1D-9EAD-DFB1D7A03A46}.Debug|x64.Build.0 = Debug|Any CPU + {859920F3-DB09-4C1D-9EAD-DFB1D7A03A46}.Debug|x86.ActiveCfg = Debug|Any CPU + {859920F3-DB09-4C1D-9EAD-DFB1D7A03A46}.Debug|x86.Build.0 = Debug|Any CPU + {859920F3-DB09-4C1D-9EAD-DFB1D7A03A46}.Release|Any CPU.ActiveCfg = Release|Any CPU + {859920F3-DB09-4C1D-9EAD-DFB1D7A03A46}.Release|Any CPU.Build.0 = Release|Any CPU + {859920F3-DB09-4C1D-9EAD-DFB1D7A03A46}.Release|x64.ActiveCfg = Release|Any CPU + {859920F3-DB09-4C1D-9EAD-DFB1D7A03A46}.Release|x64.Build.0 = Release|Any CPU + {859920F3-DB09-4C1D-9EAD-DFB1D7A03A46}.Release|x86.ActiveCfg = Release|Any CPU + {859920F3-DB09-4C1D-9EAD-DFB1D7A03A46}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/References/Microsoft.Json.Pointer.dll b/src/References/Microsoft.Json.Pointer.dll new file mode 100644 index 0000000000000000000000000000000000000000..85ad5bae378c5c8825ebde3673b5a226a4801ee1 GIT binary patch literal 11776 zcmeHNeQ+Grk?%LVJG)-nYiW%?vCY`BY+07q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~h566zkt*1ZJNp+`El!99?hu?qI+XbU zrt#2N^4d|8W5Xj@>OAGd&HIzOVdfWVKK116#hX{{yQgX6qdi|YU;aY0?XWmGckLyoF8cO^ zzke>h@1K^xcWqPiqup;!`TTu%eC21yqw`|{u8v=Pd*jwH=Msp={>3-JW|KD?6OIhdJxvZ7((Ix*kI4-RZ+ihzm z(}}AP_kP+iQwzE=$y{5AIf(Zk=U%I~;~r+2`I2f_)6#?YDXVtoE)H-46c{my?D z1^HX^T}UhX0NaqjB$3!`!*>&Xcz01d%KSVMeB)1iCajZ~|7`^!>2eX$tA zu-pA>LQ29r`ylddfi%fN^5mya{DXrQ*%K!_oZM+r9~g)8I*bhYD-Q>sLcc&GI!wuP=rD z>L&7R?SAx^M$d%H1D+%0{@v)~G@gCQ-j_c~VO4R_!DFz^(~YBo$H0$2#yG0R^Y8l` zi#7PxPEzpZ+p@h_*sUwi(`jlll`Y4Z=O literal 0 HcmV?d00001 diff --git a/src/Sarif.FunctionalTests/Sarif.FunctionalTests.csproj b/src/Sarif.FunctionalTests/Sarif.FunctionalTests.csproj index 92c358c17..a8bae8b6c 100644 --- a/src/Sarif.FunctionalTests/Sarif.FunctionalTests.csproj +++ b/src/Sarif.FunctionalTests/Sarif.FunctionalTests.csproj @@ -73,6 +73,7 @@ + PreserveNewest @@ -742,9 +743,6 @@ PreserveNewest - - PreserveNewest - PreserveNewest diff --git a/src/Sarif/ConsoleLogger.cs b/src/Sarif/ConsoleLogger.cs index fae862a86..5db2283f5 100644 --- a/src/Sarif/ConsoleLogger.cs +++ b/src/Sarif/ConsoleLogger.cs @@ -206,7 +206,7 @@ public static string NormalizeMessage(string message, bool enquote) } return (enquote ? "\"" : "") + - message.Replace('"', '\'') + + message + (enquote ? "\"" : ""); } diff --git a/src/Sarif/Writers/MimeType.cs b/src/Sarif/Writers/MimeType.cs index 26f310767..62b9678b2 100644 --- a/src/Sarif/Writers/MimeType.cs +++ b/src/Sarif/Writers/MimeType.cs @@ -73,6 +73,8 @@ public static string DetermineFromFileExtension(Uri fileUri) public static readonly string Directory = "application/x-directory"; /// The MIME type used for CSharp files. public static readonly string CSharp = "text/x-csharp"; + /// The MIME type for SARIF files. + public static readonly string Sarif = "text/x-sarif"; private static bool HasExtension(string fileName, string extension) { @@ -117,6 +119,7 @@ private static bool HasExtension(string fileName, string extension) ImmutableArray.Create("text/python", "py"), ImmutableArray.Create("text/x-cshtml", "cshtml"), ImmutableArray.Create("text/ruby", "ruby", "gemspec"), + ImmutableArray.Create(MimeType.Sarif, "sarif"), ImmutableArray.Create("text/scss", "scss"), ImmutableArray.Create("text/typescript", "ts"), ImmutableArray.Create("text/x-vb", "vb"), diff --git a/src/SarifCli.FunctionalTests/Properties/AssemblyInfo.cs b/src/SarifCli.FunctionalTests/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..2b22cda5e --- /dev/null +++ b/src/SarifCli.FunctionalTests/Properties/AssemblyInfo.cs @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Reflection; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Sarif CLI Unit Tests")] +[assembly: AssemblyDescription("Unit tests for the SARIF command line interface tool")] diff --git a/src/SarifCli.FunctionalTests/Rules/DoNotUseFriendlyNameAsRuleIdTests.cs b/src/SarifCli.FunctionalTests/Rules/DoNotUseFriendlyNameAsRuleIdTests.cs new file mode 100644 index 000000000..a4c547329 --- /dev/null +++ b/src/SarifCli.FunctionalTests/Rules/DoNotUseFriendlyNameAsRuleIdTests.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.CodeAnalysis.Sarif.Cli.Rules; +using Xunit; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules +{ + public class DoNotUseFriendlyNameAsRuleIdTests : SkimmerTestsBase + { + [Fact] + public void DoNotUseFriendlyNameAsRuleId_Diagnostic_RuleIdMatchesFriendlyName() + { + Verify(new DoNotUseFriendlyNameAsRuleId(), "RuleIdMatchesFriendlyName.sarif"); + } + + [Fact] + public void DoNotUseFriendlyNameAsRuleId_NoDiagnostic_RuleIdDoesNotMatchFriendlyName() + { + Verify(new DoNotUseFriendlyNameAsRuleId(), "RuleIdDoesNotMatchFriendlyName.sarif"); + } + } +} diff --git a/src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs b/src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs new file mode 100644 index 000000000..203dc8afe --- /dev/null +++ b/src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs @@ -0,0 +1,116 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.IO; +using System.Linq; +using FluentAssertions; +using Microsoft.CodeAnalysis.Sarif.Cli.Rules; +using Microsoft.CodeAnalysis.Sarif.Readers; +using Microsoft.CodeAnalysis.Sarif.Writers; +using Newtonsoft.Json; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules +{ + public abstract class SkimmerTestsBase + { + private const string JsonSchemaFile = "Sarif.schema.json"; + private const string TestDataDirectory = "TestData"; + + protected void Verify(SarifValidationSkimmerBase skimmer, string testFileName) + { + string ruleName = skimmer.GetType().Name; + string testDirectory = Path.Combine(Environment.CurrentDirectory, TestDataDirectory, ruleName); + + string targetPath = Path.Combine(testDirectory, testFileName); + string expectedFilePath = MakeExpectedFilePath(testDirectory, testFileName); + string actualFilePath = MakeActualFilePath(testDirectory, testFileName); + + using (var logger = new SarifLogger( + actualFilePath, + new string[] { targetPath }, + verbose: false, + logEnvironment: false, + computeTargetsHash: false, + prereleaseInfo: null, + invocationTokensToRedact: null)) + { + logger.AnalysisStarted(); + + var context = new SarifValidationContext + { + Rule = skimmer, + Logger = logger, + TargetUri = new Uri(targetPath), + SchemaFilePath = JsonSchemaFile + }; + + skimmer.Initialize(context); + context.Logger.AnalyzingTarget(context); + + skimmer.Analyze(context); + + logger.AnalysisStopped(RuntimeConditions.None); + } + + string actualLogContents = File.ReadAllText(actualFilePath); + string expectedLogContents = File.ReadAllText(expectedFilePath); + + // We can't just compare the text of the log files because properties + // like start time, and absolute paths, will differ from run to run. + // Until SarifLogger has a "deterministic" option (see http://github.com/Microsoft/sarif-sdk/issues/500), + // we perform a selective compare of just the elements we care about. + SelectiveCompare(actualLogContents, expectedLogContents); + } + + private static void SelectiveCompare(string actualText, string expectedText) + { + var settings = new JsonSerializerSettings() + { + ContractResolver = SarifContractResolver.Instance + }; + + SarifLog actualLog = JsonConvert.DeserializeObject(actualText, settings); + SarifLog expectedLog = JsonConvert.DeserializeObject(expectedText, settings); + + SelectiveCompare(actualLog, expectedLog); + } + + private static void SelectiveCompare(SarifLog actualLog, SarifLog expectedLog) + { + Result[] actualResults = actualLog.Runs[0].Results.ToArray(); + Result[] expectedResults = expectedLog.Runs[0].Results.ToArray(); + + actualResults.Length.Should().Be(expectedResults.Length); + + for (int i = 0; i < actualResults.Length; ++i) + { + Result actualResult = actualResults[i]; + Result expectedResult = expectedResults[i]; + + actualResult.RuleId.Should().Be(expectedResult.RuleId); + + actualResult.Locations[0].AnalysisTarget.Region.ValueEquals( + expectedResult.Locations[0].AnalysisTarget.Region).Should().BeTrue(); + } + } + + private static string MakeExpectedFilePath(string testDirectory, string testFileName) + { + return MakeQualifiedFilePath(testDirectory, testFileName, "Expected"); + } + + private static string MakeActualFilePath(string testDirectory, string testFileName) + { + return MakeQualifiedFilePath(testDirectory, testFileName, "Actual"); + } + + private static string MakeQualifiedFilePath(string testDirectory, string testFileName, string qualifier) + { + string qualifiedFileName = + Path.GetFileNameWithoutExtension(testFileName) + "_" + qualifier + Path.GetExtension(testFileName); + + return Path.Combine(testDirectory, qualifiedFileName); + } + } +} diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj new file mode 100644 index 000000000..1249ae7f4 --- /dev/null +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -0,0 +1,101 @@ + + + + + {859920F3-DB09-4C1D-9EAD-DFB1D7A03A46} + Library + Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests + Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests + + + + + true + ..\TestKey.snk + + + + v4.5.1 + + + + ..\packages\FluentAssertions.4.2.1\lib\net45\FluentAssertions.dll + True + + + ..\packages\FluentAssertions.4.2.1\lib\net45\FluentAssertions.Core.dll + True + + + ..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll + True + + + + + + + + + + + ..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll + True + + + ..\packages\xunit.assert.2.1.0\lib\dotnet\xunit.assert.dll + True + + + ..\packages\xunit.extensibility.core.2.1.0\lib\dotnet\xunit.core.dll + True + + + ..\packages\xunit.extensibility.execution.2.1.0\lib\net45\xunit.execution.desktop.dll + True + + + + + + + + + + {8ceaea61-b1a2-4777-bcbe-c9a129a5f6c5} + Sarif.Driver + + + {0eba700d-29e7-4fff-8ebf-20b8c0ef9a98} + SarifCli + + + {cc9b247e-7103-4bf7-bdab-6e625b3680a8} + Sarif + + + + + Designer + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + + + + + + + \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdDoesNotMatchFriendlyName.sarif b/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdDoesNotMatchFriendlyName.sarif new file mode 100644 index 000000000..bb0b6bf98 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdDoesNotMatchFriendlyName.sarif @@ -0,0 +1,25 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0", + "version": "1.0.0" + }, + "results": [], + "rules": { + "ImportantRule": { + "id": "TST0001", + "name": "ImportantRule", + "shortDescription": "Important rule", + "fullDescription": "Important rule", + "messageFormats": { + "DefaultFormatId": "\"{0}\" violates an important rule." + } + } + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdDoesNotMatchFriendlyName_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdDoesNotMatchFriendlyName_Expected.sarif new file mode 100644 index 000000000..457f224ab --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdDoesNotMatchFriendlyName_Expected.sarif @@ -0,0 +1,47 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "4f730ffa-cc94-4b7b-ba08-23211cb25d03", + "tool": { + "name": "Sarif", + "fullName": "Sarif 1.5.28.0", + "version": "1.5.28.0", + "semanticVersion": "1.5.28", + "sarifLoggerVersion": "1.5.28.0", + "language": "en-US", + "properties": { + "Comments": "Object model and utilities for reading and writing files in the SARIF format.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Release/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdDoesNotMatchFriendlyName.sarif" + }, + "message": "Analyzing 'RuleIdDoesNotMatchFriendlyName.sarif'...", + "level": "note", + "time": "2016-08-23T22:55:51.110Z" + } + ], + "files": { + "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Release/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdDoesNotMatchFriendlyName.sarif": { + "mimeType": "text/x-sarif" + } + }, + "invocation": { + "commandLine": "src\\packages\\xunit.runner.console.2.1.0\\tools\\xunit.console.x86.exe bld\\bin\\SarifCli.FunctionalTests\\AnyCPU_Release\\Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.dll", + "startTime": "2016-08-23T22:55:51.109Z", + "endTime": "2016-08-23T22:55:51.190Z", + "processId": 9688, + "fileName": "C:\\Users\\lgolding\\AppData\\Local\\Temp\\bcef3d89-d123-4f33-b0de-1c3a541c8040\\bcef3d89-d123-4f33-b0de-1c3a541c8040\\assembly\\dl3\\acb70b02\\0b034856_91fdd101\\Sarif.dll", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli.FunctionalTests\\AnyCPU_Release" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdMatchesFriendlyName.sarif b/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdMatchesFriendlyName.sarif new file mode 100644 index 000000000..61f46e4af --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdMatchesFriendlyName.sarif @@ -0,0 +1,25 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0", + "version": "1.0.0" + }, + "results": [], + "rules": { + "ImportantRule": { + "id": "ImportantRule", + "name": "ImportantRule", + "shortDescription": "Important rule", + "fullDescription": "Important rule", + "messageFormats": { + "DefaultFormatId": "\"{0}\" violates an important rule." + } + } + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdMatchesFriendlyName_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdMatchesFriendlyName_Expected.sarif new file mode 100644 index 000000000..d4d58881f --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdMatchesFriendlyName_Expected.sarif @@ -0,0 +1,83 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "0ecc3107-1021-4ce7-87ff-a553d00bb644", + "tool": { + "name": "Sarif", + "fullName": "Sarif 1.5.28.0", + "version": "1.5.28.0", + "semanticVersion": "1.5.28", + "sarifLoggerVersion": "1.5.28.0", + "language": "en-US", + "properties": { + "Comments": "Object model and utilities for reading and writing files in the SARIF format.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0001", + "level": "warning", + "formattedRuleMessage": { + "formatId": "DefaultFormatId", + "arguments": [ + "RuleIdMatchesFriendlyName.sarif", + "ImportantRule" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Release/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdMatchesFriendlyName.sarif", + "region": { + "startLine": 13, + "startColumn": 27 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Release/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdMatchesFriendlyName.sarif" + }, + "message": "Analyzing 'RuleIdMatchesFriendlyName.sarif'...", + "level": "note", + "time": "2016-08-23T22:55:51.352Z" + } + ], + "rules": { + "SV0001": { + "id": "SV0001", + "name": "DoNotUseFriendlyNameAsRuleId", + "shortDescription": "Do not use the same string for a rule's id and name properties. The id property ...", + "fullDescription": "Do not use the same string for a rule's id and name properties. The id property must be a stable, opaque identifer such as \"SV0001\". The name property should be a string that is understandable to an end user, such as \"DoNotUserFriendlyNameAsRuleId\".", + "messageFormats": { + "DefaultFormatId": "In \"{0}\", the name and id properties of rule \"{1}\" are the same." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Release/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdMatchesFriendlyName.sarif": { + "mimeType": "text/x-sarif" + } + }, + "invocation": { + "commandLine": "src\\packages\\xunit.runner.console.2.1.0\\tools\\xunit.console.x86.exe bld\\bin\\SarifCli.FunctionalTests\\AnyCPU_Release\\Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.dll", + "startTime": "2016-08-23T22:55:51.352Z", + "endTime": "2016-08-23T22:55:51.434Z", + "processId": 9688, + "fileName": "C:\\Users\\lgolding\\AppData\\Local\\Temp\\bcef3d89-d123-4f33-b0de-1c3a541c8040\\bcef3d89-d123-4f33-b0de-1c3a541c8040\\assembly\\dl3\\acb70b02\\0b034856_91fdd101\\Sarif.dll", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli.FunctionalTests\\AnyCPU_Release" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/packages.config b/src/SarifCli.FunctionalTests/packages.config new file mode 100644 index 000000000..ad18c0e1b --- /dev/null +++ b/src/SarifCli.FunctionalTests/packages.config @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/SarifCli/AnalyzeCommand.cs b/src/SarifCli/AnalyzeCommand.cs new file mode 100644 index 000000000..a6243bd97 --- /dev/null +++ b/src/SarifCli/AnalyzeCommand.cs @@ -0,0 +1,159 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; +using Microsoft.CodeAnalysis.Sarif.Driver; +using Microsoft.Json.Schema; +using Microsoft.Json.Schema.Validation; + +namespace Microsoft.CodeAnalysis.Sarif.Cli +{ + internal class AnalyzeCommand : AnalyzeCommandBase + { + public override string Prerelease => VersionConstants.Prerelease; + + public override void ConfigureFromOptions(SarifValidationContext context, AnalyzeOptions analyzeOptions) + { + base.ConfigureFromOptions(context, analyzeOptions); + + context.SchemaFilePath = analyzeOptions.SchemaFilePath; + } + + private List _defaultPlugInAssemblies; + + public override IEnumerable DefaultPlugInAssemblies + { + get + { + if (_defaultPlugInAssemblies == null) + { + _defaultPlugInAssemblies = new List + { + this.GetType().Assembly + }; + } + + return _defaultPlugInAssemblies; + } + } + + protected override SarifValidationContext CreateContext(AnalyzeOptions options, IAnalysisLogger logger, RuntimeConditions runtimeErrors, string filePath = null) + { + SarifValidationContext context = base.CreateContext(options, logger, runtimeErrors, filePath); + context.SchemaFilePath = options.SchemaFilePath; + return context; + } + + protected override void AnalyzeTarget(IEnumerable> skimmers, SarifValidationContext context, HashSet disabledSkimmers) + { + // The base class knows how to invoke the skimmers that implement smart validation... + base.AnalyzeTarget(skimmers, context, disabledSkimmers); + + // ... but it doesn't know how to invoke schema validation, which has its own set of rules, + // so we do that ourselves. + Validate(context.TargetUri.LocalPath, context.SchemaFilePath, context.Logger); + } + + private int Validate(string instanceFilePath, string schemaFilePath, IAnalysisLogger logger) + { + int returnCode = 1; + + try + { + string instanceText = File.ReadAllText(instanceFilePath); + + returnCode = PerformSchemaValidation(instanceText, instanceFilePath, schemaFilePath, logger); + } + catch (JsonSyntaxException ex) + { + ReportResult(ex.Result, logger); + } + catch (SchemaValidationException ex) + { + ReportInvalidSchemaErrors(ex, schemaFilePath, logger); + } + catch (Exception ex) + { + LogToolNotification(logger, ex.Message, NotificationLevel.Error, ex); + } + + return returnCode; + } + + private int PerformSchemaValidation(string instanceText, string instanceFilePath, string schemaFilePath, IAnalysisLogger logger) + { + string schemaText = File.ReadAllText(schemaFilePath); + JsonSchema schema = SchemaReader.ReadSchema(schemaText, schemaFilePath); + + var validator = new Validator(schema); + + Result[] results = validator.Validate(instanceText, instanceFilePath); + ReportResults(results, logger); + + return results.Length; + } + + private static void ReportInvalidSchemaErrors( + SchemaValidationException ex, + string schemaFile, + IAnalysisLogger logger) + { + foreach (Result result in ex.Results) + { + result.SetAnalysisTargetUri(schemaFile); + + ReportResult(result, logger); + } + } + + private static void ReportResults( + Result[] results, + IAnalysisLogger logger) + { + foreach (Result result in results) + { + ReportResult(result, logger); + } + } + + private static void ReportResult(Result result, IAnalysisLogger logger) + { + Rule rule = Json.Schema.Sarif.RuleFactory.GetRuleFromRuleId(result.RuleId); + + logger.Log(rule, result); + } + + private static void LogToolNotification( + IAnalysisLogger logger, + string message, + NotificationLevel level = NotificationLevel.Note, + Exception ex = null) + { + ExceptionData exceptionData = null; + if (ex != null) + { + exceptionData = new ExceptionData + { + Kind = ex.GetType().FullName, + Message = ex.Message, + Stack = Stack.CreateStacks(ex).FirstOrDefault() + }; + } + + TextWriter writer = level == NotificationLevel.Error ? Console.Error : Console.Out; + writer.WriteLine(message); + + logger.LogToolNotification(new Notification + { + Level = level, + Message = message, + Exception = exceptionData + }); + } + } +} diff --git a/src/SarifCli/AnalyzeOptions.cs b/src/SarifCli/AnalyzeOptions.cs new file mode 100644 index 000000000..f7c723f18 --- /dev/null +++ b/src/SarifCli/AnalyzeOptions.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using CommandLine; +using Microsoft.CodeAnalysis.Sarif.Driver; + +namespace Microsoft.CodeAnalysis.Sarif.Cli +{ + [Verb("validate", HelpText = "Validate a SARIF file against the schema and against additional correctness rules.")] + internal class AnalyzeOptions : AnalyzeOptionsBase + { + [Option( + 'j', + "json-schema-file-path", + HelpText = "Path to the SARIF JSON schema.", + Required = true)] + public string SchemaFilePath { get; set; } + } +} diff --git a/src/SarifValidator/App.config b/src/SarifCli/App.config similarity index 100% rename from src/SarifValidator/App.config rename to src/SarifCli/App.config diff --git a/src/SarifCli/ExportRulesMetadataCommand.cs b/src/SarifCli/ExportRulesMetadataCommand.cs new file mode 100644 index 000000000..27f9e49c3 --- /dev/null +++ b/src/SarifCli/ExportRulesMetadataCommand.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Collections.Generic; +using System.Reflection; +using Microsoft.CodeAnalysis.Sarif.Driver; + +namespace Microsoft.CodeAnalysis.Sarif.Cli +{ + internal class ExportRulesMetadataCommand : ExportRulesMetadataCommandBase + { + public override IEnumerable DefaultPlugInAssemblies + { + get + { + return new Assembly[] { + this.GetType().Assembly + }; + } + } + + public override string Prerelease { get { return VersionConstants.Prerelease; } } + } +} diff --git a/src/SarifValidator/Program.cs b/src/SarifCli/Program.cs similarity index 67% rename from src/SarifValidator/Program.cs rename to src/SarifCli/Program.cs index f3886d873..213e37fa1 100644 --- a/src/SarifValidator/Program.cs +++ b/src/SarifCli/Program.cs @@ -2,35 +2,34 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; -using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Reflection; using CommandLine; +using Microsoft.CodeAnalysis.Sarif.Driver; -namespace Microsoft.CodeAnalysis.Sarif.SarifValidator +namespace Microsoft.CodeAnalysis.Sarif.Cli { internal class Program { private static int Main(string[] args) - { - return Parser.Default.ParseArguments(args) - .MapResult( - options => Run(options), - errs => 1); - } - - private static int Run(CommandLineOptions options) { Banner(); - return 0; + return Parser.Default.ParseArguments< + AnalyzeOptions, + ExportRulesMetadataOptions + >(args) + .MapResult( + (AnalyzeOptions analyzeOptions) => new AnalyzeCommand().Run(analyzeOptions), + (ExportRulesMetadataOptions exportRulesMetadataOptions) => new ExportRulesMetadataCommand().Run(exportRulesMetadataOptions), + errs => 1); } private static void Banner() { Assembly entryAssembly = Assembly.GetEntryAssembly(); - IEnumerable attributes = entryAssembly.GetCustomAttributes(); + System.Collections.Generic.IEnumerable attributes = entryAssembly.GetCustomAttributes(); var titleAttribute = attributes.Single(a => a is AssemblyTitleAttribute) as AssemblyTitleAttribute; string programName = titleAttribute.Title; diff --git a/src/SarifCli/Properties/AssemblyInfo.cs b/src/SarifCli/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..1d96b9553 --- /dev/null +++ b/src/SarifCli/Properties/AssemblyInfo.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Reflection; +using System.Runtime.CompilerServices; + +[assembly: AssemblyTitle("SARIF Command Line Interface")] +[assembly: AssemblyDescription("Command line tool for working with SARIF log files.")] + +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] + +[assembly: InternalsVisibleTo("Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100433fbf156abe9718142bdbd48a440e779a1b708fd21486ee0ae536f4c548edf8a7185c1e3ac89ceef76c15b8cc2497906798779a59402f9b9e27281fb15e7111566cdc9a9f8326301d45320623c5222089cf4d0013f365ae729fb0a9c9d15138042825cd511a0f3d4887a7b92f4c2749f81b410813d297b73244cf64995effb1")] \ No newline at end of file diff --git a/src/SarifValidator/Resources.Designer.cs b/src/SarifCli/Resources.Designer.cs similarity index 76% rename from src/SarifValidator/Resources.Designer.cs rename to src/SarifCli/Resources.Designer.cs index 0b18f83f6..66ab1efce 100644 --- a/src/SarifValidator/Resources.Designer.cs +++ b/src/SarifCli/Resources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace Microsoft.CodeAnalysis.Sarif.SarifValidator { +namespace Microsoft.CodeAnalysis.Sarif.Cli { using System; @@ -39,7 +39,7 @@ internal Resources() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.CodeAnalysis.Sarif.SarifValidator.Resources", typeof(Resources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.CodeAnalysis.Sarif.Cli.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; @@ -68,5 +68,23 @@ internal static string Banner { return ResourceManager.GetString("Banner", resourceCulture); } } + + /// + /// Looks up a localized string similar to A context object was reinitialized with a new target URI.. + /// + internal static string ErrorIllegalContextReuse { + get { + return ResourceManager.GetString("ErrorIllegalContextReuse", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The rule id "{0}" does not match the expected format for rule ids from the JSON schema validator.. + /// + internal static string ErrorUnrecognizedSchemaValidationRuleId { + get { + return ResourceManager.GetString("ErrorUnrecognizedSchemaValidationRuleId", resourceCulture); + } + } } } diff --git a/src/SarifValidator/Resources.resx b/src/SarifCli/Resources.resx similarity index 94% rename from src/SarifValidator/Resources.resx rename to src/SarifCli/Resources.resx index 145eb0e32..db34e73d7 100644 --- a/src/SarifValidator/Resources.resx +++ b/src/SarifCli/Resources.resx @@ -120,4 +120,10 @@ {0} version {1} + + A context object was reinitialized with a new target URI. + + + The rule id "{0}" does not match the expected format for rule ids from the JSON schema validator. + \ No newline at end of file diff --git a/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs b/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs new file mode 100644 index 000000000..ac834b80b --- /dev/null +++ b/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs @@ -0,0 +1,64 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules +{ + public class DoNotUseFriendlyNameAsRuleId : SarifValidationSkimmerBase + { + public override string FullDescription => RuleResources.SV0001_DoNotUseFriendlyNameAsRuleIdDescription; + + public override Uri HelpUri => + new Uri("https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html"); + + /// + /// SV0001 + /// + public override string Id => RuleIds.DoNotUseFriendlyNameAsRuleId; + + protected override IEnumerable FormatIds + { + get + { + return new string[] + { + nameof(RuleResources.SV0001_DefaultFormatId) + }; + } + } + + protected override void AnalyzeCore(SarifValidationContext context) + { + SarifLog log = context.InputLog; + if (log.Runs != null) + { + Run[] runs = log.Runs.ToArray(); + for (int iRun = 0; iRun < runs.Length; ++iRun) + { + Run run = runs[iRun]; + if (run.Rules != null) + { + Rule[] rules = run.Rules.Values.ToArray(); + for (int iRule = 0; iRule < rules.Length; ++iRule) + { + Rule rule = rules[iRule]; + if (rule.Id != null + && rule.Name != null + && rule.Id.Equals(rule.Name, StringComparison.OrdinalIgnoreCase)) + { + string jPointerValue = $"/runs/{iRun}/rules/{rule.Id}"; + Region region = GetRegionFromJPointer(jPointerValue, context); + + context.Logger.Log(this, + RuleUtilities.BuildResult(ResultLevel.Warning, context, region, nameof(RuleResources.SV0001_DefaultFormatId), rule.Id)); + } + } + } + } + } + } + } +} diff --git a/src/SarifCli/Rules/RuleIds.cs b/src/SarifCli/Rules/RuleIds.cs new file mode 100644 index 000000000..2374cbcfb --- /dev/null +++ b/src/SarifCli/Rules/RuleIds.cs @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules +{ + public static class RuleIds + { + public const string DoNotUseFriendlyNameAsRuleId = "SV0001"; + } +} diff --git a/src/SarifCli/Rules/RuleResources.Designer.cs b/src/SarifCli/Rules/RuleResources.Designer.cs new file mode 100644 index 000000000..0773aa8ca --- /dev/null +++ b/src/SarifCli/Rules/RuleResources.Designer.cs @@ -0,0 +1,81 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class RuleResources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal RuleResources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.CodeAnalysis.Sarif.Cli.Rules.RuleResources", typeof(RuleResources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to In "{0}", the name and id properties of rule "{1}" are the same.. + /// + internal static string SV0001_DefaultFormatId { + get { + return ResourceManager.GetString("SV0001_DefaultFormatId", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Do not use the same string for a rule's id and name properties. The id property must be a stable, opaque identifer such as "SV0001". The name property should be a string that is understandable to an end user, such as "DoNotUserFriendlyNameAsRuleId".. + /// + internal static string SV0001_DoNotUseFriendlyNameAsRuleIdDescription { + get { + return ResourceManager.GetString("SV0001_DoNotUseFriendlyNameAsRuleIdDescription", resourceCulture); + } + } + } +} diff --git a/src/SarifCli/Rules/RuleResources.resx b/src/SarifCli/Rules/RuleResources.resx new file mode 100644 index 000000000..addf9cbad --- /dev/null +++ b/src/SarifCli/Rules/RuleResources.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + In "{0}", the name and id properties of rule "{1}" are the same. + + + Do not use the same string for a rule's id and name properties. The id property must be a stable, opaque identifer such as "SV0001". The name property should be a string that is understandable to an end user, such as "DoNotUserFriendlyNameAsRuleId". + + \ No newline at end of file diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs new file mode 100644 index 000000000..d364f30af --- /dev/null +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.IO; +using System.Resources; +using Microsoft.CodeAnalysis.Sarif.Driver; +using Microsoft.CodeAnalysis.Sarif.Readers; +using Microsoft.Json.Pointer; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules +{ + public abstract class SarifValidationSkimmerBase : SkimmerBase + { + protected override ResourceManager ResourceManager => RuleResources.ResourceManager; + + public override void Analyze(SarifValidationContext context) + { + JsonSerializerSettings settings = new JsonSerializerSettings + { + ContractResolver = SarifContractResolver.Instance + }; + + context.InputLogContents = File.ReadAllText(context.TargetUri.LocalPath); + context.InputLog = JsonConvert.DeserializeObject(context.InputLogContents, settings); + + AnalyzeCore(context); + } + + protected abstract void AnalyzeCore(SarifValidationContext context); + + protected Region GetRegionFromJPointer(string jPointerValue, SarifValidationContext context) + { + if (context.InputLogToken == null) + { + context.InputLogToken = JToken.Parse(context.InputLogContents); + } + + JsonPointer jPointer = new JsonPointer(jPointerValue); + JToken jToken = jPointer.Evaluate(context.InputLogToken); + IJsonLineInfo lineInfo = jToken; + + Region region = null; + if (lineInfo.HasLineInfo()) + { + region = new Region + { + StartLine = lineInfo.LineNumber, + StartColumn = lineInfo.LinePosition + }; + } + + return region; + } + } +} diff --git a/src/SarifCli/SarifCli.csproj b/src/SarifCli/SarifCli.csproj new file mode 100644 index 000000000..7e690d0f1 --- /dev/null +++ b/src/SarifCli/SarifCli.csproj @@ -0,0 +1,88 @@ + + + + {0EBA700D-29E7-4FFF-8EBF-20B8C0EF9A98} + Exe + Microsoft.CodeAnalysis.Sarif.Cli + SarifCli + true + + + true + ..\..\GeneratedKey.snk + + + + v4.5.1 + + + + ..\packages\CommandLineParser.2.0.275-beta\lib\net45\CommandLine.dll + True + + + ..\References\Microsoft.Json.Schema.dll + + + ..\References\Microsoft.Json.Pointer.dll + + + ..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll + True + + + + + + + + + + + + + + + True + True + RuleResources.resx + + + + + + + + + + True + True + Resources.resx + + + + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + ResXFileCodeGenerator + RuleResources.Designer.cs + + + + + {8CEAEA61-B1A2-4777-BCBE-C9A129A5F6C5} + Sarif.Driver + + + {cc9b247e-7103-4bf7-bdab-6e625b3680a8} + Sarif + + + + \ No newline at end of file diff --git a/src/SarifCli/SarifValidationContext.cs b/src/SarifCli/SarifValidationContext.cs new file mode 100644 index 000000000..39902874e --- /dev/null +++ b/src/SarifCli/SarifValidationContext.cs @@ -0,0 +1,69 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.IO; +using Newtonsoft.Json.Linq; + +namespace Microsoft.CodeAnalysis.Sarif.Cli +{ + public class SarifValidationContext : IAnalysisContext + { + public bool IsValidAnalysisTarget + { + get + { + return Path.GetExtension(TargetUri.LocalPath).Equals(".sarif", StringComparison.OrdinalIgnoreCase); + } + } + + public IAnalysisLogger Logger { get; set; } + + public string MimeType + { + get { return Microsoft.CodeAnalysis.Sarif.Writers.MimeType.Sarif; } + set { throw new InvalidOperationException(); } + } + + public PropertiesDictionary Policy { get; set; } + + public IRule Rule { get; set; } + + public RuntimeConditions RuntimeErrors { get; set; } + + public Exception TargetLoadException { get; set; } + + private Uri _uri; + + public Uri TargetUri + { + get + { + return _uri; + } + + set + { + if (_uri != null) + { + throw new InvalidOperationException(Resources.ErrorIllegalContextReuse); + } + + _uri = value; + } + } + + public string SchemaFilePath { get; internal set; } + + public SarifLog InputLog { get; internal set; } + + public string InputLogContents { get; internal set; } + + public JToken InputLogToken { get; internal set; } + + public void Dispose() + { + // Nothing to dispose. + } + } +} diff --git a/src/SarifValidator/packages.config b/src/SarifCli/packages.config similarity index 66% rename from src/SarifValidator/packages.config rename to src/SarifCli/packages.config index 7054a28c4..842b847ba 100644 --- a/src/SarifValidator/packages.config +++ b/src/SarifCli/packages.config @@ -1,4 +1,5 @@  + \ No newline at end of file diff --git a/src/SarifValidator/CommandLineOptions.cs b/src/SarifValidator/CommandLineOptions.cs deleted file mode 100644 index 94b67df59..000000000 --- a/src/SarifValidator/CommandLineOptions.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using CommandLine; - -namespace Microsoft.CodeAnalysis.Sarif.SarifValidator -{ - internal class CommandLineOptions - { - [Value(0, - MetaName = "", - HelpText = "Path to the SARIF log file to be validated.", - Required = true)] - public string InputFilePath { get; set; } - } -} diff --git a/src/SarifValidator/Properties/AssemblyInfo.cs b/src/SarifValidator/Properties/AssemblyInfo.cs deleted file mode 100644 index b1da6e5ae..000000000 --- a/src/SarifValidator/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Reflection; - -[assembly: AssemblyTitle("SARIF Validation Tool")] -[assembly: AssemblyDescription("Command line tool for validating SARIF log files.")] - -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/src/SarifValidator/SarifValidator.csproj b/src/SarifValidator/SarifValidator.csproj deleted file mode 100644 index 4ce2d3582..000000000 --- a/src/SarifValidator/SarifValidator.csproj +++ /dev/null @@ -1,46 +0,0 @@ - - - - {0EBA700D-29E7-4FFF-8EBF-20B8C0EF9A98} - Exe - Microsoft.CodeAnalysis.Sarif.SarifValidator - SarifValidator - true - - - - - ..\packages\CommandLineParser.2.0.275-beta\lib\net45\CommandLine.dll - True - - - - - - - - - - - - - - - - True - True - Resources.resx - - - - - - - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - \ No newline at end of file From ebb4a4c87b565807067fbf241dfcad93f3f93b38 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Tue, 23 Aug 2016 16:24:07 -0700 Subject: [PATCH 02/51] Revert an accidental change to a .csproj file --- src/Sarif.FunctionalTests/Sarif.FunctionalTests.csproj | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Sarif.FunctionalTests/Sarif.FunctionalTests.csproj b/src/Sarif.FunctionalTests/Sarif.FunctionalTests.csproj index a8bae8b6c..92c358c17 100644 --- a/src/Sarif.FunctionalTests/Sarif.FunctionalTests.csproj +++ b/src/Sarif.FunctionalTests/Sarif.FunctionalTests.csproj @@ -73,7 +73,6 @@ - PreserveNewest @@ -743,6 +742,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest From 302d02f828d910d7d78cb9582ad25d94c82336f2 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Wed, 24 Aug 2016 07:16:55 -0700 Subject: [PATCH 03/51] SarifCli: Minor cleanups --- .../Properties/AssemblyInfo.cs | 4 +-- .../Rules/SkimmerTestsBase.cs | 6 ++-- src/SarifCli/AnalyzeCommand.cs | 32 +++++++------------ src/SarifCli/Program.cs | 3 +- src/SarifCli/Resources.Designer.cs | 9 ------ src/SarifCli/Resources.resx | 3 -- .../Rules/SarifValidationSkimmerBase.cs | 10 ++---- src/SarifCli/SarifValidationContext.cs | 4 +-- 8 files changed, 22 insertions(+), 49 deletions(-) diff --git a/src/SarifCli.FunctionalTests/Properties/AssemblyInfo.cs b/src/SarifCli.FunctionalTests/Properties/AssemblyInfo.cs index 2b22cda5e..c42c39663 100644 --- a/src/SarifCli.FunctionalTests/Properties/AssemblyInfo.cs +++ b/src/SarifCli.FunctionalTests/Properties/AssemblyInfo.cs @@ -6,5 +6,5 @@ // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("Sarif CLI Unit Tests")] -[assembly: AssemblyDescription("Unit tests for the SARIF command line interface tool")] +[assembly: AssemblyTitle("Sarif CLI Functional Tests")] +[assembly: AssemblyDescription("Functional tests for the SARIF command line interface tool")] diff --git a/src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs b/src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs index 203dc8afe..60c961198 100644 --- a/src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs +++ b/src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs @@ -63,15 +63,15 @@ protected void Verify(SarifValidationSkimmerBase skimmer, string testFileName) SelectiveCompare(actualLogContents, expectedLogContents); } - private static void SelectiveCompare(string actualText, string expectedText) + private static void SelectiveCompare(string actualLogContents, string expectedLogContents) { var settings = new JsonSerializerSettings() { ContractResolver = SarifContractResolver.Instance }; - SarifLog actualLog = JsonConvert.DeserializeObject(actualText, settings); - SarifLog expectedLog = JsonConvert.DeserializeObject(expectedText, settings); + SarifLog actualLog = JsonConvert.DeserializeObject(actualLogContents, settings); + SarifLog expectedLog = JsonConvert.DeserializeObject(expectedLogContents, settings); SelectiveCompare(actualLog, expectedLog); } diff --git a/src/SarifCli/AnalyzeCommand.cs b/src/SarifCli/AnalyzeCommand.cs index a6243bd97..21ebb7dae 100644 --- a/src/SarifCli/AnalyzeCommand.cs +++ b/src/SarifCli/AnalyzeCommand.cs @@ -17,13 +17,6 @@ internal class AnalyzeCommand : AnalyzeCommandBase VersionConstants.Prerelease; - public override void ConfigureFromOptions(SarifValidationContext context, AnalyzeOptions analyzeOptions) - { - base.ConfigureFromOptions(context, analyzeOptions); - - context.SchemaFilePath = analyzeOptions.SchemaFilePath; - } - private List _defaultPlugInAssemblies; public override IEnumerable DefaultPlugInAssemblies @@ -59,15 +52,12 @@ protected override void AnalyzeTarget(IEnumerable attributes = entryAssembly.GetCustomAttributes(); + IEnumerable attributes = entryAssembly.GetCustomAttributes(); var titleAttribute = attributes.Single(a => a is AssemblyTitleAttribute) as AssemblyTitleAttribute; string programName = titleAttribute.Title; diff --git a/src/SarifCli/Resources.Designer.cs b/src/SarifCli/Resources.Designer.cs index 66ab1efce..cb99a9a38 100644 --- a/src/SarifCli/Resources.Designer.cs +++ b/src/SarifCli/Resources.Designer.cs @@ -77,14 +77,5 @@ internal static string ErrorIllegalContextReuse { return ResourceManager.GetString("ErrorIllegalContextReuse", resourceCulture); } } - - /// - /// Looks up a localized string similar to The rule id "{0}" does not match the expected format for rule ids from the JSON schema validator.. - /// - internal static string ErrorUnrecognizedSchemaValidationRuleId { - get { - return ResourceManager.GetString("ErrorUnrecognizedSchemaValidationRuleId", resourceCulture); - } - } } } diff --git a/src/SarifCli/Resources.resx b/src/SarifCli/Resources.resx index db34e73d7..fbee81e26 100644 --- a/src/SarifCli/Resources.resx +++ b/src/SarifCli/Resources.resx @@ -123,7 +123,4 @@ A context object was reinitialized with a new target URI. - - The rule id "{0}" does not match the expected format for rule ids from the JSON schema validator. - \ No newline at end of file diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs index d364f30af..d23732574 100644 --- a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -22,8 +22,9 @@ public override void Analyze(SarifValidationContext context) ContractResolver = SarifContractResolver.Instance }; - context.InputLogContents = File.ReadAllText(context.TargetUri.LocalPath); - context.InputLog = JsonConvert.DeserializeObject(context.InputLogContents, settings); + string inputLogContents = File.ReadAllText(context.TargetUri.LocalPath); + context.InputLogToken = JToken.Parse(inputLogContents); + context.InputLog = JsonConvert.DeserializeObject(inputLogContents, settings); AnalyzeCore(context); } @@ -32,11 +33,6 @@ public override void Analyze(SarifValidationContext context) protected Region GetRegionFromJPointer(string jPointerValue, SarifValidationContext context) { - if (context.InputLogToken == null) - { - context.InputLogToken = JToken.Parse(context.InputLogContents); - } - JsonPointer jPointer = new JsonPointer(jPointerValue); JToken jToken = jPointer.Evaluate(context.InputLogToken); IJsonLineInfo lineInfo = jToken; diff --git a/src/SarifCli/SarifValidationContext.cs b/src/SarifCli/SarifValidationContext.cs index 39902874e..c47ad193d 100644 --- a/src/SarifCli/SarifValidationContext.cs +++ b/src/SarifCli/SarifValidationContext.cs @@ -21,7 +21,7 @@ public bool IsValidAnalysisTarget public string MimeType { - get { return Microsoft.CodeAnalysis.Sarif.Writers.MimeType.Sarif; } + get { return "text/x-sarif"; } set { throw new InvalidOperationException(); } } @@ -57,8 +57,6 @@ public Uri TargetUri public SarifLog InputLog { get; internal set; } - public string InputLogContents { get; internal set; } - public JToken InputLogToken { get; internal set; } public void Dispose() From bf4b015b0a978723b8ba13329481d73582f4f775 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Wed, 24 Aug 2016 10:36:17 -0700 Subject: [PATCH 04/51] Fix appVeyor build break The build broke on AppVeyor. I don't know why it built on my machine. SarifCli had a P2P dependency on Sarif.csproj, which is currently building version 1.5.28 of Sarif.dll. But SarifCli also has a binary dependency on a foreign checked in binary (FCIB), Microsoft.Json.Schema.dll, which in turn took a NuGet dependency on Sarif version 1.5.25. This broke the build because (for example), the code tried to assign an object of type "Result from Sarif v1.5.25" to a variable of type "Result from Sarif v1.5.28". To fix this, we did the following: 1. Update the JSchema project to take a NuGet dependency on Sarif 1.5.27 (the latest published version). 2. Bump the JSchema version number from 0.44.0 to 0.45.0. 3. Rebuild JSchema, and publish v0.45.0 of its NuGet packages. 4. Update the FCIBs with the v0.45.0 of the JSchema assemblies. 5. Replace the P2P dependencies on Sarif.Sdk and Sarif.Driver with NuGet dependencies on v1.5.27 of the SARIF packages. This should fix the problem. Again, this builds on my machine, but we won't know for sure until the AppVeyor build passes. --- src/References/Microsoft.Json.Pointer.dll | Bin 11776 -> 11776 bytes src/References/Microsoft.Json.Schema.dll | Bin 75264 -> 69632 bytes .../Sarif.ValidationTests.csproj | 4 ++-- src/Sarif.ValidationTests/packages.config | 2 +- .../SarifCli.FunctionalTests.csproj | 16 ++++++++-------- src/SarifCli.FunctionalTests/packages.config | 2 ++ src/SarifCli/AnalyzeCommand.cs | 1 - src/SarifCli/SarifCli.csproj | 18 ++++++++---------- src/SarifCli/SarifValidationContext.cs | 2 +- src/SarifCli/packages.config | 2 ++ 10 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/References/Microsoft.Json.Pointer.dll b/src/References/Microsoft.Json.Pointer.dll index 85ad5bae378c5c8825ebde3673b5a226a4801ee1..ad0fc571d0cb8883a14002c7c5d16d4fbea3e800 100644 GIT binary patch delta 287 zcmZpOX^5H7!R&i%@5F9j=4%BE8*j7oGU{%A%zKqbpk~oMlc*J!e3rdVopkh4vd88V zQoc-lrVM%v1`GlQK+1%{bhEPT0!BvD%}3-Ou++aX3wgZnSJ&(&_nm#415bZGyiR)- zZ_ees=Ldi3@+V*(OK8YOPhI_U;SLk+tgRx&zr2D|{9B>-)U5_fWaiA%*&L!`!o;ZyQUL_InilN}0PCT1Q2+n{ delta 287 zcmZpOX^5H7!R&T!&%|zD=1wifjkno(8Fe;4=Do@zaQEq~nlI;W_--<`RS}Z8Q@Z(t zlrIyX34cns*d&4M~@jGGyC{xbpqN;+*a diff --git a/src/References/Microsoft.Json.Schema.dll b/src/References/Microsoft.Json.Schema.dll index e249f0a32cdf4b4b5374e82381f48b05761149ee..4dd45a145fef5bd881d775ba48105bbffb925433 100644 GIT binary patch literal 69632 zcmdS?33yc1`3H`__s-0nWHOnoWMNGpflDR{OK^z@vSXA@Ha8T8FhDTm#+d|&2nL}p z6>_CL9Mk_Tea4@BG#o^wQ8%iwl4qA`<`=W?j(cD_y7EU&-07s zz3+D3bIyCtdCzuln0v~_nKh1r#`sc=+N2?dF zZA(^lCY&{i*!rs0SVxD`Rkbo+mFVuMYU`+)F@I6jdS_LN58QvzNriJ^8u6>GN~)d z?ft1DTG5zDCR)LivZ0Jp(HuNIKT}Zp#zef`fg+ccP-gZ4Mf&MYW3l(==j>PfaM?@> z(AYIZi!Ub16)ybqA!PMLkBl&=SMxsavD&mNh(c!h7TEQh$?kFwsiKK36 zrlL@Dn0Zu43d=47dDz$$A*x)OT<|#(<^pxqLCR!U=;3-)hZu+``m^Nx*)qSI4 zR}qm>TV~p9bmtrp*VdMsHk-ZHp2#{>GS(#5Ilcz7tWGKWq#R8RO1ad&0m==v}4coy}ZN8_+7{ z`uS)k>?1{yzl$@6{j^`}BR)lz+vr@JOUhODFqER}I2iMl?JC8?sp0|;HSKDCHYN*@ zLoW*9ZDNchf87nLF@4Hy^?3=@qBA)hsm?NeTabYt-9$9g&5jH#;h8>X02kfc?95Qj z&WX9XB{iNxbF+gXxn?vw8%;MmTXCB`Tf4Ki&tb^zt_tC{J5#D)Zo8-D{o5TQ!K&kS zM?1UiE(QE*?T+4?t=)^6jdrj6GVPA`LA!J2Xm?d+9#7KlOs3jB<*P%qdt-7a)O*o& zyzL!ia-KVQZR8f+g2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 zRsMj?5z7P9UE9KsrGmLgupBuL@HxB8ahU;xMGYGskL6uvf)F_91r(MFoTK1=DWAqi zWX~yE77F<(ozn|Db(TRomo|;Q=}VKkGvFt(`51~^1{L#R(8LM=#Kb})pff?#FV%>on!!HiY3R&ZG!@a~7i7bZ5re0AWUb%(2|nV=(k zr7(U+Y@y)j2=8cdv1#QyDvj?=#=49QLR35p=b}S4`IsncIZ(U;z;{`WDKWoYvYEw~ z32XSWUQDH5UeRd{%bw2?U@_CSU{K&|#oC$i3=0XEON_mXC!cf}`;s2bCU%E@`An-9 z^xcb1dm`rMfg4_NQ7R&cP54W0oQPIC5e-o~&q^?f*X1}d%_p7aJQiye@eKhB&@%&R z_GS&gyirV`PGND@K%!H7BH7BJ+$hX+%g(O9AQxfm8$bYWNrtr)fo;H>8fblH)tP>k zo02l-fJNGNkCXYTl;bu-brM}O^stBS@N*Rmev`x9+M>H*A_kP>sF|kP9-m)6r|Qv%U}k(dVAO7XDNy82R97%elmi2 z{}kZBc7#9YKbZ{xKmO&5M?ueC;b%mba%#64pO2g_OEa)XQ~b^FL~wZy9s#}($Cc7% zT&G>P9W)wH!h{WmDw2pgEp*8(C)*4Vsx%og>~P9S>Y$d|iw>f_3J7q(0rL(LoF4Lndwx zB1wO(ZY8Q@C{p6@iWRqHN1^rMt#-_;?p0t?M0ZJ?of9b~yg zGw2yRMA5sme=czuwCZELx(E>BFTuvY(WH$efhZPpLU$xdZu2@ZA3CI|po8zU$l&Sv zG)8W7cD#ATo+~zw#c*S1(`_ynF}O~QjyTc>*`O`VIyACa65L<~KmKz56X5`!zQXoY RY2D&K5qkbY#{Vk^{uj&6e%Js2 diff --git a/src/Sarif.ValidationTests/Sarif.ValidationTests.csproj b/src/Sarif.ValidationTests/Sarif.ValidationTests.csproj index 651f54ef1..5d1906544 100644 --- a/src/Sarif.ValidationTests/Sarif.ValidationTests.csproj +++ b/src/Sarif.ValidationTests/Sarif.ValidationTests.csproj @@ -39,8 +39,8 @@ - - ..\packages\Sarif.Sdk.1.5.25\lib\net45\Sarif.dll + + ..\packages\Sarif.Sdk.1.5.27\lib\net45\Sarif.dll True diff --git a/src/Sarif.ValidationTests/packages.config b/src/Sarif.ValidationTests/packages.config index b952e2631..99be2bb82 100644 --- a/src/Sarif.ValidationTests/packages.config +++ b/src/Sarif.ValidationTests/packages.config @@ -2,7 +2,7 @@ - + diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj index 1249ae7f4..dc9b709a3 100644 --- a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -30,6 +30,14 @@ ..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll True + + ..\packages\Sarif.Sdk.1.5.27\lib\net45\Sarif.dll + True + + + ..\packages\Sarif.Sdk.1.5.27\lib\net45\Sarif.Driver.dll + True + @@ -61,18 +69,10 @@ - - {8ceaea61-b1a2-4777-bcbe-c9a129a5f6c5} - Sarif.Driver - {0eba700d-29e7-4fff-8ebf-20b8c0ef9a98} SarifCli - - {cc9b247e-7103-4bf7-bdab-6e625b3680a8} - Sarif - diff --git a/src/SarifCli.FunctionalTests/packages.config b/src/SarifCli.FunctionalTests/packages.config index ad18c0e1b..fadaed30e 100644 --- a/src/SarifCli.FunctionalTests/packages.config +++ b/src/SarifCli.FunctionalTests/packages.config @@ -2,6 +2,8 @@ + + diff --git a/src/SarifCli/AnalyzeCommand.cs b/src/SarifCli/AnalyzeCommand.cs index 21ebb7dae..f3bfb5cfc 100644 --- a/src/SarifCli/AnalyzeCommand.cs +++ b/src/SarifCli/AnalyzeCommand.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Globalization; using System.IO; using System.Linq; using System.Reflection; diff --git a/src/SarifCli/SarifCli.csproj b/src/SarifCli/SarifCli.csproj index 7e690d0f1..e7e5b3a4e 100644 --- a/src/SarifCli/SarifCli.csproj +++ b/src/SarifCli/SarifCli.csproj @@ -20,6 +20,14 @@ ..\packages\CommandLineParser.2.0.275-beta\lib\net45\CommandLine.dll True + + ..\packages\Sarif.Sdk.1.5.27\lib\net45\Sarif.dll + True + + + ..\packages\Sarif.Driver.1.5.27\lib\net45\Sarif.Driver.dll + True + ..\References\Microsoft.Json.Schema.dll @@ -74,15 +82,5 @@ RuleResources.Designer.cs - - - {8CEAEA61-B1A2-4777-BCBE-C9A129A5F6C5} - Sarif.Driver - - - {cc9b247e-7103-4bf7-bdab-6e625b3680a8} - Sarif - - \ No newline at end of file diff --git a/src/SarifCli/SarifValidationContext.cs b/src/SarifCli/SarifValidationContext.cs index c47ad193d..37f37e77c 100644 --- a/src/SarifCli/SarifValidationContext.cs +++ b/src/SarifCli/SarifValidationContext.cs @@ -25,7 +25,7 @@ public string MimeType set { throw new InvalidOperationException(); } } - public PropertiesDictionary Policy { get; set; } + public PropertyBagDictionary Policy { get; set; } public IRule Rule { get; set; } diff --git a/src/SarifCli/packages.config b/src/SarifCli/packages.config index 842b847ba..52a89806c 100644 --- a/src/SarifCli/packages.config +++ b/src/SarifCli/packages.config @@ -2,4 +2,6 @@ + + \ No newline at end of file From 046c98fc4f5b14a770797bb96eb1add2ea50adda Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Wed, 24 Aug 2016 11:25:03 -0700 Subject: [PATCH 05/51] SarifCli: Get JSchema/JPointer from NuGet, not FCIB --- src/SarifCli/SarifCli.csproj | 10 ++++++---- src/SarifCli/packages.config | 2 ++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/SarifCli/SarifCli.csproj b/src/SarifCli/SarifCli.csproj index e7e5b3a4e..33e7c96f6 100644 --- a/src/SarifCli/SarifCli.csproj +++ b/src/SarifCli/SarifCli.csproj @@ -28,11 +28,13 @@ ..\packages\Sarif.Driver.1.5.27\lib\net45\Sarif.Driver.dll True - - ..\References\Microsoft.Json.Schema.dll + + ..\packages\Microsoft.Json.Schema.0.45.0\lib\net451\Microsoft.Json.Schema.dll + True - - ..\References\Microsoft.Json.Pointer.dll + + ..\packages\Microsoft.Json.Pointer.0.45.0\lib\net451\Microsoft.Json.Pointer.dll + True ..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll diff --git a/src/SarifCli/packages.config b/src/SarifCli/packages.config index 52a89806c..f2ffea301 100644 --- a/src/SarifCli/packages.config +++ b/src/SarifCli/packages.config @@ -4,4 +4,6 @@ + + \ No newline at end of file From d6de9206db283575ce118c3fdc62c7573288275c Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Wed, 24 Aug 2016 11:35:15 -0700 Subject: [PATCH 06/51] Sarif.ValidationTests: Get JSchema from NuGet, not FCIB --- src/Sarif.ValidationTests/Sarif.ValidationTests.csproj | 5 +++-- src/Sarif.ValidationTests/packages.config | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Sarif.ValidationTests/Sarif.ValidationTests.csproj b/src/Sarif.ValidationTests/Sarif.ValidationTests.csproj index 5d1906544..853a98d42 100644 --- a/src/Sarif.ValidationTests/Sarif.ValidationTests.csproj +++ b/src/Sarif.ValidationTests/Sarif.ValidationTests.csproj @@ -16,8 +16,9 @@ v4.5.1 - - ..\References\Microsoft.Json.Schema.dll + + ..\packages\Microsoft.Json.Schema.0.45.0\lib\net451\Microsoft.Json.Schema.dll + True ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll diff --git a/src/Sarif.ValidationTests/packages.config b/src/Sarif.ValidationTests/packages.config index 99be2bb82..da9368289 100644 --- a/src/Sarif.ValidationTests/packages.config +++ b/src/Sarif.ValidationTests/packages.config @@ -3,6 +3,7 @@ + From 00a6e3081834f6a9ac675ec6c5d49d22d413850c Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Wed, 24 Aug 2016 11:45:42 -0700 Subject: [PATCH 07/51] Upgrade ToDotNet.targets to JSchema.ToDotNet 0.45.0 --- src/Sarif/Autogenerated/AlgorithmKind.cs | 2 +- src/Sarif/Autogenerated/AnnotatedCodeLocation.cs | 2 +- .../Autogenerated/AnnotatedCodeLocationEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/AnnotatedCodeLocationImportance.cs | 2 +- src/Sarif/Autogenerated/AnnotatedCodeLocationKind.cs | 2 +- src/Sarif/Autogenerated/BaselineState.cs | 2 +- src/Sarif/Autogenerated/CodeFlow.cs | 2 +- src/Sarif/Autogenerated/CodeFlowEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/ExceptionData.cs | 2 +- src/Sarif/Autogenerated/ExceptionDataEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/FileChange.cs | 2 +- src/Sarif/Autogenerated/FileChangeEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/FileData.cs | 2 +- src/Sarif/Autogenerated/FileDataEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/Fix.cs | 2 +- src/Sarif/Autogenerated/FixEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/FormattedRuleMessage.cs | 2 +- src/Sarif/Autogenerated/FormattedRuleMessageEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/Hash.cs | 2 +- src/Sarif/Autogenerated/HashEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/IRule.cs | 2 +- src/Sarif/Autogenerated/ISarifNode.cs | 2 +- src/Sarif/Autogenerated/Invocation.cs | 2 +- src/Sarif/Autogenerated/InvocationEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/Location.cs | 2 +- src/Sarif/Autogenerated/LocationEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/LogicalLocation.cs | 2 +- src/Sarif/Autogenerated/LogicalLocationEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/Notification.cs | 2 +- src/Sarif/Autogenerated/NotificationEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/NotificationLevel.cs | 2 +- src/Sarif/Autogenerated/PhysicalLocation.cs | 2 +- src/Sarif/Autogenerated/PhysicalLocationEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/Region.cs | 2 +- src/Sarif/Autogenerated/RegionEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/Replacement.cs | 2 +- src/Sarif/Autogenerated/ReplacementEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/Result.cs | 2 +- src/Sarif/Autogenerated/ResultEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/ResultLevel.cs | 2 +- src/Sarif/Autogenerated/Rule.cs | 2 +- src/Sarif/Autogenerated/RuleEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/Run.cs | 2 +- src/Sarif/Autogenerated/RunEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/SarifLog.cs | 2 +- src/Sarif/Autogenerated/SarifLogEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/SarifNodeKind.cs | 2 +- src/Sarif/Autogenerated/SarifRewritingVisitor.cs | 2 +- src/Sarif/Autogenerated/SarifVersion.cs | 2 +- src/Sarif/Autogenerated/Stack.cs | 2 +- src/Sarif/Autogenerated/StackEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/StackFrame.cs | 2 +- src/Sarif/Autogenerated/StackFrameEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/SuppressionStates.cs | 2 +- src/Sarif/Autogenerated/Tool.cs | 2 +- src/Sarif/Autogenerated/ToolEqualityComparer.cs | 2 +- src/Sarif/ToDotNet/ToDotNet.targets | 2 +- src/Sarif/ToDotNet/packages.config | 2 +- 58 files changed, 58 insertions(+), 58 deletions(-) diff --git a/src/Sarif/Autogenerated/AlgorithmKind.cs b/src/Sarif/Autogenerated/AlgorithmKind.cs index be7f08771..fe033e579 100644 --- a/src/Sarif/Autogenerated/AlgorithmKind.cs +++ b/src/Sarif/Autogenerated/AlgorithmKind.cs @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Values specifying different hashing algorithms. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public enum AlgorithmKind { Unknown, diff --git a/src/Sarif/Autogenerated/AnnotatedCodeLocation.cs b/src/Sarif/Autogenerated/AnnotatedCodeLocation.cs index 8370e4f5b..5e888e459 100644 --- a/src/Sarif/Autogenerated/AnnotatedCodeLocation.cs +++ b/src/Sarif/Autogenerated/AnnotatedCodeLocation.cs @@ -14,7 +14,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// An annotation used to express code flows through a method or other locations that are related to a result. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public partial class AnnotatedCodeLocation : PropertyBagHolder, ISarifNode { public static IEqualityComparer ValueComparer => AnnotatedCodeLocationEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/AnnotatedCodeLocationEqualityComparer.cs b/src/Sarif/Autogenerated/AnnotatedCodeLocationEqualityComparer.cs index 507b618e0..a936106d0 100644 --- a/src/Sarif/Autogenerated/AnnotatedCodeLocationEqualityComparer.cs +++ b/src/Sarif/Autogenerated/AnnotatedCodeLocationEqualityComparer.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type AnnotatedCodeLocation for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] internal sealed class AnnotatedCodeLocationEqualityComparer : IEqualityComparer { internal static readonly AnnotatedCodeLocationEqualityComparer Instance = new AnnotatedCodeLocationEqualityComparer(); diff --git a/src/Sarif/Autogenerated/AnnotatedCodeLocationImportance.cs b/src/Sarif/Autogenerated/AnnotatedCodeLocationImportance.cs index 54a66eeae..8ba2c1928 100644 --- a/src/Sarif/Autogenerated/AnnotatedCodeLocationImportance.cs +++ b/src/Sarif/Autogenerated/AnnotatedCodeLocationImportance.cs @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Values specifying the importance of an "annotatedCodeLocation" within the "codeFlow" in which it occurs /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public enum AnnotatedCodeLocationImportance { Important, diff --git a/src/Sarif/Autogenerated/AnnotatedCodeLocationKind.cs b/src/Sarif/Autogenerated/AnnotatedCodeLocationKind.cs index ee77c5c06..a65e0b247 100644 --- a/src/Sarif/Autogenerated/AnnotatedCodeLocationKind.cs +++ b/src/Sarif/Autogenerated/AnnotatedCodeLocationKind.cs @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Values specifying the kind of an annotated code location. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public enum AnnotatedCodeLocationKind { Unknown, diff --git a/src/Sarif/Autogenerated/BaselineState.cs b/src/Sarif/Autogenerated/BaselineState.cs index a9169913f..7331c3bce 100644 --- a/src/Sarif/Autogenerated/BaselineState.cs +++ b/src/Sarif/Autogenerated/BaselineState.cs @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// The state of a result relative to a baseline of a previous run. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public enum BaselineState { None, diff --git a/src/Sarif/Autogenerated/CodeFlow.cs b/src/Sarif/Autogenerated/CodeFlow.cs index 63a511bc0..7fbca6cf6 100644 --- a/src/Sarif/Autogenerated/CodeFlow.cs +++ b/src/Sarif/Autogenerated/CodeFlow.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif { [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public partial class CodeFlow : PropertyBagHolder, ISarifNode { public static IEqualityComparer ValueComparer => CodeFlowEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/CodeFlowEqualityComparer.cs b/src/Sarif/Autogenerated/CodeFlowEqualityComparer.cs index fd28f4aeb..4422a03ff 100644 --- a/src/Sarif/Autogenerated/CodeFlowEqualityComparer.cs +++ b/src/Sarif/Autogenerated/CodeFlowEqualityComparer.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type CodeFlow for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] internal sealed class CodeFlowEqualityComparer : IEqualityComparer { internal static readonly CodeFlowEqualityComparer Instance = new CodeFlowEqualityComparer(); diff --git a/src/Sarif/Autogenerated/ExceptionData.cs b/src/Sarif/Autogenerated/ExceptionData.cs index aff4239f5..f5fbc3adb 100644 --- a/src/Sarif/Autogenerated/ExceptionData.cs +++ b/src/Sarif/Autogenerated/ExceptionData.cs @@ -9,7 +9,7 @@ namespace Microsoft.CodeAnalysis.Sarif { [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public partial class ExceptionData : ISarifNode { public static IEqualityComparer ValueComparer => ExceptionDataEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/ExceptionDataEqualityComparer.cs b/src/Sarif/Autogenerated/ExceptionDataEqualityComparer.cs index e2ea2b0c9..48898aae1 100644 --- a/src/Sarif/Autogenerated/ExceptionDataEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ExceptionDataEqualityComparer.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type ExceptionData for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] internal sealed class ExceptionDataEqualityComparer : IEqualityComparer { internal static readonly ExceptionDataEqualityComparer Instance = new ExceptionDataEqualityComparer(); diff --git a/src/Sarif/Autogenerated/FileChange.cs b/src/Sarif/Autogenerated/FileChange.cs index 8efced3ab..d6fcbc3c3 100644 --- a/src/Sarif/Autogenerated/FileChange.cs +++ b/src/Sarif/Autogenerated/FileChange.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// A change to a single file. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public partial class FileChange : ISarifNode { public static IEqualityComparer ValueComparer => FileChangeEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/FileChangeEqualityComparer.cs b/src/Sarif/Autogenerated/FileChangeEqualityComparer.cs index c988d7768..b284d66b4 100644 --- a/src/Sarif/Autogenerated/FileChangeEqualityComparer.cs +++ b/src/Sarif/Autogenerated/FileChangeEqualityComparer.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type FileChange for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] internal sealed class FileChangeEqualityComparer : IEqualityComparer { internal static readonly FileChangeEqualityComparer Instance = new FileChangeEqualityComparer(); diff --git a/src/Sarif/Autogenerated/FileData.cs b/src/Sarif/Autogenerated/FileData.cs index fb5f6e5b0..be100a5f8 100644 --- a/src/Sarif/Autogenerated/FileData.cs +++ b/src/Sarif/Autogenerated/FileData.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// A single file. In some cases, this file might be nested within another file. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public partial class FileData : PropertyBagHolder, ISarifNode { public static IEqualityComparer ValueComparer => FileDataEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/FileDataEqualityComparer.cs b/src/Sarif/Autogenerated/FileDataEqualityComparer.cs index 37631978b..eb291e784 100644 --- a/src/Sarif/Autogenerated/FileDataEqualityComparer.cs +++ b/src/Sarif/Autogenerated/FileDataEqualityComparer.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type FileData for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] internal sealed class FileDataEqualityComparer : IEqualityComparer { internal static readonly FileDataEqualityComparer Instance = new FileDataEqualityComparer(); diff --git a/src/Sarif/Autogenerated/Fix.cs b/src/Sarif/Autogenerated/Fix.cs index 7ad48903f..3b553289e 100644 --- a/src/Sarif/Autogenerated/Fix.cs +++ b/src/Sarif/Autogenerated/Fix.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// A proposed fix for the problem represented by a result object. A fix specifies a set of file to modify. For each file, it specifies a set of bytes to remove, and provides a set of new bytes to replace them. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public partial class Fix : ISarifNode { public static IEqualityComparer ValueComparer => FixEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/FixEqualityComparer.cs b/src/Sarif/Autogenerated/FixEqualityComparer.cs index 53b1d11f8..6de7ffa40 100644 --- a/src/Sarif/Autogenerated/FixEqualityComparer.cs +++ b/src/Sarif/Autogenerated/FixEqualityComparer.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Fix for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] internal sealed class FixEqualityComparer : IEqualityComparer { internal static readonly FixEqualityComparer Instance = new FixEqualityComparer(); diff --git a/src/Sarif/Autogenerated/FormattedRuleMessage.cs b/src/Sarif/Autogenerated/FormattedRuleMessage.cs index 0a82d673e..0178e70d8 100644 --- a/src/Sarif/Autogenerated/FormattedRuleMessage.cs +++ b/src/Sarif/Autogenerated/FormattedRuleMessage.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// Contains information that can be used to construct a formatted message that describes a result. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public partial class FormattedRuleMessage : ISarifNode { public static IEqualityComparer ValueComparer => FormattedRuleMessageEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/FormattedRuleMessageEqualityComparer.cs b/src/Sarif/Autogenerated/FormattedRuleMessageEqualityComparer.cs index fb75ae274..36df586c9 100644 --- a/src/Sarif/Autogenerated/FormattedRuleMessageEqualityComparer.cs +++ b/src/Sarif/Autogenerated/FormattedRuleMessageEqualityComparer.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type FormattedRuleMessage for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] internal sealed class FormattedRuleMessageEqualityComparer : IEqualityComparer { internal static readonly FormattedRuleMessageEqualityComparer Instance = new FormattedRuleMessageEqualityComparer(); diff --git a/src/Sarif/Autogenerated/Hash.cs b/src/Sarif/Autogenerated/Hash.cs index 1306a01b0..7002b0a58 100644 --- a/src/Sarif/Autogenerated/Hash.cs +++ b/src/Sarif/Autogenerated/Hash.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// A hash value of some file or collection of files, together with the algorithm used to compute the hash. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public partial class Hash : ISarifNode { public static IEqualityComparer ValueComparer => HashEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/HashEqualityComparer.cs b/src/Sarif/Autogenerated/HashEqualityComparer.cs index 51ca29337..aa52d8c76 100644 --- a/src/Sarif/Autogenerated/HashEqualityComparer.cs +++ b/src/Sarif/Autogenerated/HashEqualityComparer.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Hash for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] internal sealed class HashEqualityComparer : IEqualityComparer { internal static readonly HashEqualityComparer Instance = new HashEqualityComparer(); diff --git a/src/Sarif/Autogenerated/IRule.cs b/src/Sarif/Autogenerated/IRule.cs index 1ca241fe6..f1add1c16 100644 --- a/src/Sarif/Autogenerated/IRule.cs +++ b/src/Sarif/Autogenerated/IRule.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Interface exposed by objects that provide information about analysis rules. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public partial interface IRule { /// diff --git a/src/Sarif/Autogenerated/ISarifNode.cs b/src/Sarif/Autogenerated/ISarifNode.cs index e4609695d..f68106099 100644 --- a/src/Sarif/Autogenerated/ISarifNode.cs +++ b/src/Sarif/Autogenerated/ISarifNode.cs @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// An interface for all types generated from the Sarif schema. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public interface ISarifNode { /// diff --git a/src/Sarif/Autogenerated/Invocation.cs b/src/Sarif/Autogenerated/Invocation.cs index 1e15b371e..23a6af0e8 100644 --- a/src/Sarif/Autogenerated/Invocation.cs +++ b/src/Sarif/Autogenerated/Invocation.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// The runtime environment of the analysis tool run. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public partial class Invocation : PropertyBagHolder, ISarifNode { public static IEqualityComparer ValueComparer => InvocationEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/InvocationEqualityComparer.cs b/src/Sarif/Autogenerated/InvocationEqualityComparer.cs index d197524ce..78b066672 100644 --- a/src/Sarif/Autogenerated/InvocationEqualityComparer.cs +++ b/src/Sarif/Autogenerated/InvocationEqualityComparer.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Invocation for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] internal sealed class InvocationEqualityComparer : IEqualityComparer { internal static readonly InvocationEqualityComparer Instance = new InvocationEqualityComparer(); diff --git a/src/Sarif/Autogenerated/Location.cs b/src/Sarif/Autogenerated/Location.cs index 42916722e..1f225648a 100644 --- a/src/Sarif/Autogenerated/Location.cs +++ b/src/Sarif/Autogenerated/Location.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// The location where an analysis tool produced a result. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public partial class Location : PropertyBagHolder, ISarifNode { public static IEqualityComparer ValueComparer => LocationEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/LocationEqualityComparer.cs b/src/Sarif/Autogenerated/LocationEqualityComparer.cs index 5ee3cab89..f9e645503 100644 --- a/src/Sarif/Autogenerated/LocationEqualityComparer.cs +++ b/src/Sarif/Autogenerated/LocationEqualityComparer.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Location for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] internal sealed class LocationEqualityComparer : IEqualityComparer { internal static readonly LocationEqualityComparer Instance = new LocationEqualityComparer(); diff --git a/src/Sarif/Autogenerated/LogicalLocation.cs b/src/Sarif/Autogenerated/LogicalLocation.cs index a7b7b5dc8..b4c95b958 100644 --- a/src/Sarif/Autogenerated/LogicalLocation.cs +++ b/src/Sarif/Autogenerated/LogicalLocation.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// A logical location of a construct that produced a result. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public partial class LogicalLocation : ISarifNode { public static IEqualityComparer ValueComparer => LogicalLocationEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/LogicalLocationEqualityComparer.cs b/src/Sarif/Autogenerated/LogicalLocationEqualityComparer.cs index f9bdda10e..ae473d3b8 100644 --- a/src/Sarif/Autogenerated/LogicalLocationEqualityComparer.cs +++ b/src/Sarif/Autogenerated/LogicalLocationEqualityComparer.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type LogicalLocation for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] internal sealed class LogicalLocationEqualityComparer : IEqualityComparer { internal static readonly LogicalLocationEqualityComparer Instance = new LogicalLocationEqualityComparer(); diff --git a/src/Sarif/Autogenerated/Notification.cs b/src/Sarif/Autogenerated/Notification.cs index 7db943ba5..4b14c1a4d 100644 --- a/src/Sarif/Autogenerated/Notification.cs +++ b/src/Sarif/Autogenerated/Notification.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// Describes a condition relevant to the tool itself, as opposed to being relevant to a target being analyzed by the tool. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public partial class Notification : PropertyBagHolder, ISarifNode { public static IEqualityComparer ValueComparer => NotificationEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/NotificationEqualityComparer.cs b/src/Sarif/Autogenerated/NotificationEqualityComparer.cs index 2b8627f15..7396c4c34 100644 --- a/src/Sarif/Autogenerated/NotificationEqualityComparer.cs +++ b/src/Sarif/Autogenerated/NotificationEqualityComparer.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Notification for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] internal sealed class NotificationEqualityComparer : IEqualityComparer { internal static readonly NotificationEqualityComparer Instance = new NotificationEqualityComparer(); diff --git a/src/Sarif/Autogenerated/NotificationLevel.cs b/src/Sarif/Autogenerated/NotificationLevel.cs index b691e1010..bc3fe6199 100644 --- a/src/Sarif/Autogenerated/NotificationLevel.cs +++ b/src/Sarif/Autogenerated/NotificationLevel.cs @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Values specifying the level of a notification. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public enum NotificationLevel { Warning, diff --git a/src/Sarif/Autogenerated/PhysicalLocation.cs b/src/Sarif/Autogenerated/PhysicalLocation.cs index 9599fb1ca..0636e6f17 100644 --- a/src/Sarif/Autogenerated/PhysicalLocation.cs +++ b/src/Sarif/Autogenerated/PhysicalLocation.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// A physical location relevant to a result. Specifies a reference to a programming artifact together with a range of bytes or characters within that artifact. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public partial class PhysicalLocation : ISarifNode { public static IEqualityComparer ValueComparer => PhysicalLocationEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/PhysicalLocationEqualityComparer.cs b/src/Sarif/Autogenerated/PhysicalLocationEqualityComparer.cs index f9debd0f6..fac642c5e 100644 --- a/src/Sarif/Autogenerated/PhysicalLocationEqualityComparer.cs +++ b/src/Sarif/Autogenerated/PhysicalLocationEqualityComparer.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type PhysicalLocation for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] internal sealed class PhysicalLocationEqualityComparer : IEqualityComparer { internal static readonly PhysicalLocationEqualityComparer Instance = new PhysicalLocationEqualityComparer(); diff --git a/src/Sarif/Autogenerated/Region.cs b/src/Sarif/Autogenerated/Region.cs index 6acee91ec..f336700a5 100644 --- a/src/Sarif/Autogenerated/Region.cs +++ b/src/Sarif/Autogenerated/Region.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// A region within a file where a result was detected. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public partial class Region : ISarifNode { public static IEqualityComparer ValueComparer => RegionEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/RegionEqualityComparer.cs b/src/Sarif/Autogenerated/RegionEqualityComparer.cs index 9fa16cd2b..f315c3a05 100644 --- a/src/Sarif/Autogenerated/RegionEqualityComparer.cs +++ b/src/Sarif/Autogenerated/RegionEqualityComparer.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Region for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] internal sealed class RegionEqualityComparer : IEqualityComparer { internal static readonly RegionEqualityComparer Instance = new RegionEqualityComparer(); diff --git a/src/Sarif/Autogenerated/Replacement.cs b/src/Sarif/Autogenerated/Replacement.cs index 87dae7721..0d5db93ef 100644 --- a/src/Sarif/Autogenerated/Replacement.cs +++ b/src/Sarif/Autogenerated/Replacement.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// The replacement of a single range of bytes in a file. Specifies the location within the file where the replacement is to be made, the number of bytes to remove at that location, and a sequence of bytes to insert at that location. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public partial class Replacement : ISarifNode { public static IEqualityComparer ValueComparer => ReplacementEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/ReplacementEqualityComparer.cs b/src/Sarif/Autogenerated/ReplacementEqualityComparer.cs index a5de8d22d..f1aae0fa3 100644 --- a/src/Sarif/Autogenerated/ReplacementEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ReplacementEqualityComparer.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Replacement for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] internal sealed class ReplacementEqualityComparer : IEqualityComparer { internal static readonly ReplacementEqualityComparer Instance = new ReplacementEqualityComparer(); diff --git a/src/Sarif/Autogenerated/Result.cs b/src/Sarif/Autogenerated/Result.cs index 00c6cf406..6405cc5e1 100644 --- a/src/Sarif/Autogenerated/Result.cs +++ b/src/Sarif/Autogenerated/Result.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// A result produced by an analysis tool. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public partial class Result : PropertyBagHolder, ISarifNode { public static IEqualityComparer ValueComparer => ResultEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/ResultEqualityComparer.cs b/src/Sarif/Autogenerated/ResultEqualityComparer.cs index 7e7acaee7..991664312 100644 --- a/src/Sarif/Autogenerated/ResultEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ResultEqualityComparer.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Result for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] internal sealed class ResultEqualityComparer : IEqualityComparer { internal static readonly ResultEqualityComparer Instance = new ResultEqualityComparer(); diff --git a/src/Sarif/Autogenerated/ResultLevel.cs b/src/Sarif/Autogenerated/ResultLevel.cs index 1870e2649..44e9df26c 100644 --- a/src/Sarif/Autogenerated/ResultLevel.cs +++ b/src/Sarif/Autogenerated/ResultLevel.cs @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Values specifying the level of a result. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public enum ResultLevel { Default, diff --git a/src/Sarif/Autogenerated/Rule.cs b/src/Sarif/Autogenerated/Rule.cs index 808d9dbb7..1c5a49907 100644 --- a/src/Sarif/Autogenerated/Rule.cs +++ b/src/Sarif/Autogenerated/Rule.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// Describes an analysis rule. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public partial class Rule : PropertyBagHolder, IRule, ISarifNode { public static IEqualityComparer ValueComparer => RuleEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/RuleEqualityComparer.cs b/src/Sarif/Autogenerated/RuleEqualityComparer.cs index d6f7486a2..83826ae01 100644 --- a/src/Sarif/Autogenerated/RuleEqualityComparer.cs +++ b/src/Sarif/Autogenerated/RuleEqualityComparer.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Rule for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] internal sealed class RuleEqualityComparer : IEqualityComparer { internal static readonly RuleEqualityComparer Instance = new RuleEqualityComparer(); diff --git a/src/Sarif/Autogenerated/Run.cs b/src/Sarif/Autogenerated/Run.cs index c11683bbe..c037f4294 100644 --- a/src/Sarif/Autogenerated/Run.cs +++ b/src/Sarif/Autogenerated/Run.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// Describes a single run of an analysis tool, and contains the output of that run. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public partial class Run : ISarifNode { public static IEqualityComparer ValueComparer => RunEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/RunEqualityComparer.cs b/src/Sarif/Autogenerated/RunEqualityComparer.cs index 74827c3c6..917b8a628 100644 --- a/src/Sarif/Autogenerated/RunEqualityComparer.cs +++ b/src/Sarif/Autogenerated/RunEqualityComparer.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Run for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] internal sealed class RunEqualityComparer : IEqualityComparer { internal static readonly RunEqualityComparer Instance = new RunEqualityComparer(); diff --git a/src/Sarif/Autogenerated/SarifLog.cs b/src/Sarif/Autogenerated/SarifLog.cs index 541ad6cc5..b0bb58e3c 100644 --- a/src/Sarif/Autogenerated/SarifLog.cs +++ b/src/Sarif/Autogenerated/SarifLog.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// Static Analysis Results Format (SARIF) Version 1.0.0 JSON Schema: a standard format for the output of static analysis and other tools. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public partial class SarifLog : ISarifNode { public static IEqualityComparer ValueComparer => SarifLogEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/SarifLogEqualityComparer.cs b/src/Sarif/Autogenerated/SarifLogEqualityComparer.cs index be90125da..5be78c89d 100644 --- a/src/Sarif/Autogenerated/SarifLogEqualityComparer.cs +++ b/src/Sarif/Autogenerated/SarifLogEqualityComparer.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type SarifLog for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] internal sealed class SarifLogEqualityComparer : IEqualityComparer { internal static readonly SarifLogEqualityComparer Instance = new SarifLogEqualityComparer(); diff --git a/src/Sarif/Autogenerated/SarifNodeKind.cs b/src/Sarif/Autogenerated/SarifNodeKind.cs index 400657607..cef1d9533 100644 --- a/src/Sarif/Autogenerated/SarifNodeKind.cs +++ b/src/Sarif/Autogenerated/SarifNodeKind.cs @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// A set of values for all the types that implement . /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public enum SarifNodeKind { /// diff --git a/src/Sarif/Autogenerated/SarifRewritingVisitor.cs b/src/Sarif/Autogenerated/SarifRewritingVisitor.cs index e4c6729ff..ea3537d19 100644 --- a/src/Sarif/Autogenerated/SarifRewritingVisitor.cs +++ b/src/Sarif/Autogenerated/SarifRewritingVisitor.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Rewriting visitor for the Sarif object model. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public abstract class SarifRewritingVisitor { /// diff --git a/src/Sarif/Autogenerated/SarifVersion.cs b/src/Sarif/Autogenerated/SarifVersion.cs index f7fb88d57..887b695da 100644 --- a/src/Sarif/Autogenerated/SarifVersion.cs +++ b/src/Sarif/Autogenerated/SarifVersion.cs @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Possible values for the SARIF schema version. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public enum SarifVersion { Unknown, diff --git a/src/Sarif/Autogenerated/Stack.cs b/src/Sarif/Autogenerated/Stack.cs index d8fa281e8..9a0576466 100644 --- a/src/Sarif/Autogenerated/Stack.cs +++ b/src/Sarif/Autogenerated/Stack.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// A call stack that is relevant to a result. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public partial class Stack : PropertyBagHolder, ISarifNode { public static IEqualityComparer ValueComparer => StackEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/StackEqualityComparer.cs b/src/Sarif/Autogenerated/StackEqualityComparer.cs index 47933bd1f..2aaaf48c2 100644 --- a/src/Sarif/Autogenerated/StackEqualityComparer.cs +++ b/src/Sarif/Autogenerated/StackEqualityComparer.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Stack for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] internal sealed class StackEqualityComparer : IEqualityComparer { internal static readonly StackEqualityComparer Instance = new StackEqualityComparer(); diff --git a/src/Sarif/Autogenerated/StackFrame.cs b/src/Sarif/Autogenerated/StackFrame.cs index 81e937d81..ae9f0ff7d 100644 --- a/src/Sarif/Autogenerated/StackFrame.cs +++ b/src/Sarif/Autogenerated/StackFrame.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// A function call within a stack trace. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public partial class StackFrame : PropertyBagHolder, ISarifNode { public static IEqualityComparer ValueComparer => StackFrameEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/StackFrameEqualityComparer.cs b/src/Sarif/Autogenerated/StackFrameEqualityComparer.cs index 8e0776fd6..41aac1330 100644 --- a/src/Sarif/Autogenerated/StackFrameEqualityComparer.cs +++ b/src/Sarif/Autogenerated/StackFrameEqualityComparer.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type StackFrame for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] internal sealed class StackFrameEqualityComparer : IEqualityComparer { internal static readonly StackFrameEqualityComparer Instance = new StackFrameEqualityComparer(); diff --git a/src/Sarif/Autogenerated/SuppressionStates.cs b/src/Sarif/Autogenerated/SuppressionStates.cs index 2fba538e2..f64b87268 100644 --- a/src/Sarif/Autogenerated/SuppressionStates.cs +++ b/src/Sarif/Autogenerated/SuppressionStates.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// The state of a result relative to a baseline of a previous run. /// [Flags] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public enum SuppressionStates { None, diff --git a/src/Sarif/Autogenerated/Tool.cs b/src/Sarif/Autogenerated/Tool.cs index 54d756a00..0903c0634 100644 --- a/src/Sarif/Autogenerated/Tool.cs +++ b/src/Sarif/Autogenerated/Tool.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// The analysis tool that was run. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public partial class Tool : PropertyBagHolder, ISarifNode { public static IEqualityComparer ValueComparer => ToolEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/ToolEqualityComparer.cs b/src/Sarif/Autogenerated/ToolEqualityComparer.cs index e0ec8c3c5..49422ac23 100644 --- a/src/Sarif/Autogenerated/ToolEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ToolEqualityComparer.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Tool for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] internal sealed class ToolEqualityComparer : IEqualityComparer { internal static readonly ToolEqualityComparer Instance = new ToolEqualityComparer(); diff --git a/src/Sarif/ToDotNet/ToDotNet.targets b/src/Sarif/ToDotNet/ToDotNet.targets index 72277bc01..38a3ea7d4 100644 --- a/src/Sarif/ToDotNet/ToDotNet.targets +++ b/src/Sarif/ToDotNet/ToDotNet.targets @@ -10,7 +10,7 @@ $(MSBuildProjectDirectory)\..\..\.nuget - ..\packages\Microsoft.Json.Schema.ToDotNet.0.42.0\tools\JsonSchemaToDotNet.exe + ..\packages\Microsoft.Json.Schema.ToDotNet.0.45.0\tools\JsonSchemaToDotNet.exe <_ObjectModelOutputDirectory>$(FlavorIndependentIntermediateOutputPath)Autogenerated diff --git a/src/Sarif/ToDotNet/packages.config b/src/Sarif/ToDotNet/packages.config index 3b7ea18df..8455bf13f 100644 --- a/src/Sarif/ToDotNet/packages.config +++ b/src/Sarif/ToDotNet/packages.config @@ -1,4 +1,4 @@ - + \ No newline at end of file From c1e22614b2b1169c6554173689045d61780809ad Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Wed, 24 Aug 2016 11:55:56 -0700 Subject: [PATCH 08/51] Remove FCIBs; Microsoft.Json.* now come from NuGet --- src/References/Microsoft.Json.Pointer.dll | Bin 11776 -> 0 bytes src/References/Microsoft.Json.Schema.dll | Bin 69632 -> 0 bytes 2 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/References/Microsoft.Json.Pointer.dll delete mode 100644 src/References/Microsoft.Json.Schema.dll diff --git a/src/References/Microsoft.Json.Pointer.dll b/src/References/Microsoft.Json.Pointer.dll deleted file mode 100644 index ad0fc571d0cb8883a14002c7c5d16d4fbea3e800..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 11776 zcmeHNeUuc{mA_TpUEMU$%rwFP0u~G(4GirJ!>0l=%nUfld@wy=)X|})yO=5M>1wK~ zfdL_nBW^Uhk!9VJC`S#exQWpE4eabk3yC%U7V zXsZ;U)^9$3x!>C>G*=xj)eM>>t5WT|1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bx=8L*H!|%S< z7TZL3Z#L77f$kpuI;OiJH`v&*9d8K4+rjSgzA>CDna}jH2LJ!A8ym|y-_2#Uj1MpQ zzrk^7J=kuWve{O=3US|0>$-Sv#kC*IhYbFV{eN`v7gh0%yEw7~K0FXkKs1WZe3#<> z$WHt$3HzOYEeP^g^BqVldH|b|z@(7awBy@E51wtb31z+>55D~eJ`=iMDg3V$grv*8 zSR}{X@T&=k1gV^^Y(mPAMVi1n$S$M_e9aTbx-Qgm(qyAvLt0^=7TL789tqwQU>ThB zSYB!}T2imzsfFF{-*TiR7z6Bm3AAm5yn#~s#6LJ_6g_dW!^xd0^s(^V3r-8!yqf|s z?xs2F87ZO)ebOTR8Gy$4T^xRZ;P;akwhUtAG|?xUF*^NJg;sb6Cwd%ibtk@bOQq3j z5*l*qYJhk6*ld9g?4{AVZ3SP8Z8}#Zy_1KYY+)b9)B(?EnhH`fcypg`9@%a``fBV>i>Ky{H5nV-w6CKiK!LJ diff --git a/src/References/Microsoft.Json.Schema.dll b/src/References/Microsoft.Json.Schema.dll deleted file mode 100644 index 4dd45a145fef5bd881d775ba48105bbffb925433..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 69632 zcmdS?33yc1`3H`__s-0nWHOnoWMNGpflDR{OK^z@vSXA@Ha8T8FhDTm#+d|&2nL}p z6>_CL9Mk_Tea4@BG#o^wQ8%iwl4qA`<`=W?j(cD_y7EU&-07s zz3+D3bIyCtdCzuln0v~_nKh1r#`sc=+N2?dF zZA(^lCY&{i*!rs0SVxD`Rkbo+mFVuMYU`+)F@I6jdS_LN58QvzNriJ^8u6>GN~)d z?ft1DTG5zDCR)LivZ0Jp(HuNIKT}Zp#zef`fg+ccP-gZ4Mf&MYW3l(==j>PfaM?@> z(AYIZi!Ub16)ybqA!PMLkBl&=SMxsavD&mNh(c!h7TEQh$?kFwsiKK36 zrlL@Dn0Zu43d=47dDz$$A*x)OT<|#(<^pxqLCR!U=;3-)hZu+``m^Nx*)qSI4 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bKg_vPp4K From 2110f950bce832869898850af6cc7f942132f2fc Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Wed, 24 Aug 2016 12:04:44 -0700 Subject: [PATCH 09/51] Add SarifCli.FunctionalTests to appveyor.yml --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index fb291fc32..3a8c67c10 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -31,6 +31,7 @@ test: - '**\Sarif.FunctionalTests.dll' - '**\Sarif.ValidationTests.dll' - '**\Sarif.Viewer.VisualStudio.UnitTests.dll' + - '**\Microsoft.CodeAnalysis.SarifCli.FunctionalTests.dll' notifications: - provider: Email From a80c8d99d7bb89dcc7f23be7e78af41318c8a457 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Thu, 25 Aug 2016 04:55:13 -0700 Subject: [PATCH 10/51] Refactor: Move HelpUri to SkimmerBase, rename RuleIds => RuleId --- src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs | 5 +---- src/SarifCli/Rules/{RuleIds.cs => RuleId.cs} | 3 ++- src/SarifCli/Rules/SarifValidationSkimmerBase.cs | 8 ++++++++ src/SarifCli/SarifCli.csproj | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) rename src/SarifCli/Rules/{RuleIds.cs => RuleId.cs} (71%) diff --git a/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs b/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs index ac834b80b..fcb6c75e0 100644 --- a/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs +++ b/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs @@ -11,13 +11,10 @@ public class DoNotUseFriendlyNameAsRuleId : SarifValidationSkimmerBase { public override string FullDescription => RuleResources.SV0001_DoNotUseFriendlyNameAsRuleIdDescription; - public override Uri HelpUri => - new Uri("https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html"); - /// /// SV0001 /// - public override string Id => RuleIds.DoNotUseFriendlyNameAsRuleId; + public override string Id => RuleId.DoNotUseFriendlyNameAsRuleId; protected override IEnumerable FormatIds { diff --git a/src/SarifCli/Rules/RuleIds.cs b/src/SarifCli/Rules/RuleId.cs similarity index 71% rename from src/SarifCli/Rules/RuleIds.cs rename to src/SarifCli/Rules/RuleId.cs index 2374cbcfb..95f9f06b7 100644 --- a/src/SarifCli/Rules/RuleIds.cs +++ b/src/SarifCli/Rules/RuleId.cs @@ -3,8 +3,9 @@ namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules { - public static class RuleIds + public static class RuleId { public const string DoNotUseFriendlyNameAsRuleId = "SV0001"; + public const string UseAbsolutePathsForNestedFileUriFragments = "SV0002"; } } diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs index d23732574..933c082fa 100644 --- a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System; using System.IO; using System.Resources; using Microsoft.CodeAnalysis.Sarif.Driver; @@ -13,6 +14,13 @@ namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules { public abstract class SarifValidationSkimmerBase : SkimmerBase { + private const string SarifSpecUri = + "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html"; + + private readonly Uri _defaultHelpUri = new Uri(SarifSpecUri); + + public override Uri HelpUri => _defaultHelpUri; + protected override ResourceManager ResourceManager => RuleResources.ResourceManager; public override void Analyze(SarifValidationContext context) diff --git a/src/SarifCli/SarifCli.csproj b/src/SarifCli/SarifCli.csproj index 33e7c96f6..87b43fa0a 100644 --- a/src/SarifCli/SarifCli.csproj +++ b/src/SarifCli/SarifCli.csproj @@ -57,7 +57,7 @@ True RuleResources.resx - + From d241fa08a682d9d38472f45b1ad341b133d5d8d7 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Thu, 25 Aug 2016 05:04:41 -0700 Subject: [PATCH 11/51] Refactor: Make Context a protected property of SkimmerBase --- .../Rules/DoNotUseFriendlyNameAsRuleId.cs | 13 ++++++------- .../Rules/SarifValidationSkimmerBase.cs | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs b/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs index fcb6c75e0..757b909d2 100644 --- a/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs +++ b/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs @@ -27,12 +27,11 @@ protected override IEnumerable FormatIds } } - protected override void AnalyzeCore(SarifValidationContext context) + protected override void AnalyzeCore() { - SarifLog log = context.InputLog; - if (log.Runs != null) + if (InputLog.Runs != null) { - Run[] runs = log.Runs.ToArray(); + Run[] runs = InputLog.Runs.ToArray(); for (int iRun = 0; iRun < runs.Length; ++iRun) { Run run = runs[iRun]; @@ -47,10 +46,10 @@ protected override void AnalyzeCore(SarifValidationContext context) && rule.Id.Equals(rule.Name, StringComparison.OrdinalIgnoreCase)) { string jPointerValue = $"/runs/{iRun}/rules/{rule.Id}"; - Region region = GetRegionFromJPointer(jPointerValue, context); + Region region = GetRegionFromJPointer(jPointerValue); - context.Logger.Log(this, - RuleUtilities.BuildResult(ResultLevel.Warning, context, region, nameof(RuleResources.SV0001_DefaultFormatId), rule.Id)); + Context.Logger.Log(this, + RuleUtilities.BuildResult(ResultLevel.Warning, Context, region, nameof(RuleResources.SV0001_DefaultFormatId), rule.Id)); } } } diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs index 933c082fa..e18f9cd28 100644 --- a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -21,28 +21,34 @@ public abstract class SarifValidationSkimmerBase : SkimmerBase _defaultHelpUri; + protected SarifValidationContext Context { get; private set; } + protected SarifLog InputLog { get; private set; } + protected JToken InputLogToken { get; private set; } + protected override ResourceManager ResourceManager => RuleResources.ResourceManager; public override void Analyze(SarifValidationContext context) { + Context = context; + JsonSerializerSettings settings = new JsonSerializerSettings { ContractResolver = SarifContractResolver.Instance }; string inputLogContents = File.ReadAllText(context.TargetUri.LocalPath); - context.InputLogToken = JToken.Parse(inputLogContents); - context.InputLog = JsonConvert.DeserializeObject(inputLogContents, settings); + InputLogToken = JToken.Parse(inputLogContents); + InputLog = JsonConvert.DeserializeObject(inputLogContents, settings); - AnalyzeCore(context); + AnalyzeCore(); } - protected abstract void AnalyzeCore(SarifValidationContext context); + protected abstract void AnalyzeCore(); - protected Region GetRegionFromJPointer(string jPointerValue, SarifValidationContext context) + protected Region GetRegionFromJPointer(string jPointerValue) { JsonPointer jPointer = new JsonPointer(jPointerValue); - JToken jToken = jPointer.Evaluate(context.InputLogToken); + JToken jToken = jPointer.Evaluate(InputLogToken); IJsonLineInfo lineInfo = jToken; Region region = null; From 3316b0a33bc54ea0f02fa579389e8f4e6d6cc27e Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Thu, 25 Aug 2016 05:13:26 -0700 Subject: [PATCH 12/51] Refactor: Move visiting logic into SkimmerBase --- .../Rules/DoNotUseFriendlyNameAsRuleId.cs | 31 +++++-------------- .../Rules/SarifValidationSkimmerBase.cs | 22 +++++++++++-- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs b/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs index 757b909d2..1c8bae675 100644 --- a/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs +++ b/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs @@ -27,33 +27,16 @@ protected override IEnumerable FormatIds } } - protected override void AnalyzeCore() + protected override void Visit(Rule rule, string jPointer) { - if (InputLog.Runs != null) + if (rule.Id != null + && rule.Name != null + && rule.Id.Equals(rule.Name, StringComparison.OrdinalIgnoreCase)) { - Run[] runs = InputLog.Runs.ToArray(); - for (int iRun = 0; iRun < runs.Length; ++iRun) - { - Run run = runs[iRun]; - if (run.Rules != null) - { - Rule[] rules = run.Rules.Values.ToArray(); - for (int iRule = 0; iRule < rules.Length; ++iRule) - { - Rule rule = rules[iRule]; - if (rule.Id != null - && rule.Name != null - && rule.Id.Equals(rule.Name, StringComparison.OrdinalIgnoreCase)) - { - string jPointerValue = $"/runs/{iRun}/rules/{rule.Id}"; - Region region = GetRegionFromJPointer(jPointerValue); + Region region = GetRegionFromJPointer(jPointer); - Context.Logger.Log(this, - RuleUtilities.BuildResult(ResultLevel.Warning, Context, region, nameof(RuleResources.SV0001_DefaultFormatId), rule.Id)); - } - } - } - } + Context.Logger.Log(this, + RuleUtilities.BuildResult(ResultLevel.Warning, Context, region, nameof(RuleResources.SV0001_DefaultFormatId), rule.Id)); } } } diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs index e18f9cd28..5ba71f3a2 100644 --- a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -3,6 +3,7 @@ using System; using System.IO; +using System.Linq; using System.Resources; using Microsoft.CodeAnalysis.Sarif.Driver; using Microsoft.CodeAnalysis.Sarif.Readers; @@ -40,10 +41,27 @@ public override void Analyze(SarifValidationContext context) InputLogToken = JToken.Parse(inputLogContents); InputLog = JsonConvert.DeserializeObject(inputLogContents, settings); - AnalyzeCore(); + if (InputLog.Runs != null) + { + Run[] runs = InputLog.Runs.ToArray(); + for (int iRun = 0; iRun < runs.Length; ++iRun) + { + Run run = runs[iRun]; + if (run.Rules != null) + { + Rule[] rules = run.Rules.Values.ToArray(); + for (int iRule = 0; iRule < rules.Length; ++iRule) + { + Rule rule = rules[iRule]; + string jPointer = $"/runs/{iRun}/rules/{rule.Id}"; + Visit(rule, jPointer); + } + } + } + } } - protected abstract void AnalyzeCore(); + protected abstract void Visit(Rule rule, string jPointer); protected Region GetRegionFromJPointer(string jPointerValue) { From b1da0ed32a45c6889c00aa8cb3bca209c7296001 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Thu, 25 Aug 2016 05:24:52 -0700 Subject: [PATCH 13/51] Refactor: Move result construction to SkimmerBase --- src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs | 5 +---- src/SarifCli/Rules/SarifValidationSkimmerBase.cs | 14 +++++++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs b/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs index 1c8bae675..b8eb85571 100644 --- a/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs +++ b/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs @@ -33,10 +33,7 @@ protected override void Visit(Rule rule, string jPointer) && rule.Name != null && rule.Id.Equals(rule.Name, StringComparison.OrdinalIgnoreCase)) { - Region region = GetRegionFromJPointer(jPointer); - - Context.Logger.Log(this, - RuleUtilities.BuildResult(ResultLevel.Warning, Context, region, nameof(RuleResources.SV0001_DefaultFormatId), rule.Id)); + LogResult(ResultLevel.Warning, jPointer, nameof(RuleResources.SV0001_DefaultFormatId), rule.Id); } } } diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs index 5ba71f3a2..e7f2676c5 100644 --- a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -26,9 +26,9 @@ public abstract class SarifValidationSkimmerBase : SkimmerBase RuleResources.ResourceManager; + protected override sealed ResourceManager ResourceManager => RuleResources.ResourceManager; - public override void Analyze(SarifValidationContext context) + public override sealed void Analyze(SarifValidationContext context) { Context = context; @@ -63,7 +63,15 @@ public override void Analyze(SarifValidationContext context) protected abstract void Visit(Rule rule, string jPointer); - protected Region GetRegionFromJPointer(string jPointerValue) + protected void LogResult(ResultLevel level, string jPointer, string formatId, params string[] args) + { + Region region = GetRegionFromJPointer(jPointer); + + Context.Logger.Log(this, + RuleUtilities.BuildResult(ResultLevel.Warning, Context, region, formatId, args)); + } + + private Region GetRegionFromJPointer(string jPointerValue) { JsonPointer jPointer = new JsonPointer(jPointerValue); JToken jToken = jPointer.Evaluate(InputLogToken); From 2da17d4cffc01fb0c9223e209255da88412760f2 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Thu, 25 Aug 2016 05:30:29 -0700 Subject: [PATCH 14/51] Refactor: Rename SkimmerBase.Visit to Analyze --- src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs | 3 +-- src/SarifCli/Rules/SarifValidationSkimmerBase.cs | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs b/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs index b8eb85571..88e8b8ab5 100644 --- a/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs +++ b/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules { @@ -27,7 +26,7 @@ protected override IEnumerable FormatIds } } - protected override void Visit(Rule rule, string jPointer) + protected override void Analyze(Rule rule, string jPointer) { if (rule.Id != null && rule.Name != null diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs index e7f2676c5..4c519aac5 100644 --- a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -54,14 +54,14 @@ public override sealed void Analyze(SarifValidationContext context) { Rule rule = rules[iRule]; string jPointer = $"/runs/{iRun}/rules/{rule.Id}"; - Visit(rule, jPointer); + Analyze(rule, jPointer); } } } } } - protected abstract void Visit(Rule rule, string jPointer); + protected abstract void Analyze(Rule rule, string jPointer); protected void LogResult(ResultLevel level, string jPointer, string formatId, params string[] args) { @@ -71,10 +71,10 @@ protected void LogResult(ResultLevel level, string jPointer, string formatId, pa RuleUtilities.BuildResult(ResultLevel.Warning, Context, region, formatId, args)); } - private Region GetRegionFromJPointer(string jPointerValue) + private Region GetRegionFromJPointer(string jPointer) { - JsonPointer jPointer = new JsonPointer(jPointerValue); - JToken jToken = jPointer.Evaluate(InputLogToken); + JsonPointer jsonPointer = new JsonPointer(jPointer); + JToken jToken = jsonPointer.Evaluate(InputLogToken); IJsonLineInfo lineInfo = jToken; Region region = null; From 06a904a1d1dddf03093ee91f76fcc8e09a594b7c Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Thu, 25 Aug 2016 05:39:47 -0700 Subject: [PATCH 15/51] Refactor: Extract Visit method; remove unneeded properties --- .../Rules/SarifValidationSkimmerBase.cs | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs index 4c519aac5..1f15c8f78 100644 --- a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -19,12 +19,11 @@ public abstract class SarifValidationSkimmerBase : SkimmerBase _defaultHelpUri; protected SarifValidationContext Context { get; private set; } - protected SarifLog InputLog { get; private set; } - protected JToken InputLogToken { get; private set; } protected override sealed ResourceManager ResourceManager => RuleResources.ResourceManager; @@ -32,18 +31,23 @@ public override sealed void Analyze(SarifValidationContext context) { Context = context; + string logContents = File.ReadAllText(context.TargetUri.LocalPath); + _rootToken = JToken.Parse(logContents); + JsonSerializerSettings settings = new JsonSerializerSettings { ContractResolver = SarifContractResolver.Instance }; - string inputLogContents = File.ReadAllText(context.TargetUri.LocalPath); - InputLogToken = JToken.Parse(inputLogContents); - InputLog = JsonConvert.DeserializeObject(inputLogContents, settings); + SarifLog log = JsonConvert.DeserializeObject(logContents, settings); + Visit(log); + } - if (InputLog.Runs != null) + private void Visit(SarifLog log) + { + if (log.Runs != null) { - Run[] runs = InputLog.Runs.ToArray(); + Run[] runs = log.Runs.ToArray(); for (int iRun = 0; iRun < runs.Length; ++iRun) { Run run = runs[iRun]; @@ -74,7 +78,7 @@ protected void LogResult(ResultLevel level, string jPointer, string formatId, pa private Region GetRegionFromJPointer(string jPointer) { JsonPointer jsonPointer = new JsonPointer(jPointer); - JToken jToken = jsonPointer.Evaluate(InputLogToken); + JToken jToken = jsonPointer.Evaluate(_rootToken); IJsonLineInfo lineInfo = jToken; Region region = null; From 7d6ccddd23919fd1bc4d7090d42bf5cfa4103b39 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Thu, 25 Aug 2016 06:04:31 -0700 Subject: [PATCH 16/51] Refactor: Extract Visit(Run), decompose pointer construction --- src/SarifCli/JPointerStringExtensions.cs | 18 +++++++++ .../Rules/DoNotUseFriendlyNameAsRuleId.cs | 4 +- .../Rules/SarifValidationSkimmerBase.cs | 40 ++++++++++++++----- src/SarifCli/SarifCli.csproj | 2 + src/SarifCli/SarifPropertyName.cs | 15 +++++++ 5 files changed, 66 insertions(+), 13 deletions(-) create mode 100644 src/SarifCli/JPointerStringExtensions.cs create mode 100644 src/SarifCli/SarifPropertyName.cs diff --git a/src/SarifCli/JPointerStringExtensions.cs b/src/SarifCli/JPointerStringExtensions.cs new file mode 100644 index 000000000..3fda6590c --- /dev/null +++ b/src/SarifCli/JPointerStringExtensions.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace Microsoft.CodeAnalysis.Sarif.Cli +{ + internal static class JPointerStringExtensions + { + internal static string AtProperty(this string jPointerValue, string propertyName) + { + return $"{jPointerValue}/{propertyName}"; + } + + internal static string AtIndex(this string jPointerValue, int index) + { + return $"{jPointerValue}/{index}"; + } + } +} diff --git a/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs b/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs index 88e8b8ab5..ab18baf2e 100644 --- a/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs +++ b/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs @@ -26,13 +26,13 @@ protected override IEnumerable FormatIds } } - protected override void Analyze(Rule rule, string jPointer) + protected override void Analyze(Rule rule, string rulePointer) { if (rule.Id != null && rule.Name != null && rule.Id.Equals(rule.Name, StringComparison.OrdinalIgnoreCase)) { - LogResult(ResultLevel.Warning, jPointer, nameof(RuleResources.SV0001_DefaultFormatId), rule.Id); + LogResult(ResultLevel.Warning, rulePointer, nameof(RuleResources.SV0001_DefaultFormatId), rule.Id); } } } diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs index 1f15c8f78..866846bbc 100644 --- a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -40,32 +40,50 @@ public override sealed void Analyze(SarifValidationContext context) }; SarifLog log = JsonConvert.DeserializeObject(logContents, settings); - Visit(log); + string logPointer = string.Empty; + + Visit(log, logPointer); } - private void Visit(SarifLog log) + private void Visit(SarifLog log, string logPointer) { if (log.Runs != null) { Run[] runs = log.Runs.ToArray(); + string runsPointer = logPointer.AtProperty(SarifPropertyName.Runs); + for (int iRun = 0; iRun < runs.Length; ++iRun) { Run run = runs[iRun]; - if (run.Rules != null) + string runPointer = runsPointer.AtIndex(iRun); + + Visit(run, runPointer); + } + } + } + + private void Visit(Run run, string runPointer) + { + if (run.Rules != null) + { + Rule[] rules = run.Rules.Values.ToArray(); + string rulesPointer = runPointer.AtProperty(SarifPropertyName.Rules); + + for (int iRule = 0; iRule < rules.Length; ++iRule) + { + Rule rule = rules[iRule]; + if (rule.Id != null) { - Rule[] rules = run.Rules.Values.ToArray(); - for (int iRule = 0; iRule < rules.Length; ++iRule) - { - Rule rule = rules[iRule]; - string jPointer = $"/runs/{iRun}/rules/{rule.Id}"; - Analyze(rule, jPointer); - } + string rulePointer = rulesPointer.AtProperty(rule.Id); + Analyze(rule, rulePointer); } } } } - protected abstract void Analyze(Rule rule, string jPointer); + protected virtual void Analyze(Rule rule, string jPointer) + { + } protected void LogResult(ResultLevel level, string jPointer, string formatId, params string[] args) { diff --git a/src/SarifCli/SarifCli.csproj b/src/SarifCli/SarifCli.csproj index 87b43fa0a..8f8aa4d14 100644 --- a/src/SarifCli/SarifCli.csproj +++ b/src/SarifCli/SarifCli.csproj @@ -51,6 +51,7 @@ + True @@ -59,6 +60,7 @@ + diff --git a/src/SarifCli/SarifPropertyName.cs b/src/SarifCli/SarifPropertyName.cs new file mode 100644 index 000000000..5c43681ab --- /dev/null +++ b/src/SarifCli/SarifPropertyName.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace Microsoft.CodeAnalysis.Sarif.Cli +{ + public static class SarifPropertyName + { + public const string AnalysisTarget = "analysisTarget"; + public const string Locations = "locations"; + public const string ResultFile = "resultFile"; + public const string Results = "results"; + public const string Rules = "rules"; + public const string Runs = "runs"; + } +} From e03e8e952d726968bc50283fa749ff9719e986f5 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Thu, 25 Aug 2016 06:18:30 -0700 Subject: [PATCH 17/51] Bug fix: Command line broken: can't find System.Composition.Hosting --- src/SarifCli/SarifCli.csproj | 30 ++++++++++++++++++++++++++---- src/SarifCli/packages.config | 9 +++++---- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/src/SarifCli/SarifCli.csproj b/src/SarifCli/SarifCli.csproj index 8f8aa4d14..bede7de6b 100644 --- a/src/SarifCli/SarifCli.csproj +++ b/src/SarifCli/SarifCli.csproj @@ -20,6 +20,10 @@ ..\packages\CommandLineParser.2.0.275-beta\lib\net45\CommandLine.dll True + + ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll + True + ..\packages\Sarif.Sdk.1.5.27\lib\net45\Sarif.dll True @@ -36,11 +40,27 @@ ..\packages\Microsoft.Json.Pointer.0.45.0\lib\net451\Microsoft.Json.Pointer.dll True - - ..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll + + + ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.AttributedModel.dll + True + + + ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.Convention.dll + True + + + ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.Hosting.dll + True + + + ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.Runtime.dll + True + + + ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll True - @@ -74,7 +94,9 @@ - + + Designer + diff --git a/src/SarifCli/packages.config b/src/SarifCli/packages.config index f2ffea301..a22ee2baf 100644 --- a/src/SarifCli/packages.config +++ b/src/SarifCli/packages.config @@ -1,9 +1,10 @@  - - - - + + + + + \ No newline at end of file From a5182913abee9eb8d0cd5a2026c89632b839a424 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Thu, 25 Aug 2016 06:31:30 -0700 Subject: [PATCH 18/51] SarifCli: Visit results (prep for the next skimmer) --- .../Rules/SarifValidationSkimmerBase.cs | 57 ++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs index 866846bbc..88fd3b585 100644 --- a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -64,6 +64,20 @@ private void Visit(SarifLog log, string logPointer) private void Visit(Run run, string runPointer) { + if (run.Results != null) + { + Result[] results = run.Results.ToArray(); + string resultsPointer = runPointer.AtProperty(SarifPropertyName.Results); + + for (int iResult = 0; iResult < results.Length; ++iResult) + { + Result result = results[iResult]; + string resultPointer = resultsPointer.AtIndex(iResult); + + Visit(result, resultPointer); + } + } + if (run.Rules != null) { Rule[] rules = run.Rules.Values.ToArray(); @@ -81,7 +95,48 @@ private void Visit(Run run, string runPointer) } } - protected virtual void Analyze(Rule rule, string jPointer) + private void Visit(Result result, string resultPointer) + { + if (result.Locations != null) + { + Location[] locations = result.Locations.ToArray(); + string locationsPointer = resultPointer.AtProperty(SarifPropertyName.Locations); + + for (int iLocation = 0; iLocation < locations.Length; ++iLocation) + { + Location location = locations[iLocation]; + string locationPointer = locationsPointer.AtIndex(iLocation); + + Visit(location, locationPointer); + } + } + } + + private void Visit(Location location, string locationPointer) + { + if (location.AnalysisTarget != null) + { + string analysisTargetPointer = locationPointer.AtProperty(SarifPropertyName.AnalysisTarget); + Visit(location.AnalysisTarget, analysisTargetPointer); + } + + if (location.ResultFile != null) + { + string resultFilePointer = locationPointer.AtProperty(SarifPropertyName.ResultFile); + Visit(location.ResultFile, resultFilePointer); + } + } + + private void Visit(PhysicalLocation physicalLocation, string physicalLocationPointer) + { + Analyze(physicalLocation, physicalLocationPointer); + } + + protected virtual void Analyze(Rule rule, string rulePointer) + { + } + + protected virtual void Analyze(PhysicalLocation physicalLocation, string physicalLocationPointer) { } From 2a7ca770955fb22620c0cb30f4f6c2a64f0e155d Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Thu, 25 Aug 2016 14:02:50 -0700 Subject: [PATCH 19/51] SarifCli: Start of UseAbsolutePathsForNestedFileUriFragments skimmer --- .../Rules/SkimmerTestsBase.cs | 25 +++-- ...lutePathsForNestedFileUriFragmentsTests.cs | 32 ++++++ .../SarifCli.FunctionalTests.csproj | 21 +++- ...ragmentIsRelativeInAnalysisTargetUri.sarif | 49 +++++++++ ...RelativeInAnalysisTargetUri_Expected.sarif | 83 ++++++++++++++++ ...FragmentIsRelativeInFilePropertyName.sarif | 49 +++++++++ ...sRelativeInFilePropertyName_Expected.sarif | 83 ++++++++++++++++ ...edFileUriFragmentIsRelativeInFileUri.sarif | 54 ++++++++++ .../NestedFileUriFragmentsAreAbsolute.sarif | 49 +++++++++ ...FileUriFragmentsAreAbsolute_Expected.sarif | 46 +++++++++ src/SarifCli/JPointerStringExtensions.cs | 28 +++++- .../Rules/DoNotUseFriendlyNameAsRuleId.cs | 6 +- src/SarifCli/Rules/RuleResources.Designer.cs | 18 ++++ src/SarifCli/Rules/RuleResources.resx | 6 ++ .../Rules/SarifValidationSkimmerBase.cs | 23 +++++ ...eAbsolutePathsForNestedFileUriFragments.cs | 99 +++++++++++++++++++ src/SarifCli/SarifCli.csproj | 1 + src/SarifCli/SarifPropertyName.cs | 2 + 18 files changed, 659 insertions(+), 15 deletions(-) create mode 100644 src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs create mode 100644 src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFileUri.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentsAreAbsolute.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentsAreAbsolute_Expected.sarif create mode 100644 src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs diff --git a/src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs b/src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs index 60c961198..c41898ae9 100644 --- a/src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs +++ b/src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs @@ -78,20 +78,27 @@ private static void SelectiveCompare(string actualLogContents, string expectedLo private static void SelectiveCompare(SarifLog actualLog, SarifLog expectedLog) { - Result[] actualResults = actualLog.Runs[0].Results.ToArray(); - Result[] expectedResults = expectedLog.Runs[0].Results.ToArray(); + Result[] actualResults = actualLog.Runs[0].Results == null ? null : actualLog.Runs[0].Results.ToArray(); + Result[] expectedResults = expectedLog.Runs[0].Results == null ? null : expectedLog.Runs[0].Results.ToArray(); - actualResults.Length.Should().Be(expectedResults.Length); + bool actualHasResults = actualResults != null && actualResults.Length > 0; + bool expectedHasResults = expectedResults != null && expectedResults.Length > 0; + actualHasResults.Should().Be(expectedHasResults); - for (int i = 0; i < actualResults.Length; ++i) + if (actualHasResults && expectedHasResults) { - Result actualResult = actualResults[i]; - Result expectedResult = expectedResults[i]; + actualResults.Length.Should().Be(expectedResults.Length); - actualResult.RuleId.Should().Be(expectedResult.RuleId); + for (int i = 0; i < actualResults.Length; ++i) + { + Result actualResult = actualResults[i]; + Result expectedResult = expectedResults[i]; + + actualResult.RuleId.Should().Be(expectedResult.RuleId); - actualResult.Locations[0].AnalysisTarget.Region.ValueEquals( - expectedResult.Locations[0].AnalysisTarget.Region).Should().BeTrue(); + actualResult.Locations[0].AnalysisTarget.Region.ValueEquals( + expectedResult.Locations[0].AnalysisTarget.Region).Should().BeTrue(); + } } } diff --git a/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs b/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs new file mode 100644 index 000000000..790b287a8 --- /dev/null +++ b/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.CodeAnalysis.Sarif.Cli.Rules; +using Xunit; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules +{ + public class UseAbsolutePathsForNestedFileUriFragmentsTests : SkimmerTestsBase + { + [Fact] + public void UseAbsolutePathsForNestedFileUriFragments_NoDiagnostic_NestedFileUriFragmentsAreAbsolute() + { + Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentsAreAbsolute.sarif"); + } + + [Fact] + public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInAnalysisTargetUri() + { + Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInAnalysisTargetUri.sarif"); + } + + // TODO Add a test for ResultFile.Uri + // TODO Add tests for other locations, like annotatedCodeLocation.Uri. + + [Fact] + public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInFilePropertyName() + { + Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInFilePropertyName.sarif"); + } + } +} diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj index dc9b709a3..0356873d6 100644 --- a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -35,7 +35,7 @@ True - ..\packages\Sarif.Sdk.1.5.27\lib\net45\Sarif.Driver.dll + ..\packages\Sarif.Driver.1.5.27\lib\net45\Sarif.Driver.dll True @@ -67,6 +67,7 @@ + @@ -90,6 +91,24 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri.sarif new file mode 100644 index 000000000..629428758 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri.sarif @@ -0,0 +1,49 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "e7d5cf38-c160-4bf9-aed1-e84ad6849df3", + "tool": { + "name": "ModernCop", + "fullName": "mod50 7.0.7000.0", + "version": "7.0.7000.0", + "semanticVersion": "7.0.7000", + "fileVersion": "7.0.20811.0", + "language": "en-US", + "properties": { + "CompanyName": "Microsoft Corporation" + } + }, + "results": [ + { + "ruleKey": "M1003.DoNotShipObfuscatedCode", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#js/minified.js", + "region": { + "startLine": 1 + } + } + } + ] + } + ], + "files": { + "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx": { + "mimeType": "application/vns.ms-appx" + }, + "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#/js/minified.js": { + "uri": "/js/minified.js", + "parentKey": "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx", + "mimeType": "text/javascript" + } + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri_Expected.sarif new file mode 100644 index 000000000..7e7a88420 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri_Expected.sarif @@ -0,0 +1,83 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "19b6f898-17e4-4fc7-a4c8-b1df8dc63bec", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0002", + "level": "warning", + "formattedRuleMessage": { + "formatId": "DefaultFormatId", + "arguments": [ + "NestedFileUriFragmentIsRelativeInLocation.sarif", + "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#js/minified.js" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInLocation.sarif", + "region": { + "startLine": 28, + "startColumn": 177 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInLocation.sarif" + }, + "message": "Analyzing 'NestedFileUriFragmentIsRelativeInLocation.sarif'...", + "level": "note", + "time": "2016-08-25T13:52:33.775Z" + } + ], + "rules": { + "SV0002": { + "id": "SV0002", + "name": "UseAbsolutePathsForNestedFileUriFragments", + "shortDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path.", + "fullDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path. That is, begin the with a forward slash, for example \"file:///C:/bin/MyApp.zip#/images/grape.jpg\".", + "messageFormats": { + "DefaultFormatId": "In \"{0}\", the fragment portion of the URI \"{1}\", which specifies the location of a nested file with respect to its parent, does not begin with a forward slash." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInLocation.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UseAbsolutePathsForNestedFileUriFragments\\NestedFileUriFragmentIsRelativeInLocation.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\SarifCli.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-25T13:52:33.603Z", + "endTime": "2016-08-25T13:52:34.072Z", + "processId": 5184, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName.sarif new file mode 100644 index 000000000..9f460c224 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName.sarif @@ -0,0 +1,49 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "e7d5cf38-c160-4bf9-aed1-e84ad6849df3", + "tool": { + "name": "ModernCop", + "fullName": "mod50 7.0.7000.0", + "version": "7.0.7000.0", + "semanticVersion": "7.0.7000", + "fileVersion": "7.0.20811.0", + "language": "en-US", + "properties": { + "CompanyName": "Microsoft Corporation" + } + }, + "results": [ + { + "ruleKey": "M1003.DoNotShipObfuscatedCode", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#/js/minified.js", + "region": { + "startLine": 1 + } + } + } + ] + } + ], + "files": { + "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx": { + "mimeType": "application/vns.ms-appx" + }, + "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#js/minified.js": { + "uri": "/js/minified.js", + "parentKey": "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx", + "mimeType": "text/javascript" + } + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName_Expected.sarif new file mode 100644 index 000000000..935578b9b --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName_Expected.sarif @@ -0,0 +1,83 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "11401fd5-e0ef-47dc-beec-c20d7d2aab1f", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0002", + "level": "warning", + "formattedRuleMessage": { + "formatId": "DefaultFormatId", + "arguments": [ + "NestedFileUriFragmentIsRelativeInFilePropertyName.sarif", + "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#js/minified.js" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName.sarif", + "region": { + "startLine": 41, + "startColumn": 165 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName.sarif" + }, + "message": "Analyzing 'NestedFileUriFragmentIsRelativeInFilePropertyName.sarif'...", + "level": "note", + "time": "2016-08-25T18:17:11.515Z" + } + ], + "rules": { + "SV0002": { + "id": "SV0002", + "name": "UseAbsolutePathsForNestedFileUriFragments", + "shortDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path.", + "fullDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path. That is, begin the with a forward slash, for example \"file:///C:/bin/MyApp.zip#/images/grape.jpg\".", + "messageFormats": { + "DefaultFormatId": "In \"{0}\", the fragment portion of the URI \"{1}\", which specifies the location of a nested file with respect to its parent, does not begin with a forward slash." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UseAbsolutePathsForNestedFileUriFragments\\NestedFileUriFragmentIsRelativeInFilePropertyName.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\SarifCli.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-25T18:17:11.434Z", + "endTime": "2016-08-25T18:17:11.774Z", + "processId": 14016, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFileUri.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFileUri.sarif new file mode 100644 index 000000000..d64dc96c7 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFileUri.sarif @@ -0,0 +1,54 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "e7d5cf38-c160-4bf9-aed1-e84ad6849df3", + "tool": { + "name": "ModernCop", + "fullName": "mod50 7.0.7000.0", + "version": "7.0.7000.0", + "semanticVersion": "7.0.7000", + "fileVersion": "7.0.20811.0", + "language": "en-US", + "properties": { + "CompanyName": "Microsoft Corporation" + } + }, + "results": [ + { + "ruleKey": "M1003.DoNotShipObfuscatedCode", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/bin/myBundle.appxBundle#/myApp.appx/js/minified.js", + "region": { + "startLine": 1 + } + } + } + ] + } + ], + "files": { + "file:///c:/bin/myBundle.appxBundle": { + "mimeType": "application/vns.ms-appxBundle" + }, + "file:///c:/bin/myBundle.appxBundle#/myApp.appx": { + "uri": "/myApp.appx", + "parentKey": "file:///c:/bin/myBundle.appxBundle", + "mimeType": "application/vns.ms-appx" + }, + "file:///c:/bin/myBundle.appxBundle#/myApp.appx/js/minified.js": { + "uri": "js/minified.js", + "parentKey": "file:///c:/bin/myBundle.appxBundle#/myApp.appx", + "mimeType": "text/javascript" + } + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentsAreAbsolute.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentsAreAbsolute.sarif new file mode 100644 index 000000000..88020b0a1 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentsAreAbsolute.sarif @@ -0,0 +1,49 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "e7d5cf38-c160-4bf9-aed1-e84ad6849df3", + "tool": { + "name": "ModernCop", + "fullName": "mod50 7.0.7000.0", + "version": "7.0.7000.0", + "semanticVersion": "7.0.7000", + "fileVersion": "7.0.20811.0", + "language": "en-US", + "properties": { + "CompanyName": "Microsoft Corporation" + } + }, + "results": [ + { + "ruleKey": "M1003.DoNotShipObfuscatedCode", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#/js/minified.js", + "region": { + "startLine": 1 + } + } + } + ] + } + ], + "files": { + "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx": { + "mimeType": "application/vns.ms-appx" + }, + "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#/js/minified.js": { + "uri": "/js/minified.js", + "parentKey": "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx", + "mimeType": "text/javascript" + } + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentsAreAbsolute_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentsAreAbsolute_Expected.sarif new file mode 100644 index 000000000..a7b180d47 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentsAreAbsolute_Expected.sarif @@ -0,0 +1,46 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "f603e2a9-fe09-434e-a0df-7261e78c9d0b", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentsAreAbsolute.sarif" + }, + "message": "Analyzing 'NestedFileUriFragmentsAreAbsolute.sarif'...", + "level": "note", + "time": "2016-08-25T20:52:39.415Z" + } + ], + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentsAreAbsolute.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UseAbsolutePathsForNestedFileUriFragments\\NestedFileUriFragmentsAreAbsolute.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\NestedFileUriFragmentsAreAbsolute_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-25T20:52:39.233Z", + "endTime": "2016-08-25T20:52:39.677Z", + "processId": 10412, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli/JPointerStringExtensions.cs b/src/SarifCli/JPointerStringExtensions.cs index 3fda6590c..27de4ddf2 100644 --- a/src/SarifCli/JPointerStringExtensions.cs +++ b/src/SarifCli/JPointerStringExtensions.cs @@ -5,14 +5,34 @@ namespace Microsoft.CodeAnalysis.Sarif.Cli { internal static class JPointerStringExtensions { - internal static string AtProperty(this string jPointerValue, string propertyName) + internal static string AtProperty(this string jPointer, string propertyName) { - return $"{jPointerValue}/{propertyName}"; + return $"{jPointer}/{propertyName.EscapeJsonPointer()}"; } - internal static string AtIndex(this string jPointerValue, int index) + internal static string AtIndex(this string jPointer, int index) { - return $"{jPointerValue}/{index}"; + return $"{jPointer}/{index}"; + } + + // The components of a JSON Pointer are separated by a '/' character. So when + // constructing a JSON Pointer one of whose components is a property name that + // includes the '/' character, that character must be escaped with "~1". But now + // the '~' character is also special, so it must be escaped with "~0". + // + // When escaping, the "~" replacement must come first. Otherwise, the string "/" + // would translate to "~01" instead of the correct "~1". Similarly, when + // unescaping, the "~1" replacement must come first. + // + // TODO: These methods belong in the Microsoft.Json.Pointer library. + internal static string EscapeJsonPointer(this string propertyName) + { + return propertyName.Replace("~", "~0").Replace("/", "~1"); + } + + internal static string UnescapeJsonPointer(this string jPointer) + { + return jPointer.Replace("~1", "/").Replace("~0", "~"); } } } diff --git a/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs b/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs index ab18baf2e..e77ded3f9 100644 --- a/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs +++ b/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs @@ -32,7 +32,11 @@ protected override void Analyze(Rule rule, string rulePointer) && rule.Name != null && rule.Id.Equals(rule.Name, StringComparison.OrdinalIgnoreCase)) { - LogResult(ResultLevel.Warning, rulePointer, nameof(RuleResources.SV0001_DefaultFormatId), rule.Id); + LogResult( + ResultLevel.Warning, + rulePointer, + nameof(RuleResources.SV0001_DefaultFormatId), + rule.Id); } } } diff --git a/src/SarifCli/Rules/RuleResources.Designer.cs b/src/SarifCli/Rules/RuleResources.Designer.cs index 0773aa8ca..dca54fe0b 100644 --- a/src/SarifCli/Rules/RuleResources.Designer.cs +++ b/src/SarifCli/Rules/RuleResources.Designer.cs @@ -77,5 +77,23 @@ internal static string SV0001_DoNotUseFriendlyNameAsRuleIdDescription { return ResourceManager.GetString("SV0001_DoNotUseFriendlyNameAsRuleIdDescription", resourceCulture); } } + + /// + /// Looks up a localized string similar to In "{0}", the fragment portion of the URI "{1}", which specifies the location of a nested file with respect to its parent, does not begin with a forward slash.. + /// + internal static string SV0002_DefaultFormatId { + get { + return ResourceManager.GetString("SV0002_DefaultFormatId", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path. That is, begin the with a forward slash, for example "file:///C:/bin/MyApp.zip#/images/grape.jpg".. + /// + internal static string SV0002_UseAbsolutePathsForNestedFileUriFragmentsDescription { + get { + return ResourceManager.GetString("SV0002_UseAbsolutePathsForNestedFileUriFragmentsDescription", resourceCulture); + } + } } } diff --git a/src/SarifCli/Rules/RuleResources.resx b/src/SarifCli/Rules/RuleResources.resx index addf9cbad..218f7d8fe 100644 --- a/src/SarifCli/Rules/RuleResources.resx +++ b/src/SarifCli/Rules/RuleResources.resx @@ -123,4 +123,10 @@ Do not use the same string for a rule's id and name properties. The id property must be a stable, opaque identifer such as "SV0001". The name property should be a string that is understandable to an end user, such as "DoNotUserFriendlyNameAsRuleId". + + In "{0}", the fragment portion of the URI "{1}", which specifies the location of a nested file with respect to its parent, does not begin with a forward slash. + + + When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path. That is, begin the with a forward slash, for example "file:///C:/bin/MyApp.zip#/images/grape.jpg". + \ No newline at end of file diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs index 88fd3b585..332494a2e 100644 --- a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Resources; @@ -78,6 +79,19 @@ private void Visit(Run run, string runPointer) } } + if (run.Files != null) + { + IDictionary files = run.Files; + string filesPointer = runPointer.AtProperty(SarifPropertyName.Files); + + foreach (string fileKey in files.Keys) + { + string filePointer = filesPointer.AtProperty(fileKey); + + Visit(files[fileKey], fileKey, filePointer); + } + } + if (run.Rules != null) { Rule[] rules = run.Rules.Values.ToArray(); @@ -132,6 +146,11 @@ private void Visit(PhysicalLocation physicalLocation, string physicalLocationPoi Analyze(physicalLocation, physicalLocationPointer); } + private void Visit(FileData fileData, string fileKey, string filePointer) + { + Analyze(fileData, fileKey, filePointer); + } + protected virtual void Analyze(Rule rule, string rulePointer) { } @@ -140,6 +159,10 @@ protected virtual void Analyze(PhysicalLocation physicalLocation, string physica { } + protected virtual void Analyze(FileData fileData, string fileKey, string filePointer) + { + } + protected void LogResult(ResultLevel level, string jPointer, string formatId, params string[] args) { Region region = GetRegionFromJPointer(jPointer); diff --git a/src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs b/src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs new file mode 100644 index 000000000..a5b9a6e0a --- /dev/null +++ b/src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs @@ -0,0 +1,99 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules +{ + public class UseAbsolutePathsForNestedFileUriFragments : SarifValidationSkimmerBase + { + public override string FullDescription => RuleResources.SV0002_UseAbsolutePathsForNestedFileUriFragmentsDescription; + + /// + /// SV0002 + /// + public override string Id => RuleId.UseAbsolutePathsForNestedFileUriFragments; + + protected override IEnumerable FormatIds + { + get + { + return new string[] + { + nameof(RuleResources.SV0002_DefaultFormatId) + }; + } + } + + protected override void Analyze(PhysicalLocation physicalLocation, string physicalLocationPointer) + { + if (UriHasNonAbsoluteFragment(physicalLocation.Uri)) + { + string uriPointer = physicalLocationPointer.AtProperty(SarifPropertyName.Uri); + + LogResult( + ResultLevel.Warning, + uriPointer, + nameof(RuleResources.SV0002_DefaultFormatId), + physicalLocation.Uri.OriginalString); + } + } + + protected override void Analyze(FileData fileData, string fileKey, string filePointer) + { + try + { + Uri fileUri = new Uri(fileKey); + if (UriHasNonAbsoluteFragment(fileUri)) + { + LogResult( + ResultLevel.Warning, + filePointer, + nameof(RuleResources.SV0002_DefaultFormatId), + fileUri.OriginalString); + } + } + catch + { + // It wasn't a value URI. TODO: implement another rule to check that. + } + + if (UriHasNonAbsoluteFragment(fileData.Uri)) + { + string uriPointer = filePointer.AtProperty(SarifPropertyName.Uri); + + LogResult( + ResultLevel.Warning, + uriPointer, + nameof(RuleResources.SV0002_DefaultFormatId), + fileData.Uri.OriginalString); + } + } + + private bool UriHasNonAbsoluteFragment(Uri uri) + { + if (uri == null) + { + return false; + } + + // You can't access the Fragment property of a relative URI, so if this URI is + // relative, turn it into a fake absolute URI, and get the fragment from that. + Uri absoluteUri = uri.IsAbsoluteUri + ? uri + : MakeFakeAbsoluteUri(uri); + + string fragment = absoluteUri.Fragment; + + return !string.IsNullOrEmpty(fragment) && !fragment.StartsWith("#/", StringComparison.Ordinal); + } + + private static readonly Uri _fakeBaseUri = new Uri("file:///root", UriKind.Absolute); + + private Uri MakeFakeAbsoluteUri(Uri relativeUri) + { + return new Uri(_fakeBaseUri, relativeUri); + } + } +} diff --git a/src/SarifCli/SarifCli.csproj b/src/SarifCli/SarifCli.csproj index bede7de6b..88d9628ca 100644 --- a/src/SarifCli/SarifCli.csproj +++ b/src/SarifCli/SarifCli.csproj @@ -80,6 +80,7 @@ + diff --git a/src/SarifCli/SarifPropertyName.cs b/src/SarifCli/SarifPropertyName.cs index 5c43681ab..88bcb512f 100644 --- a/src/SarifCli/SarifPropertyName.cs +++ b/src/SarifCli/SarifPropertyName.cs @@ -6,10 +6,12 @@ namespace Microsoft.CodeAnalysis.Sarif.Cli public static class SarifPropertyName { public const string AnalysisTarget = "analysisTarget"; + public const string Files = "files"; public const string Locations = "locations"; public const string ResultFile = "resultFile"; public const string Results = "results"; public const string Rules = "rules"; public const string Runs = "runs"; + public const string Uri = "uri"; } } From 4918d39a4ae36c4a6fdd8cbc1321d2439efc5e53 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Thu, 25 Aug 2016 14:18:06 -0700 Subject: [PATCH 20/51] UseAbsolutePathsForNestedFileUriFragments checks location.resultFile.uri --- ...lutePathsForNestedFileUriFragmentsTests.cs | 7 +- .../SarifCli.FunctionalTests.csproj | 6 ++ ...UriFragmentIsRelativeInResultFileUri.sarif | 49 +++++++++++ ...ntIsRelativeInResultFileUri_Expected.sarif | 83 +++++++++++++++++++ 4 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri_Expected.sarif diff --git a/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs b/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs index 790b287a8..547bd8889 100644 --- a/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs +++ b/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs @@ -20,7 +20,12 @@ public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFr Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInAnalysisTargetUri.sarif"); } - // TODO Add a test for ResultFile.Uri + [Fact] + public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInResultFileUri() + { + Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInResultFileUri.sarif"); + } + // TODO Add tests for other locations, like annotatedCodeLocation.Uri. [Fact] diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj index 0356873d6..09b46b08b 100644 --- a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -103,6 +103,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri.sarif new file mode 100644 index 000000000..6fbd5323a --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri.sarif @@ -0,0 +1,49 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "e7d5cf38-c160-4bf9-aed1-e84ad6849df3", + "tool": { + "name": "ModernCop", + "fullName": "mod50 7.0.7000.0", + "version": "7.0.7000.0", + "semanticVersion": "7.0.7000", + "fileVersion": "7.0.20811.0", + "language": "en-US", + "properties": { + "CompanyName": "Microsoft Corporation" + } + }, + "results": [ + { + "ruleKey": "M1003.DoNotShipObfuscatedCode", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "resultFile": { + "uri": "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#js/minified.js", + "region": { + "startLine": 1 + } + } + } + ] + } + ], + "files": { + "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx": { + "mimeType": "application/vns.ms-appx" + }, + "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#/js/minified.js": { + "uri": "/js/minified.js", + "parentKey": "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx", + "mimeType": "text/javascript" + } + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri_Expected.sarif new file mode 100644 index 000000000..97f7c9a2f --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri_Expected.sarif @@ -0,0 +1,83 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "59e5d58a-922b-403e-96a6-e5daf8a071f5", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0002", + "level": "warning", + "formattedRuleMessage": { + "formatId": "DefaultFormatId", + "arguments": [ + "NestedFileUriFragmentIsRelativeInResultFileUri.sarif", + "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#js/minified.js" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri.sarif", + "region": { + "startLine": 28, + "startColumn": 177 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri.sarif" + }, + "message": "Analyzing 'NestedFileUriFragmentIsRelativeInResultFileUri.sarif'...", + "level": "note", + "time": "2016-08-25T21:13:01.032Z" + } + ], + "rules": { + "SV0002": { + "id": "SV0002", + "name": "UseAbsolutePathsForNestedFileUriFragments", + "shortDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path.", + "fullDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path. That is, begin the with a forward slash, for example \"file:///C:/bin/MyApp.zip#/images/grape.jpg\".", + "messageFormats": { + "DefaultFormatId": "In \"{0}\", the fragment portion of the URI \"{1}\", which specifies the location of a nested file with respect to its parent, does not begin with a forward slash." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UseAbsolutePathsForNestedFileUriFragments\\NestedFileUriFragmentIsRelativeInResultFileUri.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\NestedFileUriFragmentIsRelativeInResultFileUri_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-25T21:13:00.933Z", + "endTime": "2016-08-25T21:13:01.305Z", + "processId": 9124, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file From b73be170e5da19af28789b27bc5c32e3bf3b1500 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Thu, 25 Aug 2016 14:53:06 -0700 Subject: [PATCH 21/51] SarifCli: Include the JSON pointer in each message --- ...eIdDoesNotMatchFriendlyName_Expected.sarif | 22 +++++------ .../RuleIdMatchesFriendlyName_Expected.sarif | 25 ++++++------ ...RelativeInAnalysisTargetUri_Expected.sarif | 39 ++++++++++--------- ...sRelativeInFilePropertyName_Expected.sarif | 35 +++++++++-------- ...ntIsRelativeInResultFileUri_Expected.sarif | 35 +++++++++-------- ...FileUriFragmentsAreAbsolute_Expected.sarif | 31 ++++++++------- src/SarifCli/Rules/RuleResources.Designer.cs | 4 +- src/SarifCli/Rules/RuleResources.resx | 4 +- .../Rules/SarifValidationSkimmerBase.cs | 8 +++- 9 files changed, 107 insertions(+), 96 deletions(-) diff --git a/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdDoesNotMatchFriendlyName_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdDoesNotMatchFriendlyName_Expected.sarif index 457f224ab..da16f24f8 100644 --- a/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdDoesNotMatchFriendlyName_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdDoesNotMatchFriendlyName_Expected.sarif @@ -3,13 +3,13 @@ "version": "1.0.0", "runs": [ { - "id": "4f730ffa-cc94-4b7b-ba08-23211cb25d03", + "id": "5b242950-d48d-4093-a21f-94885100c31e", "tool": { "name": "Sarif", - "fullName": "Sarif 1.5.28.0", - "version": "1.5.28.0", - "semanticVersion": "1.5.28", - "sarifLoggerVersion": "1.5.28.0", + "fullName": "Sarif 1.5.27.0", + "version": "1.5.27.0", + "semanticVersion": "1.5.27", + "sarifLoggerVersion": "1.5.27.0", "language": "en-US", "properties": { "Comments": "Object model and utilities for reading and writing files in the SARIF format.", @@ -26,20 +26,20 @@ }, "message": "Analyzing 'RuleIdDoesNotMatchFriendlyName.sarif'...", "level": "note", - "time": "2016-08-23T22:55:51.110Z" + "time": "2016-08-25T21:26:41.799Z" } ], "files": { "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Release/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdDoesNotMatchFriendlyName.sarif": { - "mimeType": "text/x-sarif" + "mimeType": "application/octet-stream" } }, "invocation": { "commandLine": "src\\packages\\xunit.runner.console.2.1.0\\tools\\xunit.console.x86.exe bld\\bin\\SarifCli.FunctionalTests\\AnyCPU_Release\\Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.dll", - "startTime": "2016-08-23T22:55:51.109Z", - "endTime": "2016-08-23T22:55:51.190Z", - "processId": 9688, - "fileName": "C:\\Users\\lgolding\\AppData\\Local\\Temp\\bcef3d89-d123-4f33-b0de-1c3a541c8040\\bcef3d89-d123-4f33-b0de-1c3a541c8040\\assembly\\dl3\\acb70b02\\0b034856_91fdd101\\Sarif.dll", + "startTime": "2016-08-25T21:26:41.798Z", + "endTime": "2016-08-25T21:26:41.887Z", + "processId": 8856, + "fileName": "C:\\Users\\lgolding\\AppData\\Local\\Temp\\108c7547-93f9-41d7-9466-6cf860afad5d\\108c7547-93f9-41d7-9466-6cf860afad5d\\assembly\\dl3\\660ee2c2\\00b7775a_e6e9d101\\Sarif.dll", "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli.FunctionalTests\\AnyCPU_Release" } } diff --git a/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdMatchesFriendlyName_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdMatchesFriendlyName_Expected.sarif index d4d58881f..35d85bcd8 100644 --- a/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdMatchesFriendlyName_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdMatchesFriendlyName_Expected.sarif @@ -3,13 +3,13 @@ "version": "1.0.0", "runs": [ { - "id": "0ecc3107-1021-4ce7-87ff-a553d00bb644", + "id": "4a05bc1d-fcf7-4d8e-880b-0a4941710af7", "tool": { "name": "Sarif", - "fullName": "Sarif 1.5.28.0", - "version": "1.5.28.0", - "semanticVersion": "1.5.28", - "sarifLoggerVersion": "1.5.28.0", + "fullName": "Sarif 1.5.27.0", + "version": "1.5.27.0", + "semanticVersion": "1.5.27", + "sarifLoggerVersion": "1.5.27.0", "language": "en-US", "properties": { "Comments": "Object model and utilities for reading and writing files in the SARIF format.", @@ -25,6 +25,7 @@ "formatId": "DefaultFormatId", "arguments": [ "RuleIdMatchesFriendlyName.sarif", + "/runs/0/rules/ImportantRule", "ImportantRule" ] }, @@ -49,7 +50,7 @@ }, "message": "Analyzing 'RuleIdMatchesFriendlyName.sarif'...", "level": "note", - "time": "2016-08-23T22:55:51.352Z" + "time": "2016-08-25T21:26:42.049Z" } ], "rules": { @@ -59,7 +60,7 @@ "shortDescription": "Do not use the same string for a rule's id and name properties. The id property ...", "fullDescription": "Do not use the same string for a rule's id and name properties. The id property must be a stable, opaque identifer such as \"SV0001\". The name property should be a string that is understandable to an end user, such as \"DoNotUserFriendlyNameAsRuleId\".", "messageFormats": { - "DefaultFormatId": "In \"{0}\", the name and id properties of rule \"{1}\" are the same." + "DefaultFormatId": "In \"{0}\", at \"{1}\", the name and id properties of rule \"{2}\" are the same." }, "defaultLevel": "warning", "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" @@ -67,15 +68,15 @@ }, "files": { "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Release/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdMatchesFriendlyName.sarif": { - "mimeType": "text/x-sarif" + "mimeType": "application/octet-stream" } }, "invocation": { "commandLine": "src\\packages\\xunit.runner.console.2.1.0\\tools\\xunit.console.x86.exe bld\\bin\\SarifCli.FunctionalTests\\AnyCPU_Release\\Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.dll", - "startTime": "2016-08-23T22:55:51.352Z", - "endTime": "2016-08-23T22:55:51.434Z", - "processId": 9688, - "fileName": "C:\\Users\\lgolding\\AppData\\Local\\Temp\\bcef3d89-d123-4f33-b0de-1c3a541c8040\\bcef3d89-d123-4f33-b0de-1c3a541c8040\\assembly\\dl3\\acb70b02\\0b034856_91fdd101\\Sarif.dll", + "startTime": "2016-08-25T21:26:42.049Z", + "endTime": "2016-08-25T21:26:42.052Z", + "processId": 8856, + "fileName": "C:\\Users\\lgolding\\AppData\\Local\\Temp\\108c7547-93f9-41d7-9466-6cf860afad5d\\108c7547-93f9-41d7-9466-6cf860afad5d\\assembly\\dl3\\660ee2c2\\00b7775a_e6e9d101\\Sarif.dll", "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli.FunctionalTests\\AnyCPU_Release" } } diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri_Expected.sarif index 7e7a88420..907e269e7 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri_Expected.sarif @@ -3,16 +3,16 @@ "version": "1.0.0", "runs": [ { - "id": "19b6f898-17e4-4fc7-a4c8-b1df8dc63bec", + "id": "0f3d4fac-c5a9-4008-82d8-5ca2005ac157", "tool": { - "name": "SarifCli", - "fullName": "SarifCli 1.0.0.0", - "version": "1.0.0.0", - "semanticVersion": "1.0.0", + "name": "Sarif", + "fullName": "Sarif 1.5.27.0", + "version": "1.5.27.0", + "semanticVersion": "1.5.27", "sarifLoggerVersion": "1.5.27.0", "language": "en-US", "properties": { - "Comments": "Command line tool for working with SARIF log files.", + "Comments": "Object model and utilities for reading and writing files in the SARIF format.", "CompanyName": "Microsoft Corporation", "ProductName": "Microsoft SARIF SDK" } @@ -24,14 +24,15 @@ "formattedRuleMessage": { "formatId": "DefaultFormatId", "arguments": [ - "NestedFileUriFragmentIsRelativeInLocation.sarif", + "NestedFileUriFragmentIsRelativeInAnalysisTargetUri.sarif", + "/runs/0/results/0/locations/0/analysisTarget/uri", "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#js/minified.js" ] }, "locations": [ { "analysisTarget": { - "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInLocation.sarif", + "uri": "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Release/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri.sarif", "region": { "startLine": 28, "startColumn": 177 @@ -45,11 +46,11 @@ { "id": "MSG001.AnalyzingTarget", "physicalLocation": { - "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInLocation.sarif" + "uri": "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Release/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri.sarif" }, - "message": "Analyzing 'NestedFileUriFragmentIsRelativeInLocation.sarif'...", + "message": "Analyzing 'NestedFileUriFragmentIsRelativeInAnalysisTargetUri.sarif'...", "level": "note", - "time": "2016-08-25T13:52:33.775Z" + "time": "2016-08-25T21:26:42.049Z" } ], "rules": { @@ -59,24 +60,24 @@ "shortDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path.", "fullDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path. That is, begin the with a forward slash, for example \"file:///C:/bin/MyApp.zip#/images/grape.jpg\".", "messageFormats": { - "DefaultFormatId": "In \"{0}\", the fragment portion of the URI \"{1}\", which specifies the location of a nested file with respect to its parent, does not begin with a forward slash." + "DefaultFormatId": "In \"{0}\", at \"{1}\", the fragment portion of the URI \"{2}\", which specifies the location of a nested file with respect to its parent, does not begin with a forward slash." }, "defaultLevel": "warning", "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" } }, "files": { - "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInLocation.sarif": { + "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Release/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri.sarif": { "mimeType": "application/octet-stream" } }, "invocation": { - "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UseAbsolutePathsForNestedFileUriFragments\\NestedFileUriFragmentIsRelativeInLocation.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\SarifCli.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", - "startTime": "2016-08-25T13:52:33.603Z", - "endTime": "2016-08-25T13:52:34.072Z", - "processId": 5184, - "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", - "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + "commandLine": "src\\packages\\xunit.runner.console.2.1.0\\tools\\xunit.console.x86.exe bld\\bin\\SarifCli.FunctionalTests\\AnyCPU_Release\\Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.dll", + "startTime": "2016-08-25T21:26:42.049Z", + "endTime": "2016-08-25T21:26:42.051Z", + "processId": 8856, + "fileName": "C:\\Users\\lgolding\\AppData\\Local\\Temp\\108c7547-93f9-41d7-9466-6cf860afad5d\\108c7547-93f9-41d7-9466-6cf860afad5d\\assembly\\dl3\\660ee2c2\\00b7775a_e6e9d101\\Sarif.dll", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli.FunctionalTests\\AnyCPU_Release" } } ] diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName_Expected.sarif index 935578b9b..a44409a86 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName_Expected.sarif @@ -3,16 +3,16 @@ "version": "1.0.0", "runs": [ { - "id": "11401fd5-e0ef-47dc-beec-c20d7d2aab1f", + "id": "9ae11e51-d960-4aca-aba8-574b056e9588", "tool": { - "name": "SarifCli", - "fullName": "SarifCli 1.0.0.0", - "version": "1.0.0.0", - "semanticVersion": "1.0.0", + "name": "Sarif", + "fullName": "Sarif 1.5.27.0", + "version": "1.5.27.0", + "semanticVersion": "1.5.27", "sarifLoggerVersion": "1.5.27.0", "language": "en-US", "properties": { - "Comments": "Command line tool for working with SARIF log files.", + "Comments": "Object model and utilities for reading and writing files in the SARIF format.", "CompanyName": "Microsoft Corporation", "ProductName": "Microsoft SARIF SDK" } @@ -25,13 +25,14 @@ "formatId": "DefaultFormatId", "arguments": [ "NestedFileUriFragmentIsRelativeInFilePropertyName.sarif", + "/runs/0/files/file:~1~1~1d:~1src~1SecDevTools~1Main~1src~1ModernCop~1Source~1WebRules.Test.Unit~1ModernCopTestData~1WebRules_PackageRules~1MinificationRuleApp.appx#js~1minified.js", "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#js/minified.js" ] }, "locations": [ { "analysisTarget": { - "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName.sarif", + "uri": "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Release/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName.sarif", "region": { "startLine": 41, "startColumn": 165 @@ -45,11 +46,11 @@ { "id": "MSG001.AnalyzingTarget", "physicalLocation": { - "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName.sarif" + "uri": "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Release/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName.sarif" }, "message": "Analyzing 'NestedFileUriFragmentIsRelativeInFilePropertyName.sarif'...", "level": "note", - "time": "2016-08-25T18:17:11.515Z" + "time": "2016-08-25T21:26:42.061Z" } ], "rules": { @@ -59,24 +60,24 @@ "shortDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path.", "fullDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path. That is, begin the with a forward slash, for example \"file:///C:/bin/MyApp.zip#/images/grape.jpg\".", "messageFormats": { - "DefaultFormatId": "In \"{0}\", the fragment portion of the URI \"{1}\", which specifies the location of a nested file with respect to its parent, does not begin with a forward slash." + "DefaultFormatId": "In \"{0}\", at \"{1}\", the fragment portion of the URI \"{2}\", which specifies the location of a nested file with respect to its parent, does not begin with a forward slash." }, "defaultLevel": "warning", "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" } }, "files": { - "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName.sarif": { + "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Release/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName.sarif": { "mimeType": "application/octet-stream" } }, "invocation": { - "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UseAbsolutePathsForNestedFileUriFragments\\NestedFileUriFragmentIsRelativeInFilePropertyName.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\SarifCli.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", - "startTime": "2016-08-25T18:17:11.434Z", - "endTime": "2016-08-25T18:17:11.774Z", - "processId": 14016, - "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", - "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + "commandLine": "src\\packages\\xunit.runner.console.2.1.0\\tools\\xunit.console.x86.exe bld\\bin\\SarifCli.FunctionalTests\\AnyCPU_Release\\Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.dll", + "startTime": "2016-08-25T21:26:42.061Z", + "endTime": "2016-08-25T21:26:42.062Z", + "processId": 8856, + "fileName": "C:\\Users\\lgolding\\AppData\\Local\\Temp\\108c7547-93f9-41d7-9466-6cf860afad5d\\108c7547-93f9-41d7-9466-6cf860afad5d\\assembly\\dl3\\660ee2c2\\00b7775a_e6e9d101\\Sarif.dll", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli.FunctionalTests\\AnyCPU_Release" } } ] diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri_Expected.sarif index 97f7c9a2f..0ba939316 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri_Expected.sarif @@ -3,16 +3,16 @@ "version": "1.0.0", "runs": [ { - "id": "59e5d58a-922b-403e-96a6-e5daf8a071f5", + "id": "67f66031-c56f-4e01-9914-122dc31b55db", "tool": { - "name": "SarifCli", - "fullName": "SarifCli 1.0.0.0", - "version": "1.0.0.0", - "semanticVersion": "1.0.0", + "name": "Sarif", + "fullName": "Sarif 1.5.27.0", + "version": "1.5.27.0", + "semanticVersion": "1.5.27", "sarifLoggerVersion": "1.5.27.0", "language": "en-US", "properties": { - "Comments": "Command line tool for working with SARIF log files.", + "Comments": "Object model and utilities for reading and writing files in the SARIF format.", "CompanyName": "Microsoft Corporation", "ProductName": "Microsoft SARIF SDK" } @@ -25,13 +25,14 @@ "formatId": "DefaultFormatId", "arguments": [ "NestedFileUriFragmentIsRelativeInResultFileUri.sarif", + "/runs/0/results/0/locations/0/resultFile/uri", "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#js/minified.js" ] }, "locations": [ { "analysisTarget": { - "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri.sarif", + "uri": "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Release/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri.sarif", "region": { "startLine": 28, "startColumn": 177 @@ -45,11 +46,11 @@ { "id": "MSG001.AnalyzingTarget", "physicalLocation": { - "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri.sarif" + "uri": "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Release/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri.sarif" }, "message": "Analyzing 'NestedFileUriFragmentIsRelativeInResultFileUri.sarif'...", "level": "note", - "time": "2016-08-25T21:13:01.032Z" + "time": "2016-08-25T21:26:41.799Z" } ], "rules": { @@ -59,24 +60,24 @@ "shortDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path.", "fullDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path. That is, begin the with a forward slash, for example \"file:///C:/bin/MyApp.zip#/images/grape.jpg\".", "messageFormats": { - "DefaultFormatId": "In \"{0}\", the fragment portion of the URI \"{1}\", which specifies the location of a nested file with respect to its parent, does not begin with a forward slash." + "DefaultFormatId": "In \"{0}\", at \"{1}\", the fragment portion of the URI \"{2}\", which specifies the location of a nested file with respect to its parent, does not begin with a forward slash." }, "defaultLevel": "warning", "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" } }, "files": { - "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri.sarif": { + "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Release/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri.sarif": { "mimeType": "application/octet-stream" } }, "invocation": { - "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UseAbsolutePathsForNestedFileUriFragments\\NestedFileUriFragmentIsRelativeInResultFileUri.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\NestedFileUriFragmentIsRelativeInResultFileUri_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", - "startTime": "2016-08-25T21:13:00.933Z", - "endTime": "2016-08-25T21:13:01.305Z", - "processId": 9124, - "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", - "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + "commandLine": "src\\packages\\xunit.runner.console.2.1.0\\tools\\xunit.console.x86.exe bld\\bin\\SarifCli.FunctionalTests\\AnyCPU_Release\\Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.dll", + "startTime": "2016-08-25T21:26:41.798Z", + "endTime": "2016-08-25T21:26:41.957Z", + "processId": 8856, + "fileName": "C:\\Users\\lgolding\\AppData\\Local\\Temp\\108c7547-93f9-41d7-9466-6cf860afad5d\\108c7547-93f9-41d7-9466-6cf860afad5d\\assembly\\dl3\\660ee2c2\\00b7775a_e6e9d101\\Sarif.dll", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli.FunctionalTests\\AnyCPU_Release" } } ] diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentsAreAbsolute_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentsAreAbsolute_Expected.sarif index a7b180d47..3dda0aa8a 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentsAreAbsolute_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentsAreAbsolute_Expected.sarif @@ -3,43 +3,44 @@ "version": "1.0.0", "runs": [ { - "id": "f603e2a9-fe09-434e-a0df-7261e78c9d0b", + "id": "a9957393-94c6-464b-9ba5-cf05eb95f245", "tool": { - "name": "SarifCli", - "fullName": "SarifCli 1.0.0.0", - "version": "1.0.0.0", - "semanticVersion": "1.0.0", + "name": "Sarif", + "fullName": "Sarif 1.5.27.0", + "version": "1.5.27.0", + "semanticVersion": "1.5.27", "sarifLoggerVersion": "1.5.27.0", "language": "en-US", "properties": { - "Comments": "Command line tool for working with SARIF log files.", + "Comments": "Object model and utilities for reading and writing files in the SARIF format.", "CompanyName": "Microsoft Corporation", "ProductName": "Microsoft SARIF SDK" } }, + "results": [], "toolNotifications": [ { "id": "MSG001.AnalyzingTarget", "physicalLocation": { - "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentsAreAbsolute.sarif" + "uri": "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Release/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentsAreAbsolute.sarif" }, "message": "Analyzing 'NestedFileUriFragmentsAreAbsolute.sarif'...", "level": "note", - "time": "2016-08-25T20:52:39.415Z" + "time": "2016-08-25T21:26:42.071Z" } ], "files": { - "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentsAreAbsolute.sarif": { + "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Release/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentsAreAbsolute.sarif": { "mimeType": "application/octet-stream" } }, "invocation": { - "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UseAbsolutePathsForNestedFileUriFragments\\NestedFileUriFragmentsAreAbsolute.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\NestedFileUriFragmentsAreAbsolute_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", - "startTime": "2016-08-25T20:52:39.233Z", - "endTime": "2016-08-25T20:52:39.677Z", - "processId": 10412, - "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", - "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + "commandLine": "src\\packages\\xunit.runner.console.2.1.0\\tools\\xunit.console.x86.exe bld\\bin\\SarifCli.FunctionalTests\\AnyCPU_Release\\Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.dll", + "startTime": "2016-08-25T21:26:42.071Z", + "endTime": "2016-08-25T21:26:42.076Z", + "processId": 8856, + "fileName": "C:\\Users\\lgolding\\AppData\\Local\\Temp\\108c7547-93f9-41d7-9466-6cf860afad5d\\108c7547-93f9-41d7-9466-6cf860afad5d\\assembly\\dl3\\660ee2c2\\00b7775a_e6e9d101\\Sarif.dll", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli.FunctionalTests\\AnyCPU_Release" } } ] diff --git a/src/SarifCli/Rules/RuleResources.Designer.cs b/src/SarifCli/Rules/RuleResources.Designer.cs index dca54fe0b..37e73b4fd 100644 --- a/src/SarifCli/Rules/RuleResources.Designer.cs +++ b/src/SarifCli/Rules/RuleResources.Designer.cs @@ -61,7 +61,7 @@ internal RuleResources() { } /// - /// Looks up a localized string similar to In "{0}", the name and id properties of rule "{1}" are the same.. + /// Looks up a localized string similar to In "{0}", at "{1}", the name and id properties of rule "{2}" are the same.. /// internal static string SV0001_DefaultFormatId { get { @@ -79,7 +79,7 @@ internal static string SV0001_DoNotUseFriendlyNameAsRuleIdDescription { } /// - /// Looks up a localized string similar to In "{0}", the fragment portion of the URI "{1}", which specifies the location of a nested file with respect to its parent, does not begin with a forward slash.. + /// Looks up a localized string similar to In "{0}", at "{1}", the fragment portion of the URI "{2}", which specifies the location of a nested file with respect to its parent, does not begin with a forward slash.. /// internal static string SV0002_DefaultFormatId { get { diff --git a/src/SarifCli/Rules/RuleResources.resx b/src/SarifCli/Rules/RuleResources.resx index 218f7d8fe..e59a10260 100644 --- a/src/SarifCli/Rules/RuleResources.resx +++ b/src/SarifCli/Rules/RuleResources.resx @@ -118,13 +118,13 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - In "{0}", the name and id properties of rule "{1}" are the same. + In "{0}", at "{1}", the name and id properties of rule "{2}" are the same. Do not use the same string for a rule's id and name properties. The id property must be a stable, opaque identifer such as "SV0001". The name property should be a string that is understandable to an end user, such as "DoNotUserFriendlyNameAsRuleId". - In "{0}", the fragment portion of the URI "{1}", which specifies the location of a nested file with respect to its parent, does not begin with a forward slash. + In "{0}", at "{1}", the fragment portion of the URI "{2}", which specifies the location of a nested file with respect to its parent, does not begin with a forward slash. When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path. That is, begin the with a forward slash, for example "file:///C:/bin/MyApp.zip#/images/grape.jpg". diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs index 332494a2e..ac063e309 100644 --- a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -167,8 +167,14 @@ protected void LogResult(ResultLevel level, string jPointer, string formatId, pa { Region region = GetRegionFromJPointer(jPointer); + // All messages start with "In {file}, at {jPointer}, ...". Prepend the jPointer to the args. + // The Sarif.Driver framework will take care of prepending the file name. + string[] argsWithPointer = new string[args.Length + 1]; + Array.Copy(args, 0, argsWithPointer, 1, args.Length); + argsWithPointer[0] = jPointer; + Context.Logger.Log(this, - RuleUtilities.BuildResult(ResultLevel.Warning, Context, region, formatId, args)); + RuleUtilities.BuildResult(ResultLevel.Warning, Context, region, formatId, argsWithPointer)); } private Region GetRegionFromJPointer(string jPointer) From d46055fa97b85d21e226389bf4a9ffa6b9535727 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Thu, 25 Aug 2016 15:37:39 -0700 Subject: [PATCH 22/51] UseAbsolutePathsForNestedFileUriFragments handles result.relatedLocations --- ...lutePathsForNestedFileUriFragmentsTests.cs | 6 +- .../SarifCli.FunctionalTests.csproj | 6 ++ ...agmentIsRelativeInRelatedLocationUri.sarif | 61 ++++++++++++++ ...elativeInRelatedLocationUri_Expected.sarif | 84 +++++++++++++++++++ .../Rules/SarifValidationSkimmerBase.cs | 23 +++++ src/SarifCli/SarifPropertyName.cs | 2 + 6 files changed, 181 insertions(+), 1 deletion(-) create mode 100644 src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri_Expected.sarif diff --git a/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs b/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs index 547bd8889..aa2600b61 100644 --- a/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs +++ b/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs @@ -26,7 +26,11 @@ public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFr Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInResultFileUri.sarif"); } - // TODO Add tests for other locations, like annotatedCodeLocation.Uri. + [Fact] + public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelatedRelativeInLocationUri() + { + Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInRelatedLocationUri.sarif"); + } [Fact] public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInFilePropertyName() diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj index 09b46b08b..30b89677b 100644 --- a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -103,6 +103,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri.sarif new file mode 100644 index 000000000..e6b4a8ad8 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri.sarif @@ -0,0 +1,61 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "e7d5cf38-c160-4bf9-aed1-e84ad6849df3", + "tool": { + "name": "ModernCop", + "fullName": "mod50 7.0.7000.0", + "version": "7.0.7000.0", + "semanticVersion": "7.0.7000", + "fileVersion": "7.0.20811.0", + "language": "en-US", + "properties": { + "CompanyName": "Microsoft Corporation" + } + }, + "results": [ + { + "ruleKey": "M1003.DoNotShipObfuscatedCode", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/bin/myApp.appx#/js/minified.js", + "region": { + "startLine": 1 + } + } + } + ], + "relatedLocations": [ + { + "physicalLocation": { + "uri": "file:///c:/bin/myApp.appx#js/other.js" + } + } + ] + } + ], + "files": { + "file:///c:/bin/myApp.appx": { + "mimeType": "application/vns.ms-appx" + }, + "file:///c:/bin/myApp.appx#/js/minified.js": { + "uri": "/js/minified.js", + "parentKey": "file:///c:/bin/myApp.appx", + "mimeType": "text/javascript" + }, + "file:///c:/bin/myApp.appx#/js/other.js": { + "uri": "/js/other.js", + "parentKey": "file:///c:/bin/myApp.appx", + "mimeType": "text/javascript" + } + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri_Expected.sarif new file mode 100644 index 000000000..e2e1ba715 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "17727053-b68e-4e9c-a67a-62c97d59b4e0", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0002", + "level": "warning", + "formattedRuleMessage": { + "formatId": "DefaultFormatId", + "arguments": [ + "NestedFileUriFragmentIsRelativeInRelatedLocationUri.sarif", + "/runs/0/results/0/relatedLocations/0/physicalLocation/uri", + "file:///c:/bin/myApp.appx#js/other.js" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri.sarif", + "region": { + "startLine": 38, + "startColumn": 63 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri.sarif" + }, + "message": "Analyzing 'NestedFileUriFragmentIsRelativeInRelatedLocationUri.sarif'...", + "level": "note", + "time": "2016-08-25T22:31:05.958Z" + } + ], + "rules": { + "SV0002": { + "id": "SV0002", + "name": "UseAbsolutePathsForNestedFileUriFragments", + "shortDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path.", + "fullDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path. That is, begin the with a forward slash, for example \"file:///C:/bin/MyApp.zip#/images/grape.jpg\".", + "messageFormats": { + "DefaultFormatId": "In \"{0}\", at \"{1}\", the fragment portion of the URI \"{2}\", which specifies the location of a nested file with respect to its parent, does not begin with a forward slash." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UseAbsolutePathsForNestedFileUriFragments\\NestedFileUriFragmentIsRelativeInRelatedLocationUri.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\NestedFileUriFragmentIsRelativeInRelatedLocationUri_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-25T22:31:05.864Z", + "endTime": "2016-08-25T22:31:06.239Z", + "processId": 14368, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs index ac063e309..162bd783f 100644 --- a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -124,6 +124,29 @@ private void Visit(Result result, string resultPointer) Visit(location, locationPointer); } } + + if (result.RelatedLocations != null) + { + AnnotatedCodeLocation[] relatedLocations = result.RelatedLocations.ToArray(); + string relatedLocationsPointer = resultPointer.AtProperty(SarifPropertyName.RelatedLocations); + + for (int iRelatedLocation = 0; iRelatedLocation < relatedLocations.Length; ++iRelatedLocation) + { + AnnotatedCodeLocation relatedLocation = relatedLocations[iRelatedLocation]; + string relatedLocationPointer = relatedLocationsPointer.AtIndex(iRelatedLocation); + + Visit(relatedLocation, relatedLocationPointer); + } + } + } + + private void Visit(AnnotatedCodeLocation annotatedCodeLocation, string annotatedCodeLocationPointer) + { + if (annotatedCodeLocation.PhysicalLocation != null) + { + string physicalLocationPointer = annotatedCodeLocationPointer.AtProperty(SarifPropertyName.PhysicalLocation); + Visit(annotatedCodeLocation.PhysicalLocation, physicalLocationPointer); + } } private void Visit(Location location, string locationPointer) diff --git a/src/SarifCli/SarifPropertyName.cs b/src/SarifCli/SarifPropertyName.cs index 88bcb512f..ff5f523df 100644 --- a/src/SarifCli/SarifPropertyName.cs +++ b/src/SarifCli/SarifPropertyName.cs @@ -8,6 +8,8 @@ public static class SarifPropertyName public const string AnalysisTarget = "analysisTarget"; public const string Files = "files"; public const string Locations = "locations"; + public const string PhysicalLocation = "physicalLocation"; + public const string RelatedLocations = "relatedLocations"; public const string ResultFile = "resultFile"; public const string Results = "results"; public const string Rules = "rules"; From 7666936a57cca67aaeec08b90345062208d814de Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Thu, 25 Aug 2016 15:59:16 -0700 Subject: [PATCH 23/51] UseAbsolutePathsForNestedFileUriFragments handles codeFlow URIs --- ...lutePathsForNestedFileUriFragmentsTests.cs | 6 ++ .../SarifCli.FunctionalTests.csproj | 6 ++ ...gmentIsRelativeInCodeFlowLocationUri.sarif | 69 +++++++++++++++ ...lativeInCodeFlowLocationUri_Expected.sarif | 84 +++++++++++++++++++ src/SarifCli/JPointerStringExtensions.cs | 3 +- .../Rules/SarifValidationSkimmerBase.cs | 31 +++++++ src/SarifCli/SarifPropertyName.cs | 1 + 7 files changed, 198 insertions(+), 2 deletions(-) create mode 100644 src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri_Expected.sarif diff --git a/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs b/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs index aa2600b61..47f0bf4cc 100644 --- a/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs +++ b/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs @@ -26,6 +26,12 @@ public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFr Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInResultFileUri.sarif"); } + [Fact] + public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsCodeFlowLocationUri() + { + Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInCodeFlowLocationUri.sarif"); + } + [Fact] public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelatedRelativeInLocationUri() { diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj index 30b89677b..85979a9fd 100644 --- a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -91,6 +91,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri.sarif new file mode 100644 index 000000000..a47fe2aaa --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri.sarif @@ -0,0 +1,69 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "e7d5cf38-c160-4bf9-aed1-e84ad6849df3", + "tool": { + "name": "ModernCop", + "fullName": "mod50 7.0.7000.0", + "version": "7.0.7000.0", + "semanticVersion": "7.0.7000", + "fileVersion": "7.0.20811.0", + "language": "en-US", + "properties": { + "CompanyName": "Microsoft Corporation" + } + }, + "results": [ + { + "ruleKey": "M1003.DoNotShipObfuscatedCode", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/bin/myApp.appx#/js/minified.js", + "region": { + "startLine": 1 + } + } + } + ], + "codeFlows": [ + { + "locations": [ + { + "physicalLocation": { + "uri": "file:///c:/bin/myApp.appx#js/minified.js", + "region": { + "startLine": 42, + "startColumn": 12 + } + } + } + ] + } + ] + } + ], + "files": { + "file:///c:/bin/myApp.appx": { + "mimeType": "application/vns.ms-appx" + }, + "file:///c:/bin/myApp.appx#/js/minified.js": { + "uri": "/js/minified.js", + "parentKey": "file:///c:/bin/myApp.appx", + "mimeType": "text/javascript" + }, + "file:///c:/bin/myApp.appx#/js/other.js": { + "uri": "/js/other.js", + "parentKey": "file:///c:/bin/myApp.appx", + "mimeType": "text/javascript" + } + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri_Expected.sarif new file mode 100644 index 000000000..7f46e4f2d --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "391375f4-09bc-4f6a-b09a-0c2317759901", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0002", + "level": "warning", + "formattedRuleMessage": { + "formatId": "DefaultFormatId", + "arguments": [ + "NestedFileUriFragmentIsRelativeInCodeFlowLocationUri.sarif", + "/runs/0/results/0/codeFlows/0/locations/0/physicalLocation/uri", + "file:///c:/bin/myApp.appx#js/minified.js" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri.sarif", + "region": { + "startLine": 40, + "startColumn": 70 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri.sarif" + }, + "message": "Analyzing 'NestedFileUriFragmentIsRelativeInCodeFlowLocationUri.sarif'...", + "level": "note", + "time": "2016-08-25T22:51:53.317Z" + } + ], + "rules": { + "SV0002": { + "id": "SV0002", + "name": "UseAbsolutePathsForNestedFileUriFragments", + "shortDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path.", + "fullDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path. That is, begin the with a forward slash, for example \"file:///C:/bin/MyApp.zip#/images/grape.jpg\".", + "messageFormats": { + "DefaultFormatId": "In \"{0}\", at \"{1}\", the fragment portion of the URI \"{2}\", which specifies the location of a nested file with respect to its parent, does not begin with a forward slash." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UseAbsolutePathsForNestedFileUriFragments\\NestedFileUriFragmentIsRelativeInCodeFlowLocationUri.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\NestedFileUriFragmentIsRelativeInCodeFlowLocationUri_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-25T22:51:53.238Z", + "endTime": "2016-08-25T22:51:53.582Z", + "processId": 13832, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli/JPointerStringExtensions.cs b/src/SarifCli/JPointerStringExtensions.cs index 27de4ddf2..fe7d27749 100644 --- a/src/SarifCli/JPointerStringExtensions.cs +++ b/src/SarifCli/JPointerStringExtensions.cs @@ -3,6 +3,7 @@ namespace Microsoft.CodeAnalysis.Sarif.Cli { + // TODO: These methods belong in the Microsoft.Json.Pointer library. internal static class JPointerStringExtensions { internal static string AtProperty(this string jPointer, string propertyName) @@ -23,8 +24,6 @@ internal static string AtIndex(this string jPointer, int index) // When escaping, the "~" replacement must come first. Otherwise, the string "/" // would translate to "~01" instead of the correct "~1". Similarly, when // unescaping, the "~1" replacement must come first. - // - // TODO: These methods belong in the Microsoft.Json.Pointer library. internal static string EscapeJsonPointer(this string propertyName) { return propertyName.Replace("~", "~0").Replace("/", "~1"); diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs index 162bd783f..2b0c9fe21 100644 --- a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -125,6 +125,20 @@ private void Visit(Result result, string resultPointer) } } + if (result.CodeFlows != null) + { + CodeFlow[] codeFlows = result.CodeFlows.ToArray(); + string codeFlowsPointer = resultPointer.AtProperty(SarifPropertyName.CodeFlows); + + for (int iCodeFlow = 0; iCodeFlow < codeFlows.Length; ++iCodeFlow) + { + CodeFlow codeFlow = codeFlows[iCodeFlow]; + string codeFlowPointer = codeFlowsPointer.AtIndex(iCodeFlow); + + Visit(codeFlow, codeFlowPointer); + } + } + if (result.RelatedLocations != null) { AnnotatedCodeLocation[] relatedLocations = result.RelatedLocations.ToArray(); @@ -149,6 +163,23 @@ private void Visit(AnnotatedCodeLocation annotatedCodeLocation, string annotated } } + private void Visit(CodeFlow codeFlow, string codeFlowPointer) + { + if (codeFlow.Locations != null) + { + AnnotatedCodeLocation[] annotatedCodeLocations = codeFlow.Locations.ToArray(); + string annotatedCodeLocationsPointer = codeFlowPointer.AtProperty(SarifPropertyName.Locations); + + for (int iAnnotatedCodeLocation = 0; iAnnotatedCodeLocation < annotatedCodeLocations.Length; ++iAnnotatedCodeLocation) + { + AnnotatedCodeLocation annotatedCodeLocation = annotatedCodeLocations[iAnnotatedCodeLocation]; + string annotatedCodeLocationPointer = annotatedCodeLocationsPointer.AtIndex(iAnnotatedCodeLocation); + + Visit(annotatedCodeLocation, annotatedCodeLocationPointer); + } + } + } + private void Visit(Location location, string locationPointer) { if (location.AnalysisTarget != null) diff --git a/src/SarifCli/SarifPropertyName.cs b/src/SarifCli/SarifPropertyName.cs index ff5f523df..d9fb67f98 100644 --- a/src/SarifCli/SarifPropertyName.cs +++ b/src/SarifCli/SarifPropertyName.cs @@ -6,6 +6,7 @@ namespace Microsoft.CodeAnalysis.Sarif.Cli public static class SarifPropertyName { public const string AnalysisTarget = "analysisTarget"; + public const string CodeFlows = "codeFlows"; public const string Files = "files"; public const string Locations = "locations"; public const string PhysicalLocation = "physicalLocation"; From 075284c8c29c19d1b55e841ffb730ea322b7c6e5 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Thu, 25 Aug 2016 16:20:22 -0700 Subject: [PATCH 24/51] UseAbsolutePathsForNestedFileUriFragments handles stack frame URIs --- ...lutePathsForNestedFileUriFragmentsTests.cs | 8 +- .../SarifCli.FunctionalTests.csproj | 6 + ...UriFragmentIsRelativeInStackFrameUri.sarif | 65 +++++++ ...ntIsRelativeInStackFrameUri_Expected.sarif | 84 +++++++++ .../Rules/SarifValidationSkimmerBase.cs | 160 +++++++++++------- ...eAbsolutePathsForNestedFileUriFragments.cs | 42 +++-- src/SarifCli/SarifPropertyName.cs | 2 + 7 files changed, 292 insertions(+), 75 deletions(-) create mode 100644 src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri_Expected.sarif diff --git a/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs b/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs index 47f0bf4cc..b1dd429a9 100644 --- a/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs +++ b/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs @@ -27,11 +27,17 @@ public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFr } [Fact] - public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsCodeFlowLocationUri() + public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentInCodeFlowLocationUri() { Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInCodeFlowLocationUri.sarif"); } + [Fact] + public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentInStackFrameUri() + { + Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInStackFrameUri.sarif"); + } + [Fact] public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelatedRelativeInLocationUri() { diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj index 85979a9fd..99c347965 100644 --- a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -121,6 +121,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri.sarif new file mode 100644 index 000000000..e60df8cc6 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri.sarif @@ -0,0 +1,65 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "e7d5cf38-c160-4bf9-aed1-e84ad6849df3", + "tool": { + "name": "ModernCop", + "fullName": "mod50 7.0.7000.0", + "version": "7.0.7000.0", + "semanticVersion": "7.0.7000", + "fileVersion": "7.0.20811.0", + "language": "en-US", + "properties": { + "CompanyName": "Microsoft Corporation" + } + }, + "results": [ + { + "ruleKey": "M1003.DoNotShipObfuscatedCode", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/bin/myApp.appx#/js/minified.js", + "region": { + "startLine": 1 + } + } + } + ], + "stacks": [ + { + "frames": [ + { + "uri": "file:///c:/bin/myApp.appx#js/minified.js", + "fullyQualifiedLogicalName": "func", + "line": 23 + } + ] + } + ] + } + ], + "files": { + "file:///c:/bin/myApp.appx": { + "mimeType": "application/vns.ms-appx" + }, + "file:///c:/bin/myApp.appx#/js/minified.js": { + "uri": "/js/minified.js", + "parentKey": "file:///c:/bin/myApp.appx", + "mimeType": "text/javascript" + }, + "file:///c:/bin/myApp.appx#/js/other.js": { + "uri": "/js/other.js", + "parentKey": "file:///c:/bin/myApp.appx", + "mimeType": "text/javascript" + } + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri_Expected.sarif new file mode 100644 index 000000000..3447b9b73 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "cfb342f0-5a8e-4eb0-ae50-aef0827d6813", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0002", + "level": "warning", + "formattedRuleMessage": { + "formatId": "DefaultFormatId", + "arguments": [ + "NestedFileUriFragmentIsRelativeInStackFrameUri.sarif", + "/runs/0/results/0/stacks/0/frames/0/uri", + "file:///c:/bin/myApp.appx#js/minified.js" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri.sarif", + "region": { + "startLine": 39, + "startColumn": 68 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri.sarif" + }, + "message": "Analyzing 'NestedFileUriFragmentIsRelativeInStackFrameUri.sarif'...", + "level": "note", + "time": "2016-08-25T23:16:44.436Z" + } + ], + "rules": { + "SV0002": { + "id": "SV0002", + "name": "UseAbsolutePathsForNestedFileUriFragments", + "shortDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path.", + "fullDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path. That is, begin the with a forward slash, for example \"file:///C:/bin/MyApp.zip#/images/grape.jpg\".", + "messageFormats": { + "DefaultFormatId": "In \"{0}\", at \"{1}\", the fragment portion of the URI \"{2}\", which specifies the location of a nested file with respect to its parent, does not begin with a forward slash." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UseAbsolutePathsForNestedFileUriFragments\\NestedFileUriFragmentIsRelativeInStackFrameUri.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\NestedFileUriFragmentIsRelativeInStackFrameUri_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-25T23:16:44.342Z", + "endTime": "2016-08-25T23:16:44.764Z", + "processId": 10452, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs index 2b0c9fe21..e1f784d95 100644 --- a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -63,52 +63,57 @@ private void Visit(SarifLog log, string logPointer) } } - private void Visit(Run run, string runPointer) + private void Visit(AnnotatedCodeLocation annotatedCodeLocation, string annotatedCodeLocationPointer) { - if (run.Results != null) + if (annotatedCodeLocation.PhysicalLocation != null) { - Result[] results = run.Results.ToArray(); - string resultsPointer = runPointer.AtProperty(SarifPropertyName.Results); - - for (int iResult = 0; iResult < results.Length; ++iResult) - { - Result result = results[iResult]; - string resultPointer = resultsPointer.AtIndex(iResult); - - Visit(result, resultPointer); - } + string physicalLocationPointer = annotatedCodeLocationPointer.AtProperty(SarifPropertyName.PhysicalLocation); + Visit(annotatedCodeLocation.PhysicalLocation, physicalLocationPointer); } + } - if (run.Files != null) + private void Visit(CodeFlow codeFlow, string codeFlowPointer) + { + if (codeFlow.Locations != null) { - IDictionary files = run.Files; - string filesPointer = runPointer.AtProperty(SarifPropertyName.Files); + AnnotatedCodeLocation[] annotatedCodeLocations = codeFlow.Locations.ToArray(); + string annotatedCodeLocationsPointer = codeFlowPointer.AtProperty(SarifPropertyName.Locations); - foreach (string fileKey in files.Keys) + for (int iAnnotatedCodeLocation = 0; iAnnotatedCodeLocation < annotatedCodeLocations.Length; ++iAnnotatedCodeLocation) { - string filePointer = filesPointer.AtProperty(fileKey); + AnnotatedCodeLocation annotatedCodeLocation = annotatedCodeLocations[iAnnotatedCodeLocation]; + string annotatedCodeLocationPointer = annotatedCodeLocationsPointer.AtIndex(iAnnotatedCodeLocation); - Visit(files[fileKey], fileKey, filePointer); + Visit(annotatedCodeLocation, annotatedCodeLocationPointer); } } + } - if (run.Rules != null) + private void Visit(FileData fileData, string fileKey, string filePointer) + { + Analyze(fileData, fileKey, filePointer); + } + + private void Visit(Location location, string locationPointer) + { + if (location.AnalysisTarget != null) { - Rule[] rules = run.Rules.Values.ToArray(); - string rulesPointer = runPointer.AtProperty(SarifPropertyName.Rules); + string analysisTargetPointer = locationPointer.AtProperty(SarifPropertyName.AnalysisTarget); + Visit(location.AnalysisTarget, analysisTargetPointer); + } - for (int iRule = 0; iRule < rules.Length; ++iRule) - { - Rule rule = rules[iRule]; - if (rule.Id != null) - { - string rulePointer = rulesPointer.AtProperty(rule.Id); - Analyze(rule, rulePointer); - } - } + if (location.ResultFile != null) + { + string resultFilePointer = locationPointer.AtProperty(SarifPropertyName.ResultFile); + Visit(location.ResultFile, resultFilePointer); } } + private void Visit(PhysicalLocation physicalLocation, string physicalLocationPointer) + { + Analyze(physicalLocation, physicalLocationPointer); + } + private void Visit(Result result, string resultPointer) { if (result.Locations != null) @@ -139,6 +144,20 @@ private void Visit(Result result, string resultPointer) } } + if (result.Stacks != null) + { + Stack[] stacks = result.Stacks.ToArray(); + string stacksPointer = resultPointer.AtProperty(SarifPropertyName.Stacks); + + for (int iStack = 0; iStack < stacks.Length; ++iStack) + { + Stack stack = stacks[iStack]; + string stackPointer = stacksPointer.AtIndex(iStack); + + Visit(stack, stackPointer); + } + } + if (result.RelatedLocations != null) { AnnotatedCodeLocation[] relatedLocations = result.RelatedLocations.ToArray(); @@ -154,66 +173,87 @@ private void Visit(Result result, string resultPointer) } } - private void Visit(AnnotatedCodeLocation annotatedCodeLocation, string annotatedCodeLocationPointer) + private void Visit(Run run, string runPointer) { - if (annotatedCodeLocation.PhysicalLocation != null) + if (run.Results != null) { - string physicalLocationPointer = annotatedCodeLocationPointer.AtProperty(SarifPropertyName.PhysicalLocation); - Visit(annotatedCodeLocation.PhysicalLocation, physicalLocationPointer); + Result[] results = run.Results.ToArray(); + string resultsPointer = runPointer.AtProperty(SarifPropertyName.Results); + + for (int iResult = 0; iResult < results.Length; ++iResult) + { + Result result = results[iResult]; + string resultPointer = resultsPointer.AtIndex(iResult); + + Visit(result, resultPointer); + } } - } - private void Visit(CodeFlow codeFlow, string codeFlowPointer) - { - if (codeFlow.Locations != null) + if (run.Files != null) { - AnnotatedCodeLocation[] annotatedCodeLocations = codeFlow.Locations.ToArray(); - string annotatedCodeLocationsPointer = codeFlowPointer.AtProperty(SarifPropertyName.Locations); + IDictionary files = run.Files; + string filesPointer = runPointer.AtProperty(SarifPropertyName.Files); - for (int iAnnotatedCodeLocation = 0; iAnnotatedCodeLocation < annotatedCodeLocations.Length; ++iAnnotatedCodeLocation) + foreach (string fileKey in files.Keys) { - AnnotatedCodeLocation annotatedCodeLocation = annotatedCodeLocations[iAnnotatedCodeLocation]; - string annotatedCodeLocationPointer = annotatedCodeLocationsPointer.AtIndex(iAnnotatedCodeLocation); + string filePointer = filesPointer.AtProperty(fileKey); - Visit(annotatedCodeLocation, annotatedCodeLocationPointer); + Visit(files[fileKey], fileKey, filePointer); } } - } - private void Visit(Location location, string locationPointer) - { - if (location.AnalysisTarget != null) + if (run.Rules != null) { - string analysisTargetPointer = locationPointer.AtProperty(SarifPropertyName.AnalysisTarget); - Visit(location.AnalysisTarget, analysisTargetPointer); + Rule[] rules = run.Rules.Values.ToArray(); + string rulesPointer = runPointer.AtProperty(SarifPropertyName.Rules); + + for (int iRule = 0; iRule < rules.Length; ++iRule) + { + Rule rule = rules[iRule]; + if (rule.Id != null) + { + string rulePointer = rulesPointer.AtProperty(rule.Id); + Analyze(rule, rulePointer); + } + } } + } - if (location.ResultFile != null) + private void Visit(Stack stack, string stackPointer) + { + if (stack.Frames != null) { - string resultFilePointer = locationPointer.AtProperty(SarifPropertyName.ResultFile); - Visit(location.ResultFile, resultFilePointer); + StackFrame[] frames = stack.Frames.ToArray(); + string framesPointer = stackPointer.AtProperty(SarifPropertyName.Frames); + + for (int iFrame = 0; iFrame < frames.Length; ++iFrame) + { + StackFrame frame = frames[iFrame]; + string framePointer = framesPointer.AtIndex(iFrame); + + Visit(frame, framePointer); + } } } - private void Visit(PhysicalLocation physicalLocation, string physicalLocationPointer) + private void Visit(StackFrame frame, string framePointer) { - Analyze(physicalLocation, physicalLocationPointer); + Analyze(frame, framePointer); } - private void Visit(FileData fileData, string fileKey, string filePointer) + protected virtual void Analyze(FileData fileData, string fileKey, string filePointer) { - Analyze(fileData, fileKey, filePointer); } - protected virtual void Analyze(Rule rule, string rulePointer) + protected virtual void Analyze(PhysicalLocation physicalLocation, string physicalLocationPointer) { } - protected virtual void Analyze(PhysicalLocation physicalLocation, string physicalLocationPointer) + protected virtual void Analyze(Rule rule, string rulePointer) { } - protected virtual void Analyze(FileData fileData, string fileKey, string filePointer) + protected virtual void Analyze(StackFrame frame, string framePointer) { } diff --git a/src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs b/src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs index a5b9a6e0a..48691568d 100644 --- a/src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs +++ b/src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs @@ -26,20 +26,6 @@ protected override IEnumerable FormatIds } } - protected override void Analyze(PhysicalLocation physicalLocation, string physicalLocationPointer) - { - if (UriHasNonAbsoluteFragment(physicalLocation.Uri)) - { - string uriPointer = physicalLocationPointer.AtProperty(SarifPropertyName.Uri); - - LogResult( - ResultLevel.Warning, - uriPointer, - nameof(RuleResources.SV0002_DefaultFormatId), - physicalLocation.Uri.OriginalString); - } - } - protected override void Analyze(FileData fileData, string fileKey, string filePointer) { try @@ -71,6 +57,34 @@ protected override void Analyze(FileData fileData, string fileKey, string filePo } } + protected override void Analyze(PhysicalLocation physicalLocation, string physicalLocationPointer) + { + if (UriHasNonAbsoluteFragment(physicalLocation.Uri)) + { + string uriPointer = physicalLocationPointer.AtProperty(SarifPropertyName.Uri); + + LogResult( + ResultLevel.Warning, + uriPointer, + nameof(RuleResources.SV0002_DefaultFormatId), + physicalLocation.Uri.OriginalString); + } + } + + protected override void Analyze(StackFrame frame, string framePointer) + { + if (UriHasNonAbsoluteFragment(frame.Uri)) + { + string uriPointer = framePointer.AtProperty(SarifPropertyName.Uri); + + LogResult( + ResultLevel.Warning, + uriPointer, + nameof(RuleResources.SV0002_DefaultFormatId), + frame.Uri.OriginalString); + } + } + private bool UriHasNonAbsoluteFragment(Uri uri) { if (uri == null) diff --git a/src/SarifCli/SarifPropertyName.cs b/src/SarifCli/SarifPropertyName.cs index d9fb67f98..e92ac55e9 100644 --- a/src/SarifCli/SarifPropertyName.cs +++ b/src/SarifCli/SarifPropertyName.cs @@ -8,6 +8,7 @@ public static class SarifPropertyName public const string AnalysisTarget = "analysisTarget"; public const string CodeFlows = "codeFlows"; public const string Files = "files"; + public const string Frames = "frames"; public const string Locations = "locations"; public const string PhysicalLocation = "physicalLocation"; public const string RelatedLocations = "relatedLocations"; @@ -15,6 +16,7 @@ public static class SarifPropertyName public const string Results = "results"; public const string Rules = "rules"; public const string Runs = "runs"; + public const string Stacks = "stacks"; public const string Uri = "uri"; } } From eb59c47ab064707fa73cc6eea409b82a55e8ee63 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Thu, 25 Aug 2016 17:23:24 -0700 Subject: [PATCH 25/51] UseAbsolutePathsForNestedFileUriFragments handles notification analysisTarget URIs --- ...lutePathsForNestedFileUriFragmentsTests.cs | 18 +++- .../SarifCli.FunctionalTests.csproj | 12 +++ ...lativeInConfigurationNotificationUri.sarif | 20 +++++ ...onfigurationNotificationUri_Expected.sarif | 84 +++++++++++++++++++ ...gmentIsRelativeInToolNotificationUri.sarif | 20 +++++ ...lativeInToolNotificationUri_Expected.sarif | 84 +++++++++++++++++++ .../Rules/SarifValidationSkimmerBase.cs | 38 +++++++++ src/SarifCli/SarifPropertyName.cs | 2 + 8 files changed, 275 insertions(+), 3 deletions(-) create mode 100644 src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInConfigurationNotificationUri.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInConfigurationNotificationUri_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInToolNotificationUri.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInToolNotificationUri_Expected.sarif diff --git a/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs b/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs index b1dd429a9..ec44bc4c5 100644 --- a/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs +++ b/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs @@ -27,19 +27,31 @@ public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFr } [Fact] - public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentInCodeFlowLocationUri() + public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInCodeFlowLocationUri() { Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInCodeFlowLocationUri.sarif"); } [Fact] - public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentInStackFrameUri() + public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInStackFrameUri() { Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInStackFrameUri.sarif"); } [Fact] - public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelatedRelativeInLocationUri() + public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInToolNotificationUri() + { + Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInToolNotificationUri.sarif"); + } + + [Fact] + public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInConfigurationNotificationUri() + { + Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInConfigurationNotificationUri.sarif"); + } + + [Fact] + public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInRelatedLocationUri() { Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInRelatedLocationUri.sarif"); } diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj index 99c347965..75bddeda9 100644 --- a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -97,6 +97,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest @@ -127,6 +133,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInConfigurationNotificationUri.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInConfigurationNotificationUri.sarif new file mode 100644 index 000000000..0756df540 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInConfigurationNotificationUri.sarif @@ -0,0 +1,20 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [], + "configurationNotifications": [ + { + "message": "The message", + "physicalLocation": { + "uri": "file:///c:/bin/myApp.appx#js/minified.js" + } + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInConfigurationNotificationUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInConfigurationNotificationUri_Expected.sarif new file mode 100644 index 000000000..00dc82230 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInConfigurationNotificationUri_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "6812f90a-ff4c-403d-8547-c9f621df9fea", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0002", + "level": "warning", + "formattedRuleMessage": { + "formatId": "DefaultFormatId", + "arguments": [ + "NestedFileUriFragmentIsRelativeInConfigurationNotificationUri.sarif", + "/runs/0/configurationNotifications/0/physicalLocation/uri", + "file:///c:/bin/myApp.appx#js/minified.js" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInConfigurationNotificationUri.sarif", + "region": { + "startLine": 14, + "startColumn": 62 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInConfigurationNotificationUri.sarif" + }, + "message": "Analyzing 'NestedFileUriFragmentIsRelativeInConfigurationNotificationUri.sarif'...", + "level": "note", + "time": "2016-08-26T00:19:23.582Z" + } + ], + "rules": { + "SV0002": { + "id": "SV0002", + "name": "UseAbsolutePathsForNestedFileUriFragments", + "shortDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path.", + "fullDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path. That is, begin the with a forward slash, for example \"file:///C:/bin/MyApp.zip#/images/grape.jpg\".", + "messageFormats": { + "DefaultFormatId": "In \"{0}\", at \"{1}\", the fragment portion of the URI \"{2}\", which specifies the location of a nested file with respect to its parent, does not begin with a forward slash." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInConfigurationNotificationUri.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UseAbsolutePathsForNestedFileUriFragments\\NestedFileUriFragmentIsRelativeInConfigurationNotificationUri.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\NestedFileUriFragmentIsRelativeInConfigurationNotificationUri_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-26T00:19:23.499Z", + "endTime": "2016-08-26T00:19:23.840Z", + "processId": 10620, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInToolNotificationUri.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInToolNotificationUri.sarif new file mode 100644 index 000000000..667311881 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInToolNotificationUri.sarif @@ -0,0 +1,20 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [], + "toolNotifications": [ + { + "message": "The message", + "physicalLocation": { + "uri": "file:///c:/bin/myApp.appx#js/minified.js" + } + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInToolNotificationUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInToolNotificationUri_Expected.sarif new file mode 100644 index 000000000..3d368b170 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInToolNotificationUri_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "152cb07e-4340-4293-90c7-0fe96501eea9", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0002", + "level": "warning", + "formattedRuleMessage": { + "formatId": "DefaultFormatId", + "arguments": [ + "NestedFileUriFragmentIsRelativeInToolNotificationUri.sarif", + "/runs/0/toolNotifications/0/physicalLocation/uri", + "file:///c:/bin/myApp.appx#js/minified.js" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInToolNotificationUri.sarif", + "region": { + "startLine": 14, + "startColumn": 62 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInToolNotificationUri.sarif" + }, + "message": "Analyzing 'NestedFileUriFragmentIsRelativeInToolNotificationUri.sarif'...", + "level": "note", + "time": "2016-08-26T00:14:12.734Z" + } + ], + "rules": { + "SV0002": { + "id": "SV0002", + "name": "UseAbsolutePathsForNestedFileUriFragments", + "shortDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path.", + "fullDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path. That is, begin the with a forward slash, for example \"file:///C:/bin/MyApp.zip#/images/grape.jpg\".", + "messageFormats": { + "DefaultFormatId": "In \"{0}\", at \"{1}\", the fragment portion of the URI \"{2}\", which specifies the location of a nested file with respect to its parent, does not begin with a forward slash." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInToolNotificationUri.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UseAbsolutePathsForNestedFileUriFragments\\NestedFileUriFragmentIsRelativeInToolNotificationUri.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\NestedFileUriFragmentIsRelativeInToolNotificationUri_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-26T00:14:12.651Z", + "endTime": "2016-08-26T00:14:13.069Z", + "processId": 4488, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs index e1f784d95..beef83dcd 100644 --- a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -109,6 +109,16 @@ private void Visit(Location location, string locationPointer) } } + private void Visit(Notification notification, string notificationPointer) + { + if (notification.PhysicalLocation != null) + { + string physicalLocationPointer = notificationPointer.AtProperty(SarifPropertyName.PhysicalLocation); + + Visit(notification.PhysicalLocation, physicalLocationPointer); + } + } + private void Visit(PhysicalLocation physicalLocation, string physicalLocationPointer) { Analyze(physicalLocation, physicalLocationPointer); @@ -217,6 +227,34 @@ private void Visit(Run run, string runPointer) } } } + + if (run.ToolNotifications != null) + { + Notification[] toolNotifications = run.ToolNotifications.ToArray(); + string toolNotificationsPointer = runPointer.AtProperty(SarifPropertyName.ToolNotifications); + + for (int iToolNotification = 0; iToolNotification < toolNotifications.Length; ++iToolNotification) + { + Notification toolNotification = toolNotifications[iToolNotification]; + string toolNotificationPointer = toolNotificationsPointer.AtIndex(iToolNotification); + + Visit(toolNotification, toolNotificationPointer); + } + } + + if (run.ConfigurationNotifications != null) + { + Notification[] configurationNotifications = run.ConfigurationNotifications.ToArray(); + string configurationNotificationsPointer = runPointer.AtProperty(SarifPropertyName.ConfigurationNotifications); + + for (int iConfigurationNotification = 0; iConfigurationNotification < configurationNotifications.Length; ++iConfigurationNotification) + { + Notification configurationNotification = configurationNotifications[iConfigurationNotification]; + string configurationNotificationPointer = configurationNotificationsPointer.AtIndex(iConfigurationNotification); + + Visit(configurationNotification, configurationNotificationPointer); + } + } } private void Visit(Stack stack, string stackPointer) diff --git a/src/SarifCli/SarifPropertyName.cs b/src/SarifCli/SarifPropertyName.cs index e92ac55e9..25c4e85fc 100644 --- a/src/SarifCli/SarifPropertyName.cs +++ b/src/SarifCli/SarifPropertyName.cs @@ -7,6 +7,7 @@ public static class SarifPropertyName { public const string AnalysisTarget = "analysisTarget"; public const string CodeFlows = "codeFlows"; + public const string ConfigurationNotifications = "configurationNotifications"; public const string Files = "files"; public const string Frames = "frames"; public const string Locations = "locations"; @@ -17,6 +18,7 @@ public static class SarifPropertyName public const string Rules = "rules"; public const string Runs = "runs"; public const string Stacks = "stacks"; + public const string ToolNotifications = "toolNotifications"; public const string Uri = "uri"; } } From 85cf6c5b0f4839c8026affb7f64c505531ef2364 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Thu, 25 Aug 2016 17:29:36 -0700 Subject: [PATCH 26/51] Refactor: DRY out UseAbsolutePathsForNestedFileUriFragments --- ...eAbsolutePathsForNestedFileUriFragments.cs | 33 ++++++------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs b/src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs index 48691568d..731267153 100644 --- a/src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs +++ b/src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs @@ -45,43 +45,30 @@ protected override void Analyze(FileData fileData, string fileKey, string filePo // It wasn't a value URI. TODO: implement another rule to check that. } - if (UriHasNonAbsoluteFragment(fileData.Uri)) - { - string uriPointer = filePointer.AtProperty(SarifPropertyName.Uri); - - LogResult( - ResultLevel.Warning, - uriPointer, - nameof(RuleResources.SV0002_DefaultFormatId), - fileData.Uri.OriginalString); - } + AnalyzeUri(fileData.Uri, filePointer); } protected override void Analyze(PhysicalLocation physicalLocation, string physicalLocationPointer) { - if (UriHasNonAbsoluteFragment(physicalLocation.Uri)) - { - string uriPointer = physicalLocationPointer.AtProperty(SarifPropertyName.Uri); - - LogResult( - ResultLevel.Warning, - uriPointer, - nameof(RuleResources.SV0002_DefaultFormatId), - physicalLocation.Uri.OriginalString); - } + AnalyzeUri(physicalLocation.Uri, physicalLocationPointer); } protected override void Analyze(StackFrame frame, string framePointer) { - if (UriHasNonAbsoluteFragment(frame.Uri)) + AnalyzeUri(frame.Uri, framePointer); + } + + private void AnalyzeUri(Uri uri, string parentPointer) + { + if (UriHasNonAbsoluteFragment(uri)) { - string uriPointer = framePointer.AtProperty(SarifPropertyName.Uri); + string uriPointer = parentPointer.AtProperty(SarifPropertyName.Uri); LogResult( ResultLevel.Warning, uriPointer, nameof(RuleResources.SV0002_DefaultFormatId), - frame.Uri.OriginalString); + uri.OriginalString); } } From 6c12eee542f141649c92bc9ad8c47473bebcda6f Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Thu, 25 Aug 2016 17:40:53 -0700 Subject: [PATCH 27/51] Refactor: SarifCli: DRY out tool and configuration notification handling --- .../Rules/SarifValidationSkimmerBase.cs | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs index beef83dcd..bbf6eafb3 100644 --- a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -230,30 +230,26 @@ private void Visit(Run run, string runPointer) if (run.ToolNotifications != null) { - Notification[] toolNotifications = run.ToolNotifications.ToArray(); - string toolNotificationsPointer = runPointer.AtProperty(SarifPropertyName.ToolNotifications); - - for (int iToolNotification = 0; iToolNotification < toolNotifications.Length; ++iToolNotification) - { - Notification toolNotification = toolNotifications[iToolNotification]; - string toolNotificationPointer = toolNotificationsPointer.AtIndex(iToolNotification); - - Visit(toolNotification, toolNotificationPointer); - } + Visit(run.ToolNotifications, runPointer, SarifPropertyName.ToolNotifications); } if (run.ConfigurationNotifications != null) { - Notification[] configurationNotifications = run.ConfigurationNotifications.ToArray(); - string configurationNotificationsPointer = runPointer.AtProperty(SarifPropertyName.ConfigurationNotifications); + Visit(run.ConfigurationNotifications, runPointer, SarifPropertyName.ConfigurationNotifications); + } + } - for (int iConfigurationNotification = 0; iConfigurationNotification < configurationNotifications.Length; ++iConfigurationNotification) - { - Notification configurationNotification = configurationNotifications[iConfigurationNotification]; - string configurationNotificationPointer = configurationNotificationsPointer.AtIndex(iConfigurationNotification); + private void Visit(IList notifications, string parentPointer, string propertyName) + { + Notification[] notificationsArray = notifications.ToArray(); + string notificationsPointer = parentPointer.AtProperty(propertyName); - Visit(configurationNotification, configurationNotificationPointer); - } + for (int iNotification = 0; iNotification < notificationsArray.Length; ++iNotification) + { + Notification notification = notificationsArray[iNotification]; + string notificationPointer = notificationsPointer.AtIndex(iNotification); + + Visit(notification, notificationPointer); } } From dadefdf7e473623cc69d22b5e42eb81540530ed2 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Fri, 26 Aug 2016 08:36:52 -0700 Subject: [PATCH 28/51] UseAbsolutePathsForNestedFileUriFragments handles fileChange URIs --- ...lutePathsForNestedFileUriFragmentsTests.cs | 34 ++++++----- .../SarifCli.FunctionalTests.csproj | 6 ++ ...UriFragmentIsRelativeInFileChangeUri.sarif | 57 +++++++++++++++++++ .../Rules/SarifValidationSkimmerBase.cs | 40 +++++++++++++ ...eAbsolutePathsForNestedFileUriFragments.cs | 5 ++ src/SarifCli/SarifPropertyName.cs | 2 + 6 files changed, 130 insertions(+), 14 deletions(-) create mode 100644 src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFileChangeUri.sarif diff --git a/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs b/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs index ec44bc4c5..0895a301f 100644 --- a/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs +++ b/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs @@ -20,12 +20,6 @@ public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFr Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInAnalysisTargetUri.sarif"); } - [Fact] - public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInResultFileUri() - { - Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInResultFileUri.sarif"); - } - [Fact] public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInCodeFlowLocationUri() { @@ -33,21 +27,21 @@ public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFr } [Fact] - public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInStackFrameUri() + public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInConfigurationNotificationUri() { - Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInStackFrameUri.sarif"); + Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInConfigurationNotificationUri.sarif"); } [Fact] - public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInToolNotificationUri() + public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInFileChangeUri() { - Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInToolNotificationUri.sarif"); + Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInFileChangeUri.sarif"); } [Fact] - public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInConfigurationNotificationUri() + public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInFilePropertyName() { - Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInConfigurationNotificationUri.sarif"); + Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInFilePropertyName.sarif"); } [Fact] @@ -57,9 +51,21 @@ public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFr } [Fact] - public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInFilePropertyName() + public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInResultFileUri() { - Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInFilePropertyName.sarif"); + Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInResultFileUri.sarif"); + } + + [Fact] + public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInStackFrameUri() + { + Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInStackFrameUri.sarif"); + } + + [Fact] + public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInToolNotificationUri() + { + Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInToolNotificationUri.sarif"); } } } diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj index 75bddeda9..f3bbc6fd0 100644 --- a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -103,6 +103,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFileChangeUri.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFileChangeUri.sarif new file mode 100644 index 000000000..f8b104c98 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFileChangeUri.sarif @@ -0,0 +1,57 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/bin/myApp.appx#/js/minified.js", + "region": { + "startLine": 1 + } + } + } + ], + "fixes": [ + { + "description": "The description", + "fileChanges": [ + { + "uri": "file:///c:/bin/myApp.appx#js/minified.js", + "replacements": [ + { + "offset": 109, + "insertedBytes": "PSBudWxs" + } + ] + } + ] + } + ] + + } + ], + "files": { + "file:///c:/bin/myApp.appx": { + "mimeType": "application/vns.ms-appx" + }, + "file:///c:/bin/myApp.appx#/js/minified.js": { + "uri": "/js/minified.js", + "parentKey": "file:///c:/bin/myApp.appx", + "mimeType": "text/javascript" + } + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs index bbf6eafb3..c83cdc1e3 100644 --- a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -94,6 +94,28 @@ private void Visit(FileData fileData, string fileKey, string filePointer) Analyze(fileData, fileKey, filePointer); } + private void Visit(Fix fix, string fixPointer) + { + if (fix.FileChanges != null) + { + FileChange[] fileChanges = fix.FileChanges.ToArray(); + string fileChangesPointer = fixPointer.AtProperty(SarifPropertyName.FileChanges); + + for (int iFileChange = 0; iFileChange < fileChanges.Length; ++iFileChange) + { + FileChange fileChange = fileChanges[iFileChange]; + string fileChangePointer = fileChangesPointer.AtIndex(iFileChange); + + Visit(fileChange, fileChangePointer); + } + } + } + + private void Visit(FileChange fileChange, string fileChangePointer) + { + Analyze(fileChange, fileChangePointer); + } + private void Visit(Location location, string locationPointer) { if (location.AnalysisTarget != null) @@ -181,6 +203,20 @@ private void Visit(Result result, string resultPointer) Visit(relatedLocation, relatedLocationPointer); } } + + if (result.Fixes != null) + { + Fix[] fixes = result.Fixes.ToArray(); + string fixesPointer = resultPointer.AtProperty(SarifPropertyName.Fixes); + + for (int iFix = 0; iFix < fixes.Length; ++iFix) + { + Fix fix = fixes[iFix]; + string fixPointer = fixesPointer.AtIndex(iFix); + + Visit(fix, fixPointer); + } + } } private void Visit(Run run, string runPointer) @@ -275,6 +311,10 @@ private void Visit(StackFrame frame, string framePointer) Analyze(frame, framePointer); } + protected virtual void Analyze(FileChange fileChange, string fileChangePointer) + { + } + protected virtual void Analyze(FileData fileData, string fileKey, string filePointer) { } diff --git a/src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs b/src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs index 731267153..f2fd00f53 100644 --- a/src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs +++ b/src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs @@ -26,6 +26,11 @@ protected override IEnumerable FormatIds } } + protected override void Analyze(FileChange fileChange, string fileChangePointer) + { + AnalyzeUri(fileChange.Uri, fileChangePointer); + } + protected override void Analyze(FileData fileData, string fileKey, string filePointer) { try diff --git a/src/SarifCli/SarifPropertyName.cs b/src/SarifCli/SarifPropertyName.cs index 25c4e85fc..21e1c53e7 100644 --- a/src/SarifCli/SarifPropertyName.cs +++ b/src/SarifCli/SarifPropertyName.cs @@ -8,7 +8,9 @@ public static class SarifPropertyName public const string AnalysisTarget = "analysisTarget"; public const string CodeFlows = "codeFlows"; public const string ConfigurationNotifications = "configurationNotifications"; + public const string FileChanges = "fileChanges"; public const string Files = "files"; + public const string Fixes = "fixes"; public const string Frames = "frames"; public const string Locations = "locations"; public const string PhysicalLocation = "physicalLocation"; From 02aff1fa4107faf288e26c7e78aa35c37c37ce15 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Fri, 26 Aug 2016 09:23:45 -0700 Subject: [PATCH 29/51] SarifCli: Remove unnecessary elements from test files * Remove `run.id`. * Use a fake tool name and remove optional ` tool` properties. * Use `ruleId` instead of `ruleKey`. * Use `TST0001` as the `ruleId`. * Shorten the file paths. --- ...ragmentIsRelativeInAnalysisTargetUri.sarif | 21 ++--- ...RelativeInAnalysisTargetUri_Expected.sarif | 6 +- ...gmentIsRelativeInCodeFlowLocationUri.sarif | 13 +-- ...lativeInCodeFlowLocationUri_Expected.sarif | 2 +- ...ntIsRelativeInFileChangeUri_Expected.sarif | 84 +++++++++++++++++++ ...FragmentIsRelativeInFilePropertyName.sarif | 21 ++--- ...sRelativeInFilePropertyName_Expected.sarif | 8 +- ...agmentIsRelativeInRelatedLocationUri.sarif | 13 +-- ...elativeInRelatedLocationUri_Expected.sarif | 2 +- ...UriFragmentIsRelativeInResultFileUri.sarif | 21 ++--- ...ntIsRelativeInResultFileUri_Expected.sarif | 6 +- ...UriFragmentIsRelativeInStackFrameUri.sarif | 13 +-- ...ntIsRelativeInStackFrameUri_Expected.sarif | 2 +- .../NestedFileUriFragmentsAreAbsolute.sarif | 21 ++--- 14 files changed, 127 insertions(+), 106 deletions(-) create mode 100644 src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFileChangeUri_Expected.sarif diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri.sarif index 629428758..5f7dd987d 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri.sarif @@ -3,21 +3,12 @@ "version": "1.0.0", "runs": [ { - "id": "e7d5cf38-c160-4bf9-aed1-e84ad6849df3", "tool": { - "name": "ModernCop", - "fullName": "mod50 7.0.7000.0", - "version": "7.0.7000.0", - "semanticVersion": "7.0.7000", - "fileVersion": "7.0.20811.0", - "language": "en-US", - "properties": { - "CompanyName": "Microsoft Corporation" - } + "name": "CodeScanner" }, "results": [ { - "ruleKey": "M1003.DoNotShipObfuscatedCode", + "ruleId": "TST0001", "level": "error", "formattedRuleMessage": { "formatId": "Default" @@ -25,7 +16,7 @@ "locations": [ { "analysisTarget": { - "uri": "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#js/minified.js", + "uri": "file:///c:/bin/myApp.appx#js/minified.js", "region": { "startLine": 1 } @@ -35,12 +26,12 @@ } ], "files": { - "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx": { + "file:///c:/bin/myApp.appx": { "mimeType": "application/vns.ms-appx" }, - "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#/js/minified.js": { + "file:///c:/bin/myApp.appx#/js/minified.js": { "uri": "/js/minified.js", - "parentKey": "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx", + "parentKey": "file:///c:/bin/myApp.appx", "mimeType": "text/javascript" } } diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri_Expected.sarif index 907e269e7..7638e6193 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri_Expected.sarif @@ -26,7 +26,7 @@ "arguments": [ "NestedFileUriFragmentIsRelativeInAnalysisTargetUri.sarif", "/runs/0/results/0/locations/0/analysisTarget/uri", - "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#js/minified.js" + "file:///c:/bin/myApp.appx#js/minified.js" ] }, "locations": [ @@ -34,8 +34,8 @@ "analysisTarget": { "uri": "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Release/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri.sarif", "region": { - "startLine": 28, - "startColumn": 177 + "startLine": 19, + "startColumn": 66 } } } diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri.sarif index a47fe2aaa..dcefc123f 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri.sarif @@ -3,21 +3,12 @@ "version": "1.0.0", "runs": [ { - "id": "e7d5cf38-c160-4bf9-aed1-e84ad6849df3", "tool": { - "name": "ModernCop", - "fullName": "mod50 7.0.7000.0", - "version": "7.0.7000.0", - "semanticVersion": "7.0.7000", - "fileVersion": "7.0.20811.0", - "language": "en-US", - "properties": { - "CompanyName": "Microsoft Corporation" - } + "name": "CodeScanner" }, "results": [ { - "ruleKey": "M1003.DoNotShipObfuscatedCode", + "ruleId": "TST0001", "level": "error", "formattedRuleMessage": { "formatId": "Default" diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri_Expected.sarif index 7f46e4f2d..54df87401 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri_Expected.sarif @@ -34,7 +34,7 @@ "analysisTarget": { "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri.sarif", "region": { - "startLine": 40, + "startLine": 31, "startColumn": 70 } } diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFileChangeUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFileChangeUri_Expected.sarif new file mode 100644 index 000000000..66674372c --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFileChangeUri_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "9f4205fd-3182-44d7-acbb-c97055bf567d", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0002", + "level": "warning", + "formattedRuleMessage": { + "formatId": "DefaultFormatId", + "arguments": [ + "NestedFileUriFragmentIsRelativeInFileChangeUri.sarif", + "/runs/0/results/0/fixes/0/fileChanges/0/uri", + "file:///c:/bin/myApp.appx#js/minified.js" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFileChangeUri.sarif", + "region": { + "startLine": 31, + "startColumn": 68 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFileChangeUri.sarif" + }, + "message": "Analyzing 'NestedFileUriFragmentIsRelativeInFileChangeUri.sarif'...", + "level": "note", + "time": "2016-08-26T15:36:38.827Z" + } + ], + "rules": { + "SV0002": { + "id": "SV0002", + "name": "UseAbsolutePathsForNestedFileUriFragments", + "shortDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path.", + "fullDescription": "When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path. That is, begin the with a forward slash, for example \"file:///C:/bin/MyApp.zip#/images/grape.jpg\".", + "messageFormats": { + "DefaultFormatId": "In \"{0}\", at \"{1}\", the fragment portion of the URI \"{2}\", which specifies the location of a nested file with respect to its parent, does not begin with a forward slash." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFileChangeUri.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UseAbsolutePathsForNestedFileUriFragments\\NestedFileUriFragmentIsRelativeInFileChangeUri.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\NestedFileUriFragmentIsRelativeInFileChangeUri_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-26T15:36:38.743Z", + "endTime": "2016-08-26T15:36:39.109Z", + "processId": 12976, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName.sarif index 9f460c224..e9c156131 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName.sarif @@ -3,21 +3,12 @@ "version": "1.0.0", "runs": [ { - "id": "e7d5cf38-c160-4bf9-aed1-e84ad6849df3", "tool": { - "name": "ModernCop", - "fullName": "mod50 7.0.7000.0", - "version": "7.0.7000.0", - "semanticVersion": "7.0.7000", - "fileVersion": "7.0.20811.0", - "language": "en-US", - "properties": { - "CompanyName": "Microsoft Corporation" - } + "name": "CodeScanner" }, "results": [ { - "ruleKey": "M1003.DoNotShipObfuscatedCode", + "ruleId": "TST0001", "level": "error", "formattedRuleMessage": { "formatId": "Default" @@ -25,7 +16,7 @@ "locations": [ { "analysisTarget": { - "uri": "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#/js/minified.js", + "uri": "file:///c:/bin/myApp.appx#/js/minified.js", "region": { "startLine": 1 } @@ -35,12 +26,12 @@ } ], "files": { - "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx": { + "file:///c:/bin/myApp.appx": { "mimeType": "application/vns.ms-appx" }, - "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#js/minified.js": { + "file:///c:/bin/myApp.appx#js/minified.js": { "uri": "/js/minified.js", - "parentKey": "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx", + "parentKey": "file:///c:/bin/myApp.appx", "mimeType": "text/javascript" } } diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName_Expected.sarif index a44409a86..7ad158846 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName_Expected.sarif @@ -25,8 +25,8 @@ "formatId": "DefaultFormatId", "arguments": [ "NestedFileUriFragmentIsRelativeInFilePropertyName.sarif", - "/runs/0/files/file:~1~1~1d:~1src~1SecDevTools~1Main~1src~1ModernCop~1Source~1WebRules.Test.Unit~1ModernCopTestData~1WebRules_PackageRules~1MinificationRuleApp.appx#js~1minified.js", - "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#js/minified.js" + "/runs/0/files/file:~1~1~1c:~1bin~1myApp.appx#js~1minified.js", + "file:///c:/bin/myApp.appx#js/minified.js" ] }, "locations": [ @@ -34,8 +34,8 @@ "analysisTarget": { "uri": "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Release/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName.sarif", "region": { - "startLine": 41, - "startColumn": 165 + "startLine": 32, + "startColumn": 54 } } } diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri.sarif index e6b4a8ad8..bc30f0a7f 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri.sarif @@ -3,21 +3,12 @@ "version": "1.0.0", "runs": [ { - "id": "e7d5cf38-c160-4bf9-aed1-e84ad6849df3", "tool": { - "name": "ModernCop", - "fullName": "mod50 7.0.7000.0", - "version": "7.0.7000.0", - "semanticVersion": "7.0.7000", - "fileVersion": "7.0.20811.0", - "language": "en-US", - "properties": { - "CompanyName": "Microsoft Corporation" - } + "name": "CodeScanner" }, "results": [ { - "ruleKey": "M1003.DoNotShipObfuscatedCode", + "ruleId": "TST0001", "level": "error", "formattedRuleMessage": { "formatId": "Default" diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri_Expected.sarif index e2e1ba715..19d816714 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri_Expected.sarif @@ -34,7 +34,7 @@ "analysisTarget": { "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri.sarif", "region": { - "startLine": 38, + "startLine": 29, "startColumn": 63 } } diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri.sarif index 6fbd5323a..b87cefa6a 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri.sarif @@ -3,21 +3,12 @@ "version": "1.0.0", "runs": [ { - "id": "e7d5cf38-c160-4bf9-aed1-e84ad6849df3", "tool": { - "name": "ModernCop", - "fullName": "mod50 7.0.7000.0", - "version": "7.0.7000.0", - "semanticVersion": "7.0.7000", - "fileVersion": "7.0.20811.0", - "language": "en-US", - "properties": { - "CompanyName": "Microsoft Corporation" - } + "name": "CodeScanner" }, "results": [ { - "ruleKey": "M1003.DoNotShipObfuscatedCode", + "ruleId": "TST0001", "level": "error", "formattedRuleMessage": { "formatId": "Default" @@ -25,7 +16,7 @@ "locations": [ { "resultFile": { - "uri": "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#js/minified.js", + "uri": "file:///c:/bin/myApp.appx#js/minified.js", "region": { "startLine": 1 } @@ -35,12 +26,12 @@ } ], "files": { - "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx": { + "file:///c:/bin/myApp.appx": { "mimeType": "application/vns.ms-appx" }, - "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#/js/minified.js": { + "file:///c:/bin/myApp.appx#/js/minified.js": { "uri": "/js/minified.js", - "parentKey": "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx", + "parentKey": "file:///c:/bin/myApp.appx", "mimeType": "text/javascript" } } diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri_Expected.sarif index 0ba939316..c55c8a6b0 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri_Expected.sarif @@ -26,7 +26,7 @@ "arguments": [ "NestedFileUriFragmentIsRelativeInResultFileUri.sarif", "/runs/0/results/0/locations/0/resultFile/uri", - "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#js/minified.js" + "file:///c:/bin/myApp.appx#js/minified.js" ] }, "locations": [ @@ -34,8 +34,8 @@ "analysisTarget": { "uri": "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Release/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri.sarif", "region": { - "startLine": 28, - "startColumn": 177 + "startLine": 19, + "startColumn": 66 } } } diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri.sarif index e60df8cc6..49bdf801c 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri.sarif @@ -3,21 +3,12 @@ "version": "1.0.0", "runs": [ { - "id": "e7d5cf38-c160-4bf9-aed1-e84ad6849df3", "tool": { - "name": "ModernCop", - "fullName": "mod50 7.0.7000.0", - "version": "7.0.7000.0", - "semanticVersion": "7.0.7000", - "fileVersion": "7.0.20811.0", - "language": "en-US", - "properties": { - "CompanyName": "Microsoft Corporation" - } + "name": "CodeScanner" }, "results": [ { - "ruleKey": "M1003.DoNotShipObfuscatedCode", + "ruleId": "TST0001", "level": "error", "formattedRuleMessage": { "formatId": "Default" diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri_Expected.sarif index 3447b9b73..14934cdba 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri_Expected.sarif @@ -34,7 +34,7 @@ "analysisTarget": { "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri.sarif", "region": { - "startLine": 39, + "startLine": 30, "startColumn": 68 } } diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentsAreAbsolute.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentsAreAbsolute.sarif index 88020b0a1..fb2ae2143 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentsAreAbsolute.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentsAreAbsolute.sarif @@ -3,21 +3,12 @@ "version": "1.0.0", "runs": [ { - "id": "e7d5cf38-c160-4bf9-aed1-e84ad6849df3", "tool": { - "name": "ModernCop", - "fullName": "mod50 7.0.7000.0", - "version": "7.0.7000.0", - "semanticVersion": "7.0.7000", - "fileVersion": "7.0.20811.0", - "language": "en-US", - "properties": { - "CompanyName": "Microsoft Corporation" - } + "name": "CodeScanner" }, "results": [ { - "ruleKey": "M1003.DoNotShipObfuscatedCode", + "ruleId": "TST0001", "level": "error", "formattedRuleMessage": { "formatId": "Default" @@ -25,7 +16,7 @@ "locations": [ { "analysisTarget": { - "uri": "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#/js/minified.js", + "uri": "file:///c:/bin/myApp.appx#/js/minified.js", "region": { "startLine": 1 } @@ -35,12 +26,12 @@ } ], "files": { - "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx": { + "file:///c:/bin/myApp.appx": { "mimeType": "application/vns.ms-appx" }, - "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx#/js/minified.js": { + "file:///c:/bin/myApp.appx#/js/minified.js": { "uri": "/js/minified.js", - "parentKey": "file:///d:/src/SecDevTools/Main/src/ModernCop/Source/WebRules.Test.Unit/ModernCopTestData/WebRules_PackageRules/MinificationRuleApp.appx", + "parentKey": "file:///c:/bin/myApp.appx", "mimeType": "text/javascript" } } From bd6596b6793f2a80590328470804b37521517aa7 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Fri, 26 Aug 2016 15:29:05 -0700 Subject: [PATCH 30/51] SarifCli: Implement UriValuedPropertiesAreValidUris and AnnotatedCodeLocationIdIsObsolete Also: * Don't hard-code `result.level` to `"warning"`. Instead, respect the `DefaultLevel` specified by the rule. Add a comparison of `result.level` to `SelectiveCompare`. --- .../AnnotatedCodeLocationIdIsObsoleteTests.cs | 29 ++++++ .../DoNotUseFriendlyNameAsRuleIdTests.cs | 8 +- .../Rules/SkimmerTestsBase.cs | 2 + .../Rules/UrisMustBeValidTests.cs | 77 +++++++++++++++ .../SarifCli.FunctionalTests.csproj | 87 ++++++++++++++++ .../AnnotatedCodeLocationDoesNotHaveId.sarif | 45 +++++++++ ...edCodeLocationDoesNotHaveId_Expected.sarif | 46 +++++++++ ...AnnotatedCodeLocationHasIdInCodeFlow.sarif | 46 +++++++++ ...CodeLocationHasIdInCodeFlow_Expected.sarif | 84 ++++++++++++++++ ...edCodeLocationHasIdInRelatedLocation.sarif | 42 ++++++++ ...ationHasIdInRelatedLocation_Expected.sarif | 84 ++++++++++++++++ .../InvalidHelpUriInRule.sarif | 17 ++++ .../InvalidHelpUriInRule_Expected.sarif | 84 ++++++++++++++++ .../InvalidUriInAnalysisTarget.sarif | 30 ++++++ .../InvalidUriInAnalysisTarget_Expected.sarif | 84 ++++++++++++++++ .../InvalidUriInCodeFlowLocation.sarif | 45 +++++++++ ...nvalidUriInCodeFlowLocation_Expected.sarif | 84 ++++++++++++++++ ...nvalidUriInConfigurationNotification.sarif | 20 ++++ ...InConfigurationNotification_Expected.sarif | 84 ++++++++++++++++ .../InvalidUriInFileChange.sarif | 46 +++++++++ .../InvalidUriInFileChange_Expected.sarif | 84 ++++++++++++++++ .../InvalidUriInFilePropertyName.sarif | 35 +++++++ ...nvalidUriInFilePropertyName_Expected.sarif | 84 ++++++++++++++++ .../InvalidUriInRelatedLocation.sarif | 37 +++++++ ...InvalidUriInRelatedLocation_Expected.sarif | 84 ++++++++++++++++ .../InvalidUriInResultFile.sarif | 30 ++++++ .../InvalidUriInResultFile_Expected.sarif | 84 ++++++++++++++++ .../InvalidUriInStackFrame.sarif | 41 ++++++++ .../InvalidUriInStackFrame_Expected.sarif | 84 ++++++++++++++++ .../InvalidUriInToolNotification.sarif | 20 ++++ ...nvalidUriInToolNotification_Expected.sarif | 84 ++++++++++++++++ .../TestData/UrisMustBeValid/ValidUris.sarif | 91 +++++++++++++++++ .../UrisMustBeValid/ValidUris_Expected.sarif | 46 +++++++++ ...RelativeInAnalysisTargetUri_Expected.sarif | 2 +- ...lativeInCodeFlowLocationUri_Expected.sarif | 2 +- ...onfigurationNotificationUri_Expected.sarif | 2 +- ...ntIsRelativeInFileChangeUri_Expected.sarif | 2 +- ...sRelativeInFilePropertyName_Expected.sarif | 2 +- ...elativeInRelatedLocationUri_Expected.sarif | 2 +- ...ntIsRelativeInResultFileUri_Expected.sarif | 2 +- ...ntIsRelativeInStackFrameUri_Expected.sarif | 2 +- ...lativeInToolNotificationUri_Expected.sarif | 2 +- .../AnnotatedCodeLocationIdIsObsolete.cs | 48 +++++++++ .../Rules/DoNotUseFriendlyNameAsRuleId.cs | 3 +- src/SarifCli/Rules/RuleId.cs | 2 + src/SarifCli/Rules/RuleResources.Designer.cs | 45 +++++++++ src/SarifCli/Rules/RuleResources.resx | 15 +++ .../Rules/SarifValidationSkimmerBase.cs | 10 +- src/SarifCli/Rules/UrisMustBeValid.cs | 98 +++++++++++++++++++ ...eAbsolutePathsForNestedFileUriFragments.cs | 6 +- src/SarifCli/SarifCli.csproj | 29 ++++++ src/SarifCli/SarifPropertyName.cs | 1 + 52 files changed, 2104 insertions(+), 19 deletions(-) create mode 100644 src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationIdIsObsoleteTests.cs create mode 100644 src/SarifCli.FunctionalTests/Rules/UrisMustBeValidTests.cs create mode 100644 src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationDoesNotHaveId.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationDoesNotHaveId_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInCodeFlow.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInCodeFlow_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInRelatedLocation.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInRelatedLocation_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidHelpUriInRule.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidHelpUriInRule_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInAnalysisTarget.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInAnalysisTarget_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInCodeFlowLocation.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInCodeFlowLocation_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInConfigurationNotification.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInConfigurationNotification_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFileChange.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFileChange_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFilePropertyName.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFilePropertyName_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInRelatedLocation.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInRelatedLocation_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInResultFile.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInResultFile_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInStackFrame.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInStackFrame_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInToolNotification.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInToolNotification_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/ValidUris.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/ValidUris_Expected.sarif create mode 100644 src/SarifCli/Rules/AnnotatedCodeLocationIdIsObsolete.cs create mode 100644 src/SarifCli/Rules/UrisMustBeValid.cs diff --git a/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationIdIsObsoleteTests.cs b/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationIdIsObsoleteTests.cs new file mode 100644 index 000000000..fd3620713 --- /dev/null +++ b/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationIdIsObsoleteTests.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.CodeAnalysis.Sarif.Cli.Rules; +using Xunit; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules +{ + class AnnotatedCodeLocationIdIsObsoleteTests : SkimmerTestsBase + { + [Fact] + public void AnnotatedCodeLocationIdIsObsolete_NoDiagnostic_AnnotatedCodeLocationDoesNotHaveId() + { + Verify(new AnnotatedCodeLocationIdIsObsolete(), "AnnotatedCodeLocationDoesNotHaveId.sarif"); + } + + [Fact] + public void AnnotatedCodeLocationIdIsObsolete_Diagnostic_AnnotatedCodeLocationInCodeFlowHasId() + { + Verify(new AnnotatedCodeLocationIdIsObsolete(), "AnnotatedCodeLocationInCodeFlowHasId.sarif"); + } + + [Fact] + public void AnnotatedCodeLocationIdIsObsolete_Diagnostic_AnnotatedCodeLocationInRelatedLocationHasId() + { + Verify(new AnnotatedCodeLocationIdIsObsolete(), "AnnotatedCodeLocationInRelatedLocationHasId.sarif"); + } + } +} diff --git a/src/SarifCli.FunctionalTests/Rules/DoNotUseFriendlyNameAsRuleIdTests.cs b/src/SarifCli.FunctionalTests/Rules/DoNotUseFriendlyNameAsRuleIdTests.cs index a4c547329..dc9d08f04 100644 --- a/src/SarifCli.FunctionalTests/Rules/DoNotUseFriendlyNameAsRuleIdTests.cs +++ b/src/SarifCli.FunctionalTests/Rules/DoNotUseFriendlyNameAsRuleIdTests.cs @@ -9,15 +9,15 @@ namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules public class DoNotUseFriendlyNameAsRuleIdTests : SkimmerTestsBase { [Fact] - public void DoNotUseFriendlyNameAsRuleId_Diagnostic_RuleIdMatchesFriendlyName() + public void DoNotUseFriendlyNameAsRuleId_NoDiagnostic_RuleIdDoesNotMatchFriendlyName() { - Verify(new DoNotUseFriendlyNameAsRuleId(), "RuleIdMatchesFriendlyName.sarif"); + Verify(new DoNotUseFriendlyNameAsRuleId(), "RuleIdDoesNotMatchFriendlyName.sarif"); } [Fact] - public void DoNotUseFriendlyNameAsRuleId_NoDiagnostic_RuleIdDoesNotMatchFriendlyName() + public void DoNotUseFriendlyNameAsRuleId_Diagnostic_RuleIdMatchesFriendlyName() { - Verify(new DoNotUseFriendlyNameAsRuleId(), "RuleIdDoesNotMatchFriendlyName.sarif"); + Verify(new DoNotUseFriendlyNameAsRuleId(), "RuleIdMatchesFriendlyName.sarif"); } } } diff --git a/src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs b/src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs index c41898ae9..6a157e7ee 100644 --- a/src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs +++ b/src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs @@ -96,6 +96,8 @@ private static void SelectiveCompare(SarifLog actualLog, SarifLog expectedLog) actualResult.RuleId.Should().Be(expectedResult.RuleId); + actualResult.Level.Should().Be(expectedResult.Level); + actualResult.Locations[0].AnalysisTarget.Region.ValueEquals( expectedResult.Locations[0].AnalysisTarget.Region).Should().BeTrue(); } diff --git a/src/SarifCli.FunctionalTests/Rules/UrisMustBeValidTests.cs b/src/SarifCli.FunctionalTests/Rules/UrisMustBeValidTests.cs new file mode 100644 index 000000000..f18ea00e6 --- /dev/null +++ b/src/SarifCli.FunctionalTests/Rules/UrisMustBeValidTests.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.CodeAnalysis.Sarif.Cli.Rules; +using Xunit; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules +{ + public class UrisMustBeValidTests : SkimmerTestsBase + { + [Fact] + public void UrisMustBeValid_NoDiagnostic_ValidUris() + { + Verify(new UrisMustBeValid(), "ValidUris.sarif"); + } + + [Fact] + public void UrisMustBeValid_Diagnostic_InvalidHelpUriInRule() + { + Verify(new UrisMustBeValid(), "InvalidHelpUriInRule.sarif"); + } + + [Fact] + public void UrisMustBeValid_Diagnostic_InvalidUriInAnalysisTarget() + { + Verify(new UrisMustBeValid(), "InvalidUriInAnalysisTarget.sarif"); + } + + [Fact] + public void UrisMustBeValid_Diagnostic_InvalidUriInCodeFlowLocation() + { + Verify(new UrisMustBeValid(), "InvalidUriInCodeFlowLocation.sarif"); + } + + [Fact] + public void UrisMustBeValid_Diagnostic_InvalidUriInConfigurationNotification() + { + Verify(new UrisMustBeValid(), "InvalidUriInConfigurationNotification.sarif"); + } + + [Fact] + public void UrisMustBeValid_Diagnostic_InvalidUriInFileChange() + { + Verify(new UrisMustBeValid(), "InvalidUriInFileChange.sarif"); + } + + [Fact] + public void UrisMustBeValid_Diagnostic_InvalidUriInFilePropertyName() + { + Verify(new UrisMustBeValid(), "InvalidUriInFilePropertyName.sarif"); + } + + [Fact] + public void UrisMustBeValid_Diagnostic_InvalidUriInRelatedLocation() + { + Verify(new UrisMustBeValid(), "InvalidUriInRelatedLocation.sarif"); + } + + [Fact] + public void UrisMustBeValid_Diagnostic_InvalidUriInResultFile() + { + Verify(new UrisMustBeValid(), "InvalidUriInResultFile.sarif"); + } + + [Fact] + public void UrisMustBeValid_Diagnostic_InvalidUriInStackFrame() + { + Verify(new UrisMustBeValid(), "InvalidUriInStackFrame.sarif"); + } + + [Fact] + public void UrisMustBeValid_Diagnostic_InvalidUriInToolNotification() + { + Verify(new UrisMustBeValid(), "InvalidUriInToolNotification.sarif"); + } + } +} diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj index f3bbc6fd0..fd18828cc 100644 --- a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -65,8 +65,10 @@ + + @@ -79,6 +81,24 @@ Designer + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest @@ -91,6 +111,72 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest @@ -155,6 +241,7 @@ + diff --git a/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationDoesNotHaveId.sarif b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationDoesNotHaveId.sarif new file mode 100644 index 000000000..46b8bdd10 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationDoesNotHaveId.sarif @@ -0,0 +1,45 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "codeFlows": [ + { + "locations": [ + { + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 42, + "startColumn": 12 + } + } + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationDoesNotHaveId_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationDoesNotHaveId_Expected.sarif new file mode 100644 index 000000000..fe75330b4 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationDoesNotHaveId_Expected.sarif @@ -0,0 +1,46 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "22d91896-a2bc-4b98-aaa5-705865aedc63", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationDoesNotHaveId.sarif" + }, + "message": "Analyzing 'AnnotatedCodeLocationDoesNotHaveId.sarif'...", + "level": "note", + "time": "2016-08-26T22:12:22.998Z" + } + ], + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationDoesNotHaveId.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\AnnotatedCodeLocationIdIsObsolete\\AnnotatedCodeLocationDoesNotHaveId.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\AnnotatedCodeLocationDoesNotHaveId_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-26T22:12:22.826Z", + "endTime": "2016-08-26T22:12:23.294Z", + "processId": 15404, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInCodeFlow.sarif b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInCodeFlow.sarif new file mode 100644 index 000000000..b0c15ee94 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInCodeFlow.sarif @@ -0,0 +1,46 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "codeFlows": [ + { + "locations": [ + { + "id": "1", + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 42, + "startColumn": 12 + } + } + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInCodeFlow_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInCodeFlow_Expected.sarif new file mode 100644 index 000000000..4d44ca5ef --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInCodeFlow_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "89530820-f4a3-4c9c-b0fc-f7706130657f", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0004", + "level": "warning", + "formattedRuleMessage": { + "formatId": "DefaultFormatId", + "arguments": [ + "AnnotatedCodeLocationHasIdInCodeFlow.sarif", + "/runs/0/results/0/codeFlows/0/locations/0/id" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInCodeFlow.sarif", + "region": { + "startLine": 30, + "startColumn": 28 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInCodeFlow.sarif" + }, + "message": "Analyzing 'AnnotatedCodeLocationHasIdInCodeFlow.sarif'...", + "level": "note", + "time": "2016-08-26T22:20:01.779Z" + } + ], + "rules": { + "SV0004": { + "id": "SV0004", + "name": "AnnotatedCodeLocationIdIsObsolete", + "shortDescription": "Do not use the property annotatedCodeLocation.", + "fullDescription": "Do not use the property annotatedCodeLocation.id, which is obsolete. Instead use annotatedCodeLocation.step, which is an integer-valued property that is 1 for the first annotatedCodeLocation in a codeFlow, and increments by 1 for every subsequent step.", + "messageFormats": { + "DefaultFormatId": "In \"{0}\", at \"{1}\", the obsolete annotatedCodeLocation.id property is used. Remove it, and instead use the step property, whose value is an integer which is 1 for the first location in a code flow, and increments by 1 for each subsequent location in the code flow.", + "OnlyInCodeFlowFormatId": "In \"{0}\", at \"{1}\", the obsolete annotatedCodeLocation.id property is used. This property has been replaced by the step property, but the step property is used only in annotatedCodeLocations objects that occur within a code flow. Remove the id property." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInCodeFlow.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\AnnotatedCodeLocationIdIsObsolete\\AnnotatedCodeLocationHasIdInCodeFlow.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\AnnotatedCodeLocationHasIdInCodeFlow_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-26T22:20:01.701Z", + "endTime": "2016-08-26T22:20:02.029Z", + "processId": 11124, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInRelatedLocation.sarif b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInRelatedLocation.sarif new file mode 100644 index 000000000..2f7b9c78c --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInRelatedLocation.sarif @@ -0,0 +1,42 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "relatedLocations": [ + { + "id": "1", + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 42, + "startColumn": 12 + } + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInRelatedLocation_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInRelatedLocation_Expected.sarif new file mode 100644 index 000000000..cb7ead36c --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInRelatedLocation_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "06223ed7-67f3-4c8f-a379-824adb998dc2", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0004", + "level": "warning", + "formattedRuleMessage": { + "formatId": "OnlyInCodeFlowFormatId", + "arguments": [ + "AnnotatedCodeLocationHasIdInRelatedLocation.sarif", + "/runs/0/results/0/relatedLocations/0/id" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInRelatedLocation.sarif", + "region": { + "startLine": 28, + "startColumn": 24 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInRelatedLocation.sarif" + }, + "message": "Analyzing 'AnnotatedCodeLocationHasIdInRelatedLocation.sarif'...", + "level": "note", + "time": "2016-08-26T22:18:28.178Z" + } + ], + "rules": { + "SV0004": { + "id": "SV0004", + "name": "AnnotatedCodeLocationIdIsObsolete", + "shortDescription": "Do not use the property annotatedCodeLocation.", + "fullDescription": "Do not use the property annotatedCodeLocation.id, which is obsolete. Instead use annotatedCodeLocation.step, which is an integer-valued property that is 1 for the first annotatedCodeLocation in a codeFlow, and increments by 1 for every subsequent step.", + "messageFormats": { + "DefaultFormatId": "In \"{0}\", at \"{1}\", the obsolete annotatedCodeLocation.id property is used. Remove it, and instead use the step property, whose value is an integer which is 1 for the first location in a code flow, and increments by 1 for each subsequent location in the code flow.", + "OnlyInCodeFlowFormatId": "In \"{0}\", at \"{1}\", the obsolete annotatedCodeLocation.id property is used. This property has been replaced by the step property, but the step property is used only in annotatedCodeLocations objects that occur within a code flow. Remove the id property." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInRelatedLocation.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\AnnotatedCodeLocationIdIsObsolete\\AnnotatedCodeLocationHasIdInRelatedLocation.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\AnnotatedCodeLocationHasIdInRelatedLocation_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-26T22:18:28.100Z", + "endTime": "2016-08-26T22:18:28.428Z", + "processId": 10472, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidHelpUriInRule.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidHelpUriInRule.sarif new file mode 100644 index 000000000..a6f734fb3 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidHelpUriInRule.sarif @@ -0,0 +1,17 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "rules": { + "TST0001": { + "id": "TST0001", + "helpUri": "ht%tp://www.example.com/rules/tst0001.html" + } + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidHelpUriInRule_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidHelpUriInRule_Expected.sarif new file mode 100644 index 000000000..352a197bd --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidHelpUriInRule_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "3fad9fad-f16a-439c-8048-a477db9af638", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0003", + "level": "error", + "formattedRuleMessage": { + "formatId": "DefaultFormatId", + "arguments": [ + "InvalidHelpUriInRule.sarif", + "/runs/0/rules/TST0001/helpUri", + "ht%tp://www.example.com/rules/tst0001.html" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidHelpUriInRule.sarif", + "region": { + "startLine": 12, + "startColumn": 66 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidHelpUriInRule.sarif" + }, + "message": "Analyzing 'InvalidHelpUriInRule.sarif'...", + "level": "note", + "time": "2016-08-26T21:16:18.879Z" + } + ], + "rules": { + "SV0003": { + "id": "SV0003", + "name": "UrisMustBeValid", + "shortDescription": "Specify a valid URI reference for every URI-valued property.", + "fullDescription": "Specify a valid URI reference for every URI-valued property.", + "messageFormats": { + "DefaultFormatId": "In \"{0}\", at \"{1}\", the string \"{2}\" is not a valid URI reference." + }, + "defaultLevel": "error", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidHelpUriInRule.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UrisMustBeValid\\InvalidHelpUriInRule.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\InvalidHelpUriInRule_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-26T21:16:18.796Z", + "endTime": "2016-08-26T21:16:19.128Z", + "processId": 14160, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInAnalysisTarget.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInAnalysisTarget.sarif new file mode 100644 index 000000000..55df88942 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInAnalysisTarget.sarif @@ -0,0 +1,30 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "fi&le:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInAnalysisTarget_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInAnalysisTarget_Expected.sarif new file mode 100644 index 000000000..778c8de47 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInAnalysisTarget_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "8212c13f-8154-4ead-b761-a3172b41f6ae", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0003", + "level": "error", + "formattedRuleMessage": { + "formatId": "DefaultFormatId", + "arguments": [ + "InvalidUriInAnalysisTarget.sarif", + "/runs/0/results/0/locations/0/analysisTarget/uri", + "fi&le:///c:/src/file.c" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInAnalysisTarget.sarif", + "region": { + "startLine": 19, + "startColumn": 48 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInAnalysisTarget.sarif" + }, + "message": "Analyzing 'InvalidUriInAnalysisTarget.sarif'...", + "level": "note", + "time": "2016-08-26T16:59:59.658Z" + } + ], + "rules": { + "SV0003": { + "id": "SV0003", + "name": "UrisMustBeValid", + "shortDescription": "Specify a valid URI reference for every URI-valued property.", + "fullDescription": "Specify a valid URI reference for every URI-valued property.", + "messageFormats": { + "DefaultFormatId": "In \"{0}\", at \"{1}\", the string \"{2}\" is not a valid URI reference." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInAnalysisTarget.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UrisMustBeValid\\InvalidUriInAnalysisTarget.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\InvalidUriInAnalysisTarget_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-26T16:59:59.574Z", + "endTime": "2016-08-26T16:59:59.912Z", + "processId": 4908, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInCodeFlowLocation.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInCodeFlowLocation.sarif new file mode 100644 index 000000000..bfdd73847 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInCodeFlowLocation.sarif @@ -0,0 +1,45 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "codeFlows": [ + { + "locations": [ + { + "physicalLocation": { + "uri": "fi%le:///c:/src/file.c", + "region": { + "startLine": 42, + "startColumn": 12 + } + } + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInCodeFlowLocation_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInCodeFlowLocation_Expected.sarif new file mode 100644 index 000000000..8f00e2143 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInCodeFlowLocation_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "ea65bf9d-f012-4a0e-84e6-5cbe1d57c6d7", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0003", + "level": "error", + "formattedRuleMessage": { + "formatId": "DefaultFormatId", + "arguments": [ + "InvalidUriInCodeFlowLocation.sarif", + "/runs/0/results/0/codeFlows/0/locations/0/physicalLocation/uri", + "fi%le:///c:/src/file.c" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInCodeFlowLocation.sarif", + "region": { + "startLine": 31, + "startColumn": 52 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInCodeFlowLocation.sarif" + }, + "message": "Analyzing 'InvalidUriInCodeFlowLocation.sarif'...", + "level": "note", + "time": "2016-08-26T17:05:59.382Z" + } + ], + "rules": { + "SV0003": { + "id": "SV0003", + "name": "UrisMustBeValid", + "shortDescription": "Specify a valid URI reference for every URI-valued property.", + "fullDescription": "Specify a valid URI reference for every URI-valued property.", + "messageFormats": { + "DefaultFormatId": "In \"{0}\", at \"{1}\", the string \"{2}\" is not a valid URI reference." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInCodeFlowLocation.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UrisMustBeValid\\InvalidUriInCodeFlowLocation.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\InvalidUriInCodeFlowLocation_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-26T17:05:59.300Z", + "endTime": "2016-08-26T17:05:59.638Z", + "processId": 14512, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInConfigurationNotification.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInConfigurationNotification.sarif new file mode 100644 index 000000000..4c0aa43a2 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInConfigurationNotification.sarif @@ -0,0 +1,20 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [], + "configurationNotifications": [ + { + "message": "The message", + "physicalLocation": { + "uri": "fi%le:///c:/src/file.c" + } + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInConfigurationNotification_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInConfigurationNotification_Expected.sarif new file mode 100644 index 000000000..5ab0ca98c --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInConfigurationNotification_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "89ae6a35-e89e-4b17-97d0-4ada36a8f54a", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0003", + "level": "error", + "formattedRuleMessage": { + "formatId": "DefaultFormatId", + "arguments": [ + "InvalidUriInConfigurationNotification.sarif", + "/runs/0/configurationNotifications/0/physicalLocation/uri", + "fi%le:///c:/src/file.c" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInConfigurationNotification.sarif", + "region": { + "startLine": 14, + "startColumn": 44 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInConfigurationNotification.sarif" + }, + "message": "Analyzing 'InvalidUriInConfigurationNotification.sarif'...", + "level": "note", + "time": "2016-08-26T17:08:28.958Z" + } + ], + "rules": { + "SV0003": { + "id": "SV0003", + "name": "UrisMustBeValid", + "shortDescription": "Specify a valid URI reference for every URI-valued property.", + "fullDescription": "Specify a valid URI reference for every URI-valued property.", + "messageFormats": { + "DefaultFormatId": "In \"{0}\", at \"{1}\", the string \"{2}\" is not a valid URI reference." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInConfigurationNotification.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UrisMustBeValid\\InvalidUriInConfigurationNotification.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\InvalidUriInConfigurationNotification_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-26T17:08:28.875Z", + "endTime": "2016-08-26T17:08:29.206Z", + "processId": 11716, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFileChange.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFileChange.sarif new file mode 100644 index 000000000..58dc44f4e --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFileChange.sarif @@ -0,0 +1,46 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "fixes": [ + { + "description": "The description", + "fileChanges": [ + { + "uri": "fi%le:///c:/src/file.c", + "replacements": [ + { + "offset": 109, + "insertedBytes": "PSBudWxs" + } + ] + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFileChange_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFileChange_Expected.sarif new file mode 100644 index 000000000..821dfe5bf --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFileChange_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "74014d14-07b1-4591-a7c3-bbde7e63d548", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0003", + "level": "error", + "formattedRuleMessage": { + "formatId": "DefaultFormatId", + "arguments": [ + "InvalidUriInFileChange.sarif", + "/runs/0/results/0/fixes/0/fileChanges/0/uri", + "fi%le:///c:/src/file.c" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFileChange.sarif", + "region": { + "startLine": 31, + "startColumn": 50 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFileChange.sarif" + }, + "message": "Analyzing 'InvalidUriInFileChange.sarif'...", + "level": "note", + "time": "2016-08-26T18:01:47.806Z" + } + ], + "rules": { + "SV0003": { + "id": "SV0003", + "name": "UrisMustBeValid", + "shortDescription": "Specify a valid URI reference for every URI-valued property.", + "fullDescription": "Specify a valid URI reference for every URI-valued property.", + "messageFormats": { + "DefaultFormatId": "In \"{0}\", at \"{1}\", the string \"{2}\" is not a valid URI reference." + }, + "defaultLevel": "error", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFileChange.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UrisMustBeValid\\InvalidUriInFileChange.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\InvalidUriInFileChange_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-26T18:01:47.628Z", + "endTime": "2016-08-26T18:01:48.114Z", + "processId": 17640, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFilePropertyName.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFilePropertyName.sarif new file mode 100644 index 000000000..a647133ac --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFilePropertyName.sarif @@ -0,0 +1,35 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ] + } + ], + "files": { + "fi%le:///c:/src/file.c": { + "mimeType": "text/x-c" + } + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFilePropertyName_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFilePropertyName_Expected.sarif new file mode 100644 index 000000000..a436ce318 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFilePropertyName_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "72cf3faa-9108-45a4-ae8c-1f04cab979b0", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0003", + "level": "error", + "formattedRuleMessage": { + "formatId": "DefaultFormatId", + "arguments": [ + "InvalidUriInFilePropertyName.sarif", + "/runs/0/files/fi%le:~1~1~1c:~1src~1file.c", + "fi%le:///c:/src/file.c" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFilePropertyName.sarif", + "region": { + "startLine": 29, + "startColumn": 36 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFilePropertyName.sarif" + }, + "message": "Analyzing 'InvalidUriInFilePropertyName.sarif'...", + "level": "note", + "time": "2016-08-26T18:13:11.879Z" + } + ], + "rules": { + "SV0003": { + "id": "SV0003", + "name": "UrisMustBeValid", + "shortDescription": "Specify a valid URI reference for every URI-valued property.", + "fullDescription": "Specify a valid URI reference for every URI-valued property.", + "messageFormats": { + "DefaultFormatId": "In \"{0}\", at \"{1}\", the string \"{2}\" is not a valid URI reference." + }, + "defaultLevel": "error", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFilePropertyName.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UrisMustBeValid\\InvalidUriInFilePropertyName.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\InvalidUriInFileCPropertyName_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-26T18:13:11.795Z", + "endTime": "2016-08-26T18:13:12.146Z", + "processId": 18768, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInRelatedLocation.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInRelatedLocation.sarif new file mode 100644 index 000000000..8892b4672 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInRelatedLocation.sarif @@ -0,0 +1,37 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "relatedLocations": [ + { + "physicalLocation": { + "uri": "fi%le:///c:/src/other.other" + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInRelatedLocation_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInRelatedLocation_Expected.sarif new file mode 100644 index 000000000..f38023d90 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInRelatedLocation_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "01986463-f0ce-4a1f-8616-ba473d5b6248", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0003", + "level": "error", + "formattedRuleMessage": { + "formatId": "DefaultFormatId", + "arguments": [ + "InvalidUriInRelatedLocation.sarif", + "/runs/0/results/0/relatedLocations/0/physicalLocation/uri", + "fi%le:///c:/src/other.other" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInRelatedLocation.sarif", + "region": { + "startLine": 29, + "startColumn": 53 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInRelatedLocation.sarif" + }, + "message": "Analyzing 'InvalidUriInRelatedLocation.sarif'...", + "level": "note", + "time": "2016-08-26T18:15:52.051Z" + } + ], + "rules": { + "SV0003": { + "id": "SV0003", + "name": "UrisMustBeValid", + "shortDescription": "Specify a valid URI reference for every URI-valued property.", + "fullDescription": "Specify a valid URI reference for every URI-valued property.", + "messageFormats": { + "DefaultFormatId": "In \"{0}\", at \"{1}\", the string \"{2}\" is not a valid URI reference." + }, + "defaultLevel": "error", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInRelatedLocation.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UrisMustBeValid\\InvalidUriInRelatedLocation.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\InvalidUriInRelatedLocation_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-26T18:15:51.968Z", + "endTime": "2016-08-26T18:15:52.305Z", + "processId": 11120, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInResultFile.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInResultFile.sarif new file mode 100644 index 000000000..274dcbb62 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInResultFile.sarif @@ -0,0 +1,30 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "resultFile": { + "uri": "fi&le:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInResultFile_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInResultFile_Expected.sarif new file mode 100644 index 000000000..6d6e2b54d --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInResultFile_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "6179d101-91a8-480c-ac93-95a95556e39b", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0003", + "level": "error", + "formattedRuleMessage": { + "formatId": "DefaultFormatId", + "arguments": [ + "InvalidUriInResultFile.sarif", + "/runs/0/results/0/locations/0/resultFile/uri", + "fi&le:///c:/src/file.c" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInResultFile.sarif", + "region": { + "startLine": 19, + "startColumn": 48 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInResultFile.sarif" + }, + "message": "Analyzing 'InvalidUriInResultFile.sarif'...", + "level": "note", + "time": "2016-08-26T17:02:56.314Z" + } + ], + "rules": { + "SV0003": { + "id": "SV0003", + "name": "UrisMustBeValid", + "shortDescription": "Specify a valid URI reference for every URI-valued property.", + "fullDescription": "Specify a valid URI reference for every URI-valued property.", + "messageFormats": { + "DefaultFormatId": "In \"{0}\", at \"{1}\", the string \"{2}\" is not a valid URI reference." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInResultFile.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UrisMustBeValid\\InvalidUriInResultFile.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\InvalidUriInResultFile_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-26T17:02:56.230Z", + "endTime": "2016-08-26T17:02:56.569Z", + "processId": 11052, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInStackFrame.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInStackFrame.sarif new file mode 100644 index 000000000..633d85177 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInStackFrame.sarif @@ -0,0 +1,41 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "stacks": [ + { + "frames": [ + { + "uri": "fi%le:///c:/src/file.cs", + "fullyQualifiedLogicalName": "func", + "line": 23 + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInStackFrame_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInStackFrame_Expected.sarif new file mode 100644 index 000000000..b0fa460b8 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInStackFrame_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "89a247ca-e1ea-4820-9d00-b5635e5234c6", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0003", + "level": "error", + "formattedRuleMessage": { + "formatId": "DefaultFormatId", + "arguments": [ + "InvalidUriInStackFrame.sarif", + "/runs/0/results/0/stacks/0/frames/0/uri", + "fi%le:///c:/src/file.cs" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInStackFrame.sarif", + "region": { + "startLine": 30, + "startColumn": 51 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInStackFrame.sarif" + }, + "message": "Analyzing 'InvalidUriInStackFrame.sarif'...", + "level": "note", + "time": "2016-08-26T18:18:25.351Z" + } + ], + "rules": { + "SV0003": { + "id": "SV0003", + "name": "UrisMustBeValid", + "shortDescription": "Specify a valid URI reference for every URI-valued property.", + "fullDescription": "Specify a valid URI reference for every URI-valued property.", + "messageFormats": { + "DefaultFormatId": "In \"{0}\", at \"{1}\", the string \"{2}\" is not a valid URI reference." + }, + "defaultLevel": "error", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInStackFrame.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UrisMustBeValid\\InvalidUriInStackFrame.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\InvalidUriInStackFrame_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-26T18:18:25.269Z", + "endTime": "2016-08-26T18:18:25.619Z", + "processId": 11436, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInToolNotification.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInToolNotification.sarif new file mode 100644 index 000000000..a5a0c3941 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInToolNotification.sarif @@ -0,0 +1,20 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [], + "toolNotifications": [ + { + "message": "The message", + "physicalLocation": { + "uri": "fi%le:///c:/src/file.c" + } + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInToolNotification_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInToolNotification_Expected.sarif new file mode 100644 index 000000000..83939aa3e --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInToolNotification_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "5f5f37ee-fa60-41c9-a266-4c60dfbc9c25", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0003", + "level": "error", + "formattedRuleMessage": { + "formatId": "DefaultFormatId", + "arguments": [ + "InvalidUriInToolNotification.sarif", + "/runs/0/toolNotifications/0/physicalLocation/uri", + "fi%le:///c:/src/file.c" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInToolNotification.sarif", + "region": { + "startLine": 14, + "startColumn": 44 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInToolNotification.sarif" + }, + "message": "Analyzing 'InvalidUriInToolNotification.sarif'...", + "level": "note", + "time": "2016-08-26T18:20:49.926Z" + } + ], + "rules": { + "SV0003": { + "id": "SV0003", + "name": "UrisMustBeValid", + "shortDescription": "Specify a valid URI reference for every URI-valued property.", + "fullDescription": "Specify a valid URI reference for every URI-valued property.", + "messageFormats": { + "DefaultFormatId": "In \"{0}\", at \"{1}\", the string \"{2}\" is not a valid URI reference." + }, + "defaultLevel": "error", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInToolNotification.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UrisMustBeValid\\InvalidUriInToolNotification.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\InvalidUriInToolNotification_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-26T18:20:49.844Z", + "endTime": "2016-08-26T18:20:50.180Z", + "processId": 7292, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/ValidUris.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/ValidUris.sarif new file mode 100644 index 000000000..7db174266 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/ValidUris.sarif @@ -0,0 +1,91 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + }, + "resultFile": { + "uri": "file:///c:/src/file2.c", + "region": { + "startLine": 1 + } + } + } + ], + "relatedLocations": [ + { + "physicalLocation": { + "uri": "file:///c:/src/file3.c" + } + } + ], + "codeFlows": [ + { + "locations": [ + { + "physicalLocation": { + "uri": "file:///c:/src/file1.c" + } + } + ] + } + ], + "stacks": [ + { + "frames": [ + { + "fullyQualifiedLogicalName": "func", + "uri": "file:///c:/src/file1.c" + } + ] + } + ] + } + ], + "configurationNotifications": [ + { + "message": "Message", + "physicalLocation": { + "uri": "file:///c:/src/file1.c" + } + } + ], + "toolNotifications": [ + { + "message": "Message", + "physicalLocation": { + "uri": "file:///c:/src/file1.c" + } + } + ], + "files": { + "file:///c:/src/file1.c": { + "uri": "file:///c:/src/file1.c" + } + }, + "rules": { + "TST0001": { + "id": "TST0001", + "helpUri": "http://www.example.com/rules/tst0001.html" + } + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/ValidUris_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/ValidUris_Expected.sarif new file mode 100644 index 000000000..373a18b34 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/ValidUris_Expected.sarif @@ -0,0 +1,46 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "bf97329b-d388-4956-865a-e33b522df6d4", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/ValidUris.sarif" + }, + "message": "Analyzing 'ValidUris.sarif'...", + "level": "note", + "time": "2016-08-26T21:08:15.619Z" + } + ], + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/ValidUris.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\UrisMustBeValid\\ValidUris.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\ValidUris_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-26T21:08:15.536Z", + "endTime": "2016-08-26T21:08:15.878Z", + "processId": 13060, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri_Expected.sarif index 7638e6193..89867aa12 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri_Expected.sarif @@ -20,7 +20,7 @@ "results": [ { "ruleId": "SV0002", - "level": "warning", + "level": "error", "formattedRuleMessage": { "formatId": "DefaultFormatId", "arguments": [ diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri_Expected.sarif index 54df87401..600860839 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri_Expected.sarif @@ -20,7 +20,7 @@ "results": [ { "ruleId": "SV0002", - "level": "warning", + "level": "error", "formattedRuleMessage": { "formatId": "DefaultFormatId", "arguments": [ diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInConfigurationNotificationUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInConfigurationNotificationUri_Expected.sarif index 00dc82230..f47a5a9fd 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInConfigurationNotificationUri_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInConfigurationNotificationUri_Expected.sarif @@ -20,7 +20,7 @@ "results": [ { "ruleId": "SV0002", - "level": "warning", + "level": "error", "formattedRuleMessage": { "formatId": "DefaultFormatId", "arguments": [ diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFileChangeUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFileChangeUri_Expected.sarif index 66674372c..55c3cd0b7 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFileChangeUri_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFileChangeUri_Expected.sarif @@ -20,7 +20,7 @@ "results": [ { "ruleId": "SV0002", - "level": "warning", + "level": "error", "formattedRuleMessage": { "formatId": "DefaultFormatId", "arguments": [ diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName_Expected.sarif index 7ad158846..a3b886eb5 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName_Expected.sarif @@ -20,7 +20,7 @@ "results": [ { "ruleId": "SV0002", - "level": "warning", + "level": "error", "formattedRuleMessage": { "formatId": "DefaultFormatId", "arguments": [ diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri_Expected.sarif index 19d816714..6fbe51494 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri_Expected.sarif @@ -20,7 +20,7 @@ "results": [ { "ruleId": "SV0002", - "level": "warning", + "level": "error", "formattedRuleMessage": { "formatId": "DefaultFormatId", "arguments": [ diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri_Expected.sarif index c55c8a6b0..c54b47fc0 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri_Expected.sarif @@ -20,7 +20,7 @@ "results": [ { "ruleId": "SV0002", - "level": "warning", + "level": "error", "formattedRuleMessage": { "formatId": "DefaultFormatId", "arguments": [ diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri_Expected.sarif index 14934cdba..96a26ec01 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri_Expected.sarif @@ -20,7 +20,7 @@ "results": [ { "ruleId": "SV0002", - "level": "warning", + "level": "error", "formattedRuleMessage": { "formatId": "DefaultFormatId", "arguments": [ diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInToolNotificationUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInToolNotificationUri_Expected.sarif index 3d368b170..5abd38025 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInToolNotificationUri_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInToolNotificationUri_Expected.sarif @@ -20,7 +20,7 @@ "results": [ { "ruleId": "SV0002", - "level": "warning", + "level": "error", "formattedRuleMessage": { "formatId": "DefaultFormatId", "arguments": [ diff --git a/src/SarifCli/Rules/AnnotatedCodeLocationIdIsObsolete.cs b/src/SarifCli/Rules/AnnotatedCodeLocationIdIsObsolete.cs new file mode 100644 index 000000000..f511e1872 --- /dev/null +++ b/src/SarifCli/Rules/AnnotatedCodeLocationIdIsObsolete.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Collections.Generic; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules +{ + public class AnnotatedCodeLocationIdIsObsolete : SarifValidationSkimmerBase + { + public override string FullDescription => RuleResources.SV0004_AnnotatedCodeLocationIdIsObsolete; + + public override ResultLevel DefaultLevel => ResultLevel.Warning; + + /// + /// SV0004 + /// + public override string Id => RuleId.AnnotatedCodeLocationIdIsObsolete; + + protected override IEnumerable FormatIds + { + get + { + return new string[] + { + nameof(RuleResources.SV0004_DefaultFormatId), + nameof(RuleResources.SV0004_OnlyInCodeFlowFormatId) + }; + } + } + + protected override void Analyze(AnnotatedCodeLocation annotatedCodeLocation, string annotatedCodeLocationPointer) + { + if (annotatedCodeLocation.Id != 0) + { + string idPointer = annotatedCodeLocationPointer.AtProperty(SarifPropertyName.Id); + + // Emit a different warning depending on whether or not this annotatedCodeLocation + // occurs in a codeFlow, because the "step" property is only meaningful within + // a codeFlow. + string formatId = annotatedCodeLocationPointer.Contains(SarifPropertyName.CodeFlows) + ? nameof(RuleResources.SV0004_DefaultFormatId) + : nameof(RuleResources.SV0004_OnlyInCodeFlowFormatId); + + LogResult(idPointer, formatId); + } + } + } +} diff --git a/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs b/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs index e77ded3f9..22b36dfe0 100644 --- a/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs +++ b/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs @@ -10,6 +10,8 @@ public class DoNotUseFriendlyNameAsRuleId : SarifValidationSkimmerBase { public override string FullDescription => RuleResources.SV0001_DoNotUseFriendlyNameAsRuleIdDescription; + public override ResultLevel DefaultLevel => ResultLevel.Warning; + /// /// SV0001 /// @@ -33,7 +35,6 @@ protected override void Analyze(Rule rule, string rulePointer) && rule.Id.Equals(rule.Name, StringComparison.OrdinalIgnoreCase)) { LogResult( - ResultLevel.Warning, rulePointer, nameof(RuleResources.SV0001_DefaultFormatId), rule.Id); diff --git a/src/SarifCli/Rules/RuleId.cs b/src/SarifCli/Rules/RuleId.cs index 95f9f06b7..2f84ed4da 100644 --- a/src/SarifCli/Rules/RuleId.cs +++ b/src/SarifCli/Rules/RuleId.cs @@ -7,5 +7,7 @@ public static class RuleId { public const string DoNotUseFriendlyNameAsRuleId = "SV0001"; public const string UseAbsolutePathsForNestedFileUriFragments = "SV0002"; + public const string UrisMustBeValid = "SV0003"; + public const string AnnotatedCodeLocationIdIsObsolete = "SV0004"; } } diff --git a/src/SarifCli/Rules/RuleResources.Designer.cs b/src/SarifCli/Rules/RuleResources.Designer.cs index 37e73b4fd..ff0d576b8 100644 --- a/src/SarifCli/Rules/RuleResources.Designer.cs +++ b/src/SarifCli/Rules/RuleResources.Designer.cs @@ -95,5 +95,50 @@ internal static string SV0002_UseAbsolutePathsForNestedFileUriFragmentsDescripti return ResourceManager.GetString("SV0002_UseAbsolutePathsForNestedFileUriFragmentsDescription", resourceCulture); } } + + /// + /// Looks up a localized string similar to In "{0}", at "{1}", the string "{2}" is not a valid URI reference.. + /// + internal static string SV0003_DefaultFormatId { + get { + return ResourceManager.GetString("SV0003_DefaultFormatId", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Specify a valid URI reference for every URI-valued property.. + /// + internal static string SV0003_UrisMustBeValid { + get { + return ResourceManager.GetString("SV0003_UrisMustBeValid", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Do not use the property annotatedCodeLocation.id, which is obsolete. Instead use annotatedCodeLocation.step, which is an integer-valued property that is 1 for the first annotatedCodeLocation in a codeFlow, and increments by 1 for every subsequent step.. + /// + internal static string SV0004_AnnotatedCodeLocationIdIsObsolete { + get { + return ResourceManager.GetString("SV0004_AnnotatedCodeLocationIdIsObsolete", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to In "{0}", at "{1}", the obsolete annotatedCodeLocation.id property is used. Remove it, and instead use the step property, whose value is an integer which is 1 for the first location in a code flow, and increments by 1 for each subsequent location in the code flow.. + /// + internal static string SV0004_DefaultFormatId { + get { + return ResourceManager.GetString("SV0004_DefaultFormatId", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to In "{0}", at "{1}", the obsolete annotatedCodeLocation.id property is used. This property has been replaced by the step property, but the step property is used only in annotatedCodeLocations objects that occur within a code flow. Remove the id property.. + /// + internal static string SV0004_OnlyInCodeFlowFormatId { + get { + return ResourceManager.GetString("SV0004_OnlyInCodeFlowFormatId", resourceCulture); + } + } } } diff --git a/src/SarifCli/Rules/RuleResources.resx b/src/SarifCli/Rules/RuleResources.resx index e59a10260..d188df44c 100644 --- a/src/SarifCli/Rules/RuleResources.resx +++ b/src/SarifCli/Rules/RuleResources.resx @@ -129,4 +129,19 @@ When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path. That is, begin the with a forward slash, for example "file:///C:/bin/MyApp.zip#/images/grape.jpg". + + In "{0}", at "{1}", the string "{2}" is not a valid URI reference. + + + Specify a valid URI reference for every URI-valued property. + + + Do not use the property annotatedCodeLocation.id, which is obsolete. Instead use annotatedCodeLocation.step, which is an integer-valued property that is 1 for the first annotatedCodeLocation in a codeFlow, and increments by 1 for every subsequent step. + + + In "{0}", at "{1}", the obsolete annotatedCodeLocation.id property is used. Remove it, and instead use the step property, whose value is an integer which is 1 for the first location in a code flow, and increments by 1 for each subsequent location in the code flow. + + + In "{0}", at "{1}", the obsolete annotatedCodeLocation.id property is used. This property has been replaced by the step property, but the step property is used only in annotatedCodeLocations objects that occur within a code flow. Remove the id property. + \ No newline at end of file diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs index c83cdc1e3..5646d81fd 100644 --- a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -65,6 +65,8 @@ private void Visit(SarifLog log, string logPointer) private void Visit(AnnotatedCodeLocation annotatedCodeLocation, string annotatedCodeLocationPointer) { + Analyze(annotatedCodeLocation, annotatedCodeLocationPointer); + if (annotatedCodeLocation.PhysicalLocation != null) { string physicalLocationPointer = annotatedCodeLocationPointer.AtProperty(SarifPropertyName.PhysicalLocation); @@ -311,6 +313,10 @@ private void Visit(StackFrame frame, string framePointer) Analyze(frame, framePointer); } + protected virtual void Analyze(AnnotatedCodeLocation annotatedCodeLocation, string annotatedCodeLocationPointer) + { + } + protected virtual void Analyze(FileChange fileChange, string fileChangePointer) { } @@ -331,7 +337,7 @@ protected virtual void Analyze(StackFrame frame, string framePointer) { } - protected void LogResult(ResultLevel level, string jPointer, string formatId, params string[] args) + protected void LogResult(string jPointer, string formatId, params string[] args) { Region region = GetRegionFromJPointer(jPointer); @@ -342,7 +348,7 @@ protected void LogResult(ResultLevel level, string jPointer, string formatId, pa argsWithPointer[0] = jPointer; Context.Logger.Log(this, - RuleUtilities.BuildResult(ResultLevel.Warning, Context, region, formatId, argsWithPointer)); + RuleUtilities.BuildResult(DefaultLevel, Context, region, formatId, argsWithPointer)); } private Region GetRegionFromJPointer(string jPointer) diff --git a/src/SarifCli/Rules/UrisMustBeValid.cs b/src/SarifCli/Rules/UrisMustBeValid.cs new file mode 100644 index 000000000..e8a9431b7 --- /dev/null +++ b/src/SarifCli/Rules/UrisMustBeValid.cs @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules +{ + public class UrisMustBeValid : SarifValidationSkimmerBase + { + public override string FullDescription => RuleResources.SV0003_UrisMustBeValid; + + public override ResultLevel DefaultLevel => ResultLevel.Error; + + /// + /// SV0003 + /// + public override string Id => RuleId.UrisMustBeValid; + + protected override IEnumerable FormatIds + { + get + { + return new string[] + { + nameof(RuleResources.SV0003_DefaultFormatId) + }; + } + } + + protected override void Analyze(FileChange fileChange, string fileChangePointer) + { + AnalyzeUri(fileChange.Uri, fileChangePointer); + } + + protected override void Analyze(FileData fileData, string fileKey, string filePointer) + { + // Check the property name, which must be a valid URI. + // We can't use AnalyzeUri for this because that method appends "/uri" + // to the JSON pointer, whereas here, the JSON pointer we have in + // hand (filePointer) already points right to the property we are + // examining. + string fileUriReference = fileKey.UnescapeJsonPointer(); + try + { + Uri fileUri = new Uri(fileUriReference); + } + catch + { + LogResult( + filePointer, + nameof(RuleResources.SV0003_DefaultFormatId), + fileUriReference); + } + + // Then check the "uri" property, if any, of the property value. + AnalyzeUri(fileData.Uri, filePointer); + } + + protected override void Analyze(PhysicalLocation physicalLocation, string physicalLocationPointer) + { + AnalyzeUri(physicalLocation.Uri, physicalLocationPointer); + } + + protected override void Analyze(StackFrame frame, string framePointer) + { + AnalyzeUri(frame.Uri, framePointer); + } + + protected override void Analyze(Rule rule, string rulePointer) + { + AnalyzeUri(rule.HelpUri, rulePointer, "helpUri"); + } + + private void AnalyzeUri( + Uri uri, + string parentPointer, + string childPropertyName = SarifPropertyName.Uri) + { + if (uri != null) + { + try + { + Uri fileUri = new Uri(uri.OriginalString); + } + catch + { + string uriPointer = parentPointer.AtProperty(childPropertyName); + + LogResult( + uriPointer, + nameof(RuleResources.SV0003_DefaultFormatId), + uri.OriginalString); + } + } + } + } +} diff --git a/src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs b/src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs index f2fd00f53..b15e3d563 100644 --- a/src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs +++ b/src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs @@ -10,6 +10,8 @@ public class UseAbsolutePathsForNestedFileUriFragments : SarifValidationSkimmerB { public override string FullDescription => RuleResources.SV0002_UseAbsolutePathsForNestedFileUriFragmentsDescription; + public override ResultLevel DefaultLevel => ResultLevel.Error; + /// /// SV0002 /// @@ -39,7 +41,6 @@ protected override void Analyze(FileData fileData, string fileKey, string filePo if (UriHasNonAbsoluteFragment(fileUri)) { LogResult( - ResultLevel.Warning, filePointer, nameof(RuleResources.SV0002_DefaultFormatId), fileUri.OriginalString); @@ -47,7 +48,7 @@ protected override void Analyze(FileData fileData, string fileKey, string filePo } catch { - // It wasn't a value URI. TODO: implement another rule to check that. + // It wasn't a value URI. Rule SV0003, UrisMustBeValid, will catch this problem. } AnalyzeUri(fileData.Uri, filePointer); @@ -70,7 +71,6 @@ private void AnalyzeUri(Uri uri, string parentPointer) string uriPointer = parentPointer.AtProperty(SarifPropertyName.Uri); LogResult( - ResultLevel.Warning, uriPointer, nameof(RuleResources.SV0002_DefaultFormatId), uri.OriginalString); diff --git a/src/SarifCli/SarifCli.csproj b/src/SarifCli/SarifCli.csproj index 88d9628ca..b9323058d 100644 --- a/src/SarifCli/SarifCli.csproj +++ b/src/SarifCli/SarifCli.csproj @@ -6,6 +6,21 @@ Microsoft.CodeAnalysis.Sarif.Cli SarifCli true + false + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + true true @@ -72,6 +87,7 @@ + True @@ -80,6 +96,7 @@ + @@ -109,5 +126,17 @@ RuleResources.Designer.cs + + + False + Microsoft .NET Framework 4.5.1 %28x86 and x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + \ No newline at end of file diff --git a/src/SarifCli/SarifPropertyName.cs b/src/SarifCli/SarifPropertyName.cs index 21e1c53e7..99921ee6c 100644 --- a/src/SarifCli/SarifPropertyName.cs +++ b/src/SarifCli/SarifPropertyName.cs @@ -12,6 +12,7 @@ public static class SarifPropertyName public const string Files = "files"; public const string Fixes = "fixes"; public const string Frames = "frames"; + public const string Id = "id"; public const string Locations = "locations"; public const string PhysicalLocation = "physicalLocation"; public const string RelatedLocations = "relatedLocations"; From 6a77b70c4713ede94d17988d69cf6a063aba18f1 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Fri, 26 Aug 2016 16:26:14 -0700 Subject: [PATCH 31/51] SarifCli: Implement HashAlgorithmsMustBeUnique rule Also: * Remove "FormatId" suffix from the names of all formatId resource identifiers. --- .../Rules/HashAlgorithmsMustBeUniqueTests.cs | 23 +++++ .../SarifCli.FunctionalTests.csproj | 13 +++ ...CodeLocationHasIdInCodeFlow_Expected.sarif | 4 +- ...ationHasIdInRelatedLocation_Expected.sarif | 4 +- .../RuleIdMatchesFriendlyName_Expected.sarif | 2 +- .../NonUniqueHashAlgorithms.sarif | 44 ++++++++++ .../NonUniqueHashAlgorithms_Expected.sarif | 84 +++++++++++++++++++ .../UniqueHashAlgorithms.sarif | 44 ++++++++++ .../UniqueHashAlgorithms_Expected.sarif | 46 ++++++++++ .../InvalidHelpUriInRule_Expected.sarif | 2 +- .../InvalidUriInAnalysisTarget_Expected.sarif | 2 +- ...nvalidUriInCodeFlowLocation_Expected.sarif | 2 +- ...InConfigurationNotification_Expected.sarif | 2 +- .../InvalidUriInFileChange_Expected.sarif | 2 +- ...nvalidUriInFilePropertyName_Expected.sarif | 2 +- ...InvalidUriInRelatedLocation_Expected.sarif | 2 +- .../InvalidUriInResultFile_Expected.sarif | 2 +- .../InvalidUriInStackFrame_Expected.sarif | 2 +- ...nvalidUriInToolNotification_Expected.sarif | 2 +- ...RelativeInAnalysisTargetUri_Expected.sarif | 2 +- ...lativeInCodeFlowLocationUri_Expected.sarif | 2 +- ...onfigurationNotificationUri_Expected.sarif | 2 +- ...ntIsRelativeInFileChangeUri_Expected.sarif | 2 +- ...sRelativeInFilePropertyName_Expected.sarif | 2 +- ...elativeInRelatedLocationUri_Expected.sarif | 2 +- ...ntIsRelativeInResultFileUri_Expected.sarif | 2 +- ...ntIsRelativeInStackFrameUri_Expected.sarif | 2 +- ...lativeInToolNotificationUri_Expected.sarif | 2 +- .../AnnotatedCodeLocationIdIsObsolete.cs | 8 +- .../Rules/DoNotUseFriendlyNameAsRuleId.cs | 4 +- .../Rules/HashAlgorithmsMustBeUnique.cs | 50 +++++++++++ src/SarifCli/Rules/RuleId.cs | 1 + src/SarifCli/Rules/RuleResources.Designer.cs | 38 ++++++--- src/SarifCli/Rules/RuleResources.resx | 16 ++-- src/SarifCli/Rules/UrisMustBeValid.cs | 6 +- ...eAbsolutePathsForNestedFileUriFragments.cs | 6 +- src/SarifCli/SarifCli.csproj | 1 + src/SarifCli/SarifPropertyName.cs | 1 + 38 files changed, 382 insertions(+), 51 deletions(-) create mode 100644 src/SarifCli.FunctionalTests/Rules/HashAlgorithmsMustBeUniqueTests.cs create mode 100644 src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/NonUniqueHashAlgorithms.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/NonUniqueHashAlgorithms_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/UniqueHashAlgorithms.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/UniqueHashAlgorithms_Expected.sarif create mode 100644 src/SarifCli/Rules/HashAlgorithmsMustBeUnique.cs diff --git a/src/SarifCli.FunctionalTests/Rules/HashAlgorithmsMustBeUniqueTests.cs b/src/SarifCli.FunctionalTests/Rules/HashAlgorithmsMustBeUniqueTests.cs new file mode 100644 index 000000000..26b411e5c --- /dev/null +++ b/src/SarifCli.FunctionalTests/Rules/HashAlgorithmsMustBeUniqueTests.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.CodeAnalysis.Sarif.Cli.Rules; +using Xunit; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules +{ + public class HashAlgorithmsMustBeUniqueTests : SkimmerTestsBase + { + [Fact] + public void HashAlgorithmsMustBeUnique_NoDiagnostic_UniqueHashAlgorithms() + { + Verify(new HashAlgorithmsMustBeUnique(), "UniqueHashAlgorithms.sarif"); + } + + [Fact] + public void HashAlgorithmsMustBeUnique_Diagnostic_NonUniqueHashAlgorithms() + { + Verify(new HashAlgorithmsMustBeUnique(), "NonUniqueHashAlgorithms.sarif"); + } + } +} diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj index fd18828cc..de93c791c 100644 --- a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -66,6 +66,7 @@ + @@ -111,6 +112,18 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInCodeFlow_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInCodeFlow_Expected.sarif index 4d44ca5ef..d9269a456 100644 --- a/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInCodeFlow_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInCodeFlow_Expected.sarif @@ -59,8 +59,8 @@ "shortDescription": "Do not use the property annotatedCodeLocation.", "fullDescription": "Do not use the property annotatedCodeLocation.id, which is obsolete. Instead use annotatedCodeLocation.step, which is an integer-valued property that is 1 for the first annotatedCodeLocation in a codeFlow, and increments by 1 for every subsequent step.", "messageFormats": { - "DefaultFormatId": "In \"{0}\", at \"{1}\", the obsolete annotatedCodeLocation.id property is used. Remove it, and instead use the step property, whose value is an integer which is 1 for the first location in a code flow, and increments by 1 for each subsequent location in the code flow.", - "OnlyInCodeFlowFormatId": "In \"{0}\", at \"{1}\", the obsolete annotatedCodeLocation.id property is used. This property has been replaced by the step property, but the step property is used only in annotatedCodeLocations objects that occur within a code flow. Remove the id property." + "Default": "In \"{0}\", at \"{1}\", the obsolete annotatedCodeLocation.id property is used. Remove it, and instead use the step property, whose value is an integer which is 1 for the first location in a code flow, and increments by 1 for each subsequent location in the code flow.", + "OnlyInCodeFlow": "In \"{0}\", at \"{1}\", the obsolete annotatedCodeLocation.id property is used. This property has been replaced by the step property, but the step property is used only in annotatedCodeLocations objects that occur within a code flow. Remove the id property." }, "defaultLevel": "warning", "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" diff --git a/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInRelatedLocation_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInRelatedLocation_Expected.sarif index cb7ead36c..c8f9cdd09 100644 --- a/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInRelatedLocation_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationIdIsObsolete/AnnotatedCodeLocationHasIdInRelatedLocation_Expected.sarif @@ -59,8 +59,8 @@ "shortDescription": "Do not use the property annotatedCodeLocation.", "fullDescription": "Do not use the property annotatedCodeLocation.id, which is obsolete. Instead use annotatedCodeLocation.step, which is an integer-valued property that is 1 for the first annotatedCodeLocation in a codeFlow, and increments by 1 for every subsequent step.", "messageFormats": { - "DefaultFormatId": "In \"{0}\", at \"{1}\", the obsolete annotatedCodeLocation.id property is used. Remove it, and instead use the step property, whose value is an integer which is 1 for the first location in a code flow, and increments by 1 for each subsequent location in the code flow.", - "OnlyInCodeFlowFormatId": "In \"{0}\", at \"{1}\", the obsolete annotatedCodeLocation.id property is used. This property has been replaced by the step property, but the step property is used only in annotatedCodeLocations objects that occur within a code flow. Remove the id property." + "Default": "In \"{0}\", at \"{1}\", the obsolete annotatedCodeLocation.id property is used. Remove it, and instead use the step property, whose value is an integer which is 1 for the first location in a code flow, and increments by 1 for each subsequent location in the code flow.", + "OnlyInCodeFlow": "In \"{0}\", at \"{1}\", the obsolete annotatedCodeLocation.id property is used. This property has been replaced by the step property, but the step property is used only in annotatedCodeLocations objects that occur within a code flow. Remove the id property." }, "defaultLevel": "warning", "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" diff --git a/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdMatchesFriendlyName_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdMatchesFriendlyName_Expected.sarif index 35d85bcd8..2f2eb2745 100644 --- a/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdMatchesFriendlyName_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/RuleIdMatchesFriendlyName_Expected.sarif @@ -60,7 +60,7 @@ "shortDescription": "Do not use the same string for a rule's id and name properties. The id property ...", "fullDescription": "Do not use the same string for a rule's id and name properties. The id property must be a stable, opaque identifer such as \"SV0001\". The name property should be a string that is understandable to an end user, such as \"DoNotUserFriendlyNameAsRuleId\".", "messageFormats": { - "DefaultFormatId": "In \"{0}\", at \"{1}\", the name and id properties of rule \"{2}\" are the same." + "Default": "In \"{0}\", at \"{1}\", the name and id properties of rule \"{2}\" are the same." }, "defaultLevel": "warning", "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" diff --git a/src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/NonUniqueHashAlgorithms.sarif b/src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/NonUniqueHashAlgorithms.sarif new file mode 100644 index 000000000..dcb71d3da --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/NonUniqueHashAlgorithms.sarif @@ -0,0 +1,44 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ] + } + ], + "files": { + "file:///c:/src/file.c": { + "hashes": [ + { + "algorithm": "sha256", + "value": "b13ce2678a8807ba0765ab94a0ecd394f869bc81" + }, + { + "algorithm": "sha256", + "value": "8a8807ba0765ab94a0ecd394f869bc81b13ce267" + } + ] + } + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/NonUniqueHashAlgorithms_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/NonUniqueHashAlgorithms_Expected.sarif new file mode 100644 index 000000000..82bc8b7aa --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/NonUniqueHashAlgorithms_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "df8b548d-4333-47ba-af26-ad35e8b83016", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0005", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "NonUniqueHashAlgorithms.sarif", + "/runs/0/files/file:~1~1~1c:~1src~1file.c/hashes", + "Sha256" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/NonUniqueHashAlgorithms.sarif", + "region": { + "startLine": 30, + "startColumn": 22 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/NonUniqueHashAlgorithms.sarif" + }, + "message": "Analyzing 'NonUniqueHashAlgorithms.sarif'...", + "level": "note", + "time": "2016-08-26T23:19:47.392Z" + } + ], + "rules": { + "SV0005": { + "id": "SV0005", + "name": "HashAlgorithmsMustBeUnique", + "shortDescription": "In any given \"file\" object, every element of the \"hashes\" array must have a different value for its \"algorithm\" property.", + "fullDescription": "In any given \"file\" object, every element of the \"hashes\" array must have a different value for its \"algorithm\" property. ", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the array contains multiple objects with the value \"{2}\" for the algorithm property." + }, + "defaultLevel": "error", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/NonUniqueHashAlgorithms.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\HashAlgorithmsMustBeUnique\\NonUniqueHashAlgorithms.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\NonUniqueHashAlgorithms_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-26T23:19:47.220Z", + "endTime": "2016-08-26T23:19:47.658Z", + "processId": 8552, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/UniqueHashAlgorithms.sarif b/src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/UniqueHashAlgorithms.sarif new file mode 100644 index 000000000..0eb19cab3 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/UniqueHashAlgorithms.sarif @@ -0,0 +1,44 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ] + } + ], + "files": { + "file:///c:/src/file.c": { + "hashes": [ + { + "algorithm": "sha256", + "value": "b13ce2678a8807ba0765ab94a0ecd394f869bc81" + }, + { + "algorithm": "sha1", + "value": "8a8807ba0765ab94a0ecd394f869bc81b13ce267" + } + ] + } + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/UniqueHashAlgorithms_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/UniqueHashAlgorithms_Expected.sarif new file mode 100644 index 000000000..b395570d8 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/UniqueHashAlgorithms_Expected.sarif @@ -0,0 +1,46 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "f5936d09-1147-487f-a44f-8cc4c4e6aa0c", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/UniqueHashAlgorithms.sarif" + }, + "message": "Analyzing 'UniqueHashAlgorithms.sarif'...", + "level": "note", + "time": "2016-08-26T23:21:00.776Z" + } + ], + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/UniqueHashAlgorithms.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\HashAlgorithmsMustBeUnique\\UniqueHashAlgorithms.sarif -o C:\\Users\\[REMOVED]\\Desktop\\SarifCli\\UniqueHashAlgorithms_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-26T23:21:00.682Z", + "endTime": "2016-08-26T23:21:01.011Z", + "processId": 17508, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidHelpUriInRule_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidHelpUriInRule_Expected.sarif index 352a197bd..b8e43fea8 100644 --- a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidHelpUriInRule_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidHelpUriInRule_Expected.sarif @@ -22,7 +22,7 @@ "ruleId": "SV0003", "level": "error", "formattedRuleMessage": { - "formatId": "DefaultFormatId", + "formatId": "Default", "arguments": [ "InvalidHelpUriInRule.sarif", "/runs/0/rules/TST0001/helpUri", diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInAnalysisTarget_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInAnalysisTarget_Expected.sarif index 778c8de47..d612a82e6 100644 --- a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInAnalysisTarget_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInAnalysisTarget_Expected.sarif @@ -22,7 +22,7 @@ "ruleId": "SV0003", "level": "error", "formattedRuleMessage": { - "formatId": "DefaultFormatId", + "formatId": "Default", "arguments": [ "InvalidUriInAnalysisTarget.sarif", "/runs/0/results/0/locations/0/analysisTarget/uri", diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInCodeFlowLocation_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInCodeFlowLocation_Expected.sarif index 8f00e2143..1ef6c9942 100644 --- a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInCodeFlowLocation_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInCodeFlowLocation_Expected.sarif @@ -22,7 +22,7 @@ "ruleId": "SV0003", "level": "error", "formattedRuleMessage": { - "formatId": "DefaultFormatId", + "formatId": "Default", "arguments": [ "InvalidUriInCodeFlowLocation.sarif", "/runs/0/results/0/codeFlows/0/locations/0/physicalLocation/uri", diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInConfigurationNotification_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInConfigurationNotification_Expected.sarif index 5ab0ca98c..3966c5ae6 100644 --- a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInConfigurationNotification_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInConfigurationNotification_Expected.sarif @@ -22,7 +22,7 @@ "ruleId": "SV0003", "level": "error", "formattedRuleMessage": { - "formatId": "DefaultFormatId", + "formatId": "Default", "arguments": [ "InvalidUriInConfigurationNotification.sarif", "/runs/0/configurationNotifications/0/physicalLocation/uri", diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFileChange_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFileChange_Expected.sarif index 821dfe5bf..13b3d314c 100644 --- a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFileChange_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFileChange_Expected.sarif @@ -22,7 +22,7 @@ "ruleId": "SV0003", "level": "error", "formattedRuleMessage": { - "formatId": "DefaultFormatId", + "formatId": "Default", "arguments": [ "InvalidUriInFileChange.sarif", "/runs/0/results/0/fixes/0/fileChanges/0/uri", diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFilePropertyName_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFilePropertyName_Expected.sarif index a436ce318..bd2cd12e3 100644 --- a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFilePropertyName_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInFilePropertyName_Expected.sarif @@ -22,7 +22,7 @@ "ruleId": "SV0003", "level": "error", "formattedRuleMessage": { - "formatId": "DefaultFormatId", + "formatId": "Default", "arguments": [ "InvalidUriInFilePropertyName.sarif", "/runs/0/files/fi%le:~1~1~1c:~1src~1file.c", diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInRelatedLocation_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInRelatedLocation_Expected.sarif index f38023d90..cf90ae6df 100644 --- a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInRelatedLocation_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInRelatedLocation_Expected.sarif @@ -22,7 +22,7 @@ "ruleId": "SV0003", "level": "error", "formattedRuleMessage": { - "formatId": "DefaultFormatId", + "formatId": "Default", "arguments": [ "InvalidUriInRelatedLocation.sarif", "/runs/0/results/0/relatedLocations/0/physicalLocation/uri", diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInResultFile_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInResultFile_Expected.sarif index 6d6e2b54d..02c7bc110 100644 --- a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInResultFile_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInResultFile_Expected.sarif @@ -22,7 +22,7 @@ "ruleId": "SV0003", "level": "error", "formattedRuleMessage": { - "formatId": "DefaultFormatId", + "formatId": "Default", "arguments": [ "InvalidUriInResultFile.sarif", "/runs/0/results/0/locations/0/resultFile/uri", diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInStackFrame_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInStackFrame_Expected.sarif index b0fa460b8..b2739b257 100644 --- a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInStackFrame_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInStackFrame_Expected.sarif @@ -22,7 +22,7 @@ "ruleId": "SV0003", "level": "error", "formattedRuleMessage": { - "formatId": "DefaultFormatId", + "formatId": "Default", "arguments": [ "InvalidUriInStackFrame.sarif", "/runs/0/results/0/stacks/0/frames/0/uri", diff --git a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInToolNotification_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInToolNotification_Expected.sarif index 83939aa3e..3109dd248 100644 --- a/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInToolNotification_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UrisMustBeValid/InvalidUriInToolNotification_Expected.sarif @@ -22,7 +22,7 @@ "ruleId": "SV0003", "level": "error", "formattedRuleMessage": { - "formatId": "DefaultFormatId", + "formatId": "Default", "arguments": [ "InvalidUriInToolNotification.sarif", "/runs/0/toolNotifications/0/physicalLocation/uri", diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri_Expected.sarif index 89867aa12..f7041def7 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInAnalysisTargetUri_Expected.sarif @@ -22,7 +22,7 @@ "ruleId": "SV0002", "level": "error", "formattedRuleMessage": { - "formatId": "DefaultFormatId", + "formatId": "Default", "arguments": [ "NestedFileUriFragmentIsRelativeInAnalysisTargetUri.sarif", "/runs/0/results/0/locations/0/analysisTarget/uri", diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri_Expected.sarif index 600860839..f003af1c3 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInCodeFlowLocationUri_Expected.sarif @@ -22,7 +22,7 @@ "ruleId": "SV0002", "level": "error", "formattedRuleMessage": { - "formatId": "DefaultFormatId", + "formatId": "Default", "arguments": [ "NestedFileUriFragmentIsRelativeInCodeFlowLocationUri.sarif", "/runs/0/results/0/codeFlows/0/locations/0/physicalLocation/uri", diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInConfigurationNotificationUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInConfigurationNotificationUri_Expected.sarif index f47a5a9fd..13094df50 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInConfigurationNotificationUri_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInConfigurationNotificationUri_Expected.sarif @@ -22,7 +22,7 @@ "ruleId": "SV0002", "level": "error", "formattedRuleMessage": { - "formatId": "DefaultFormatId", + "formatId": "Default", "arguments": [ "NestedFileUriFragmentIsRelativeInConfigurationNotificationUri.sarif", "/runs/0/configurationNotifications/0/physicalLocation/uri", diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFileChangeUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFileChangeUri_Expected.sarif index 55c3cd0b7..ddbe41640 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFileChangeUri_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFileChangeUri_Expected.sarif @@ -22,7 +22,7 @@ "ruleId": "SV0002", "level": "error", "formattedRuleMessage": { - "formatId": "DefaultFormatId", + "formatId": "Default", "arguments": [ "NestedFileUriFragmentIsRelativeInFileChangeUri.sarif", "/runs/0/results/0/fixes/0/fileChanges/0/uri", diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName_Expected.sarif index a3b886eb5..64ee35e0e 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInFilePropertyName_Expected.sarif @@ -22,7 +22,7 @@ "ruleId": "SV0002", "level": "error", "formattedRuleMessage": { - "formatId": "DefaultFormatId", + "formatId": "Default", "arguments": [ "NestedFileUriFragmentIsRelativeInFilePropertyName.sarif", "/runs/0/files/file:~1~1~1c:~1bin~1myApp.appx#js~1minified.js", diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri_Expected.sarif index 6fbe51494..8f97bb858 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInRelatedLocationUri_Expected.sarif @@ -22,7 +22,7 @@ "ruleId": "SV0002", "level": "error", "formattedRuleMessage": { - "formatId": "DefaultFormatId", + "formatId": "Default", "arguments": [ "NestedFileUriFragmentIsRelativeInRelatedLocationUri.sarif", "/runs/0/results/0/relatedLocations/0/physicalLocation/uri", diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri_Expected.sarif index c54b47fc0..b5e0540c5 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInResultFileUri_Expected.sarif @@ -22,7 +22,7 @@ "ruleId": "SV0002", "level": "error", "formattedRuleMessage": { - "formatId": "DefaultFormatId", + "formatId": "Default", "arguments": [ "NestedFileUriFragmentIsRelativeInResultFileUri.sarif", "/runs/0/results/0/locations/0/resultFile/uri", diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri_Expected.sarif index 96a26ec01..be8410ec7 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInStackFrameUri_Expected.sarif @@ -22,7 +22,7 @@ "ruleId": "SV0002", "level": "error", "formattedRuleMessage": { - "formatId": "DefaultFormatId", + "formatId": "Default", "arguments": [ "NestedFileUriFragmentIsRelativeInStackFrameUri.sarif", "/runs/0/results/0/stacks/0/frames/0/uri", diff --git a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInToolNotificationUri_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInToolNotificationUri_Expected.sarif index 5abd38025..6c456c5c3 100644 --- a/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInToolNotificationUri_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/UseAbsolutePathsForNestedFileUriFragments/NestedFileUriFragmentIsRelativeInToolNotificationUri_Expected.sarif @@ -22,7 +22,7 @@ "ruleId": "SV0002", "level": "error", "formattedRuleMessage": { - "formatId": "DefaultFormatId", + "formatId": "Default", "arguments": [ "NestedFileUriFragmentIsRelativeInToolNotificationUri.sarif", "/runs/0/toolNotifications/0/physicalLocation/uri", diff --git a/src/SarifCli/Rules/AnnotatedCodeLocationIdIsObsolete.cs b/src/SarifCli/Rules/AnnotatedCodeLocationIdIsObsolete.cs index f511e1872..ef2661897 100644 --- a/src/SarifCli/Rules/AnnotatedCodeLocationIdIsObsolete.cs +++ b/src/SarifCli/Rules/AnnotatedCodeLocationIdIsObsolete.cs @@ -22,8 +22,8 @@ protected override IEnumerable FormatIds { return new string[] { - nameof(RuleResources.SV0004_DefaultFormatId), - nameof(RuleResources.SV0004_OnlyInCodeFlowFormatId) + nameof(RuleResources.SV0004_Default), + nameof(RuleResources.SV0004_OnlyInCodeFlow) }; } } @@ -38,8 +38,8 @@ protected override void Analyze(AnnotatedCodeLocation annotatedCodeLocation, str // occurs in a codeFlow, because the "step" property is only meaningful within // a codeFlow. string formatId = annotatedCodeLocationPointer.Contains(SarifPropertyName.CodeFlows) - ? nameof(RuleResources.SV0004_DefaultFormatId) - : nameof(RuleResources.SV0004_OnlyInCodeFlowFormatId); + ? nameof(RuleResources.SV0004_Default) + : nameof(RuleResources.SV0004_OnlyInCodeFlow); LogResult(idPointer, formatId); } diff --git a/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs b/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs index 22b36dfe0..c2c5cbbc2 100644 --- a/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs +++ b/src/SarifCli/Rules/DoNotUseFriendlyNameAsRuleId.cs @@ -23,7 +23,7 @@ protected override IEnumerable FormatIds { return new string[] { - nameof(RuleResources.SV0001_DefaultFormatId) + nameof(RuleResources.SV0001_Default) }; } } @@ -36,7 +36,7 @@ protected override void Analyze(Rule rule, string rulePointer) { LogResult( rulePointer, - nameof(RuleResources.SV0001_DefaultFormatId), + nameof(RuleResources.SV0001_Default), rule.Id); } } diff --git a/src/SarifCli/Rules/HashAlgorithmsMustBeUnique.cs b/src/SarifCli/Rules/HashAlgorithmsMustBeUnique.cs new file mode 100644 index 000000000..63293cb16 --- /dev/null +++ b/src/SarifCli/Rules/HashAlgorithmsMustBeUnique.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Collections.Generic; +using System.Linq; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules +{ + public class HashAlgorithmsMustBeUnique : SarifValidationSkimmerBase + { + public override string FullDescription => RuleResources.SV0005_HashAlgorithmsMustBeUnique; + + public override ResultLevel DefaultLevel => ResultLevel.Error; + + /// + /// SV0005 + /// + public override string Id => RuleId.HashAlgorithmsMustBeUnique; + + protected override IEnumerable FormatIds + { + get + { + return new string[] + { + nameof(RuleResources.SV0005_Default) + }; + } + } + + protected override void Analyze(FileData fileData, string fileKey, string filePointer) + { + if (fileData.Hashes != null) + { + foreach (AlgorithmKind algorithmKind in fileData.Hashes.Select(h => h.Algorithm).Distinct()) + { + if (fileData.Hashes.Count(h => h.Algorithm == algorithmKind) > 1) + { + string hashesPointer = filePointer.AtProperty(SarifPropertyName.Hashes); + + LogResult( + hashesPointer, + nameof(RuleResources.SV0005_Default), + algorithmKind.ToString()); + } + } + } + } + } +} diff --git a/src/SarifCli/Rules/RuleId.cs b/src/SarifCli/Rules/RuleId.cs index 2f84ed4da..c018c54db 100644 --- a/src/SarifCli/Rules/RuleId.cs +++ b/src/SarifCli/Rules/RuleId.cs @@ -9,5 +9,6 @@ public static class RuleId public const string UseAbsolutePathsForNestedFileUriFragments = "SV0002"; public const string UrisMustBeValid = "SV0003"; public const string AnnotatedCodeLocationIdIsObsolete = "SV0004"; + public const string HashAlgorithmsMustBeUnique = "SV0005"; } } diff --git a/src/SarifCli/Rules/RuleResources.Designer.cs b/src/SarifCli/Rules/RuleResources.Designer.cs index ff0d576b8..e22e1f1f4 100644 --- a/src/SarifCli/Rules/RuleResources.Designer.cs +++ b/src/SarifCli/Rules/RuleResources.Designer.cs @@ -63,9 +63,9 @@ internal RuleResources() { /// /// Looks up a localized string similar to In "{0}", at "{1}", the name and id properties of rule "{2}" are the same.. /// - internal static string SV0001_DefaultFormatId { + internal static string SV0001_Default { get { - return ResourceManager.GetString("SV0001_DefaultFormatId", resourceCulture); + return ResourceManager.GetString("SV0001_Default", resourceCulture); } } @@ -81,9 +81,9 @@ internal static string SV0001_DoNotUseFriendlyNameAsRuleIdDescription { /// /// Looks up a localized string similar to In "{0}", at "{1}", the fragment portion of the URI "{2}", which specifies the location of a nested file with respect to its parent, does not begin with a forward slash.. /// - internal static string SV0002_DefaultFormatId { + internal static string SV0002_Default { get { - return ResourceManager.GetString("SV0002_DefaultFormatId", resourceCulture); + return ResourceManager.GetString("SV0002_Default", resourceCulture); } } @@ -99,9 +99,9 @@ internal static string SV0002_UseAbsolutePathsForNestedFileUriFragmentsDescripti /// /// Looks up a localized string similar to In "{0}", at "{1}", the string "{2}" is not a valid URI reference.. /// - internal static string SV0003_DefaultFormatId { + internal static string SV0003_Default { get { - return ResourceManager.GetString("SV0003_DefaultFormatId", resourceCulture); + return ResourceManager.GetString("SV0003_Default", resourceCulture); } } @@ -126,18 +126,36 @@ internal static string SV0004_AnnotatedCodeLocationIdIsObsolete { /// /// Looks up a localized string similar to In "{0}", at "{1}", the obsolete annotatedCodeLocation.id property is used. Remove it, and instead use the step property, whose value is an integer which is 1 for the first location in a code flow, and increments by 1 for each subsequent location in the code flow.. /// - internal static string SV0004_DefaultFormatId { + internal static string SV0004_Default { get { - return ResourceManager.GetString("SV0004_DefaultFormatId", resourceCulture); + return ResourceManager.GetString("SV0004_Default", resourceCulture); } } /// /// Looks up a localized string similar to In "{0}", at "{1}", the obsolete annotatedCodeLocation.id property is used. This property has been replaced by the step property, but the step property is used only in annotatedCodeLocations objects that occur within a code flow. Remove the id property.. /// - internal static string SV0004_OnlyInCodeFlowFormatId { + internal static string SV0004_OnlyInCodeFlow { get { - return ResourceManager.GetString("SV0004_OnlyInCodeFlowFormatId", resourceCulture); + return ResourceManager.GetString("SV0004_OnlyInCodeFlow", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to In "{0}", at "{1}", the array contains multiple objects with the value "{2}" for the algorithm property.. + /// + internal static string SV0005_Default { + get { + return ResourceManager.GetString("SV0005_Default", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to In any given "file" object, every element of the "hashes" array must have a different value for its "algorithm" property. . + /// + internal static string SV0005_HashAlgorithmsMustBeUnique { + get { + return ResourceManager.GetString("SV0005_HashAlgorithmsMustBeUnique", resourceCulture); } } } diff --git a/src/SarifCli/Rules/RuleResources.resx b/src/SarifCli/Rules/RuleResources.resx index d188df44c..139756487 100644 --- a/src/SarifCli/Rules/RuleResources.resx +++ b/src/SarifCli/Rules/RuleResources.resx @@ -117,19 +117,19 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + In "{0}", at "{1}", the name and id properties of rule "{2}" are the same. Do not use the same string for a rule's id and name properties. The id property must be a stable, opaque identifer such as "SV0001". The name property should be a string that is understandable to an end user, such as "DoNotUserFriendlyNameAsRuleId". - + In "{0}", at "{1}", the fragment portion of the URI "{2}", which specifies the location of a nested file with respect to its parent, does not begin with a forward slash. When specifying the URI of a nested file with a URI fragment, express the fragment as an absolute path. That is, begin the with a forward slash, for example "file:///C:/bin/MyApp.zip#/images/grape.jpg". - + In "{0}", at "{1}", the string "{2}" is not a valid URI reference. @@ -138,10 +138,16 @@ Do not use the property annotatedCodeLocation.id, which is obsolete. Instead use annotatedCodeLocation.step, which is an integer-valued property that is 1 for the first annotatedCodeLocation in a codeFlow, and increments by 1 for every subsequent step. - + In "{0}", at "{1}", the obsolete annotatedCodeLocation.id property is used. Remove it, and instead use the step property, whose value is an integer which is 1 for the first location in a code flow, and increments by 1 for each subsequent location in the code flow. - + In "{0}", at "{1}", the obsolete annotatedCodeLocation.id property is used. This property has been replaced by the step property, but the step property is used only in annotatedCodeLocations objects that occur within a code flow. Remove the id property. + + In "{0}", at "{1}", the array contains multiple objects with the value "{2}" for the algorithm property. + + + In any given "file" object, every element of the "hashes" array must have a different value for its "algorithm" property. + \ No newline at end of file diff --git a/src/SarifCli/Rules/UrisMustBeValid.cs b/src/SarifCli/Rules/UrisMustBeValid.cs index e8a9431b7..4da5bdd37 100644 --- a/src/SarifCli/Rules/UrisMustBeValid.cs +++ b/src/SarifCli/Rules/UrisMustBeValid.cs @@ -23,7 +23,7 @@ protected override IEnumerable FormatIds { return new string[] { - nameof(RuleResources.SV0003_DefaultFormatId) + nameof(RuleResources.SV0003_Default) }; } } @@ -49,7 +49,7 @@ protected override void Analyze(FileData fileData, string fileKey, string filePo { LogResult( filePointer, - nameof(RuleResources.SV0003_DefaultFormatId), + nameof(RuleResources.SV0003_Default), fileUriReference); } @@ -89,7 +89,7 @@ private void AnalyzeUri( LogResult( uriPointer, - nameof(RuleResources.SV0003_DefaultFormatId), + nameof(RuleResources.SV0003_Default), uri.OriginalString); } } diff --git a/src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs b/src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs index b15e3d563..a0c4408b4 100644 --- a/src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs +++ b/src/SarifCli/Rules/UseAbsolutePathsForNestedFileUriFragments.cs @@ -23,7 +23,7 @@ protected override IEnumerable FormatIds { return new string[] { - nameof(RuleResources.SV0002_DefaultFormatId) + nameof(RuleResources.SV0002_Default) }; } } @@ -42,7 +42,7 @@ protected override void Analyze(FileData fileData, string fileKey, string filePo { LogResult( filePointer, - nameof(RuleResources.SV0002_DefaultFormatId), + nameof(RuleResources.SV0002_Default), fileUri.OriginalString); } } @@ -72,7 +72,7 @@ private void AnalyzeUri(Uri uri, string parentPointer) LogResult( uriPointer, - nameof(RuleResources.SV0002_DefaultFormatId), + nameof(RuleResources.SV0002_Default), uri.OriginalString); } } diff --git a/src/SarifCli/SarifCli.csproj b/src/SarifCli/SarifCli.csproj index b9323058d..57b1f0306 100644 --- a/src/SarifCli/SarifCli.csproj +++ b/src/SarifCli/SarifCli.csproj @@ -89,6 +89,7 @@ + True True diff --git a/src/SarifCli/SarifPropertyName.cs b/src/SarifCli/SarifPropertyName.cs index 99921ee6c..e5eb603da 100644 --- a/src/SarifCli/SarifPropertyName.cs +++ b/src/SarifCli/SarifPropertyName.cs @@ -12,6 +12,7 @@ public static class SarifPropertyName public const string Files = "files"; public const string Fixes = "fixes"; public const string Frames = "frames"; + public const string Hashes = "hashes"; public const string Id = "id"; public const string Locations = "locations"; public const string PhysicalLocation = "physicalLocation"; From 714ef3abb54a625114df75975478c5b3698e137c Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Fri, 26 Aug 2016 17:00:40 -0700 Subject: [PATCH 32/51] SarifCli: Implement EndTimeMustBeAfterStartTime --- .../Rules/EndTimeMustBeAfterStartTimeTests.cs | 29 +++++++ .../SarifCli.FunctionalTests.csproj | 19 +++++ .../EndTimeEqualsStartTime.sarif | 17 ++++ .../EndTimeEqualsStartTime_Expected.sarif | 46 ++++++++++ .../EndTimeIsAfterStartTime.sarif | 17 ++++ .../EndTimeIsAfterStartTime_Expected.sarif | 46 ++++++++++ .../EndTimeIsBeforeStartTime.sarif | 17 ++++ .../EndTimeIsBeforeStartTime_Expected.sarif | 85 +++++++++++++++++++ .../Rules/EndTimeMustBeAfterStartTime.cs | 53 ++++++++++++ src/SarifCli/Rules/RuleId.cs | 1 + src/SarifCli/Rules/RuleResources.Designer.cs | 18 ++++ src/SarifCli/Rules/RuleResources.resx | 6 ++ .../Rules/SarifValidationSkimmerBase.cs | 16 ++++ src/SarifCli/SarifCli.csproj | 1 + src/SarifCli/SarifPropertyName.cs | 2 + 15 files changed, 373 insertions(+) create mode 100644 src/SarifCli.FunctionalTests/Rules/EndTimeMustBeAfterStartTimeTests.cs create mode 100644 src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeEqualsStartTime.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeEqualsStartTime_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsAfterStartTime.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsAfterStartTime_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsBeforeStartTime.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsBeforeStartTime_Expected.sarif create mode 100644 src/SarifCli/Rules/EndTimeMustBeAfterStartTime.cs diff --git a/src/SarifCli.FunctionalTests/Rules/EndTimeMustBeAfterStartTimeTests.cs b/src/SarifCli.FunctionalTests/Rules/EndTimeMustBeAfterStartTimeTests.cs new file mode 100644 index 000000000..441520db4 --- /dev/null +++ b/src/SarifCli.FunctionalTests/Rules/EndTimeMustBeAfterStartTimeTests.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.CodeAnalysis.Sarif.Cli.Rules; +using Xunit; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules +{ + public class EndTimeMustBeAfterStartTimeTests : SkimmerTestsBase + { + [Fact] + public void EndTimeMustBeAfterStartTime_NoDiagnostic_EndTimeIsAfterStartTime() + { + Verify(new EndTimeMustBeAfterStartTime(), "EndTimeIsAfterStartTime.sarif"); + } + + [Fact] + public void EndTimeMustBeAfterStartTime_Diagnostic_EndTimeEqualsStartTime() + { + Verify(new EndTimeMustBeAfterStartTime(), "EndTimeEqualsStartTime.sarif"); + } + + [Fact] + public void EndTimeMustBeAfterStartTime_Diagnostic_EndTimeIsBeforeStartTime() + { + Verify(new EndTimeMustBeAfterStartTime(), "EndTimeIsBeforeStartTime.sarif"); + } + } +} diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj index de93c791c..fa0e8f0cc 100644 --- a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -66,6 +66,7 @@ + @@ -112,6 +113,24 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeEqualsStartTime.sarif b/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeEqualsStartTime.sarif new file mode 100644 index 000000000..7a11b875d --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeEqualsStartTime.sarif @@ -0,0 +1,17 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [], + "invocation": { + "commandLine": "CodeScanner.exe *.dll", + "startTime": "2016-08-25T21:26:42.049Z", + "endTime": "2016-08-25T21:26:42.049Z" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeEqualsStartTime_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeEqualsStartTime_Expected.sarif new file mode 100644 index 000000000..44b576d15 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeEqualsStartTime_Expected.sarif @@ -0,0 +1,46 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "73efc698-2c45-4d59-b871-ab73f35cae0e", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeEqualsStartTime.sarif" + }, + "message": "Analyzing 'EndTimeEqualsStartTime.sarif'...", + "level": "note", + "time": "2016-08-26T23:57:20.601Z" + } + ], + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeEqualsStartTime.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndTimeMustBeAfterStartTime\\EndTimeEqualsStartTime.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndTimeMustBeAfterStartTime\\EndTimeEqualsStartTime_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-26T23:57:20.507Z", + "endTime": "2016-08-26T23:57:20.820Z", + "processId": 11104, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsAfterStartTime.sarif b/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsAfterStartTime.sarif new file mode 100644 index 000000000..d7fb1dba2 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsAfterStartTime.sarif @@ -0,0 +1,17 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [], + "invocation": { + "commandLine": "CodeScanner.exe *.dll", + "startTime": "2016-08-25T21:26:42.049Z", + "endTime": "2016-08-25T21:26:42.051Z" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsAfterStartTime_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsAfterStartTime_Expected.sarif new file mode 100644 index 000000000..56199997a --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsAfterStartTime_Expected.sarif @@ -0,0 +1,46 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "fb405af4-cfb8-4680-9ed7-77646cfdb823", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsAfterStartTime.sarif" + }, + "message": "Analyzing 'EndTimeIsAfterStartTime.sarif'...", + "level": "note", + "time": "2016-08-26T23:56:43.024Z" + } + ], + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsAfterStartTime.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndTimeMustBeAfterStartTime\\EndTimeIsAfterStartTime.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndTimeMustBeAfterStartTime\\EndTimeIsAfterStartTime_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-26T23:56:42.939Z", + "endTime": "2016-08-26T23:56:43.243Z", + "processId": 4852, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsBeforeStartTime.sarif b/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsBeforeStartTime.sarif new file mode 100644 index 000000000..abe506d24 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsBeforeStartTime.sarif @@ -0,0 +1,17 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [], + "invocation": { + "commandLine": "CodeScanner.exe *.dll", + "startTime": "2016-08-25T21:26:42.049Z", + "endTime": "2016-08-25T21:26:41.051Z" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsBeforeStartTime_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsBeforeStartTime_Expected.sarif new file mode 100644 index 000000000..e0052941d --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsBeforeStartTime_Expected.sarif @@ -0,0 +1,85 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "b703b243-53e4-42d4-b07e-c80b7b27ad78", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0006", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "EndTimeIsBeforeStartTime.sarif", + "/runs/0/invocation/endTime", + "2016-08-25T21:26:41.051Z", + "2016-08-25T21:26:42.049Z" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsBeforeStartTime.sarif", + "region": { + "startLine": 13, + "startColumn": 46 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsBeforeStartTime.sarif" + }, + "message": "Analyzing 'EndTimeIsBeforeStartTime.sarif'...", + "level": "note", + "time": "2016-08-26T23:55:39.788Z" + } + ], + "rules": { + "SV0006": { + "id": "SV0006", + "name": "EndTimeMustBeAfterStartTime", + "shortDescription": "The end time of a run must be after the start time.", + "fullDescription": "The end time of a run must be after the start time. To allow for the possibility that the duration of the run is less than the resolution of the string representation of the time, the start time and the end time may be equal.", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the end time \"{2}\" is before the start time \"{3}\"." + }, + "defaultLevel": "error", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsBeforeStartTime.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndTimeMustBeAfterStartTime\\EndTimeIsBeforeStartTime.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndTimeMustBeAfterStartTime\\EndTimeIsBeforeStartTime_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-26T23:55:39.694Z", + "endTime": "2016-08-26T23:55:40.038Z", + "processId": 14564, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli/Rules/EndTimeMustBeAfterStartTime.cs b/src/SarifCli/Rules/EndTimeMustBeAfterStartTime.cs new file mode 100644 index 000000000..9b9fb4184 --- /dev/null +++ b/src/SarifCli/Rules/EndTimeMustBeAfterStartTime.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using System.Globalization; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules +{ + public class EndTimeMustBeAfterStartTime : SarifValidationSkimmerBase + { + public override string FullDescription => RuleResources.SV0006_EndTimeMustBeAfterStartTime; + + public override ResultLevel DefaultLevel => ResultLevel.Error; + + /// + /// SV0006 + /// + public override string Id => RuleId.EndTimeMustBeAfterStartTime; + + protected override IEnumerable FormatIds + { + get + { + return new string[] + { + nameof(RuleResources.SV0006_Default) + }; + } + } + + protected override void Analyze(Invocation invocation, string invocationPointer) + { + if (invocation.StartTime > invocation.EndTime) + { + string endTimePointer = invocationPointer.AtProperty(SarifPropertyName.EndTime); + + LogResult( + endTimePointer, + nameof(RuleResources.SV0006_Default), + FormatDateTime(invocation.EndTime), + FormatDateTime(invocation.StartTime)); + } + } + + private static string FormatDateTime(DateTime dateTime) + { + return dateTime.ToString( + SarifUtilities.SarifDateTimeFormatMillisecondsPrecision, + CultureInfo.InvariantCulture); + } + } +} diff --git a/src/SarifCli/Rules/RuleId.cs b/src/SarifCli/Rules/RuleId.cs index c018c54db..3c7460648 100644 --- a/src/SarifCli/Rules/RuleId.cs +++ b/src/SarifCli/Rules/RuleId.cs @@ -10,5 +10,6 @@ public static class RuleId public const string UrisMustBeValid = "SV0003"; public const string AnnotatedCodeLocationIdIsObsolete = "SV0004"; public const string HashAlgorithmsMustBeUnique = "SV0005"; + public const string EndTimeMustBeAfterStartTime = "SV0006"; } } diff --git a/src/SarifCli/Rules/RuleResources.Designer.cs b/src/SarifCli/Rules/RuleResources.Designer.cs index e22e1f1f4..609ad9f54 100644 --- a/src/SarifCli/Rules/RuleResources.Designer.cs +++ b/src/SarifCli/Rules/RuleResources.Designer.cs @@ -158,5 +158,23 @@ internal static string SV0005_HashAlgorithmsMustBeUnique { return ResourceManager.GetString("SV0005_HashAlgorithmsMustBeUnique", resourceCulture); } } + + /// + /// Looks up a localized string similar to In "{0}", at "{1}", the end time "{2}" is before the start time "{3}".. + /// + internal static string SV0006_Default { + get { + return ResourceManager.GetString("SV0006_Default", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The end time of a run must be after the start time. To allow for the possibility that the duration of the run is less than the resolution of the string representation of the time, the start time and the end time may be equal.. + /// + internal static string SV0006_EndTimeMustBeAfterStartTime { + get { + return ResourceManager.GetString("SV0006_EndTimeMustBeAfterStartTime", resourceCulture); + } + } } } diff --git a/src/SarifCli/Rules/RuleResources.resx b/src/SarifCli/Rules/RuleResources.resx index 139756487..20488c34f 100644 --- a/src/SarifCli/Rules/RuleResources.resx +++ b/src/SarifCli/Rules/RuleResources.resx @@ -150,4 +150,10 @@ In any given "file" object, every element of the "hashes" array must have a different value for its "algorithm" property. + + In "{0}", at "{1}", the end time "{2}" is before the start time "{3}". + + + The end time of a run must be after the start time. To allow for the possibility that the duration of the run is less than the resolution of the string representation of the time, the start time and the end time may be equal. + \ No newline at end of file diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs index 5646d81fd..b2eedc8db 100644 --- a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -118,6 +118,11 @@ private void Visit(FileChange fileChange, string fileChangePointer) Analyze(fileChange, fileChangePointer); } + private void Visit(Invocation invocation, string invocationPointer) + { + Analyze(invocation, invocationPointer); + } + private void Visit(Location location, string locationPointer) { if (location.AnalysisTarget != null) @@ -275,6 +280,13 @@ private void Visit(Run run, string runPointer) { Visit(run.ConfigurationNotifications, runPointer, SarifPropertyName.ConfigurationNotifications); } + + if (run.Invocation != null) + { + string invocationPointer = runPointer.AtProperty(SarifPropertyName.Invocation); + + Visit(run.Invocation, invocationPointer); + } } private void Visit(IList notifications, string parentPointer, string propertyName) @@ -325,6 +337,10 @@ protected virtual void Analyze(FileData fileData, string fileKey, string filePoi { } + protected virtual void Analyze(Invocation invocation, string invocationPointer) + { + } + protected virtual void Analyze(PhysicalLocation physicalLocation, string physicalLocationPointer) { } diff --git a/src/SarifCli/SarifCli.csproj b/src/SarifCli/SarifCli.csproj index 57b1f0306..d75fecd80 100644 --- a/src/SarifCli/SarifCli.csproj +++ b/src/SarifCli/SarifCli.csproj @@ -89,6 +89,7 @@ + True diff --git a/src/SarifCli/SarifPropertyName.cs b/src/SarifCli/SarifPropertyName.cs index e5eb603da..9e44edec7 100644 --- a/src/SarifCli/SarifPropertyName.cs +++ b/src/SarifCli/SarifPropertyName.cs @@ -8,12 +8,14 @@ public static class SarifPropertyName public const string AnalysisTarget = "analysisTarget"; public const string CodeFlows = "codeFlows"; public const string ConfigurationNotifications = "configurationNotifications"; + public const string EndTime = "endTime"; public const string FileChanges = "fileChanges"; public const string Files = "files"; public const string Fixes = "fixes"; public const string Frames = "frames"; public const string Hashes = "hashes"; public const string Id = "id"; + public const string Invocation = "invocation"; public const string Locations = "locations"; public const string PhysicalLocation = "physicalLocation"; public const string RelatedLocations = "relatedLocations"; From 255ad4f55858d3756f13fe4b662af1fa7f04b0eb Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Fri, 26 Aug 2016 17:10:28 -0700 Subject: [PATCH 33/51] SarifCli: Remove "Diagnostic" from test names; use DisplayName --- .../AnnotatedCodeLocationIdIsObsoleteTests.cs | 12 ++--- .../DoNotUseFriendlyNameAsRuleIdTests.cs | 8 ++-- .../Rules/EndTimeMustBeAfterStartTimeTests.cs | 12 ++--- .../Rules/HashAlgorithmsMustBeUniqueTests.cs | 8 ++-- .../Rules/UrisMustBeValidTests.cs | 44 +++++++++---------- ...lutePathsForNestedFileUriFragmentsTests.cs | 40 ++++++++--------- 6 files changed, 62 insertions(+), 62 deletions(-) diff --git a/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationIdIsObsoleteTests.cs b/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationIdIsObsoleteTests.cs index fd3620713..5bbeedd8c 100644 --- a/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationIdIsObsoleteTests.cs +++ b/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationIdIsObsoleteTests.cs @@ -8,20 +8,20 @@ namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules { class AnnotatedCodeLocationIdIsObsoleteTests : SkimmerTestsBase { - [Fact] - public void AnnotatedCodeLocationIdIsObsolete_NoDiagnostic_AnnotatedCodeLocationDoesNotHaveId() + [Fact(DisplayName = nameof(AnnotatedCodeLocationIdIsObsolete_AnnotatedCodeLocationDoesNotHaveId))] + public void AnnotatedCodeLocationIdIsObsolete_AnnotatedCodeLocationDoesNotHaveId() { Verify(new AnnotatedCodeLocationIdIsObsolete(), "AnnotatedCodeLocationDoesNotHaveId.sarif"); } - [Fact] - public void AnnotatedCodeLocationIdIsObsolete_Diagnostic_AnnotatedCodeLocationInCodeFlowHasId() + [Fact(DisplayName = nameof(AnnotatedCodeLocationIdIsObsolete_AnnotatedCodeLocationInCodeFlowHasId))] + public void AnnotatedCodeLocationIdIsObsolete_AnnotatedCodeLocationInCodeFlowHasId() { Verify(new AnnotatedCodeLocationIdIsObsolete(), "AnnotatedCodeLocationInCodeFlowHasId.sarif"); } - [Fact] - public void AnnotatedCodeLocationIdIsObsolete_Diagnostic_AnnotatedCodeLocationInRelatedLocationHasId() + [Fact(DisplayName = nameof(AnnotatedCodeLocationIdIsObsolete_AnnotatedCodeLocationInRelatedLocationHasId))] + public void AnnotatedCodeLocationIdIsObsolete_AnnotatedCodeLocationInRelatedLocationHasId() { Verify(new AnnotatedCodeLocationIdIsObsolete(), "AnnotatedCodeLocationInRelatedLocationHasId.sarif"); } diff --git a/src/SarifCli.FunctionalTests/Rules/DoNotUseFriendlyNameAsRuleIdTests.cs b/src/SarifCli.FunctionalTests/Rules/DoNotUseFriendlyNameAsRuleIdTests.cs index dc9d08f04..c5b9cd85a 100644 --- a/src/SarifCli.FunctionalTests/Rules/DoNotUseFriendlyNameAsRuleIdTests.cs +++ b/src/SarifCli.FunctionalTests/Rules/DoNotUseFriendlyNameAsRuleIdTests.cs @@ -8,14 +8,14 @@ namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules { public class DoNotUseFriendlyNameAsRuleIdTests : SkimmerTestsBase { - [Fact] - public void DoNotUseFriendlyNameAsRuleId_NoDiagnostic_RuleIdDoesNotMatchFriendlyName() + [Fact(DisplayName = nameof(DoNotUseFriendlyNameAsRuleId_RuleIdDoesNotMatchFriendlyName))] + public void DoNotUseFriendlyNameAsRuleId_RuleIdDoesNotMatchFriendlyName() { Verify(new DoNotUseFriendlyNameAsRuleId(), "RuleIdDoesNotMatchFriendlyName.sarif"); } - [Fact] - public void DoNotUseFriendlyNameAsRuleId_Diagnostic_RuleIdMatchesFriendlyName() + [Fact(DisplayName = nameof(DoNotUseFriendlyNameAsRuleId_RuleIdMatchesFriendlyName))] + public void DoNotUseFriendlyNameAsRuleId_RuleIdMatchesFriendlyName() { Verify(new DoNotUseFriendlyNameAsRuleId(), "RuleIdMatchesFriendlyName.sarif"); } diff --git a/src/SarifCli.FunctionalTests/Rules/EndTimeMustBeAfterStartTimeTests.cs b/src/SarifCli.FunctionalTests/Rules/EndTimeMustBeAfterStartTimeTests.cs index 441520db4..11284a0d7 100644 --- a/src/SarifCli.FunctionalTests/Rules/EndTimeMustBeAfterStartTimeTests.cs +++ b/src/SarifCli.FunctionalTests/Rules/EndTimeMustBeAfterStartTimeTests.cs @@ -8,20 +8,20 @@ namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules { public class EndTimeMustBeAfterStartTimeTests : SkimmerTestsBase { - [Fact] - public void EndTimeMustBeAfterStartTime_NoDiagnostic_EndTimeIsAfterStartTime() + [Fact(DisplayName = nameof(EndTimeMustBeAfterStartTime_EndTimeIsAfterStartTime))] + public void EndTimeMustBeAfterStartTime_EndTimeIsAfterStartTime() { Verify(new EndTimeMustBeAfterStartTime(), "EndTimeIsAfterStartTime.sarif"); } - [Fact] - public void EndTimeMustBeAfterStartTime_Diagnostic_EndTimeEqualsStartTime() + [Fact(DisplayName = nameof(EndTimeMustBeAfterStartTime_EndTimeEqualsStartTime))] + public void EndTimeMustBeAfterStartTime_EndTimeEqualsStartTime() { Verify(new EndTimeMustBeAfterStartTime(), "EndTimeEqualsStartTime.sarif"); } - [Fact] - public void EndTimeMustBeAfterStartTime_Diagnostic_EndTimeIsBeforeStartTime() + [Fact(DisplayName = nameof(EndTimeMustBeAfterStartTime_EndTimeIsBeforeStartTime))] + public void EndTimeMustBeAfterStartTime_EndTimeIsBeforeStartTime() { Verify(new EndTimeMustBeAfterStartTime(), "EndTimeIsBeforeStartTime.sarif"); } diff --git a/src/SarifCli.FunctionalTests/Rules/HashAlgorithmsMustBeUniqueTests.cs b/src/SarifCli.FunctionalTests/Rules/HashAlgorithmsMustBeUniqueTests.cs index 26b411e5c..fe9ae4eaf 100644 --- a/src/SarifCli.FunctionalTests/Rules/HashAlgorithmsMustBeUniqueTests.cs +++ b/src/SarifCli.FunctionalTests/Rules/HashAlgorithmsMustBeUniqueTests.cs @@ -8,14 +8,14 @@ namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules { public class HashAlgorithmsMustBeUniqueTests : SkimmerTestsBase { - [Fact] - public void HashAlgorithmsMustBeUnique_NoDiagnostic_UniqueHashAlgorithms() + [Fact(DisplayName = nameof(HashAlgorithmsMustBeUnique_UniqueHashAlgorithms))] + public void HashAlgorithmsMustBeUnique_UniqueHashAlgorithms() { Verify(new HashAlgorithmsMustBeUnique(), "UniqueHashAlgorithms.sarif"); } - [Fact] - public void HashAlgorithmsMustBeUnique_Diagnostic_NonUniqueHashAlgorithms() + [Fact(DisplayName = nameof(HashAlgorithmsMustBeUnique_NonUniqueHashAlgorithms))] + public void HashAlgorithmsMustBeUnique_NonUniqueHashAlgorithms() { Verify(new HashAlgorithmsMustBeUnique(), "NonUniqueHashAlgorithms.sarif"); } diff --git a/src/SarifCli.FunctionalTests/Rules/UrisMustBeValidTests.cs b/src/SarifCli.FunctionalTests/Rules/UrisMustBeValidTests.cs index f18ea00e6..0f9b0965e 100644 --- a/src/SarifCli.FunctionalTests/Rules/UrisMustBeValidTests.cs +++ b/src/SarifCli.FunctionalTests/Rules/UrisMustBeValidTests.cs @@ -8,68 +8,68 @@ namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules { public class UrisMustBeValidTests : SkimmerTestsBase { - [Fact] - public void UrisMustBeValid_NoDiagnostic_ValidUris() + [Fact(DisplayName = nameof(UrisMustBeValid_ValidUris))] + public void UrisMustBeValid_ValidUris() { Verify(new UrisMustBeValid(), "ValidUris.sarif"); } - [Fact] - public void UrisMustBeValid_Diagnostic_InvalidHelpUriInRule() + [Fact(DisplayName = nameof(UrisMustBeValid_InvalidHelpUriInRule))] + public void UrisMustBeValid_InvalidHelpUriInRule() { Verify(new UrisMustBeValid(), "InvalidHelpUriInRule.sarif"); } - [Fact] - public void UrisMustBeValid_Diagnostic_InvalidUriInAnalysisTarget() + [Fact(DisplayName = nameof(UrisMustBeValid_InvalidUriInAnalysisTarget))] + public void UrisMustBeValid_InvalidUriInAnalysisTarget() { Verify(new UrisMustBeValid(), "InvalidUriInAnalysisTarget.sarif"); } - [Fact] - public void UrisMustBeValid_Diagnostic_InvalidUriInCodeFlowLocation() + [Fact(DisplayName = nameof(UrisMustBeValid_InvalidUriInCodeFlowLocation))] + public void UrisMustBeValid_InvalidUriInCodeFlowLocation() { Verify(new UrisMustBeValid(), "InvalidUriInCodeFlowLocation.sarif"); } - [Fact] - public void UrisMustBeValid_Diagnostic_InvalidUriInConfigurationNotification() + [Fact(DisplayName = nameof(UrisMustBeValid_InvalidUriInConfigurationNotification))] + public void UrisMustBeValid_InvalidUriInConfigurationNotification() { Verify(new UrisMustBeValid(), "InvalidUriInConfigurationNotification.sarif"); } - [Fact] - public void UrisMustBeValid_Diagnostic_InvalidUriInFileChange() + [Fact(DisplayName = nameof(UrisMustBeValid_InvalidUriInFileChange))] + public void UrisMustBeValid_InvalidUriInFileChange() { Verify(new UrisMustBeValid(), "InvalidUriInFileChange.sarif"); } - [Fact] - public void UrisMustBeValid_Diagnostic_InvalidUriInFilePropertyName() + [Fact(DisplayName = nameof(UrisMustBeValid_InvalidUriInFilePropertyName))] + public void UrisMustBeValid_InvalidUriInFilePropertyName() { Verify(new UrisMustBeValid(), "InvalidUriInFilePropertyName.sarif"); } - [Fact] - public void UrisMustBeValid_Diagnostic_InvalidUriInRelatedLocation() + [Fact(DisplayName = nameof(UrisMustBeValid_InvalidUriInRelatedLocation))] + public void UrisMustBeValid_InvalidUriInRelatedLocation() { Verify(new UrisMustBeValid(), "InvalidUriInRelatedLocation.sarif"); } - [Fact] - public void UrisMustBeValid_Diagnostic_InvalidUriInResultFile() + [Fact(DisplayName = nameof(UrisMustBeValid_InvalidUriInResultFile))] + public void UrisMustBeValid_InvalidUriInResultFile() { Verify(new UrisMustBeValid(), "InvalidUriInResultFile.sarif"); } - [Fact] - public void UrisMustBeValid_Diagnostic_InvalidUriInStackFrame() + [Fact(DisplayName = nameof(UrisMustBeValid_InvalidUriInStackFrame))] + public void UrisMustBeValid_InvalidUriInStackFrame() { Verify(new UrisMustBeValid(), "InvalidUriInStackFrame.sarif"); } - [Fact] - public void UrisMustBeValid_Diagnostic_InvalidUriInToolNotification() + [Fact(DisplayName = nameof(UrisMustBeValid_InvalidUriInToolNotification))] + public void UrisMustBeValid_InvalidUriInToolNotification() { Verify(new UrisMustBeValid(), "InvalidUriInToolNotification.sarif"); } diff --git a/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs b/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs index 0895a301f..9e32e30a3 100644 --- a/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs +++ b/src/SarifCli.FunctionalTests/Rules/UseAbsolutePathsForNestedFileUriFragmentsTests.cs @@ -8,62 +8,62 @@ namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules { public class UseAbsolutePathsForNestedFileUriFragmentsTests : SkimmerTestsBase { - [Fact] - public void UseAbsolutePathsForNestedFileUriFragments_NoDiagnostic_NestedFileUriFragmentsAreAbsolute() + [Fact(DisplayName = nameof(UseAbsolutePathsForNestedFileUriFragments_NestedFileUriFragmentsAreAbsolute))] + public void UseAbsolutePathsForNestedFileUriFragments_NestedFileUriFragmentsAreAbsolute() { Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentsAreAbsolute.sarif"); } - [Fact] - public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInAnalysisTargetUri() + [Fact(DisplayName = nameof(UseAbsolutePathsForNestedFileUriFragments_NestedFileUriFragmentIsRelativeInAnalysisTargetUri))] + public void UseAbsolutePathsForNestedFileUriFragments_NestedFileUriFragmentIsRelativeInAnalysisTargetUri() { Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInAnalysisTargetUri.sarif"); } - [Fact] - public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInCodeFlowLocationUri() + [Fact(DisplayName = nameof(UseAbsolutePathsForNestedFileUriFragments_NestedFileUriFragmentIsRelativeInCodeFlowLocationUri))] + public void UseAbsolutePathsForNestedFileUriFragments_NestedFileUriFragmentIsRelativeInCodeFlowLocationUri() { Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInCodeFlowLocationUri.sarif"); } - [Fact] - public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInConfigurationNotificationUri() + [Fact(DisplayName = nameof(UseAbsolutePathsForNestedFileUriFragments_NestedFileUriFragmentIsRelativeInConfigurationNotificationUri))] + public void UseAbsolutePathsForNestedFileUriFragments_NestedFileUriFragmentIsRelativeInConfigurationNotificationUri() { Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInConfigurationNotificationUri.sarif"); } - [Fact] - public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInFileChangeUri() + [Fact(DisplayName = nameof(UseAbsolutePathsForNestedFileUriFragments_NestedFileUriFragmentIsRelativeInFileChangeUri))] + public void UseAbsolutePathsForNestedFileUriFragments_NestedFileUriFragmentIsRelativeInFileChangeUri() { Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInFileChangeUri.sarif"); } - [Fact] - public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInFilePropertyName() + [Fact(DisplayName = nameof(UseAbsolutePathsForNestedFileUriFragments_NestedFileUriFragmentIsRelativeInFilePropertyName))] + public void UseAbsolutePathsForNestedFileUriFragments_NestedFileUriFragmentIsRelativeInFilePropertyName() { Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInFilePropertyName.sarif"); } - [Fact] - public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInRelatedLocationUri() + [Fact(DisplayName = nameof(UseAbsolutePathsForNestedFileUriFragments_NestedFileUriFragmentIsRelativeInRelatedLocationUri))] + public void UseAbsolutePathsForNestedFileUriFragments_NestedFileUriFragmentIsRelativeInRelatedLocationUri() { Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInRelatedLocationUri.sarif"); } - [Fact] - public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInResultFileUri() + [Fact(DisplayName = nameof(UseAbsolutePathsForNestedFileUriFragments_NestedFileUriFragmentIsRelativeInResultFileUri))] + public void UseAbsolutePathsForNestedFileUriFragments_NestedFileUriFragmentIsRelativeInResultFileUri() { Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInResultFileUri.sarif"); } - [Fact] - public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInStackFrameUri() + [Fact(DisplayName = nameof(UseAbsolutePathsForNestedFileUriFragments_NestedFileUriFragmentIsRelativeInStackFrameUri))] + public void UseAbsolutePathsForNestedFileUriFragments_NestedFileUriFragmentIsRelativeInStackFrameUri() { Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInStackFrameUri.sarif"); } - [Fact] - public void UseAbsolutePathsForNestedFileUriFragments_Diagnostic_NestedFileUriFragmentIsRelativeInToolNotificationUri() + [Fact(DisplayName = nameof(UseAbsolutePathsForNestedFileUriFragments_NestedFileUriFragmentIsRelativeInToolNotificationUri))] + public void UseAbsolutePathsForNestedFileUriFragments_NestedFileUriFragmentIsRelativeInToolNotificationUri() { Verify(new UseAbsolutePathsForNestedFileUriFragments(), "NestedFileUriFragmentIsRelativeInToolNotificationUri.sarif"); } From 4dd64a8f57e5843facb18856ad0914e96fa76bb4 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Fri, 26 Aug 2016 20:44:36 -0700 Subject: [PATCH 34/51] SarifCli: Implement AnnotatedCodeLocationEssentialIsObsolete rule --- ...tedCodeLocationEssentialIsObsoleteTests.cs | 29 +++++++ .../SarifCli.FunctionalTests.csproj | 19 +++++ ...atedCodeLocationDoesNotHaveEssential.sarif | 45 ++++++++++ ...ocationDoesNotHaveEssential_Expected.sarif | 46 ++++++++++ ...edCodeLocationHasEssentialInCodeFlow.sarif | 46 ++++++++++ ...ationHasEssentialInCodeFlow_Expected.sarif | 84 +++++++++++++++++++ ...ocationHasEssentialInRelatedLocation.sarif | 42 ++++++++++ ...sEssentialInRelatedLocation_Expected.sarif | 84 +++++++++++++++++++ .../EndTimeIsBeforeStartTime_Expected.sarif | 6 +- .../NonUniqueHashAlgorithms_Expected.sarif | 6 +- ...nnotatedCodeLocationEssentialIsObsolete.cs | 48 +++++++++++ .../Rules/EndTimeMustBeAfterStartTime.cs | 6 +- .../Rules/HashAlgorithmsMustBeUnique.cs | 6 +- src/SarifCli/Rules/RuleId.cs | 5 +- src/SarifCli/Rules/RuleResources.Designer.cs | 47 ++++++++--- src/SarifCli/Rules/RuleResources.resx | 21 +++-- src/SarifCli/SarifCli.csproj | 2 + src/SarifCli/SarifPropertyName.cs | 1 + 18 files changed, 513 insertions(+), 30 deletions(-) create mode 100644 src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationEssentialIsObsoleteTests.cs create mode 100644 src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationDoesNotHaveEssential.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationDoesNotHaveEssential_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasEssentialInCodeFlow.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasEssentialInCodeFlow_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasEssentialInRelatedLocation.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasEssentialInRelatedLocation_Expected.sarif create mode 100644 src/SarifCli/Rules/AnnotatedCodeLocationEssentialIsObsolete.cs diff --git a/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationEssentialIsObsoleteTests.cs b/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationEssentialIsObsoleteTests.cs new file mode 100644 index 000000000..a58fadde0 --- /dev/null +++ b/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationEssentialIsObsoleteTests.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.CodeAnalysis.Sarif.Cli.Rules; +using Xunit; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules +{ + class AnnotatedCodeLocationEssentialIsObsoleteTests : SkimmerTestsBase + { + [Fact(DisplayName = nameof(AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationDoesNotHaveEssential))] + public void AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationDoesNotHaveEssential() + { + Verify(new AnnotatedCodeLocationEssentialIsObsolete(), "AnnotatedCodeLocationDoesNotHaveId.sarif"); + } + + [Fact(DisplayName = nameof(AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationInCodeFlowHasEssential))] + public void AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationInCodeFlowHasEssential() + { + Verify(new AnnotatedCodeLocationEssentialIsObsolete(), "AnnotatedCodeLocationInCodeFlowHasEssential.sarif"); + } + + [Fact(DisplayName = nameof(AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationInRelatedLocationHasEssential))] + public void AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationInRelatedLocationHasEssential() + { + Verify(new AnnotatedCodeLocationEssentialIsObsolete(), "AnnotatedCodeLocationInRelatedLocationHasEssential.sarif"); + } + } +} diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj index fa0e8f0cc..b4bf53724 100644 --- a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -65,6 +65,7 @@ + @@ -83,6 +84,24 @@ Designer + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationDoesNotHaveEssential.sarif b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationDoesNotHaveEssential.sarif new file mode 100644 index 000000000..46b8bdd10 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationDoesNotHaveEssential.sarif @@ -0,0 +1,45 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "codeFlows": [ + { + "locations": [ + { + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 42, + "startColumn": 12 + } + } + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationDoesNotHaveEssential_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationDoesNotHaveEssential_Expected.sarif new file mode 100644 index 000000000..5e8d68310 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationDoesNotHaveEssential_Expected.sarif @@ -0,0 +1,46 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "72266e9a-82cf-416b-b165-f08cf1ce54ae", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationDoesNotHaveEssential.sarif" + }, + "message": "Analyzing 'AnnotatedCodeLocationDoesNotHaveEssential.sarif'...", + "level": "note", + "time": "2016-08-27T03:33:36.903Z" + } + ], + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationDoesNotHaveEssential.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\AnnotatedCodeLocationEssentialIsObsolete\\AnnotatedCodeLocationDoesNotHaveEssential.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\AnnotatedCodeLocationEssentialIsObsolete\\AnnotatedCodeLocationDoesNotHaveEssential_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-27T03:33:36.721Z", + "endTime": "2016-08-27T03:33:37.140Z", + "processId": 19020, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasEssentialInCodeFlow.sarif b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasEssentialInCodeFlow.sarif new file mode 100644 index 000000000..854371350 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasEssentialInCodeFlow.sarif @@ -0,0 +1,46 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "codeFlows": [ + { + "locations": [ + { + "essential": true, + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 42, + "startColumn": 12 + } + } + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasEssentialInCodeFlow_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasEssentialInCodeFlow_Expected.sarif new file mode 100644 index 000000000..c5a40ce4c --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasEssentialInCodeFlow_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "fbf4e8ba-fb01-4103-87db-3fe84334aa78", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0005", + "level": "warning", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "AnnotatedCodeLocationHasEssentialInCodeFlow.sarif", + "/runs/0/results/0/codeFlows/0/locations/0/essential" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasEssentialInCodeFlow.sarif", + "region": { + "startLine": 30, + "startColumn": 36 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasEssentialInCodeFlow.sarif" + }, + "message": "Analyzing 'AnnotatedCodeLocationHasEssentialInCodeFlow.sarif'...", + "level": "note", + "time": "2016-08-27T03:36:58.146Z" + } + ], + "rules": { + "SV0005": { + "id": "SV0005", + "name": "AnnotatedCodeLocationEssentialIsObsolete", + "shortDescription": "Do not use the obsolete \"essential\" property of the annotatedCodeLocation object.", + "fullDescription": "Do not use the obsolete \"essential\" property of the annotatedCodeLocation object. Instead use \"importance\", which is an string-valued property that must have one of the values \"essential\", \"important\", or \"unimportant\".", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the obsolete \"essential\" property is used. Remove it, and instead use the \"importance\" property, whose value is a string with one of the values \"essential\", \"important\", or \"unimportant\".", + "OnlyInCodeFlow": "In \"{0}\", at \"{1}\", the obsolete \"essential\" property is used. This property has been replaced by the \"importance\" property, but the \"importance\" property is used only in annotatedCodeLocations objects that occur within a code flow. Remove the \"essential\" property." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasEssentialInCodeFlow.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\AnnotatedCodeLocationEssentialIsObsolete\\AnnotatedCodeLocationHasEssentialInCodeFlow.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\AnnotatedCodeLocationEssentialIsObsolete\\AnnotatedCodeLocationHasEssentialInCodeFlow_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-27T03:36:58.060Z", + "endTime": "2016-08-27T03:36:58.416Z", + "processId": 9192, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasEssentialInRelatedLocation.sarif b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasEssentialInRelatedLocation.sarif new file mode 100644 index 000000000..4751cc178 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasEssentialInRelatedLocation.sarif @@ -0,0 +1,42 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "relatedLocations": [ + { + "essential": true, + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 42, + "startColumn": 12 + } + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasEssentialInRelatedLocation_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasEssentialInRelatedLocation_Expected.sarif new file mode 100644 index 000000000..1e0612bce --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasEssentialInRelatedLocation_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "ea49ba66-d278-4a80-bdd7-07bf6d47c150", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0005", + "level": "warning", + "formattedRuleMessage": { + "formatId": "OnlyInCodeFlow", + "arguments": [ + "AnnotatedCodeLocationHasEssentialInRelatedLocation.sarif", + "/runs/0/results/0/relatedLocations/0/essential" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasEssentialInRelatedLocation.sarif", + "region": { + "startLine": 28, + "startColumn": 32 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasEssentialInRelatedLocation.sarif" + }, + "message": "Analyzing 'AnnotatedCodeLocationHasEssentialInRelatedLocation.sarif'...", + "level": "note", + "time": "2016-08-27T03:38:46.717Z" + } + ], + "rules": { + "SV0005": { + "id": "SV0005", + "name": "AnnotatedCodeLocationEssentialIsObsolete", + "shortDescription": "Do not use the obsolete \"essential\" property of the annotatedCodeLocation object.", + "fullDescription": "Do not use the obsolete \"essential\" property of the annotatedCodeLocation object. Instead use \"importance\", which is an string-valued property that must have one of the values \"essential\", \"important\", or \"unimportant\".", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the obsolete \"essential\" property is used. Remove it, and instead use the \"importance\" property, whose value is a string with one of the values \"essential\", \"important\", or \"unimportant\".", + "OnlyInCodeFlow": "In \"{0}\", at \"{1}\", the obsolete \"essential\" property is used. This property has been replaced by the \"importance\" property, but the \"importance\" property is used only in annotatedCodeLocations objects that occur within a code flow. Remove the \"essential\" property." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasEssentialInRelatedLocation.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\AnnotatedCodeLocationEssentialIsObsolete\\AnnotatedCodeLocationHasEssentialInRelatedLocation.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\AnnotatedCodeLocationEssentialIsObsolete\\AnnotatedCodeLocationHasEssentialInRelatedLocation_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-27T03:38:46.633Z", + "endTime": "2016-08-27T03:38:46.992Z", + "processId": 9984, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsBeforeStartTime_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsBeforeStartTime_Expected.sarif index e0052941d..5ab7ed64d 100644 --- a/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsBeforeStartTime_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/EndTimeMustBeAfterStartTime/EndTimeIsBeforeStartTime_Expected.sarif @@ -19,7 +19,7 @@ }, "results": [ { - "ruleId": "SV0006", + "ruleId": "SV0007", "level": "error", "formattedRuleMessage": { "formatId": "Default", @@ -55,8 +55,8 @@ } ], "rules": { - "SV0006": { - "id": "SV0006", + "SV0007": { + "id": "SV0007", "name": "EndTimeMustBeAfterStartTime", "shortDescription": "The end time of a run must be after the start time.", "fullDescription": "The end time of a run must be after the start time. To allow for the possibility that the duration of the run is less than the resolution of the string representation of the time, the start time and the end time may be equal.", diff --git a/src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/NonUniqueHashAlgorithms_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/NonUniqueHashAlgorithms_Expected.sarif index 82bc8b7aa..d0ca6156c 100644 --- a/src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/NonUniqueHashAlgorithms_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/HashAlgorithmsMustBeUnique/NonUniqueHashAlgorithms_Expected.sarif @@ -19,7 +19,7 @@ }, "results": [ { - "ruleId": "SV0005", + "ruleId": "SV0006", "level": "error", "formattedRuleMessage": { "formatId": "Default", @@ -54,8 +54,8 @@ } ], "rules": { - "SV0005": { - "id": "SV0005", + "SV0006": { + "id": "SV0006", "name": "HashAlgorithmsMustBeUnique", "shortDescription": "In any given \"file\" object, every element of the \"hashes\" array must have a different value for its \"algorithm\" property.", "fullDescription": "In any given \"file\" object, every element of the \"hashes\" array must have a different value for its \"algorithm\" property. ", diff --git a/src/SarifCli/Rules/AnnotatedCodeLocationEssentialIsObsolete.cs b/src/SarifCli/Rules/AnnotatedCodeLocationEssentialIsObsolete.cs new file mode 100644 index 000000000..c8849ea4f --- /dev/null +++ b/src/SarifCli/Rules/AnnotatedCodeLocationEssentialIsObsolete.cs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Collections.Generic; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules +{ + public class AnnotatedCodeLocationEssentialIsObsolete : SarifValidationSkimmerBase + { + public override string FullDescription => RuleResources.SV0005_AnnotatedCodeLocationEssentialIsObsolete; + + public override ResultLevel DefaultLevel => ResultLevel.Warning; + + /// + /// SV0005 + /// + public override string Id => RuleId.AnnotatedCodeLocationEssentialIsObsolete; + + protected override IEnumerable FormatIds + { + get + { + return new string[] + { + nameof(RuleResources.SV0005_Default), + nameof(RuleResources.SV0005_OnlyInCodeFlow) + }; + } + } + + protected override void Analyze(AnnotatedCodeLocation annotatedCodeLocation, string annotatedCodeLocationPointer) + { + if (annotatedCodeLocation.Essential) + { + string essentialPointer = annotatedCodeLocationPointer.AtProperty(SarifPropertyName.Essential); + + // Emit a different warning depending on whether or not this annotatedCodeLocation + // occurs in a codeFlow, because the "importance" property is only meaningful within + // a codeFlow. + string formatId = annotatedCodeLocationPointer.Contains(SarifPropertyName.CodeFlows) + ? nameof(RuleResources.SV0005_Default) + : nameof(RuleResources.SV0005_OnlyInCodeFlow); + + LogResult(essentialPointer, formatId); + } + } + } +} diff --git a/src/SarifCli/Rules/EndTimeMustBeAfterStartTime.cs b/src/SarifCli/Rules/EndTimeMustBeAfterStartTime.cs index 9b9fb4184..c230b49ed 100644 --- a/src/SarifCli/Rules/EndTimeMustBeAfterStartTime.cs +++ b/src/SarifCli/Rules/EndTimeMustBeAfterStartTime.cs @@ -9,7 +9,7 @@ namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules { public class EndTimeMustBeAfterStartTime : SarifValidationSkimmerBase { - public override string FullDescription => RuleResources.SV0006_EndTimeMustBeAfterStartTime; + public override string FullDescription => RuleResources.SV0007_EndTimeMustBeAfterStartTime; public override ResultLevel DefaultLevel => ResultLevel.Error; @@ -24,7 +24,7 @@ protected override IEnumerable FormatIds { return new string[] { - nameof(RuleResources.SV0006_Default) + nameof(RuleResources.SV0007_Default) }; } } @@ -37,7 +37,7 @@ protected override void Analyze(Invocation invocation, string invocationPointer) LogResult( endTimePointer, - nameof(RuleResources.SV0006_Default), + nameof(RuleResources.SV0007_Default), FormatDateTime(invocation.EndTime), FormatDateTime(invocation.StartTime)); } diff --git a/src/SarifCli/Rules/HashAlgorithmsMustBeUnique.cs b/src/SarifCli/Rules/HashAlgorithmsMustBeUnique.cs index 63293cb16..691bdb549 100644 --- a/src/SarifCli/Rules/HashAlgorithmsMustBeUnique.cs +++ b/src/SarifCli/Rules/HashAlgorithmsMustBeUnique.cs @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules { public class HashAlgorithmsMustBeUnique : SarifValidationSkimmerBase { - public override string FullDescription => RuleResources.SV0005_HashAlgorithmsMustBeUnique; + public override string FullDescription => RuleResources.SV0006_HashAlgorithmsMustBeUnique; public override ResultLevel DefaultLevel => ResultLevel.Error; @@ -23,7 +23,7 @@ protected override IEnumerable FormatIds { return new string[] { - nameof(RuleResources.SV0005_Default) + nameof(RuleResources.SV0006_Default) }; } } @@ -40,7 +40,7 @@ protected override void Analyze(FileData fileData, string fileKey, string filePo LogResult( hashesPointer, - nameof(RuleResources.SV0005_Default), + nameof(RuleResources.SV0006_Default), algorithmKind.ToString()); } } diff --git a/src/SarifCli/Rules/RuleId.cs b/src/SarifCli/Rules/RuleId.cs index 3c7460648..0151ccecd 100644 --- a/src/SarifCli/Rules/RuleId.cs +++ b/src/SarifCli/Rules/RuleId.cs @@ -9,7 +9,8 @@ public static class RuleId public const string UseAbsolutePathsForNestedFileUriFragments = "SV0002"; public const string UrisMustBeValid = "SV0003"; public const string AnnotatedCodeLocationIdIsObsolete = "SV0004"; - public const string HashAlgorithmsMustBeUnique = "SV0005"; - public const string EndTimeMustBeAfterStartTime = "SV0006"; + public const string AnnotatedCodeLocationEssentialIsObsolete = "SV0005"; + public const string HashAlgorithmsMustBeUnique = "SV0006"; + public const string EndTimeMustBeAfterStartTime = "SV0007"; } } diff --git a/src/SarifCli/Rules/RuleResources.Designer.cs b/src/SarifCli/Rules/RuleResources.Designer.cs index 609ad9f54..2a1c0abc1 100644 --- a/src/SarifCli/Rules/RuleResources.Designer.cs +++ b/src/SarifCli/Rules/RuleResources.Designer.cs @@ -115,7 +115,7 @@ internal static string SV0003_UrisMustBeValid { } /// - /// Looks up a localized string similar to Do not use the property annotatedCodeLocation.id, which is obsolete. Instead use annotatedCodeLocation.step, which is an integer-valued property that is 1 for the first annotatedCodeLocation in a codeFlow, and increments by 1 for every subsequent step.. + /// Looks up a localized string similar to Do not use the obsolete "id" property of the annotatedCodeLocation object. Instead use "step", which is an integer-valued property that is 1 for the first annotatedCodeLocation in a codeFlow, and increments by 1 for every subsequent step.. /// internal static string SV0004_AnnotatedCodeLocationIdIsObsolete { get { @@ -124,7 +124,7 @@ internal static string SV0004_AnnotatedCodeLocationIdIsObsolete { } /// - /// Looks up a localized string similar to In "{0}", at "{1}", the obsolete annotatedCodeLocation.id property is used. Remove it, and instead use the step property, whose value is an integer which is 1 for the first location in a code flow, and increments by 1 for each subsequent location in the code flow.. + /// Looks up a localized string similar to In "{0}", at "{1}", the obsolete annotatedCodeLocation.id property is used. Remove it, and instead use the "step" property, whose value is an integer which is 1 for the first location in a code flow, and increments by 1 for each subsequent location in the code flow.. /// internal static string SV0004_Default { get { @@ -133,7 +133,7 @@ internal static string SV0004_Default { } /// - /// Looks up a localized string similar to In "{0}", at "{1}", the obsolete annotatedCodeLocation.id property is used. This property has been replaced by the step property, but the step property is used only in annotatedCodeLocations objects that occur within a code flow. Remove the id property.. + /// Looks up a localized string similar to In "{0}", at "{1}", the obsolete "id" property is used. This property has been replaced by the "step" property, but the "step" property is used only in annotatedCodeLocations objects that occur within a code flow. Remove the "id" property.. /// internal static string SV0004_OnlyInCodeFlow { get { @@ -142,7 +142,16 @@ internal static string SV0004_OnlyInCodeFlow { } /// - /// Looks up a localized string similar to In "{0}", at "{1}", the array contains multiple objects with the value "{2}" for the algorithm property.. + /// Looks up a localized string similar to Do not use the obsolete "essential" property of the annotatedCodeLocation object. Instead use "importance", which is an string-valued property that must have one of the values "essential", "important", or "unimportant".. + /// + internal static string SV0005_AnnotatedCodeLocationEssentialIsObsolete { + get { + return ResourceManager.GetString("SV0005_AnnotatedCodeLocationEssentialIsObsolete", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to In "{0}", at "{1}", the obsolete "essential" property is used. Remove it, and instead use the "importance" property, whose value is a string with one of the values "essential", "important", or "unimportant".. /// internal static string SV0005_Default { get { @@ -151,16 +160,16 @@ internal static string SV0005_Default { } /// - /// Looks up a localized string similar to In any given "file" object, every element of the "hashes" array must have a different value for its "algorithm" property. . + /// Looks up a localized string similar to In "{0}", at "{1}", the obsolete "essential" property is used. This property has been replaced by the "importance" property, but the "importance" property is used only in annotatedCodeLocations objects that occur within a code flow. Remove the "essential" property.. /// - internal static string SV0005_HashAlgorithmsMustBeUnique { + internal static string SV0005_OnlyInCodeFlow { get { - return ResourceManager.GetString("SV0005_HashAlgorithmsMustBeUnique", resourceCulture); + return ResourceManager.GetString("SV0005_OnlyInCodeFlow", resourceCulture); } } /// - /// Looks up a localized string similar to In "{0}", at "{1}", the end time "{2}" is before the start time "{3}".. + /// Looks up a localized string similar to In "{0}", at "{1}", the array contains multiple objects with the value "{2}" for the algorithm property.. /// internal static string SV0006_Default { get { @@ -168,12 +177,30 @@ internal static string SV0006_Default { } } + /// + /// Looks up a localized string similar to In any given "file" object, every element of the "hashes" array must have a different value for its "algorithm" property. . + /// + internal static string SV0006_HashAlgorithmsMustBeUnique { + get { + return ResourceManager.GetString("SV0006_HashAlgorithmsMustBeUnique", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to In "{0}", at "{1}", the end time "{2}" is before the start time "{3}".. + /// + internal static string SV0007_Default { + get { + return ResourceManager.GetString("SV0007_Default", resourceCulture); + } + } + /// /// Looks up a localized string similar to The end time of a run must be after the start time. To allow for the possibility that the duration of the run is less than the resolution of the string representation of the time, the start time and the end time may be equal.. /// - internal static string SV0006_EndTimeMustBeAfterStartTime { + internal static string SV0007_EndTimeMustBeAfterStartTime { get { - return ResourceManager.GetString("SV0006_EndTimeMustBeAfterStartTime", resourceCulture); + return ResourceManager.GetString("SV0007_EndTimeMustBeAfterStartTime", resourceCulture); } } } diff --git a/src/SarifCli/Rules/RuleResources.resx b/src/SarifCli/Rules/RuleResources.resx index 20488c34f..552ba25b5 100644 --- a/src/SarifCli/Rules/RuleResources.resx +++ b/src/SarifCli/Rules/RuleResources.resx @@ -136,24 +136,33 @@ Specify a valid URI reference for every URI-valued property. - Do not use the property annotatedCodeLocation.id, which is obsolete. Instead use annotatedCodeLocation.step, which is an integer-valued property that is 1 for the first annotatedCodeLocation in a codeFlow, and increments by 1 for every subsequent step. + Do not use the obsolete "id" property of the annotatedCodeLocation object. Instead use "step", which is an integer-valued property that is 1 for the first annotatedCodeLocation in a codeFlow, and increments by 1 for every subsequent step. - In "{0}", at "{1}", the obsolete annotatedCodeLocation.id property is used. Remove it, and instead use the step property, whose value is an integer which is 1 for the first location in a code flow, and increments by 1 for each subsequent location in the code flow. + In "{0}", at "{1}", the obsolete annotatedCodeLocation.id property is used. Remove it, and instead use the "step" property, whose value is an integer which is 1 for the first location in a code flow, and increments by 1 for each subsequent location in the code flow. - In "{0}", at "{1}", the obsolete annotatedCodeLocation.id property is used. This property has been replaced by the step property, but the step property is used only in annotatedCodeLocations objects that occur within a code flow. Remove the id property. + In "{0}", at "{1}", the obsolete "id" property is used. This property has been replaced by the "step" property, but the "step" property is used only in annotatedCodeLocations objects that occur within a code flow. Remove the "id" property. + + + Do not use the obsolete "essential" property of the annotatedCodeLocation object. Instead use "importance", which is an string-valued property that must have one of the values "essential", "important", or "unimportant". + In "{0}", at "{1}", the obsolete "essential" property is used. Remove it, and instead use the "importance" property, whose value is a string with one of the values "essential", "important", or "unimportant". + + + In "{0}", at "{1}", the obsolete "essential" property is used. This property has been replaced by the "importance" property, but the "importance" property is used only in annotatedCodeLocations objects that occur within a code flow. Remove the "essential" property. + + In "{0}", at "{1}", the array contains multiple objects with the value "{2}" for the algorithm property. - + In any given "file" object, every element of the "hashes" array must have a different value for its "algorithm" property. - + In "{0}", at "{1}", the end time "{2}" is before the start time "{3}". - + The end time of a run must be after the start time. To allow for the possibility that the duration of the run is less than the resolution of the string representation of the time, the start time and the end time may be equal. \ No newline at end of file diff --git a/src/SarifCli/SarifCli.csproj b/src/SarifCli/SarifCli.csproj index d75fecd80..5413597fb 100644 --- a/src/SarifCli/SarifCli.csproj +++ b/src/SarifCli/SarifCli.csproj @@ -87,6 +87,7 @@ + @@ -126,6 +127,7 @@ ResXFileCodeGenerator RuleResources.Designer.cs + Designer diff --git a/src/SarifCli/SarifPropertyName.cs b/src/SarifCli/SarifPropertyName.cs index 9e44edec7..08db23458 100644 --- a/src/SarifCli/SarifPropertyName.cs +++ b/src/SarifCli/SarifPropertyName.cs @@ -9,6 +9,7 @@ public static class SarifPropertyName public const string CodeFlows = "codeFlows"; public const string ConfigurationNotifications = "configurationNotifications"; public const string EndTime = "endTime"; + public const string Essential = "essential"; public const string FileChanges = "fileChanges"; public const string Files = "files"; public const string Fixes = "fixes"; From 372554e7569b10885932397c553e463c3df2ad25 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Sat, 27 Aug 2016 07:45:16 -0700 Subject: [PATCH 35/51] Bug fix: Don't run skimmers if log has a syntax error --- .../AnalyzeCommandTests.cs | 41 ++++++ .../Rules/SkimmerTestsBase.cs | 68 +--------- .../SarifCli.FunctionalTests.csproj | 28 ++++ .../SarifCliTestBase.cs | 123 ++++++++++++++++++ .../TestData/SyntaxError.sarif | 18 +++ .../TestData/SyntaxError_Expected.sarif | 81 ++++++++++++ src/SarifCli.FunctionalTests/packages.config | 3 +- src/SarifCli/AnalyzeCommand.cs | 30 ++++- 8 files changed, 318 insertions(+), 74 deletions(-) create mode 100644 src/SarifCli.FunctionalTests/AnalyzeCommandTests.cs create mode 100644 src/SarifCli.FunctionalTests/SarifCliTestBase.cs create mode 100644 src/SarifCli.FunctionalTests/TestData/SyntaxError.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/SyntaxError_Expected.sarif diff --git a/src/SarifCli.FunctionalTests/AnalyzeCommandTests.cs b/src/SarifCli.FunctionalTests/AnalyzeCommandTests.cs new file mode 100644 index 000000000..a928289c0 --- /dev/null +++ b/src/SarifCli.FunctionalTests/AnalyzeCommandTests.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.IO; +using Xunit; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests +{ + public class AnalyzeCommandTests : SarifCliTestBase + { + [Fact(DisplayName = nameof(AnalyzeCommand_ReportsJsonSyntaxError))] + public void AnalyzeCommand_ReportsJsonSyntaxError() + { + const string TestFileName = "SyntaxError.sarif"; + string testDirectory = Path.Combine(Environment.CurrentDirectory, TestDataDirectory); + + string testFilePath = Path.Combine(TestDataDirectory, TestFileName); + string expectedFilePath = MakeExpectedFilePath(testDirectory, TestFileName); + string actualFilePath = MakeActualFilePath(testDirectory, TestFileName); + + var analyzeOptions = new AnalyzeOptions + { + TargetFileSpecifiers = new[] { testFilePath }, + OutputFilePath = actualFilePath, + SchemaFilePath = JsonSchemaFile + }; + + new AnalyzeCommand().Run(analyzeOptions); + + string actualLogContents = File.ReadAllText(actualFilePath); + string expectedLogContents = File.ReadAllText(expectedFilePath); + + // We can't just compare the text of the log files because properties + // like start time, and absolute paths, will differ from run to run. + // Until SarifLogger has a "deterministic" option (see http://github.com/Microsoft/sarif-sdk/issues/500), + // we perform a selective compare of just the elements we care about. + SelectiveCompare(actualLogContents, expectedLogContents); + } + } +} diff --git a/src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs b/src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs index 6a157e7ee..f8314b28d 100644 --- a/src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs +++ b/src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs @@ -3,20 +3,13 @@ using System; using System.IO; -using System.Linq; -using FluentAssertions; using Microsoft.CodeAnalysis.Sarif.Cli.Rules; -using Microsoft.CodeAnalysis.Sarif.Readers; using Microsoft.CodeAnalysis.Sarif.Writers; -using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules { - public abstract class SkimmerTestsBase + public abstract class SkimmerTestsBase : SarifCliTestBase { - private const string JsonSchemaFile = "Sarif.schema.json"; - private const string TestDataDirectory = "TestData"; - protected void Verify(SarifValidationSkimmerBase skimmer, string testFileName) { string ruleName = skimmer.GetType().Name; @@ -62,64 +55,5 @@ protected void Verify(SarifValidationSkimmerBase skimmer, string testFileName) // we perform a selective compare of just the elements we care about. SelectiveCompare(actualLogContents, expectedLogContents); } - - private static void SelectiveCompare(string actualLogContents, string expectedLogContents) - { - var settings = new JsonSerializerSettings() - { - ContractResolver = SarifContractResolver.Instance - }; - - SarifLog actualLog = JsonConvert.DeserializeObject(actualLogContents, settings); - SarifLog expectedLog = JsonConvert.DeserializeObject(expectedLogContents, settings); - - SelectiveCompare(actualLog, expectedLog); - } - - private static void SelectiveCompare(SarifLog actualLog, SarifLog expectedLog) - { - Result[] actualResults = actualLog.Runs[0].Results == null ? null : actualLog.Runs[0].Results.ToArray(); - Result[] expectedResults = expectedLog.Runs[0].Results == null ? null : expectedLog.Runs[0].Results.ToArray(); - - bool actualHasResults = actualResults != null && actualResults.Length > 0; - bool expectedHasResults = expectedResults != null && expectedResults.Length > 0; - actualHasResults.Should().Be(expectedHasResults); - - if (actualHasResults && expectedHasResults) - { - actualResults.Length.Should().Be(expectedResults.Length); - - for (int i = 0; i < actualResults.Length; ++i) - { - Result actualResult = actualResults[i]; - Result expectedResult = expectedResults[i]; - - actualResult.RuleId.Should().Be(expectedResult.RuleId); - - actualResult.Level.Should().Be(expectedResult.Level); - - actualResult.Locations[0].AnalysisTarget.Region.ValueEquals( - expectedResult.Locations[0].AnalysisTarget.Region).Should().BeTrue(); - } - } - } - - private static string MakeExpectedFilePath(string testDirectory, string testFileName) - { - return MakeQualifiedFilePath(testDirectory, testFileName, "Expected"); - } - - private static string MakeActualFilePath(string testDirectory, string testFileName) - { - return MakeQualifiedFilePath(testDirectory, testFileName, "Actual"); - } - - private static string MakeQualifiedFilePath(string testDirectory, string testFileName, string qualifier) - { - string qualifiedFileName = - Path.GetFileNameWithoutExtension(testFileName) + "_" + qualifier + Path.GetExtension(testFileName); - - return Path.Combine(testDirectory, qualifiedFileName); - } } } diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj index b4bf53724..69167573e 100644 --- a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -39,6 +39,26 @@ True + + ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.AttributedModel.dll + True + + + ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.Convention.dll + True + + + ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.Hosting.dll + True + + + ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.Runtime.dll + True + + + ..\packages\Microsoft.Composition.1.0.30\lib\portable-net45+win8+wp8+wpa81\System.Composition.TypedParts.dll + True + @@ -64,6 +84,7 @@ + @@ -73,6 +94,7 @@ + @@ -162,6 +184,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/src/SarifCli.FunctionalTests/SarifCliTestBase.cs b/src/SarifCli.FunctionalTests/SarifCliTestBase.cs new file mode 100644 index 000000000..a115f5c2d --- /dev/null +++ b/src/SarifCli.FunctionalTests/SarifCliTestBase.cs @@ -0,0 +1,123 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.IO; +using System.Linq; +using FluentAssertions; +using Microsoft.CodeAnalysis.Sarif.Readers; +using Newtonsoft.Json; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests +{ + public abstract class SarifCliTestBase + { + protected const string JsonSchemaFile = "Sarif.schema.json"; + protected const string TestDataDirectory = "TestData"; + + protected static string MakeExpectedFilePath(string testDirectory, string testFileName) + { + return MakeQualifiedFilePath(testDirectory, testFileName, "Expected"); + } + + protected static string MakeActualFilePath(string testDirectory, string testFileName) + { + return MakeQualifiedFilePath(testDirectory, testFileName, "Actual"); + } + + // We can't just compare the text of the log files because properties + // like start time, and absolute paths, will differ from run to run. + // Until SarifLogger has a "deterministic" option (see http://github.com/Microsoft/sarif-sdk/issues/500), + // we perform a selective compare of just the elements we care about. + protected static void SelectiveCompare(string actualLogContents, string expectedLogContents) + { + var settings = new JsonSerializerSettings() + { + ContractResolver = SarifContractResolver.Instance + }; + + SarifLog actualLog = JsonConvert.DeserializeObject(actualLogContents, settings); + SarifLog expectedLog = JsonConvert.DeserializeObject(expectedLogContents, settings); + + SelectiveCompare(actualLog, expectedLog); + } + + private static string MakeQualifiedFilePath(string testDirectory, string testFileName, string qualifier) + { + string qualifiedFileName = + Path.GetFileNameWithoutExtension(testFileName) + "_" + qualifier + Path.GetExtension(testFileName); + + return Path.Combine(testDirectory, qualifiedFileName); + } + + private static void SelectiveCompare(SarifLog actualLog, SarifLog expectedLog) + { + Result[] actualResults = SafeListToArray(actualLog.Runs[0].Results); + Result[] expectedResults = SafeListToArray(expectedLog.Runs[0].Results); + + SelectiveCompare(actualResults, expectedResults); + + Notification[] actualConfigurationNotifications = SafeListToArray(actualLog.Runs[0].ConfigurationNotifications); + Notification[] expectedConfigurationNotifications = SafeListToArray(expectedLog.Runs[0].ConfigurationNotifications); + + SelectiveCompare(actualConfigurationNotifications, expectedConfigurationNotifications); + + Notification[] actualToolNotifications = SafeListToArray(actualLog.Runs[0].ToolNotifications); + Notification[] expectedToolNotifications = SafeListToArray(expectedLog.Runs[0].ToolNotifications); + + SelectiveCompare(actualToolNotifications, expectedToolNotifications); + } + + private static void SelectiveCompare(Notification[] actualNotifications, Notification[] expectedNotifications) + { + bool actualHasNotifications = actualNotifications != null && actualNotifications.Length > 0; + bool expectedHasNotifications = expectedNotifications != null && expectedNotifications.Length > 0; + actualHasNotifications.Should().Be(expectedHasNotifications); + + if (actualHasNotifications && expectedHasNotifications) + { + actualNotifications.Length.Should().Be(expectedNotifications.Length); + + for (int i = 0; i < actualNotifications.Length; ++i) + { + Notification actualNotification = actualNotifications[i]; + Notification expectedNotification = expectedNotifications[i]; + + actualNotification.RuleId.Should().Be(expectedNotification.RuleId); + + actualNotification.Level.Should().Be(expectedNotification.Level); + } + } + } + + private static void SelectiveCompare(Result[] actualResults, Result[] expectedResults) + { + bool actualHasResults = actualResults != null && actualResults.Length > 0; + bool expectedHasResults = expectedResults != null && expectedResults.Length > 0; + actualHasResults.Should().Be(expectedHasResults); + + if (actualHasResults && expectedHasResults) + { + actualResults.Length.Should().Be(expectedResults.Length); + + for (int i = 0; i < actualResults.Length; ++i) + { + Result actualResult = actualResults[i]; + Result expectedResult = expectedResults[i]; + + actualResult.RuleId.Should().Be(expectedResult.RuleId); + + actualResult.Level.Should().Be(expectedResult.Level); + + actualResult.Locations[0].AnalysisTarget.Region.ValueEquals( + expectedResult.Locations[0].AnalysisTarget.Region).Should().BeTrue(); + } + } + } + + private static T[] SafeListToArray(IList list) + { + return list == null ? null : list.ToArray(); + } + } +} diff --git a/src/SarifCli.FunctionalTests/TestData/SyntaxError.sarif b/src/SarifCli.FunctionalTests/TestData/SyntaxError.sarif new file mode 100644 index 000000000..d2c0ab785 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/SyntaxError.sarif @@ -0,0 +1,18 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + , + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "rules": { + "TST0001": { + "id": "TST0001", + "helpUri": "http://www.example.com/rules/tst0001.html" + } + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/SyntaxError_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/SyntaxError_Expected.sarif new file mode 100644 index 000000000..d7690e59a --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/SyntaxError_Expected.sarif @@ -0,0 +1,81 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "b7cd6b83-2433-4b4e-80c4-d04cc65de2dd", + "tool": { + "name": "Sarif", + "fullName": "Sarif 1.5.27.0", + "version": "1.5.27.0", + "semanticVersion": "1.5.27", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Object model and utilities for reading and writing files in the SARIF format.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "JS0001", + "level": "error", + "formattedRuleMessage": { + "formatId": "default", + "arguments": [ + "$schema", + "Invalid property identifier character: ,. Path '$schema', line 3, position 3." + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Debug/TestData/SyntaxError.sarif", + "region": { + "startLine": 3, + "startColumn": 3 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Debug/TestData/SyntaxError.sarif" + }, + "message": "Analyzing 'SyntaxError.sarif'...", + "level": "note", + "time": "2016-08-27T13:42:14.981Z" + } + ], + "rules": { + "JS0001": { + "id": "JS0001", + "name": "SyntaxError", + "fullDescription": "The schema is not a valid JSON document.", + "messageFormats": { + "default": "at \"{0}\": JSON syntax error: {1}" + }, + "defaultLevel": "error" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/bld/bin/SarifCli.FunctionalTests/AnyCPU_Debug/TestData/SyntaxError.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"C:\\PROGRAM FILES (X86)\\MICROSOFT VISUAL STUDIO 14.0\\COMMON7\\IDE\\COMMONEXTENSIONS\\MICROSOFT\\TESTWINDOW\\vstest.executionengine.x86.exe\" /parentProcessId 13468 ", + "startTime": "2016-08-27T13:42:14.503Z", + "endTime": "2016-08-27T13:42:15.495Z", + "processId": 13476, + "fileName": "C:\\Users\\lgolding\\AppData\\Local\\Temp\\25c745bf-a38e-4299-bc25-51a57f4bb617\\25c745bf-a38e-4299-bc25-51a57f4bb617\\assembly\\dl3\\54e8f1c0\\00b7775a_e6e9d101\\Sarif.dll", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli.FunctionalTests\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/packages.config b/src/SarifCli.FunctionalTests/packages.config index fadaed30e..6586b6eec 100644 --- a/src/SarifCli.FunctionalTests/packages.config +++ b/src/SarifCli.FunctionalTests/packages.config @@ -1,9 +1,10 @@  + - + diff --git a/src/SarifCli/AnalyzeCommand.cs b/src/SarifCli/AnalyzeCommand.cs index f3bfb5cfc..c7fffafdd 100644 --- a/src/SarifCli/AnalyzeCommand.cs +++ b/src/SarifCli/AnalyzeCommand.cs @@ -43,16 +43,21 @@ protected override SarifValidationContext CreateContext(AnalyzeOptions options, protected override void AnalyzeTarget(IEnumerable> skimmers, SarifValidationContext context, HashSet disabledSkimmers) { - // The base class knows how to invoke the skimmers that implement smart validation... - base.AnalyzeTarget(skimmers, context, disabledSkimmers); - - // ... but it doesn't know how to invoke schema validation, which has its own set of rules, + // The base class knows how to invoke the skimmers that implement smart validation, + // but it doesn't know how to invoke schema validation, which has its own set of rules, // so we do that ourselves. - Validate(context.TargetUri.LocalPath, context.SchemaFilePath, context.Logger); + bool ok = Validate(context.TargetUri.LocalPath, context.SchemaFilePath, context.Logger); + + if (ok) + { + base.AnalyzeTarget(skimmers, context, disabledSkimmers); + } } - private void Validate(string instanceFilePath, string schemaFilePath, IAnalysisLogger logger) + private bool Validate(string instanceFilePath, string schemaFilePath, IAnalysisLogger logger) { + bool ok = true; + try { string instanceText = File.ReadAllText(instanceFilePath); @@ -61,6 +66,11 @@ private void Validate(string instanceFilePath, string schemaFilePath, IAnalysisL catch (JsonSyntaxException ex) { ReportResult(ex.Result, logger); + + // If the file isn't syntactically valid JSON, we won't be able to run + // the skimmers, because they rely on being able to deserialized the file + // into a SarifLog object. + ok = false; } catch (SchemaValidationException ex) { @@ -69,7 +79,15 @@ private void Validate(string instanceFilePath, string schemaFilePath, IAnalysisL catch (Exception ex) { LogToolNotification(logger, ex.Message, NotificationLevel.Error, ex); + + // Don't try to run the skimmers if something unexpected happened. + // Sure, if it were something schema-validation-specific, like "can't + // find schema file," then we could successfully run the skimmers, + // but I don't think it's worth trying to be that clever. + ok = false; } + + return ok; } private void PerformSchemaValidation( From 0f7d0d2b28a5c7c72fbbf97ba4c128aacbcca1cb Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Sat, 27 Aug 2016 15:30:53 -0700 Subject: [PATCH 36/51] Bug fix: Don't run skimmers if log can't be deserialized --- .../AnalyzeCommandTests.cs | 18 +++- ...tedCodeLocationEssentialIsObsoleteTests.cs | 2 +- .../AnnotatedCodeLocationIdIsObsoleteTests.cs | 2 +- .../Rules/SkimmerTestsBase.cs | 15 +++- .../SarifCli.FunctionalTests.csproj | 6 ++ .../TestData/DeserializationError.sarif | 38 +++++++++ .../DeserializationError_Expected.sarif | 84 +++++++++++++++++++ src/SarifCli/AnalyzeCommand.cs | 44 +++++++++- .../Rules/SarifValidationSkimmerBase.cs | 15 +--- src/SarifCli/SarifValidationContext.cs | 5 +- 10 files changed, 204 insertions(+), 25 deletions(-) create mode 100644 src/SarifCli.FunctionalTests/TestData/DeserializationError.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/DeserializationError_Expected.sarif diff --git a/src/SarifCli.FunctionalTests/AnalyzeCommandTests.cs b/src/SarifCli.FunctionalTests/AnalyzeCommandTests.cs index a928289c0..e09aac703 100644 --- a/src/SarifCli.FunctionalTests/AnalyzeCommandTests.cs +++ b/src/SarifCli.FunctionalTests/AnalyzeCommandTests.cs @@ -12,12 +12,22 @@ public class AnalyzeCommandTests : SarifCliTestBase [Fact(DisplayName = nameof(AnalyzeCommand_ReportsJsonSyntaxError))] public void AnalyzeCommand_ReportsJsonSyntaxError() { - const string TestFileName = "SyntaxError.sarif"; + Verify("SyntaxError.sarif"); + } + + [Fact(DisplayName = nameof(AnalyzeCommand_ReportsDeserializationError))] + public void AnalyzeCommand_ReportsDeserializationError() + { + Verify("DeserializationError.sarif"); + } + + private void Verify(string testFileName) + { string testDirectory = Path.Combine(Environment.CurrentDirectory, TestDataDirectory); - string testFilePath = Path.Combine(TestDataDirectory, TestFileName); - string expectedFilePath = MakeExpectedFilePath(testDirectory, TestFileName); - string actualFilePath = MakeActualFilePath(testDirectory, TestFileName); + string testFilePath = Path.Combine(TestDataDirectory, testFileName); + string expectedFilePath = MakeExpectedFilePath(testDirectory, testFileName); + string actualFilePath = MakeActualFilePath(testDirectory, testFileName); var analyzeOptions = new AnalyzeOptions { diff --git a/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationEssentialIsObsoleteTests.cs b/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationEssentialIsObsoleteTests.cs index a58fadde0..fe32ad9a3 100644 --- a/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationEssentialIsObsoleteTests.cs +++ b/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationEssentialIsObsoleteTests.cs @@ -6,7 +6,7 @@ namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules { - class AnnotatedCodeLocationEssentialIsObsoleteTests : SkimmerTestsBase + public class AnnotatedCodeLocationEssentialIsObsoleteTests : SkimmerTestsBase { [Fact(DisplayName = nameof(AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationDoesNotHaveEssential))] public void AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationDoesNotHaveEssential() diff --git a/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationIdIsObsoleteTests.cs b/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationIdIsObsoleteTests.cs index 5bbeedd8c..db0eaed16 100644 --- a/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationIdIsObsoleteTests.cs +++ b/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationIdIsObsoleteTests.cs @@ -6,7 +6,7 @@ namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules { - class AnnotatedCodeLocationIdIsObsoleteTests : SkimmerTestsBase + public class AnnotatedCodeLocationIdIsObsoleteTests : SkimmerTestsBase { [Fact(DisplayName = nameof(AnnotatedCodeLocationIdIsObsolete_AnnotatedCodeLocationDoesNotHaveId))] public void AnnotatedCodeLocationIdIsObsolete_AnnotatedCodeLocationDoesNotHaveId() diff --git a/src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs b/src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs index f8314b28d..107c06954 100644 --- a/src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs +++ b/src/SarifCli.FunctionalTests/Rules/SkimmerTestsBase.cs @@ -4,7 +4,9 @@ using System; using System.IO; using Microsoft.CodeAnalysis.Sarif.Cli.Rules; +using Microsoft.CodeAnalysis.Sarif.Readers; using Microsoft.CodeAnalysis.Sarif.Writers; +using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules { @@ -19,6 +21,15 @@ protected void Verify(SarifValidationSkimmerBase skimmer, string testFileName) string expectedFilePath = MakeExpectedFilePath(testDirectory, testFileName); string actualFilePath = MakeActualFilePath(testDirectory, testFileName); + string inputLogContents = File.ReadAllText(targetPath); + + JsonSerializerSettings settings = new JsonSerializerSettings + { + ContractResolver = SarifContractResolver.Instance + }; + + SarifLog inputLog = JsonConvert.DeserializeObject(inputLogContents, settings); + using (var logger = new SarifLogger( actualFilePath, new string[] { targetPath }, @@ -35,7 +46,9 @@ protected void Verify(SarifValidationSkimmerBase skimmer, string testFileName) Rule = skimmer, Logger = logger, TargetUri = new Uri(targetPath), - SchemaFilePath = JsonSchemaFile + SchemaFilePath = JsonSchemaFile, + InputLogContents = inputLogContents, + InputLog = inputLog }; skimmer.Initialize(context); diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj index 69167573e..e66cf34fc 100644 --- a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -142,6 +142,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/src/SarifCli.FunctionalTests/TestData/DeserializationError.sarif b/src/SarifCli.FunctionalTests/TestData/DeserializationError.sarif new file mode 100644 index 000000000..b22c7db36 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/DeserializationError.sarif @@ -0,0 +1,38 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c" + } + } + ], + "stacks": [ + { + "frames": [ + { + "uri": "file:///c:/src/file.c", + "line": 42 + } + ] + } + ] + } + ], + "rules": { + "TST0001": { + "id": "TST0001", + "helpUri": "http://www.example.com/rules/tst0001.html" + } + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/DeserializationError_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/DeserializationError_Expected.sarif new file mode 100644 index 000000000..cbd2bb8eb --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/DeserializationError_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "c4c42f77-ff81-40a5-8fd3-93cc78ace9af", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "JS1002", + "level": "error", + "formattedRuleMessage": { + "formatId": "default", + "arguments": [ + "runs[0].results[0].stacks[0].frames[0]", + "fullyQualifiedLogicalName" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/DeserializationError.sarif", + "region": { + "startLine": 21, + "startColumn": 18 + } + } + } + ], + "properties": { + "jsonPath": "runs[0].results[0].stacks[0].frames[0]" + } + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/DeserializationError.sarif" + }, + "message": "Analyzing 'DeserializationError.sarif'...", + "level": "note", + "time": "2016-08-27T21:47:00.464Z" + } + ], + "rules": { + "JS1002": { + "id": "JS1002", + "name": "RequiredPropertyMissing", + "fullDescription": "A property required by the schema's \"required\" property is missing.", + "messageFormats": { + "default": "at \"{0}\": The required property \"{1}\" is missing." + }, + "defaultLevel": "error" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/DeserializationError.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\DeserializationError.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\DeserializationError_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-27T21:47:00.378Z", + "endTime": "2016-08-27T21:47:00.733Z", + "processId": 4696, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli/AnalyzeCommand.cs b/src/SarifCli/AnalyzeCommand.cs index c7fffafdd..c3fbb4657 100644 --- a/src/SarifCli/AnalyzeCommand.cs +++ b/src/SarifCli/AnalyzeCommand.cs @@ -7,8 +7,10 @@ using System.Linq; using System.Reflection; using Microsoft.CodeAnalysis.Sarif.Driver; +using Microsoft.CodeAnalysis.Sarif.Readers; using Microsoft.Json.Schema; using Microsoft.Json.Schema.Validation; +using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif.Cli { @@ -41,19 +43,57 @@ protected override SarifValidationContext CreateContext(AnalyzeOptions options, return context; } - protected override void AnalyzeTarget(IEnumerable> skimmers, SarifValidationContext context, HashSet disabledSkimmers) + protected override void AnalyzeTarget( + IEnumerable> skimmers, + SarifValidationContext context, + HashSet disabledSkimmers) { // The base class knows how to invoke the skimmers that implement smart validation, // but it doesn't know how to invoke schema validation, which has its own set of rules, // so we do that ourselves. + // + // Validate will return false if there are any JSON syntax errors. In that case + // there's no point in going on. bool ok = Validate(context.TargetUri.LocalPath, context.SchemaFilePath, context.Logger); if (ok) { - base.AnalyzeTarget(skimmers, context, disabledSkimmers); + // Deserialize will return null if there are any JSON deserialization errors + // (which can happen, for example, if a property required by the schema is + // missing. In that case, again, there's no point in going on. + context.InputLog = Deserialize(context); + + if (context.InputLog != null) + { + // Everything's ready, so run all the skimmers. + base.AnalyzeTarget(skimmers, context, disabledSkimmers); + } } } + private SarifLog Deserialize(SarifValidationContext context) + { + context.InputLogContents = File.ReadAllText(context.TargetUri.AbsolutePath); + + JsonSerializerSettings settings = new JsonSerializerSettings + { + ContractResolver = SarifContractResolver.Instance + }; + + SarifLog log = null; + try + { + return JsonConvert.DeserializeObject(context.InputLogContents, settings); + } + catch (JsonSerializationException) + { + // This exception can happen, for example, if a property required by the schema is + // missing. + } + + return log; + } + private bool Validate(string instanceFilePath, string schemaFilePath, IAnalysisLogger logger) { bool ok = true; diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs index b2eedc8db..3e85f3231 100644 --- a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -3,11 +3,9 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Resources; using Microsoft.CodeAnalysis.Sarif.Driver; -using Microsoft.CodeAnalysis.Sarif.Readers; using Microsoft.Json.Pointer; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -32,18 +30,9 @@ public override sealed void Analyze(SarifValidationContext context) { Context = context; - string logContents = File.ReadAllText(context.TargetUri.LocalPath); - _rootToken = JToken.Parse(logContents); + _rootToken = JToken.Parse(Context.InputLogContents); - JsonSerializerSettings settings = new JsonSerializerSettings - { - ContractResolver = SarifContractResolver.Instance - }; - - SarifLog log = JsonConvert.DeserializeObject(logContents, settings); - string logPointer = string.Empty; - - Visit(log, logPointer); + Visit(Context.InputLog, logPointer: string.Empty); } private void Visit(SarifLog log, string logPointer) diff --git a/src/SarifCli/SarifValidationContext.cs b/src/SarifCli/SarifValidationContext.cs index 37f37e77c..452055b90 100644 --- a/src/SarifCli/SarifValidationContext.cs +++ b/src/SarifCli/SarifValidationContext.cs @@ -3,7 +3,6 @@ using System; using System.IO; -using Newtonsoft.Json.Linq; namespace Microsoft.CodeAnalysis.Sarif.Cli { @@ -55,9 +54,9 @@ public Uri TargetUri public string SchemaFilePath { get; internal set; } - public SarifLog InputLog { get; internal set; } + public string InputLogContents { get; internal set; } - public JToken InputLogToken { get; internal set; } + public SarifLog InputLog { get; internal set; } public void Dispose() { From b2e999c60a27dcd599c8c5fe0cb3fe36ab236c30 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Sun, 28 Aug 2016 08:17:43 -0700 Subject: [PATCH 37/51] Bug fix: Tests failed because of misnamed test files --- ...nnotatedCodeLocationEssentialIsObsoleteTests.cs | 14 +++++++------- .../AnnotatedCodeLocationIdIsObsoleteTests.cs | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationEssentialIsObsoleteTests.cs b/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationEssentialIsObsoleteTests.cs index fe32ad9a3..a21eddaa8 100644 --- a/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationEssentialIsObsoleteTests.cs +++ b/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationEssentialIsObsoleteTests.cs @@ -11,19 +11,19 @@ public class AnnotatedCodeLocationEssentialIsObsoleteTests : SkimmerTestsBase [Fact(DisplayName = nameof(AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationDoesNotHaveEssential))] public void AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationDoesNotHaveEssential() { - Verify(new AnnotatedCodeLocationEssentialIsObsolete(), "AnnotatedCodeLocationDoesNotHaveId.sarif"); + Verify(new AnnotatedCodeLocationEssentialIsObsolete(), "AnnotatedCodeLocationDoesNotHaveEssential.sarif"); } - [Fact(DisplayName = nameof(AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationInCodeFlowHasEssential))] - public void AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationInCodeFlowHasEssential() + [Fact(DisplayName = nameof(AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationHasEssentialInCodeFlow))] + public void AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationHasEssentialInCodeFlow() { - Verify(new AnnotatedCodeLocationEssentialIsObsolete(), "AnnotatedCodeLocationInCodeFlowHasEssential.sarif"); + Verify(new AnnotatedCodeLocationEssentialIsObsolete(), "AnnotatedCodeLocationHasEssentialInCodeFlow.sarif"); } - [Fact(DisplayName = nameof(AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationInRelatedLocationHasEssential))] - public void AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationInRelatedLocationHasEssential() + [Fact(DisplayName = nameof(AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationHasEssentialInRelatedLocation))] + public void AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationHasEssentialInRelatedLocation() { - Verify(new AnnotatedCodeLocationEssentialIsObsolete(), "AnnotatedCodeLocationInRelatedLocationHasEssential.sarif"); + Verify(new AnnotatedCodeLocationEssentialIsObsolete(), "AnnotatedCodeLocationHasEssentialInRelatedLocation.sarif"); } } } diff --git a/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationIdIsObsoleteTests.cs b/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationIdIsObsoleteTests.cs index db0eaed16..ab965834d 100644 --- a/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationIdIsObsoleteTests.cs +++ b/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationIdIsObsoleteTests.cs @@ -14,16 +14,16 @@ public void AnnotatedCodeLocationIdIsObsolete_AnnotatedCodeLocationDoesNotHaveId Verify(new AnnotatedCodeLocationIdIsObsolete(), "AnnotatedCodeLocationDoesNotHaveId.sarif"); } - [Fact(DisplayName = nameof(AnnotatedCodeLocationIdIsObsolete_AnnotatedCodeLocationInCodeFlowHasId))] - public void AnnotatedCodeLocationIdIsObsolete_AnnotatedCodeLocationInCodeFlowHasId() + [Fact(DisplayName = nameof(AnnotatedCodeLocationIdIsObsolete_AnnotatedCodeLocationHasIdInCodeFlow))] + public void AnnotatedCodeLocationIdIsObsolete_AnnotatedCodeLocationHasIdInCodeFlow() { - Verify(new AnnotatedCodeLocationIdIsObsolete(), "AnnotatedCodeLocationInCodeFlowHasId.sarif"); + Verify(new AnnotatedCodeLocationIdIsObsolete(), "AnnotatedCodeLocationHasIdInCodeFlow.sarif"); } - [Fact(DisplayName = nameof(AnnotatedCodeLocationIdIsObsolete_AnnotatedCodeLocationInRelatedLocationHasId))] - public void AnnotatedCodeLocationIdIsObsolete_AnnotatedCodeLocationInRelatedLocationHasId() + [Fact(DisplayName = nameof(AnnotatedCodeLocationIdIsObsolete_AnnotatedCodeLocationHasIdInRelatedLocation))] + public void AnnotatedCodeLocationIdIsObsolete_AnnotatedCodeLocationHasIdInRelatedLocation() { - Verify(new AnnotatedCodeLocationIdIsObsolete(), "AnnotatedCodeLocationInRelatedLocationHasId.sarif"); + Verify(new AnnotatedCodeLocationIdIsObsolete(), "AnnotatedCodeLocationHasIdInRelatedLocation.sarif"); } } } From 1445d1c59f89026e694e3fa4c98bac5d7860c5c5 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Sun, 28 Aug 2016 09:33:24 -0700 Subject: [PATCH 38/51] Bug fix: Missed presence of default value for aCL.essential Just by looking at the object model, you can't tell if a property has its default value because the property is present with its default value in the log file (which would be a warning according to these rules), or whether it is missing altogether. To see the difference, you have to look directly at the JToken of the aCL object. --- ...tedCodeLocationEssentialIsObsoleteTests.cs | 12 +++ .../SarifCli.FunctionalTests.csproj | 12 +++ ...ocationHasDefaultEssentialInCodeFlow.sarif | 46 ++++++++++ ...sDefaultEssentialInCodeFlow_Expected.sarif | 84 +++++++++++++++++++ ...HasDefaultEssentialInRelatedLocation.sarif | 42 ++++++++++ ...tEssentialInRelatedLocation_Expected.sarif | 84 +++++++++++++++++++ src/SarifCli/AnalyzeCommand.cs | 9 +- ...nnotatedCodeLocationEssentialIsObsolete.cs | 9 +- .../Rules/SarifValidationSkimmerBase.cs | 6 +- src/SarifCli/SarifValidationContext.cs | 3 + 10 files changed, 297 insertions(+), 10 deletions(-) create mode 100644 src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasDefaultEssentialInCodeFlow.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasDefaultEssentialInCodeFlow_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasDefaultEssentialInRelatedLocation.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasDefaultEssentialInRelatedLocation_Expected.sarif diff --git a/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationEssentialIsObsoleteTests.cs b/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationEssentialIsObsoleteTests.cs index a21eddaa8..2da7db2ae 100644 --- a/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationEssentialIsObsoleteTests.cs +++ b/src/SarifCli.FunctionalTests/Rules/AnnotatedCodeLocationEssentialIsObsoleteTests.cs @@ -20,10 +20,22 @@ public void AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationHasEss Verify(new AnnotatedCodeLocationEssentialIsObsolete(), "AnnotatedCodeLocationHasEssentialInCodeFlow.sarif"); } + [Fact(DisplayName = nameof(AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationHasDefaultEssentialInCodeFlow))] + public void AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationHasDefaultEssentialInCodeFlow() + { + Verify(new AnnotatedCodeLocationEssentialIsObsolete(), "AnnotatedCodeLocationHasDefaultEssentialInCodeFlow.sarif"); + } + [Fact(DisplayName = nameof(AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationHasEssentialInRelatedLocation))] public void AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationHasEssentialInRelatedLocation() { Verify(new AnnotatedCodeLocationEssentialIsObsolete(), "AnnotatedCodeLocationHasEssentialInRelatedLocation.sarif"); } + + [Fact(DisplayName = nameof(AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationHasDefaultEssentialInRelatedLocation))] + public void AnnotatedCodeLocationEssentialIsObsolete_AnnotatedCodeLocationHasDefaultEssentialInRelatedLocation() + { + Verify(new AnnotatedCodeLocationEssentialIsObsolete(), "AnnotatedCodeLocationHasDefaultEssentialInRelatedLocation.sarif"); + } } } diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj index e66cf34fc..255d623fc 100644 --- a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -112,12 +112,24 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasDefaultEssentialInCodeFlow.sarif b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasDefaultEssentialInCodeFlow.sarif new file mode 100644 index 000000000..f47c9cf35 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasDefaultEssentialInCodeFlow.sarif @@ -0,0 +1,46 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "codeFlows": [ + { + "locations": [ + { + "essential": false, + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 42, + "startColumn": 12 + } + } + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasDefaultEssentialInCodeFlow_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasDefaultEssentialInCodeFlow_Expected.sarif new file mode 100644 index 000000000..52a9ecb7e --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasDefaultEssentialInCodeFlow_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "70bff1e1-2f05-4e43-9508-f7bd55b3a330", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0005", + "level": "warning", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "AnnotatedCodeLocationHasDefaultEssentialInCodeFlow.sarif", + "/runs/0/results/0/codeFlows/0/locations/0/essential" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasDefaultEssentialInCodeFlow.sarif", + "region": { + "startLine": 30, + "startColumn": 37 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasDefaultEssentialInCodeFlow.sarif" + }, + "message": "Analyzing 'AnnotatedCodeLocationHasDefaultEssentialInCodeFlow.sarif'...", + "level": "note", + "time": "2016-08-28T16:30:21.488Z" + } + ], + "rules": { + "SV0005": { + "id": "SV0005", + "name": "AnnotatedCodeLocationEssentialIsObsolete", + "shortDescription": "Do not use the obsolete \"essential\" property of the annotatedCodeLocation object.", + "fullDescription": "Do not use the obsolete \"essential\" property of the annotatedCodeLocation object. Instead use \"importance\", which is an string-valued property that must have one of the values \"essential\", \"important\", or \"unimportant\".", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the obsolete \"essential\" property is used. Remove it, and instead use the \"importance\" property, whose value is a string with one of the values \"essential\", \"important\", or \"unimportant\".", + "OnlyInCodeFlow": "In \"{0}\", at \"{1}\", the obsolete \"essential\" property is used. This property has been replaced by the \"importance\" property, but the \"importance\" property is used only in annotatedCodeLocations objects that occur within a code flow. Remove the \"essential\" property." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasDefaultEssentialInCodeFlow.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\AnnotatedCodeLocationEssentialIsObsolete\\AnnotatedCodeLocationHasDefaultEssentialInCodeFlow.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\AnnotatedCodeLocationEssentialIsObsolete\\AnnotatedCodeLocationHasDefaultEssentialInCodeFlow_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-28T16:30:21.409Z", + "endTime": "2016-08-28T16:30:21.738Z", + "processId": 15500, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasDefaultEssentialInRelatedLocation.sarif b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasDefaultEssentialInRelatedLocation.sarif new file mode 100644 index 000000000..e1663d2ee --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasDefaultEssentialInRelatedLocation.sarif @@ -0,0 +1,42 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default" + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "relatedLocations": [ + { + "essential": false, + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 42, + "startColumn": 12 + } + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasDefaultEssentialInRelatedLocation_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasDefaultEssentialInRelatedLocation_Expected.sarif new file mode 100644 index 000000000..f77641f36 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasDefaultEssentialInRelatedLocation_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "b2cc57c0-aac6-4468-a57d-5258774f0311", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0005", + "level": "warning", + "formattedRuleMessage": { + "formatId": "OnlyInCodeFlow", + "arguments": [ + "AnnotatedCodeLocationHasDefaultEssentialInRelatedLocation.sarif", + "/runs/0/results/0/relatedLocations/0/essential" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasDefaultEssentialInRelatedLocation.sarif", + "region": { + "startLine": 28, + "startColumn": 33 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasDefaultEssentialInRelatedLocation.sarif" + }, + "message": "Analyzing 'AnnotatedCodeLocationHasDefaultEssentialInRelatedLocation.sarif'...", + "level": "note", + "time": "2016-08-28T16:29:29.571Z" + } + ], + "rules": { + "SV0005": { + "id": "SV0005", + "name": "AnnotatedCodeLocationEssentialIsObsolete", + "shortDescription": "Do not use the obsolete \"essential\" property of the annotatedCodeLocation object.", + "fullDescription": "Do not use the obsolete \"essential\" property of the annotatedCodeLocation object. Instead use \"importance\", which is an string-valued property that must have one of the values \"essential\", \"important\", or \"unimportant\".", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the obsolete \"essential\" property is used. Remove it, and instead use the \"importance\" property, whose value is a string with one of the values \"essential\", \"important\", or \"unimportant\".", + "OnlyInCodeFlow": "In \"{0}\", at \"{1}\", the obsolete \"essential\" property is used. This property has been replaced by the \"importance\" property, but the \"importance\" property is used only in annotatedCodeLocations objects that occur within a code flow. Remove the \"essential\" property." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/AnnotatedCodeLocationEssentialIsObsolete/AnnotatedCodeLocationHasDefaultEssentialInRelatedLocation.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\AnnotatedCodeLocationEssentialIsObsolete\\AnnotatedCodeLocationHasDefaultEssentialInRelatedLocation.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\AnnotatedCodeLocationEssentialIsObsolete\\AnnotatedCodeLocationHasDefaultEssentialInRelatedLocation_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-28T16:29:29.400Z", + "endTime": "2016-08-28T16:29:29.900Z", + "processId": 2164, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli/AnalyzeCommand.cs b/src/SarifCli/AnalyzeCommand.cs index c3fbb4657..674492d3f 100644 --- a/src/SarifCli/AnalyzeCommand.cs +++ b/src/SarifCli/AnalyzeCommand.cs @@ -61,7 +61,8 @@ protected override void AnalyzeTarget( // Deserialize will return null if there are any JSON deserialization errors // (which can happen, for example, if a property required by the schema is // missing. In that case, again, there's no point in going on. - context.InputLog = Deserialize(context); + context.InputLogContents = File.ReadAllText(context.TargetUri.AbsolutePath); + context.InputLog = Deserialize(context.InputLogContents); if (context.InputLog != null) { @@ -71,10 +72,8 @@ protected override void AnalyzeTarget( } } - private SarifLog Deserialize(SarifValidationContext context) + private SarifLog Deserialize(string logContents) { - context.InputLogContents = File.ReadAllText(context.TargetUri.AbsolutePath); - JsonSerializerSettings settings = new JsonSerializerSettings { ContractResolver = SarifContractResolver.Instance @@ -83,7 +82,7 @@ private SarifLog Deserialize(SarifValidationContext context) SarifLog log = null; try { - return JsonConvert.DeserializeObject(context.InputLogContents, settings); + return JsonConvert.DeserializeObject(logContents, settings); } catch (JsonSerializationException) { diff --git a/src/SarifCli/Rules/AnnotatedCodeLocationEssentialIsObsolete.cs b/src/SarifCli/Rules/AnnotatedCodeLocationEssentialIsObsolete.cs index c8849ea4f..3df79594f 100644 --- a/src/SarifCli/Rules/AnnotatedCodeLocationEssentialIsObsolete.cs +++ b/src/SarifCli/Rules/AnnotatedCodeLocationEssentialIsObsolete.cs @@ -1,7 +1,11 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System; using System.Collections.Generic; +using System.Linq; +using Microsoft.Json.Pointer; +using Newtonsoft.Json.Linq; namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules { @@ -30,7 +34,10 @@ protected override IEnumerable FormatIds protected override void Analyze(AnnotatedCodeLocation annotatedCodeLocation, string annotatedCodeLocationPointer) { - if (annotatedCodeLocation.Essential) + var pointer = new JsonPointer(annotatedCodeLocationPointer); + JToken token = pointer.Evaluate(Context.InputLogToken); + + if (token.Children().Any(jp => jp.Name.Equals(SarifPropertyName.Essential, StringComparison.Ordinal))) { string essentialPointer = annotatedCodeLocationPointer.AtProperty(SarifPropertyName.Essential); diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs index 3e85f3231..0a6b79794 100644 --- a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -18,7 +18,6 @@ public abstract class SarifValidationSkimmerBase : SkimmerBase _defaultHelpUri; @@ -29,8 +28,7 @@ public abstract class SarifValidationSkimmerBase : SkimmerBase Date: Sun, 28 Aug 2016 19:05:46 -0700 Subject: [PATCH 39/51] Implement MessagesShouldEndWithPeriod rule --- .../Rules/MessagesShouldEndWithPeriodTests.cs | 59 ++++++++++ .../SarifCli.FunctionalTests.csproj | 49 ++++++++ ...atedCodeLocationMessageWithoutPeriod.sarif | 44 +++++++ ...ocationMessageWithoutPeriod_Expected.sarif | 84 ++++++++++++++ .../CodeFlowMessageWithoutPeriod.sarif | 44 +++++++ ...odeFlowMessageWithoutPeriod_Expected.sarif | 84 ++++++++++++++ .../NotificationMessageWithoutPeriod.sarif | 22 ++++ ...icationMessageWithoutPeriod_Expected.sarif | 107 +++++++++++++++++ .../PeriodsAfterAllMessages.sarif | 64 +++++++++++ .../PeriodsAfterAllMessages_Expected.sarif | 46 ++++++++ .../ResultMessageWithoutPeriod.sarif | 28 +++++ .../ResultMessageWithoutPeriod_Expected.sarif | 84 ++++++++++++++ .../RuleMessageFormatWithoutPeriod.sarif | 21 ++++ ...eMessageFormatWithoutPeriod_Expected.sarif | 107 +++++++++++++++++ .../StackFrameMessageWithoutPeriod.sarif | 38 ++++++ ...ckFrameMessageWithoutPeriod_Expected.sarif | 84 ++++++++++++++ .../StackMessageWithoutPeriod.sarif | 38 ++++++ .../StackMessageWithoutPeriod_Expected.sarif | 84 ++++++++++++++ .../Rules/MessagesShouldEndWithPeriod.cs | 101 ++++++++++++++++ src/SarifCli/Rules/RuleId.cs | 1 + src/SarifCli/Rules/RuleResources.Designer.cs | 18 +++ src/SarifCli/Rules/RuleResources.resx | 6 + .../Rules/SarifValidationSkimmerBase.cs | 108 +++++++++++------- src/SarifCli/SarifCli.csproj | 1 + src/SarifCli/SarifPropertyName.cs | 2 + 25 files changed, 1282 insertions(+), 42 deletions(-) create mode 100644 src/SarifCli.FunctionalTests/Rules/MessagesShouldEndWithPeriodTests.cs create mode 100644 src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/AnnotatedCodeLocationMessageWithoutPeriod.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/AnnotatedCodeLocationMessageWithoutPeriod_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/CodeFlowMessageWithoutPeriod.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/CodeFlowMessageWithoutPeriod_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/NotificationMessageWithoutPeriod.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/NotificationMessageWithoutPeriod_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/PeriodsAfterAllMessages.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/PeriodsAfterAllMessages_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/ResultMessageWithoutPeriod.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/ResultMessageWithoutPeriod_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/RuleMessageFormatWithoutPeriod.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/RuleMessageFormatWithoutPeriod_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/StackFrameMessageWithoutPeriod.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/StackFrameMessageWithoutPeriod_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/StackMessageWithoutPeriod.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/StackMessageWithoutPeriod_Expected.sarif create mode 100644 src/SarifCli/Rules/MessagesShouldEndWithPeriod.cs diff --git a/src/SarifCli.FunctionalTests/Rules/MessagesShouldEndWithPeriodTests.cs b/src/SarifCli.FunctionalTests/Rules/MessagesShouldEndWithPeriodTests.cs new file mode 100644 index 000000000..3099e3293 --- /dev/null +++ b/src/SarifCli.FunctionalTests/Rules/MessagesShouldEndWithPeriodTests.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.CodeAnalysis.Sarif.Cli.Rules; +using Xunit; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules +{ + public class MessagesShouldEndWithPeriodTests : SkimmerTestsBase + { + [Fact(DisplayName = nameof(MessagesShouldEndWithPeriod_AnnotatedCodeLocationDoesNotHaveEssential))] + public void MessagesShouldEndWithPeriod_AnnotatedCodeLocationDoesNotHaveEssential() + { + Verify(new MessagesShouldEndWithPeriod(), "PeriodsAfterAllMessages.sarif"); + } + + [Fact(DisplayName = nameof(MessagesShouldEndWithPeriod_AnnotatedCodeLocationMessageWithoutPeriod))] + public void MessagesShouldEndWithPeriod_AnnotatedCodeLocationMessageWithoutPeriod() + { + Verify(new MessagesShouldEndWithPeriod(), "AnnotatedCodeLocationMessageWithoutPeriod.sarif"); + } + + [Fact(DisplayName = nameof(MessagesShouldEndWithPeriod_CodeFlowMessageWithoutPeriod))] + public void MessagesShouldEndWithPeriod_CodeFlowMessageWithoutPeriod() + { + Verify(new MessagesShouldEndWithPeriod(), "CodeFlowMessageWithoutPeriod.sarif"); + } + + [Fact(DisplayName = nameof(MessagesShouldEndWithPeriod_NotificationMessageWithoutPeriod))] + public void MessagesShouldEndWithPeriod_NotificationMessageWithoutPeriod() + { + Verify(new MessagesShouldEndWithPeriod(), "NotificationMessageWithoutPeriod.sarif"); + } + + [Fact(DisplayName = nameof(MessagesShouldEndWithPeriod_ResultMessageWithoutPeriod))] + public void MessagesShouldEndWithPeriod_ResultMessageWithoutPeriod() + { + Verify(new MessagesShouldEndWithPeriod(), "ResultMessageWithoutPeriod.sarif"); + } + + [Fact(DisplayName = nameof(MessagesShouldEndWithPeriod_RuleMessageFormatWithoutPeriod))] + public void MessagesShouldEndWithPeriod_RuleMessageFormatWithoutPeriod() + { + Verify(new MessagesShouldEndWithPeriod(), "RuleMessageFormatWithoutPeriod.sarif"); + } + + [Fact(DisplayName = nameof(MessagesShouldEndWithPeriod_StackMessageWithoutPeriod))] + public void MessagesShouldEndWithPeriod_StackMessageWithoutPeriod() + { + Verify(new MessagesShouldEndWithPeriod(), "StackMessageWithoutPeriod.sarif"); + } + + [Fact(DisplayName = nameof(MessagesShouldEndWithPeriod_StackFrameMessageWithoutPeriod))] + public void MessagesShouldEndWithPeriod_StackFrameMessageWithoutPeriod() + { + Verify(new MessagesShouldEndWithPeriod(), "StackFrameMessageWithoutPeriod.sarif"); + } + } +} diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj index 255d623fc..188e6131a 100644 --- a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -91,6 +91,7 @@ + @@ -202,6 +203,51 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest @@ -334,6 +380,9 @@ PreserveNewest + + PreserveNewest + diff --git a/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/AnnotatedCodeLocationMessageWithoutPeriod.sarif b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/AnnotatedCodeLocationMessageWithoutPeriod.sarif new file mode 100644 index 000000000..9f6fd1f29 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/AnnotatedCodeLocationMessageWithoutPeriod.sarif @@ -0,0 +1,44 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message with period.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "codeFlows": [ + { + "locations": [ + { + "message": "CodeFlow location message without period", + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 42, + "startColumn": 12 + } + } + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/AnnotatedCodeLocationMessageWithoutPeriod_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/AnnotatedCodeLocationMessageWithoutPeriod_Expected.sarif new file mode 100644 index 000000000..531b395d3 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/AnnotatedCodeLocationMessageWithoutPeriod_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "4226acda-784d-43cc-a173-cb719bdbb27a", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0008", + "level": "warning", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "AnnotatedCodeLocationMessageWithoutPeriod.sarif", + "/runs/0/results/0/codeFlows/0/locations/0/message", + "CodeFlow location message without period" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/AnnotatedCodeLocationMessageWithoutPeriod.sarif", + "region": { + "startLine": 28, + "startColumn": 72 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/AnnotatedCodeLocationMessageWithoutPeriod.sarif" + }, + "message": "Analyzing 'AnnotatedCodeLocationMessageWithoutPeriod.sarif'...", + "level": "note", + "time": "2016-08-29T01:54:58.429Z" + } + ], + "rules": { + "SV0008": { + "id": "SV0008", + "name": "MessagesShouldEndWithPeriod", + "shortDescription": "Messages should consist of one or more complete sentences, ending with a period.", + "fullDescription": "Messages should consist of one or more complete sentences, ending with a period.", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the message \"{2}\" does not end with a period." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/AnnotatedCodeLocationMessageWithoutPeriod.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\MessagesShouldEndWithPeriod\\AnnotatedCodeLocationMessageWithoutPeriod.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\MessagesShouldEndWithPeriod\\AnnotatedCodeLocationMessageWithoutPeriod_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T01:54:58.335Z", + "endTime": "2016-08-29T01:54:58.685Z", + "processId": 14032, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/CodeFlowMessageWithoutPeriod.sarif b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/CodeFlowMessageWithoutPeriod.sarif new file mode 100644 index 000000000..c3c73f704 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/CodeFlowMessageWithoutPeriod.sarif @@ -0,0 +1,44 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message with period.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "codeFlows": [ + { + "message": "CodeFlow message without period", + "locations": [ + { + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 42, + "startColumn": 12 + } + } + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/CodeFlowMessageWithoutPeriod_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/CodeFlowMessageWithoutPeriod_Expected.sarif new file mode 100644 index 000000000..ae2132d44 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/CodeFlowMessageWithoutPeriod_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "c5cf9835-25a9-41ab-b8bf-f104557c4586", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0008", + "level": "warning", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "CodeFlowMessageWithoutPeriod.sarif", + "/runs/0/results/0/codeFlows/0/message", + "CodeFlow message without period" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/CodeFlowMessageWithoutPeriod.sarif", + "region": { + "startLine": 26, + "startColumn": 59 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/CodeFlowMessageWithoutPeriod.sarif" + }, + "message": "Analyzing 'CodeFlowMessageWithoutPeriod.sarif'...", + "level": "note", + "time": "2016-08-29T01:51:02.775Z" + } + ], + "rules": { + "SV0008": { + "id": "SV0008", + "name": "MessagesShouldEndWithPeriod", + "shortDescription": "Messages should consist of one or more complete sentences, ending with a period.", + "fullDescription": "Messages should consist of one or more complete sentences, ending with a period.", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the message \"{2}\" does not end with a period." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/CodeFlowMessageWithoutPeriod.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\MessagesShouldEndWithPeriod\\CodeFlowMessageWithoutPeriod.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\MessagesShouldEndWithPeriod\\CodeFlowMessageWithoutPeriod_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T01:51:02.681Z", + "endTime": "2016-08-29T01:51:03.041Z", + "processId": 18668, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/NotificationMessageWithoutPeriod.sarif b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/NotificationMessageWithoutPeriod.sarif new file mode 100644 index 000000000..2c171f3c4 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/NotificationMessageWithoutPeriod.sarif @@ -0,0 +1,22 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [], + "toolNotifications": [ + { + "message": "Run started" + } + ], + "configurationNotifications": [ + { + "message": "Using default configuration" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/NotificationMessageWithoutPeriod_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/NotificationMessageWithoutPeriod_Expected.sarif new file mode 100644 index 000000000..8eb481a80 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/NotificationMessageWithoutPeriod_Expected.sarif @@ -0,0 +1,107 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "6d939a43-9463-4adc-ae69-9b72175bb750", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0008", + "level": "warning", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "NotificationMessageWithoutPeriod.sarif", + "/runs/0/toolNotifications/0/message", + "Run started" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/NotificationMessageWithoutPeriod.sarif", + "region": { + "startLine": 12, + "startColumn": 35 + } + } + } + ] + }, + { + "ruleId": "SV0008", + "level": "warning", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "NotificationMessageWithoutPeriod.sarif", + "/runs/0/configurationNotifications/0/message", + "Using default configuration" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/NotificationMessageWithoutPeriod.sarif", + "region": { + "startLine": 17, + "startColumn": 51 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/NotificationMessageWithoutPeriod.sarif" + }, + "message": "Analyzing 'NotificationMessageWithoutPeriod.sarif'...", + "level": "note", + "time": "2016-08-29T02:03:26.927Z" + } + ], + "rules": { + "SV0008": { + "id": "SV0008", + "name": "MessagesShouldEndWithPeriod", + "shortDescription": "Messages should consist of one or more complete sentences, ending with a period.", + "fullDescription": "Messages should consist of one or more complete sentences, ending with a period.", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the message \"{2}\" does not end with a period." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/NotificationMessageWithoutPeriod.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\MessagesShouldEndWithPeriod\\NotificationMessageWithoutPeriod.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\MessagesShouldEndWithPeriod\\NotificationMessageWithoutPeriod_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T02:03:26.848Z", + "endTime": "2016-08-29T02:03:27.192Z", + "processId": 904, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/PeriodsAfterAllMessages.sarif b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/PeriodsAfterAllMessages.sarif new file mode 100644 index 000000000..2618c731b --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/PeriodsAfterAllMessages.sarif @@ -0,0 +1,64 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message with period.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "codeFlows": [ + { + "message": "CodeFlow message with period.", + "locations": [ + { + "message": "AnnotatedCodeLocation message with period.", + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 42, + "startColumn": 12 + } + } + } + ] + } + ], + "stacks": [ + { + "message": "Stack message with period.", + "frames": [ + { + "fullyQualifiedLogicalName": "func", + "message": "Frame message with period." + } + ] + } + ] + } + ], + "rules": { + "TST0001": { + "id": "TST0001", + "messageFormats": { + "Default": "Message format with period." + } + } + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/PeriodsAfterAllMessages_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/PeriodsAfterAllMessages_Expected.sarif new file mode 100644 index 000000000..844564001 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/PeriodsAfterAllMessages_Expected.sarif @@ -0,0 +1,46 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "c31ac324-eee6-453b-a725-026769de4c09", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/PeriodsAfterAllMessages.sarif" + }, + "message": "Analyzing 'PeriodsAfterAllMessages.sarif'...", + "level": "note", + "time": "2016-08-29T00:07:33.033Z" + } + ], + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/PeriodsAfterAllMessages.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\MessagesShouldEndWithPeriod\\PeriodsAfterAllMessages.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\MessagesShouldEndWithPeriod\\PeriodsAfterAllMessages_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T00:07:32.955Z", + "endTime": "2016-08-29T00:07:33.298Z", + "processId": 11668, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/ResultMessageWithoutPeriod.sarif b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/ResultMessageWithoutPeriod.sarif new file mode 100644 index 000000000..d1d70fa8d --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/ResultMessageWithoutPeriod.sarif @@ -0,0 +1,28 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message without period", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/ResultMessageWithoutPeriod_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/ResultMessageWithoutPeriod_Expected.sarif new file mode 100644 index 000000000..2c73748e0 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/ResultMessageWithoutPeriod_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "f55c1c12-1729-4c51-8dad-13caa2b192df", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0008", + "level": "warning", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "ResultMessageWithoutPeriod.sarif", + "/runs/0/results/0/message", + "Result message without period" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/ResultMessageWithoutPeriod.sarif", + "region": { + "startLine": 13, + "startColumn": 53 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/ResultMessageWithoutPeriod.sarif" + }, + "message": "Analyzing 'ResultMessageWithoutPeriod.sarif'...", + "level": "note", + "time": "2016-08-29T00:39:41.034Z" + } + ], + "rules": { + "SV0008": { + "id": "SV0008", + "name": "MessagesShouldEndWithPeriod", + "shortDescription": "Messages should consist of one or more complete sentences, ending with a period.", + "fullDescription": "Messages should consist of one or more complete sentences, ending with a period.", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the message \"{2}\" does not end with a period." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/ResultMessageWithoutPeriod.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\MessagesShouldEndWithPeriod\\ResultMessageWithoutPeriod.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\MessagesShouldEndWithPeriod\\ResultMessageWithoutPeriod_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T00:39:40.862Z", + "endTime": "2016-08-29T00:39:41.362Z", + "processId": 16724, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/RuleMessageFormatWithoutPeriod.sarif b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/RuleMessageFormatWithoutPeriod.sarif new file mode 100644 index 000000000..f7dbad2ae --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/RuleMessageFormatWithoutPeriod.sarif @@ -0,0 +1,21 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "rules": { + "TST0001": { + "id": "TST0001", + "messageFormats": { + "One": "Message format without period", + "Two": "Message format with period.", + "Three": "Another message format without period" + } + } + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/RuleMessageFormatWithoutPeriod_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/RuleMessageFormatWithoutPeriod_Expected.sarif new file mode 100644 index 000000000..7d5f7bf59 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/RuleMessageFormatWithoutPeriod_Expected.sarif @@ -0,0 +1,107 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "45d9024d-b8c1-4e7d-bbfe-10d3e0b2e521", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0008", + "level": "warning", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "RuleMessageFormatWithoutPeriod.sarif", + "/runs/0/rules/TST0001/messageFormats/One", + "Message format without period" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/RuleMessageFormatWithoutPeriod.sarif", + "region": { + "startLine": 13, + "startColumn": 51 + } + } + } + ] + }, + { + "ruleId": "SV0008", + "level": "warning", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "RuleMessageFormatWithoutPeriod.sarif", + "/runs/0/rules/TST0001/messageFormats/Three", + "Another message format without period" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/RuleMessageFormatWithoutPeriod.sarif", + "region": { + "startLine": 15, + "startColumn": 61 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/RuleMessageFormatWithoutPeriod.sarif" + }, + "message": "Analyzing 'RuleMessageFormatWithoutPeriod.sarif'...", + "level": "note", + "time": "2016-08-29T00:57:04.316Z" + } + ], + "rules": { + "SV0008": { + "id": "SV0008", + "name": "MessagesShouldEndWithPeriod", + "shortDescription": "Messages should consist of one or more complete sentences, ending with a period.", + "fullDescription": "Messages should consist of one or more complete sentences, ending with a period.", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the message \"{2}\" does not end with a period." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/RuleMessageFormatWithoutPeriod.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\MessagesShouldEndWithPeriod\\RuleMessageFormatWithoutPeriod.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\MessagesShouldEndWithPeriod\\RuleMessageFormatWithoutPeriod_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T00:57:04.223Z", + "endTime": "2016-08-29T00:57:04.566Z", + "processId": 1068, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/StackFrameMessageWithoutPeriod.sarif b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/StackFrameMessageWithoutPeriod.sarif new file mode 100644 index 000000000..e56eaec28 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/StackFrameMessageWithoutPeriod.sarif @@ -0,0 +1,38 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message with period.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "stacks": [ + { + "frames": [ + { + "message": "Stack frame message without period", + "fullyQualifiedLogicalName": "func" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/StackFrameMessageWithoutPeriod_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/StackFrameMessageWithoutPeriod_Expected.sarif new file mode 100644 index 000000000..e9b9e87a3 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/StackFrameMessageWithoutPeriod_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "9d6f7ec2-1b38-48fb-bb3c-955cc88f0e1d", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0008", + "level": "warning", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "StackFrameMessageWithoutPeriod.sarif", + "/runs/0/results/0/stacks/0/frames/0/message", + "Stack frame message without period" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/StackFrameMessageWithoutPeriod.sarif", + "region": { + "startLine": 28, + "startColumn": 66 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/StackFrameMessageWithoutPeriod.sarif" + }, + "message": "Analyzing 'StackFrameMessageWithoutPeriod.sarif'...", + "level": "note", + "time": "2016-08-29T01:18:35.506Z" + } + ], + "rules": { + "SV0008": { + "id": "SV0008", + "name": "MessagesShouldEndWithPeriod", + "shortDescription": "Messages should consist of one or more complete sentences, ending with a period.", + "fullDescription": "Messages should consist of one or more complete sentences, ending with a period.", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the message \"{2}\" does not end with a period." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/StackFrameMessageWithoutPeriod.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\MessagesShouldEndWithPeriod\\StackFrameMessageWithoutPeriod.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\MessagesShouldEndWithPeriod\\StackFrameMessgeWithoutPeriod_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T01:18:35.413Z", + "endTime": "2016-08-29T01:18:35.761Z", + "processId": 13460, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/StackMessageWithoutPeriod.sarif b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/StackMessageWithoutPeriod.sarif new file mode 100644 index 000000000..5e4548ebe --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/StackMessageWithoutPeriod.sarif @@ -0,0 +1,38 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message with period.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "stacks": [ + { + "message": "Stack message without period", + "frames": [ + { + "fullyQualifiedLogicalName": "func" + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/StackMessageWithoutPeriod_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/StackMessageWithoutPeriod_Expected.sarif new file mode 100644 index 000000000..d7da028bf --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/StackMessageWithoutPeriod_Expected.sarif @@ -0,0 +1,84 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "a873e1dd-d3e8-43ef-8120-cca5614ed720", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0008", + "level": "warning", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "StackMessageWithoutPeriod.sarif", + "/runs/0/results/0/stacks/0/message", + "Stack message without period" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/StackMessageWithoutPeriod.sarif", + "region": { + "startLine": 26, + "startColumn": 56 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/StackMessageWithoutPeriod.sarif" + }, + "message": "Analyzing 'StackMessageWithoutPeriod.sarif'...", + "level": "note", + "time": "2016-08-29T01:11:43.471Z" + } + ], + "rules": { + "SV0008": { + "id": "SV0008", + "name": "MessagesShouldEndWithPeriod", + "shortDescription": "Messages should consist of one or more complete sentences, ending with a period.", + "fullDescription": "Messages should consist of one or more complete sentences, ending with a period.", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the message \"{2}\" does not end with a period." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/MessagesShouldEndWithPeriod/StackMessageWithoutPeriod.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\MessagesShouldEndWithPeriod\\StackMessageWithoutPeriod.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\MessagesShouldEndWithPeriod\\StackMessgeWithoutPeriod_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T01:11:43.393Z", + "endTime": "2016-08-29T01:11:43.737Z", + "processId": 16720, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli/Rules/MessagesShouldEndWithPeriod.cs b/src/SarifCli/Rules/MessagesShouldEndWithPeriod.cs new file mode 100644 index 000000000..f24e109d2 --- /dev/null +++ b/src/SarifCli/Rules/MessagesShouldEndWithPeriod.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules +{ + public class MessagesShouldEndWithPeriod : SarifValidationSkimmerBase + { + public override string FullDescription => RuleResources.SV0008_MessagesShouldEndWithPeriod; + + public override ResultLevel DefaultLevel => ResultLevel.Warning; + + /// + /// SV0008 + /// + public override string Id => RuleId.MessagesShouldEndWithPeriod; + + protected override IEnumerable FormatIds + { + get + { + return new string[] + { + nameof(RuleResources.SV0008_Default) + }; + } + } + + protected override void Analyze(AnnotatedCodeLocation annotatedCodeLocation, string annotatedCodeLocationPointer) + { + Analyze(annotatedCodeLocation.Message, annotatedCodeLocationPointer); + } + + protected override void Analyze(CodeFlow codeFlow, string codeFlowPointer) + { + Analyze(codeFlow.Message, codeFlowPointer); + } + + protected override void Analyze(Notification notification, string notificationPointer) + { + Analyze(notification.Message, notificationPointer); + } + + protected override void Analyze(Result result, string resultPointer) + { + Analyze(result.Message, resultPointer); + } + + protected override void Analyze(Rule rule, string rulePointer) + { + if (rule.MessageFormats != null) + { + foreach (string formatId in rule.MessageFormats.Keys) + { + string messageFormat = rule.MessageFormats[formatId]; + if (DoesNotEndWithPeriod(messageFormat)) + { + string messagePointer = rulePointer + .AtProperty(SarifPropertyName.MessageFormats) + .AtProperty(formatId); + + LogResult( + messagePointer, + nameof(RuleResources.SV0008_Default), + messageFormat); + } + } + } + } + + protected override void Analyze(Stack stack, string stackPointer) + { + Analyze(stack.Message, stackPointer); + } + + protected override void Analyze(StackFrame frame, string framePointer) + { + Analyze(frame.Message, framePointer); + } + + private void Analyze(string message, string pointer) + { + if (DoesNotEndWithPeriod(message)) + { + string messagePointer = pointer.AtProperty(SarifPropertyName.Message); + + LogResult( + messagePointer, + nameof(RuleResources.SV0008_Default), + message); + } + } + + private static bool DoesNotEndWithPeriod(string message) + { + return message != null && !message.EndsWith(".", StringComparison.Ordinal); + } + } +} diff --git a/src/SarifCli/Rules/RuleId.cs b/src/SarifCli/Rules/RuleId.cs index 0151ccecd..f3e7748a0 100644 --- a/src/SarifCli/Rules/RuleId.cs +++ b/src/SarifCli/Rules/RuleId.cs @@ -12,5 +12,6 @@ public static class RuleId public const string AnnotatedCodeLocationEssentialIsObsolete = "SV0005"; public const string HashAlgorithmsMustBeUnique = "SV0006"; public const string EndTimeMustBeAfterStartTime = "SV0007"; + public const string MessagesShouldEndWithPeriod = "SV0008"; } } diff --git a/src/SarifCli/Rules/RuleResources.Designer.cs b/src/SarifCli/Rules/RuleResources.Designer.cs index 2a1c0abc1..64292627e 100644 --- a/src/SarifCli/Rules/RuleResources.Designer.cs +++ b/src/SarifCli/Rules/RuleResources.Designer.cs @@ -203,5 +203,23 @@ internal static string SV0007_EndTimeMustBeAfterStartTime { return ResourceManager.GetString("SV0007_EndTimeMustBeAfterStartTime", resourceCulture); } } + + /// + /// Looks up a localized string similar to In "{0}", at "{1}", the message "{2}" does not end with a period.. + /// + internal static string SV0008_Default { + get { + return ResourceManager.GetString("SV0008_Default", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Messages should consist of one or more complete sentences, ending with a period.. + /// + internal static string SV0008_MessagesShouldEndWithPeriod { + get { + return ResourceManager.GetString("SV0008_MessagesShouldEndWithPeriod", resourceCulture); + } + } } } diff --git a/src/SarifCli/Rules/RuleResources.resx b/src/SarifCli/Rules/RuleResources.resx index 552ba25b5..f64d27a33 100644 --- a/src/SarifCli/Rules/RuleResources.resx +++ b/src/SarifCli/Rules/RuleResources.resx @@ -165,4 +165,10 @@ The end time of a run must be after the start time. To allow for the possibility that the duration of the run is less than the resolution of the string representation of the time, the start time and the end time may be equal. + + In "{0}", at "{1}", the message "{2}" does not end with a period. + + + Messages should consist of one or more complete sentences, ending with a period. + \ No newline at end of file diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs index 0a6b79794..39ff609c1 100644 --- a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -33,6 +33,64 @@ public override sealed void Analyze(SarifValidationContext context) Visit(Context.InputLog, logPointer: string.Empty); } + protected void LogResult(string jPointer, string formatId, params string[] args) + { + Region region = GetRegionFromJPointer(jPointer); + + // All messages start with "In {file}, at {jPointer}, ...". Prepend the jPointer to the args. + // The Sarif.Driver framework will take care of prepending the file name. + string[] argsWithPointer = new string[args.Length + 1]; + Array.Copy(args, 0, argsWithPointer, 1, args.Length); + argsWithPointer[0] = jPointer; + + Context.Logger.Log(this, + RuleUtilities.BuildResult(DefaultLevel, Context, region, formatId, argsWithPointer)); + } + + protected virtual void Analyze(AnnotatedCodeLocation annotatedCodeLocation, string annotatedCodeLocationPointer) + { + } + + protected virtual void Analyze(CodeFlow codeFlow, string codeFlowPointer) + { + } + + protected virtual void Analyze(FileChange fileChange, string fileChangePointer) + { + } + + protected virtual void Analyze(FileData fileData, string fileKey, string filePointer) + { + } + + protected virtual void Analyze(Invocation invocation, string invocationPointer) + { + } + + protected virtual void Analyze(Notification notification, string notificationPointer) + { + } + + protected virtual void Analyze(PhysicalLocation physicalLocation, string physicalLocationPointer) + { + } + + protected virtual void Analyze(Result result, string resultPointer) + { + } + + protected virtual void Analyze(Rule rule, string rulePointer) + { + } + + protected virtual void Analyze(Stack stack, string stackPointer) + { + } + + protected virtual void Analyze(StackFrame frame, string framePointer) + { + } + private void Visit(SarifLog log, string logPointer) { if (log.Runs != null) @@ -63,6 +121,8 @@ private void Visit(AnnotatedCodeLocation annotatedCodeLocation, string annotated private void Visit(CodeFlow codeFlow, string codeFlowPointer) { + Analyze(codeFlow, codeFlowPointer); + if (codeFlow.Locations != null) { AnnotatedCodeLocation[] annotatedCodeLocations = codeFlow.Locations.ToArray(); @@ -127,6 +187,8 @@ private void Visit(Location location, string locationPointer) private void Visit(Notification notification, string notificationPointer) { + Analyze(notification, notificationPointer); + if (notification.PhysicalLocation != null) { string physicalLocationPointer = notificationPointer.AtProperty(SarifPropertyName.PhysicalLocation); @@ -142,6 +204,8 @@ private void Visit(PhysicalLocation physicalLocation, string physicalLocationPoi private void Visit(Result result, string resultPointer) { + Analyze(result, resultPointer); + if (result.Locations != null) { Location[] locations = result.Locations.ToArray(); @@ -292,6 +356,8 @@ private void Visit(IList notifications, string parentPointer, stri private void Visit(Stack stack, string stackPointer) { + Analyze(stack, stackPointer); + if (stack.Frames != null) { StackFrame[] frames = stack.Frames.ToArray(); @@ -312,48 +378,6 @@ private void Visit(StackFrame frame, string framePointer) Analyze(frame, framePointer); } - protected virtual void Analyze(AnnotatedCodeLocation annotatedCodeLocation, string annotatedCodeLocationPointer) - { - } - - protected virtual void Analyze(FileChange fileChange, string fileChangePointer) - { - } - - protected virtual void Analyze(FileData fileData, string fileKey, string filePointer) - { - } - - protected virtual void Analyze(Invocation invocation, string invocationPointer) - { - } - - protected virtual void Analyze(PhysicalLocation physicalLocation, string physicalLocationPointer) - { - } - - protected virtual void Analyze(Rule rule, string rulePointer) - { - } - - protected virtual void Analyze(StackFrame frame, string framePointer) - { - } - - protected void LogResult(string jPointer, string formatId, params string[] args) - { - Region region = GetRegionFromJPointer(jPointer); - - // All messages start with "In {file}, at {jPointer}, ...". Prepend the jPointer to the args. - // The Sarif.Driver framework will take care of prepending the file name. - string[] argsWithPointer = new string[args.Length + 1]; - Array.Copy(args, 0, argsWithPointer, 1, args.Length); - argsWithPointer[0] = jPointer; - - Context.Logger.Log(this, - RuleUtilities.BuildResult(DefaultLevel, Context, region, formatId, argsWithPointer)); - } - private Region GetRegionFromJPointer(string jPointer) { JsonPointer jsonPointer = new JsonPointer(jPointer); diff --git a/src/SarifCli/SarifCli.csproj b/src/SarifCli/SarifCli.csproj index 5413597fb..701021ec0 100644 --- a/src/SarifCli/SarifCli.csproj +++ b/src/SarifCli/SarifCli.csproj @@ -101,6 +101,7 @@ + diff --git a/src/SarifCli/SarifPropertyName.cs b/src/SarifCli/SarifPropertyName.cs index 08db23458..6d977b54d 100644 --- a/src/SarifCli/SarifPropertyName.cs +++ b/src/SarifCli/SarifPropertyName.cs @@ -18,6 +18,8 @@ public static class SarifPropertyName public const string Id = "id"; public const string Invocation = "invocation"; public const string Locations = "locations"; + public const string Message = "message"; + public const string MessageFormats = "messageFormats"; public const string PhysicalLocation = "physicalLocation"; public const string RelatedLocations = "relatedLocations"; public const string ResultFile = "resultFile"; From 0d70945e25450b0547defb4d710349ed0854e3ff Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Mon, 29 Aug 2016 07:19:09 -0700 Subject: [PATCH 40/51] Implement StepMustIncreaseByOneFromOne (NotPresentOnAll) Partial implementation of the rule that validates the values of the aCL.step property. Still to do: must start with 1 and must increment by 1. --- .../Rules/StepMustIncreaseByOneFromOne.cs | 23 +++++ .../SarifCli.FunctionalTests.csproj | 13 +++ .../StepNotPresentOnAllLocations.sarif | 63 ++++++++++++ ...tepNotPresentOnAllLocations_Expected.sarif | 83 ++++++++++++++++ .../ValidSteps.sarif | 64 +++++++++++++ .../ValidSteps_Expected.sarif | 46 +++++++++ src/SarifCli/Rules/RuleId.cs | 1 + src/SarifCli/Rules/RuleResources.Designer.cs | 18 ++++ src/SarifCli/Rules/RuleResources.resx | 6 ++ .../Rules/StepMustIncreaseByOneFromOne.cs | 95 +++++++++++++++++++ src/SarifCli/SarifCli.csproj | 1 + src/SarifCli/SarifPropertyName.cs | 1 + 12 files changed, 414 insertions(+) create mode 100644 src/SarifCli.FunctionalTests/Rules/StepMustIncreaseByOneFromOne.cs create mode 100644 src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/StepNotPresentOnAllLocations.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/StepNotPresentOnAllLocations_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/ValidSteps.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/ValidSteps_Expected.sarif create mode 100644 src/SarifCli/Rules/StepMustIncreaseByOneFromOne.cs diff --git a/src/SarifCli.FunctionalTests/Rules/StepMustIncreaseByOneFromOne.cs b/src/SarifCli.FunctionalTests/Rules/StepMustIncreaseByOneFromOne.cs new file mode 100644 index 000000000..d56485610 --- /dev/null +++ b/src/SarifCli.FunctionalTests/Rules/StepMustIncreaseByOneFromOne.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.CodeAnalysis.Sarif.Cli.Rules; +using Xunit; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules +{ + public class StepMustIncreaseByOneFromOneTests : SkimmerTestsBase + { + [Fact(DisplayName = nameof(StepMustIncreaseByOneFromOne_ValidSteps))] + public void StepMustIncreaseByOneFromOne_ValidSteps() + { + Verify(new StepMustIncreaseByOneFromOne(), "ValidSteps.sarif"); + } + + [Fact(DisplayName = nameof(StepMustIncreaseByOneFromOne_StepNotPresentOnAllLocations))] + public void StepMustIncreaseByOneFromOne_StepNotPresentOnAllLocations() + { + Verify(new StepMustIncreaseByOneFromOne(), "StepNotPresentOnAllLocations.sarif"); + } + } +} diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj index 188e6131a..fcf93cd2d 100644 --- a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -86,6 +86,7 @@ + @@ -248,6 +249,18 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/StepNotPresentOnAllLocations.sarif b/src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/StepNotPresentOnAllLocations.sarif new file mode 100644 index 000000000..9d09fb090 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/StepNotPresentOnAllLocations.sarif @@ -0,0 +1,63 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message with period.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "codeFlows": [ + { + "locations": [ + { + "step": 1, + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 42, + "startColumn": 12 + } + } + }, + { + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 43, + "startColumn": 12 + } + } + }, + { + "step": 3, + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 44, + "startColumn": 12 + } + } + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/StepNotPresentOnAllLocations_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/StepNotPresentOnAllLocations_Expected.sarif new file mode 100644 index 000000000..bf5179e07 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/StepNotPresentOnAllLocations_Expected.sarif @@ -0,0 +1,83 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "c8e08f7b-e61b-4cd0-9c03-85747743db3f", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0009", + "level": "error", + "formattedRuleMessage": { + "formatId": "StepNotPresentOnAllLocations", + "arguments": [ + "StepNotPresentOnAllLocations.sarif", + "/runs/0/results/0/codeFlows/0/locations/1" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/StepNotPresentOnAllLocations.sarif", + "region": { + "startLine": 37, + "startColumn": 18 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/StepNotPresentOnAllLocations.sarif" + }, + "message": "Analyzing 'StepNotPresentOnAllLocations.sarif'...", + "level": "note", + "time": "2016-08-29T13:54:49.704Z" + } + ], + "rules": { + "SV0009": { + "id": "SV0009", + "name": "StepMustIncreaseByOneFromOne", + "shortDescription": "If the \"step\" property is used on any annotatedCodeLocation in a code flow, then it must be present for every location in the code flow, its value must be 1 for the first location, and its value must increase by 1 for each succeeding location.", + "fullDescription": "If the \"step\" property is used on any annotatedCodeLocation in a code flow, then it must be present for every location in the code flow, its value must be 1 for the first location, and its value must increase by 1 for each succeeding location.", + "messageFormats": { + "StepNotPresentOnAllLocations": "In \"{0}\", at \"{1}\", the \"step\" property is absent. The \"step\" property is present on some but not all locations in this code flow. If the \"step\" property is used on any location in a code flow, it must be present on every location in that code flow." + }, + "defaultLevel": "error", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/StepNotPresentOnAllLocations.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\StepMustIncreaseByOneFromOne\\StepNotPresentOnAllLocations.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\StepMustIncreaseByOneFromOne\\StepNotPresentOnAllLocations_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T13:54:49.625Z", + "endTime": "2016-08-29T13:54:50.000Z", + "processId": 8808, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/ValidSteps.sarif b/src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/ValidSteps.sarif new file mode 100644 index 000000000..7d9515830 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/ValidSteps.sarif @@ -0,0 +1,64 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message with period.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "codeFlows": [ + { + "locations": [ + { + "step": 1, + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 42, + "startColumn": 12 + } + } + }, + { + "step": 2, + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 43, + "startColumn": 12 + } + } + }, + { + "step": 3, + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 44, + "startColumn": 12 + } + } + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/ValidSteps_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/ValidSteps_Expected.sarif new file mode 100644 index 000000000..7eae808aa --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/ValidSteps_Expected.sarif @@ -0,0 +1,46 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "90d42f85-74c7-4301-bc4b-2dbf98453f46", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/ValidSteps.sarif" + }, + "message": "Analyzing 'ValidSteps.sarif'...", + "level": "note", + "time": "2016-08-29T13:40:25.242Z" + } + ], + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/ValidSteps.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\StepMustIncreaseByOneFromOne\\ValidSteps.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\StepMustIncreaseByOneFromOne\\ValidSteps_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T13:40:25.054Z", + "endTime": "2016-08-29T13:40:25.554Z", + "processId": 8500, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli/Rules/RuleId.cs b/src/SarifCli/Rules/RuleId.cs index f3e7748a0..0e231e49d 100644 --- a/src/SarifCli/Rules/RuleId.cs +++ b/src/SarifCli/Rules/RuleId.cs @@ -13,5 +13,6 @@ public static class RuleId public const string HashAlgorithmsMustBeUnique = "SV0006"; public const string EndTimeMustBeAfterStartTime = "SV0007"; public const string MessagesShouldEndWithPeriod = "SV0008"; + public const string StepMustIncreaseByOneFromOne = "SV0009"; } } diff --git a/src/SarifCli/Rules/RuleResources.Designer.cs b/src/SarifCli/Rules/RuleResources.Designer.cs index 64292627e..f24b59b93 100644 --- a/src/SarifCli/Rules/RuleResources.Designer.cs +++ b/src/SarifCli/Rules/RuleResources.Designer.cs @@ -221,5 +221,23 @@ internal static string SV0008_MessagesShouldEndWithPeriod { return ResourceManager.GetString("SV0008_MessagesShouldEndWithPeriod", resourceCulture); } } + + /// + /// Looks up a localized string similar to If the "step" property is used on any annotatedCodeLocation in a code flow, then it must be present for every location in the code flow, its value must be 1 for the first location, and its value must increase by 1 for each succeeding location.. + /// + internal static string SV0009_StepMustIncreaseByOneFromOne { + get { + return ResourceManager.GetString("SV0009_StepMustIncreaseByOneFromOne", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to In "{0}", at "{1}", the "step" property is absent. The "step" property is present on some but not all locations in this code flow. If the "step" property is used on any location in a code flow, it must be present on every location in that code flow.. + /// + internal static string SV0009_StepNotPresentOnAllLocations { + get { + return ResourceManager.GetString("SV0009_StepNotPresentOnAllLocations", resourceCulture); + } + } } } diff --git a/src/SarifCli/Rules/RuleResources.resx b/src/SarifCli/Rules/RuleResources.resx index f64d27a33..2d5028a7c 100644 --- a/src/SarifCli/Rules/RuleResources.resx +++ b/src/SarifCli/Rules/RuleResources.resx @@ -171,4 +171,10 @@ Messages should consist of one or more complete sentences, ending with a period. + + If the "step" property is used on any annotatedCodeLocation in a code flow, then it must be present for every location in the code flow, its value must be 1 for the first location, and its value must increase by 1 for each succeeding location. + + + In "{0}", at "{1}", the "step" property is absent. The "step" property is present on some but not all locations in this code flow. If the "step" property is used on any location in a code flow, it must be present on every location in that code flow. + \ No newline at end of file diff --git a/src/SarifCli/Rules/StepMustIncreaseByOneFromOne.cs b/src/SarifCli/Rules/StepMustIncreaseByOneFromOne.cs new file mode 100644 index 000000000..e0b04e95e --- /dev/null +++ b/src/SarifCli/Rules/StepMustIncreaseByOneFromOne.cs @@ -0,0 +1,95 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using Microsoft.Json.Pointer; +using Newtonsoft.Json.Linq; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules +{ + public class StepMustIncreaseByOneFromOne : SarifValidationSkimmerBase + { + public override string FullDescription => RuleResources.SV0009_StepMustIncreaseByOneFromOne; + + public override ResultLevel DefaultLevel => ResultLevel.Error; + + /// + /// SV0009 + /// + public override string Id => RuleId.StepMustIncreaseByOneFromOne; + + protected override IEnumerable FormatIds + { + get + { + return new string[] + { + nameof(RuleResources.SV0009_StepNotPresentOnAllLocations) + }; + } + } + + protected override void Analyze(CodeFlow codeFlow, string codeFlowPointer) + { + var pointer = new JsonPointer(codeFlowPointer); + JToken codeFlowToken = pointer.Evaluate(Context.InputLogToken); + + JProperty locationsProperty = codeFlowToken.Children() + .FirstOrDefault(prop => prop.Name.Equals(SarifPropertyName.Locations, StringComparison.Ordinal)); + if (locationsProperty != null) + { + JArray annotatedCodeLocationArray = locationsProperty.Value as JArray; + string annotatedCodeLocationsPointer = codeFlowPointer.AtProperty(SarifPropertyName.Locations); + + ReportMissingStepProperty(annotatedCodeLocationArray, annotatedCodeLocationsPointer); + } + } + + private void ReportMissingStepProperty( + JArray annotatedCodeLocationArray, + string annotatedCodeLocationsPointer) + { + JObject[] annotatedCodeLocationObjects = annotatedCodeLocationArray.Children().ToArray(); + if (annotatedCodeLocationObjects.Length > 0) + { + JObject[] locationsWithStep = GetLocationsWithStep(annotatedCodeLocationObjects); + if (locationsWithStep.Length < annotatedCodeLocationObjects.Length) + { + int missingStepIndex = FindFirstLocationWithMissingStep(annotatedCodeLocationObjects); + Debug.Assert(missingStepIndex != -1, "Couldn't find location with missing step."); + + string missingStepPointer = annotatedCodeLocationsPointer.AtIndex(missingStepIndex); + + LogResult(missingStepPointer, nameof(RuleResources.SV0009_StepNotPresentOnAllLocations)); + } + } + } + + private int FindFirstLocationWithMissingStep(JObject[] annotatedCodeLocationObjects) + { + int index = -1; + + for (int i = 0; i < annotatedCodeLocationObjects.Length; ++i) + { + if (!annotatedCodeLocationObjects[i].Children().Any(prop => prop.Name.Equals(SarifPropertyName.Step, StringComparison.Ordinal))) + { + index = i; + break; + } + } + + return index; + } + + private static JObject[] GetLocationsWithStep(JObject[] annotatedCodeLocationObjects) + { + return annotatedCodeLocationObjects + .Where(loc => loc.Children().Any( + prop => prop.Name.Equals(SarifPropertyName.Step, StringComparison.Ordinal))) + .ToArray(); + } + } +} diff --git a/src/SarifCli/SarifCli.csproj b/src/SarifCli/SarifCli.csproj index 701021ec0..93baa11ff 100644 --- a/src/SarifCli/SarifCli.csproj +++ b/src/SarifCli/SarifCli.csproj @@ -87,6 +87,7 @@ + diff --git a/src/SarifCli/SarifPropertyName.cs b/src/SarifCli/SarifPropertyName.cs index 6d977b54d..d07a2113c 100644 --- a/src/SarifCli/SarifPropertyName.cs +++ b/src/SarifCli/SarifPropertyName.cs @@ -27,6 +27,7 @@ public static class SarifPropertyName public const string Rules = "rules"; public const string Runs = "runs"; public const string Stacks = "stacks"; + public const string Step = "step"; public const string ToolNotifications = "toolNotifications"; public const string Uri = "uri"; } From 78d9a5e89338f3054584dc0e290b4dd5cd3162d5 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Mon, 29 Aug 2016 09:32:19 -0700 Subject: [PATCH 41/51] StepValuesMustFormOneBasedSequence (InvalidStepValue) --- .../Rules/StepMustIncreaseByOneFromOne.cs | 23 --- ...StepValuesMustFormOneBasedSequenceTests.cs | 35 +++++ .../SarifCli.FunctionalTests.csproj | 22 ++- .../InvalidStepValues.sarif | 63 +++++++++ .../InvalidStepValues_Expected.sarif | 132 ++++++++++++++++++ .../NoStepsPresent.sarif | 61 ++++++++ .../NoStepsPresent_Expected.sarif | 46 ++++++ .../StepNotPresentOnAllLocations.sarif | 2 +- ...tepNotPresentOnAllLocations_Expected.sarif | 0 .../ValidSteps.sarif | 2 +- .../ValidSteps_Expected.sarif | 0 src/SarifCli/Rules/RuleId.cs | 2 +- src/SarifCli/Rules/RuleResources.Designer.cs | 15 +- src/SarifCli/Rules/RuleResources.resx | 7 +- ... => StepValuesMustFormOneBasedSequence.cs} | 62 ++++++-- src/SarifCli/SarifCli.csproj | 2 +- 16 files changed, 429 insertions(+), 45 deletions(-) delete mode 100644 src/SarifCli.FunctionalTests/Rules/StepMustIncreaseByOneFromOne.cs create mode 100644 src/SarifCli.FunctionalTests/Rules/StepValuesMustFormOneBasedSequenceTests.cs create mode 100644 src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/InvalidStepValues.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/InvalidStepValues_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/NoStepsPresent.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/NoStepsPresent_Expected.sarif rename src/SarifCli.FunctionalTests/TestData/{StepMustIncreaseByOneFromOne => StepValuesMustFormOneBasedSequence}/StepNotPresentOnAllLocations.sarif (96%) rename src/SarifCli.FunctionalTests/TestData/{StepMustIncreaseByOneFromOne => StepValuesMustFormOneBasedSequence}/StepNotPresentOnAllLocations_Expected.sarif (100%) rename src/SarifCli.FunctionalTests/TestData/{StepMustIncreaseByOneFromOne => StepValuesMustFormOneBasedSequence}/ValidSteps.sarif (96%) rename src/SarifCli.FunctionalTests/TestData/{StepMustIncreaseByOneFromOne => StepValuesMustFormOneBasedSequence}/ValidSteps_Expected.sarif (100%) rename src/SarifCli/Rules/{StepMustIncreaseByOneFromOne.cs => StepValuesMustFormOneBasedSequence.cs} (55%) diff --git a/src/SarifCli.FunctionalTests/Rules/StepMustIncreaseByOneFromOne.cs b/src/SarifCli.FunctionalTests/Rules/StepMustIncreaseByOneFromOne.cs deleted file mode 100644 index d56485610..000000000 --- a/src/SarifCli.FunctionalTests/Rules/StepMustIncreaseByOneFromOne.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) Microsoft. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Microsoft.CodeAnalysis.Sarif.Cli.Rules; -using Xunit; - -namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules -{ - public class StepMustIncreaseByOneFromOneTests : SkimmerTestsBase - { - [Fact(DisplayName = nameof(StepMustIncreaseByOneFromOne_ValidSteps))] - public void StepMustIncreaseByOneFromOne_ValidSteps() - { - Verify(new StepMustIncreaseByOneFromOne(), "ValidSteps.sarif"); - } - - [Fact(DisplayName = nameof(StepMustIncreaseByOneFromOne_StepNotPresentOnAllLocations))] - public void StepMustIncreaseByOneFromOne_StepNotPresentOnAllLocations() - { - Verify(new StepMustIncreaseByOneFromOne(), "StepNotPresentOnAllLocations.sarif"); - } - } -} diff --git a/src/SarifCli.FunctionalTests/Rules/StepValuesMustFormOneBasedSequenceTests.cs b/src/SarifCli.FunctionalTests/Rules/StepValuesMustFormOneBasedSequenceTests.cs new file mode 100644 index 000000000..6829b9872 --- /dev/null +++ b/src/SarifCli.FunctionalTests/Rules/StepValuesMustFormOneBasedSequenceTests.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.CodeAnalysis.Sarif.Cli.Rules; +using Xunit; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules +{ + public class StepValuesMustFormOneBasedSequenceTests : SkimmerTestsBase + { + [Fact(DisplayName = nameof(StepValuesMustFormOneBasedSequence_ValidSteps))] + public void StepValuesMustFormOneBasedSequence_ValidSteps() + { + Verify(new StepValuesMustFormOneBasedSequence(), "ValidSteps.sarif"); + } + + [Fact(DisplayName = nameof(StepValuesMustFormOneBasedSequence_NoStepsPresent))] + public void StepValuesMustFormOneBasedSequence_NoStepsPresent() + { + Verify(new StepValuesMustFormOneBasedSequence(), "NoStepsPresent.sarif"); + } + + [Fact(DisplayName = nameof(StepValuesMustFormOneBasedSequence_StepNotPresentOnAllLocations))] + public void StepValuesMustFormOneBasedSequence_StepNotPresentOnAllLocations() + { + Verify(new StepValuesMustFormOneBasedSequence(), "StepNotPresentOnAllLocations.sarif"); + } + + [Fact(DisplayName = nameof(StepValuesMustFormOneBasedSequence_InvalidStepValues))] + public void StepValuesMustFormOneBasedSequence_InvalidStepValues() + { + Verify(new StepValuesMustFormOneBasedSequence(), "InvalidStepValues.sarif"); + } + } +} diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj index fcf93cd2d..17d528444 100644 --- a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -86,7 +86,7 @@ - + @@ -249,16 +249,28 @@ PreserveNewest - + PreserveNewest - + PreserveNewest - + PreserveNewest - + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + PreserveNewest diff --git a/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/InvalidStepValues.sarif b/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/InvalidStepValues.sarif new file mode 100644 index 000000000..ef5e92107 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/InvalidStepValues.sarif @@ -0,0 +1,63 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "codeFlows": [ + { + "locations": [ + { + "step": 2, + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 42, + "startColumn": 12 + } + } + }, + { + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 43, + "startColumn": 12 + } + } + }, + { + "step": 4, + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 44, + "startColumn": 12 + } + } + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/InvalidStepValues_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/InvalidStepValues_Expected.sarif new file mode 100644 index 000000000..37ce6eeed --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/InvalidStepValues_Expected.sarif @@ -0,0 +1,132 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "048b53be-1275-4771-af1d-941cd2e1365b", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0009", + "level": "error", + "formattedRuleMessage": { + "formatId": "StepNotPresentOnAllLocations", + "arguments": [ + "InvalidStepValues.sarif", + "/runs/0/results/0/codeFlows/0/locations/1" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/InvalidStepValues.sarif", + "region": { + "startLine": 37, + "startColumn": 18 + } + } + } + ] + }, + { + "ruleId": "SV0009", + "level": "error", + "formattedRuleMessage": { + "formatId": "InvalidStepValue", + "arguments": [ + "InvalidStepValues.sarif", + "/runs/0/results/0/codeFlows/0/locations/0/step", + "1", + "2" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/InvalidStepValues.sarif", + "region": { + "startLine": 28, + "startColumn": 29 + } + } + } + ] + }, + { + "ruleId": "SV0009", + "level": "error", + "formattedRuleMessage": { + "formatId": "InvalidStepValue", + "arguments": [ + "InvalidStepValues.sarif", + "/runs/0/results/0/codeFlows/0/locations/2/step", + "3", + "4" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/InvalidStepValues.sarif", + "region": { + "startLine": 47, + "startColumn": 29 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/InvalidStepValues.sarif" + }, + "message": "Analyzing 'InvalidStepValues.sarif'...", + "level": "note", + "time": "2016-08-29T16:22:31.571Z" + } + ], + "rules": { + "SV0009": { + "id": "SV0009", + "name": "StepValuesMustFormOneBasedSequence", + "shortDescription": "If the \"step\" property is used on any annotatedCodeLocation in a code flow, then it must be present for every location in the code flow, its value must be 1 for the first location, and its value must increase by 1 for each succeeding location.", + "fullDescription": "If the \"step\" property is used on any annotatedCodeLocation in a code flow, then it must be present for every location in the code flow, its value must be 1 for the first location, and its value must increase by 1 for each succeeding location.", + "messageFormats": { + "StepNotPresentOnAllLocations": "In \"{0}\", at \"{1}\", the \"step\" property is absent. The \"step\" property is present on some but not all locations in this code flow. If the \"step\" property is used on any location in a code flow, it must be present on every location in that code flow.", + "InvalidStepValue": "In \"{0}\", at \"{1}\", the value of the \"step\" property should be {2}, but is {3}. The step values must form a 1-based sequence starting at the first location in the code flow." + }, + "defaultLevel": "error", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/InvalidStepValues.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\StepValuesMustFormOneBasedSequence\\InvalidStepValues.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\StepValuesMustFormOneBasedSequence\\InvalidStepValues_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T16:22:31.477Z", + "endTime": "2016-08-29T16:22:31.821Z", + "processId": 20192, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/NoStepsPresent.sarif b/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/NoStepsPresent.sarif new file mode 100644 index 000000000..b53de80de --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/NoStepsPresent.sarif @@ -0,0 +1,61 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "codeFlows": [ + { + "locations": [ + { + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 42, + "startColumn": 12 + } + } + }, + { + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 43, + "startColumn": 12 + } + } + }, + { + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 44, + "startColumn": 12 + } + } + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/NoStepsPresent_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/NoStepsPresent_Expected.sarif new file mode 100644 index 000000000..70765250a --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/NoStepsPresent_Expected.sarif @@ -0,0 +1,46 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "bbe1aafb-f5ea-4882-8d75-a14123b28c7c", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/NoStepsPresent.sarif" + }, + "message": "Analyzing 'NoStepsPresent.sarif'...", + "level": "note", + "time": "2016-08-29T15:39:58.160Z" + } + ], + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/NoStepsPresent.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\StepValuesMustFormOneBasedSequence\\NoStepsPresent.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\StepValuesMustFormOneBasedSequence\\NoStepsPresent_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T15:39:58.067Z", + "endTime": "2016-08-29T15:39:58.395Z", + "processId": 20184, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/StepNotPresentOnAllLocations.sarif b/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/StepNotPresentOnAllLocations.sarif similarity index 96% rename from src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/StepNotPresentOnAllLocations.sarif rename to src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/StepNotPresentOnAllLocations.sarif index 9d09fb090..7ecad770c 100644 --- a/src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/StepNotPresentOnAllLocations.sarif +++ b/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/StepNotPresentOnAllLocations.sarif @@ -10,7 +10,7 @@ { "ruleId": "TST0001", "level": "error", - "message": "Result message with period.", + "message": "Result message.", "locations": [ { "analysisTarget": { diff --git a/src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/StepNotPresentOnAllLocations_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/StepNotPresentOnAllLocations_Expected.sarif similarity index 100% rename from src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/StepNotPresentOnAllLocations_Expected.sarif rename to src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/StepNotPresentOnAllLocations_Expected.sarif diff --git a/src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/ValidSteps.sarif b/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/ValidSteps.sarif similarity index 96% rename from src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/ValidSteps.sarif rename to src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/ValidSteps.sarif index 7d9515830..a2d0b6739 100644 --- a/src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/ValidSteps.sarif +++ b/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/ValidSteps.sarif @@ -10,7 +10,7 @@ { "ruleId": "TST0001", "level": "error", - "message": "Result message with period.", + "message": "Result message.", "locations": [ { "analysisTarget": { diff --git a/src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/ValidSteps_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/ValidSteps_Expected.sarif similarity index 100% rename from src/SarifCli.FunctionalTests/TestData/StepMustIncreaseByOneFromOne/ValidSteps_Expected.sarif rename to src/SarifCli.FunctionalTests/TestData/StepValuesMustFormOneBasedSequence/ValidSteps_Expected.sarif diff --git a/src/SarifCli/Rules/RuleId.cs b/src/SarifCli/Rules/RuleId.cs index 0e231e49d..894f990e7 100644 --- a/src/SarifCli/Rules/RuleId.cs +++ b/src/SarifCli/Rules/RuleId.cs @@ -13,6 +13,6 @@ public static class RuleId public const string HashAlgorithmsMustBeUnique = "SV0006"; public const string EndTimeMustBeAfterStartTime = "SV0007"; public const string MessagesShouldEndWithPeriod = "SV0008"; - public const string StepMustIncreaseByOneFromOne = "SV0009"; + public const string StepValuesMustFormOneBasedSequence = "SV0009"; } } diff --git a/src/SarifCli/Rules/RuleResources.Designer.cs b/src/SarifCli/Rules/RuleResources.Designer.cs index f24b59b93..343c3f795 100644 --- a/src/SarifCli/Rules/RuleResources.Designer.cs +++ b/src/SarifCli/Rules/RuleResources.Designer.cs @@ -223,11 +223,11 @@ internal static string SV0008_MessagesShouldEndWithPeriod { } /// - /// Looks up a localized string similar to If the "step" property is used on any annotatedCodeLocation in a code flow, then it must be present for every location in the code flow, its value must be 1 for the first location, and its value must increase by 1 for each succeeding location.. + /// Looks up a localized string similar to In "{0}", at "{1}", the value of the "step" property should be {2}, but is {3}. The step values must form a 1-based sequence starting at the first location in the code flow.. /// - internal static string SV0009_StepMustIncreaseByOneFromOne { + internal static string SV0009_InvalidStepValue { get { - return ResourceManager.GetString("SV0009_StepMustIncreaseByOneFromOne", resourceCulture); + return ResourceManager.GetString("SV0009_InvalidStepValue", resourceCulture); } } @@ -239,5 +239,14 @@ internal static string SV0009_StepNotPresentOnAllLocations { return ResourceManager.GetString("SV0009_StepNotPresentOnAllLocations", resourceCulture); } } + + /// + /// Looks up a localized string similar to If the "step" property is used on any annotatedCodeLocation in a code flow, then it must be present for every location in the code flow, its value must be 1 for the first location, and its value must increase by 1 for each succeeding location.. + /// + internal static string SV0009_StepValuesMustFormOneBasedSequence { + get { + return ResourceManager.GetString("SV0009_StepValuesMustFormOneBasedSequence", resourceCulture); + } + } } } diff --git a/src/SarifCli/Rules/RuleResources.resx b/src/SarifCli/Rules/RuleResources.resx index 2d5028a7c..0f7127636 100644 --- a/src/SarifCli/Rules/RuleResources.resx +++ b/src/SarifCli/Rules/RuleResources.resx @@ -171,10 +171,13 @@ Messages should consist of one or more complete sentences, ending with a period. - - If the "step" property is used on any annotatedCodeLocation in a code flow, then it must be present for every location in the code flow, its value must be 1 for the first location, and its value must increase by 1 for each succeeding location. + + In "{0}", at "{1}", the value of the "step" property should be {2}, but is {3}. The step values must form a 1-based sequence starting at the first location in the code flow. In "{0}", at "{1}", the "step" property is absent. The "step" property is present on some but not all locations in this code flow. If the "step" property is used on any location in a code flow, it must be present on every location in that code flow. + + If the "step" property is used on any annotatedCodeLocation in a code flow, then it must be present for every location in the code flow, its value must be 1 for the first location, and its value must increase by 1 for each succeeding location. + \ No newline at end of file diff --git a/src/SarifCli/Rules/StepMustIncreaseByOneFromOne.cs b/src/SarifCli/Rules/StepValuesMustFormOneBasedSequence.cs similarity index 55% rename from src/SarifCli/Rules/StepMustIncreaseByOneFromOne.cs rename to src/SarifCli/Rules/StepValuesMustFormOneBasedSequence.cs index e0b04e95e..94cceba4c 100644 --- a/src/SarifCli/Rules/StepMustIncreaseByOneFromOne.cs +++ b/src/SarifCli/Rules/StepValuesMustFormOneBasedSequence.cs @@ -4,22 +4,23 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Globalization; using System.Linq; using Microsoft.Json.Pointer; using Newtonsoft.Json.Linq; namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules { - public class StepMustIncreaseByOneFromOne : SarifValidationSkimmerBase + public class StepValuesMustFormOneBasedSequence : SarifValidationSkimmerBase { - public override string FullDescription => RuleResources.SV0009_StepMustIncreaseByOneFromOne; + public override string FullDescription => RuleResources.SV0009_StepValuesMustFormOneBasedSequence; public override ResultLevel DefaultLevel => ResultLevel.Error; /// /// SV0009 /// - public override string Id => RuleId.StepMustIncreaseByOneFromOne; + public override string Id => RuleId.StepValuesMustFormOneBasedSequence; protected override IEnumerable FormatIds { @@ -27,7 +28,8 @@ protected override IEnumerable FormatIds { return new string[] { - nameof(RuleResources.SV0009_StepNotPresentOnAllLocations) + nameof(RuleResources.SV0009_StepNotPresentOnAllLocations), + nameof(RuleResources.SV0009_InvalidStepValue) }; } } @@ -44,7 +46,42 @@ protected override void Analyze(CodeFlow codeFlow, string codeFlowPointer) JArray annotatedCodeLocationArray = locationsProperty.Value as JArray; string annotatedCodeLocationsPointer = codeFlowPointer.AtProperty(SarifPropertyName.Locations); - ReportMissingStepProperty(annotatedCodeLocationArray, annotatedCodeLocationsPointer); + ReportMissingStepProperty( + annotatedCodeLocationArray, + annotatedCodeLocationsPointer); + + ReportInvalidStepValues( + codeFlow.Locations.ToArray(), + annotatedCodeLocationArray, + annotatedCodeLocationsPointer); + } + } + + private void ReportInvalidStepValues( + AnnotatedCodeLocation[] locations, + JArray annotatedCodeLocationArray, + string annotatedCodeLocationsPointer) + { + JObject[] annotatedCodeLocationObjects = annotatedCodeLocationArray.Children().ToArray(); + + for (int i = 0; i < locations.Length; ++i) + { + // Only report "invalid step value" for locations that actually specify + // the "step" property (the value of the Step property in the object + // model will be 0 for such steps, which is never valid), because we + // already reported the missing "step" properties. + if (LocationHasStep(annotatedCodeLocationObjects[i]) && + locations[i].Step != i + 1) + { + string invalidStepPointer = annotatedCodeLocationsPointer + .AtIndex(i).AtProperty(SarifPropertyName.Step); + + LogResult( + invalidStepPointer, + nameof(RuleResources.SV0009_InvalidStepValue), + (i + 1).ToString(CultureInfo.InvariantCulture), + (locations[i].Step).ToString(CultureInfo.InvariantCulture)); + } } } @@ -56,7 +93,11 @@ private void ReportMissingStepProperty( if (annotatedCodeLocationObjects.Length > 0) { JObject[] locationsWithStep = GetLocationsWithStep(annotatedCodeLocationObjects); - if (locationsWithStep.Length < annotatedCodeLocationObjects.Length) + + // It's ok if there are no steps, but if any location has a step property, + // all locations must have it. + if (locationsWithStep.Length > 0 && + locationsWithStep.Length < annotatedCodeLocationObjects.Length) { int missingStepIndex = FindFirstLocationWithMissingStep(annotatedCodeLocationObjects); Debug.Assert(missingStepIndex != -1, "Couldn't find location with missing step."); @@ -87,9 +128,14 @@ private int FindFirstLocationWithMissingStep(JObject[] annotatedCodeLocationObje private static JObject[] GetLocationsWithStep(JObject[] annotatedCodeLocationObjects) { return annotatedCodeLocationObjects - .Where(loc => loc.Children().Any( - prop => prop.Name.Equals(SarifPropertyName.Step, StringComparison.Ordinal))) + .Where(LocationHasStep) .ToArray(); } + + private static bool LocationHasStep(JObject loc) + { + return loc.Children().Any( + prop => prop.Name.Equals(SarifPropertyName.Step, StringComparison.Ordinal)); + } } } diff --git a/src/SarifCli/SarifCli.csproj b/src/SarifCli/SarifCli.csproj index 93baa11ff..b23db4a8b 100644 --- a/src/SarifCli/SarifCli.csproj +++ b/src/SarifCli/SarifCli.csproj @@ -87,7 +87,7 @@ - + From 0466ffec108d619c0d364d886d82f4746dfaaaeb Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Mon, 29 Aug 2016 10:18:54 -0700 Subject: [PATCH 42/51] SarifCli: Implement StepMustAppearOnlyInCodeFlowLocations rule --- ...pMustAppearOnlyInCodeFlowLocationsTests.cs | 23 +++++ .../SarifCli.FunctionalTests.csproj | 13 +++ .../StepAppearsInCodeFlow.sarif | 44 ++++++++++ .../StepAppearsInCodeFlow_Expected.sarif | 46 ++++++++++ .../StepAppearsInRelatedLocation.sarif | 39 +++++++++ ...tepAppearsInRelatedLocation_Expected.sarif | 83 +++++++++++++++++++ src/SarifCli/Rules/RuleId.cs | 1 + src/SarifCli/Rules/RuleResources.Designer.cs | 18 ++++ src/SarifCli/Rules/RuleResources.resx | 6 ++ .../StepMustAppearOnlyInCodeFlowLocations.cs | 50 +++++++++++ src/SarifCli/SarifCli.csproj | 1 + 11 files changed, 324 insertions(+) create mode 100644 src/SarifCli.FunctionalTests/Rules/StepMustAppearOnlyInCodeFlowLocationsTests.cs create mode 100644 src/SarifCli.FunctionalTests/TestData/StepMustAppearOnlyInCodeFlowLocations/StepAppearsInCodeFlow.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/StepMustAppearOnlyInCodeFlowLocations/StepAppearsInCodeFlow_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/StepMustAppearOnlyInCodeFlowLocations/StepAppearsInRelatedLocation.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/StepMustAppearOnlyInCodeFlowLocations/StepAppearsInRelatedLocation_Expected.sarif create mode 100644 src/SarifCli/Rules/StepMustAppearOnlyInCodeFlowLocations.cs diff --git a/src/SarifCli.FunctionalTests/Rules/StepMustAppearOnlyInCodeFlowLocationsTests.cs b/src/SarifCli.FunctionalTests/Rules/StepMustAppearOnlyInCodeFlowLocationsTests.cs new file mode 100644 index 000000000..c3e344068 --- /dev/null +++ b/src/SarifCli.FunctionalTests/Rules/StepMustAppearOnlyInCodeFlowLocationsTests.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.CodeAnalysis.Sarif.Cli.Rules; +using Xunit; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules +{ + public class StepMustAppearOnlyInCodeFlowLocationsTests : SkimmerTestsBase + { + [Fact(DisplayName = nameof(StepMustAppearOnlyInCodeFlowLocations_StepAppearsInCodeFlow))] + public void StepMustAppearOnlyInCodeFlowLocations_StepAppearsInCodeFlow() + { + Verify(new StepMustAppearOnlyInCodeFlowLocations(), "StepAppearsInCodeFlow.sarif"); + } + + [Fact(DisplayName = nameof(StepMustAppearOnlyInCodeFlowLocations_StepAppearsInRelatedLocation))] + public void StepMustAppearOnlyInCodeFlowLocations_StepAppearsInRelatedLocation() + { + Verify(new StepMustAppearOnlyInCodeFlowLocations(), "StepAppearsInRelatedLocation.sarif"); + } + } +} diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj index 17d528444..da7a5d736 100644 --- a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -86,6 +86,7 @@ + @@ -249,6 +250,18 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/src/SarifCli.FunctionalTests/TestData/StepMustAppearOnlyInCodeFlowLocations/StepAppearsInCodeFlow.sarif b/src/SarifCli.FunctionalTests/TestData/StepMustAppearOnlyInCodeFlowLocations/StepAppearsInCodeFlow.sarif new file mode 100644 index 000000000..057475c5f --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/StepMustAppearOnlyInCodeFlowLocations/StepAppearsInCodeFlow.sarif @@ -0,0 +1,44 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "codeFlows": [ + { + "locations": [ + { + "step": 1, + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 42, + "startColumn": 12 + } + } + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/StepMustAppearOnlyInCodeFlowLocations/StepAppearsInCodeFlow_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/StepMustAppearOnlyInCodeFlowLocations/StepAppearsInCodeFlow_Expected.sarif new file mode 100644 index 000000000..9d91278b5 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/StepMustAppearOnlyInCodeFlowLocations/StepAppearsInCodeFlow_Expected.sarif @@ -0,0 +1,46 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "61035d62-fb6e-4bfa-9444-6c7815200f83", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/StepMustAppearOnlyInCodeFlows/StepAppearsInCodeFlow.sarif" + }, + "message": "Analyzing 'StepAppearsInCodeFlow.sarif'...", + "level": "note", + "time": "2016-08-29T17:02:34.741Z" + } + ], + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/StepMustAppearOnlyInCodeFlows/StepAppearsInCodeFlow.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\StepMustAppearOnlyInCodeFlows\\StepAppearsInCodeFlow.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\StepMustAppearOnlyInCodeFlows\\StepAppearsInCodeFlow_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T17:02:34.569Z", + "endTime": "2016-08-29T17:02:35.053Z", + "processId": 5956, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/StepMustAppearOnlyInCodeFlowLocations/StepAppearsInRelatedLocation.sarif b/src/SarifCli.FunctionalTests/TestData/StepMustAppearOnlyInCodeFlowLocations/StepAppearsInRelatedLocation.sarif new file mode 100644 index 000000000..a834b3b54 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/StepMustAppearOnlyInCodeFlowLocations/StepAppearsInRelatedLocation.sarif @@ -0,0 +1,39 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "relatedLocations": [ + { + "step": 1, + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 2 + } + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/StepMustAppearOnlyInCodeFlowLocations/StepAppearsInRelatedLocation_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/StepMustAppearOnlyInCodeFlowLocations/StepAppearsInRelatedLocation_Expected.sarif new file mode 100644 index 000000000..2e1989584 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/StepMustAppearOnlyInCodeFlowLocations/StepAppearsInRelatedLocation_Expected.sarif @@ -0,0 +1,83 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "6b85686a-cbde-4836-bec4-a9803bf9970b", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0010", + "level": "warning", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "StepAppearsInRelatedLocation.sarif", + "/runs/0/results/0/relatedLocations/0/step" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/StepMustAppearOnlyInCodeFlows/StepAppearsInRelatedLocation.sarif", + "region": { + "startLine": 26, + "startColumn": 24 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/StepMustAppearOnlyInCodeFlows/StepAppearsInRelatedLocation.sarif" + }, + "message": "Analyzing 'StepAppearsInRelatedLocation.sarif'...", + "level": "note", + "time": "2016-08-29T17:03:22.820Z" + } + ], + "rules": { + "SV0010": { + "id": "SV0010", + "name": "StepMustAppearOnlyInCodeFlowLocations", + "shortDescription": "The \"step\" property must appear only in annotatedCodeLocation objects which occur within code flows.", + "fullDescription": "The \"step\" property must appear only in annotatedCodeLocation objects which occur within code flows.", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the \"step\" property appears in an annotatedCodeLocation object which does not occur in a code flow. The \"step\" property must appear only in annotatedCodeLocation objects which occur within code flows." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/StepMustAppearOnlyInCodeFlows/StepAppearsInRelatedLocation.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\StepMustAppearOnlyInCodeFlows\\StepAppearsInRelatedLocation.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\StepMustAppearOnlyInCodeFlows\\StepAppearsInRelatedLocation_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T17:03:22.730Z", + "endTime": "2016-08-29T17:03:23.076Z", + "processId": 3024, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli/Rules/RuleId.cs b/src/SarifCli/Rules/RuleId.cs index 894f990e7..da203ad5e 100644 --- a/src/SarifCli/Rules/RuleId.cs +++ b/src/SarifCli/Rules/RuleId.cs @@ -14,5 +14,6 @@ public static class RuleId public const string EndTimeMustBeAfterStartTime = "SV0007"; public const string MessagesShouldEndWithPeriod = "SV0008"; public const string StepValuesMustFormOneBasedSequence = "SV0009"; + public const string StepMustAppearOnlyInCodeFlowLocations = "SV0010"; } } diff --git a/src/SarifCli/Rules/RuleResources.Designer.cs b/src/SarifCli/Rules/RuleResources.Designer.cs index 343c3f795..fd099c154 100644 --- a/src/SarifCli/Rules/RuleResources.Designer.cs +++ b/src/SarifCli/Rules/RuleResources.Designer.cs @@ -248,5 +248,23 @@ internal static string SV0009_StepValuesMustFormOneBasedSequence { return ResourceManager.GetString("SV0009_StepValuesMustFormOneBasedSequence", resourceCulture); } } + + /// + /// Looks up a localized string similar to In "{0}", at "{1}", the "step" property appears in an annotatedCodeLocation object which does not occur in a code flow. The "step" property must appear only in annotatedCodeLocation objects which occur within code flows.. + /// + internal static string SV0010_Default { + get { + return ResourceManager.GetString("SV0010_Default", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The "step" property must appear only in annotatedCodeLocation objects which occur within code flows.. + /// + internal static string SV0010_StepMustAppearOnlyInCodeFlowLocations { + get { + return ResourceManager.GetString("SV0010_StepMustAppearOnlyInCodeFlowLocations", resourceCulture); + } + } } } diff --git a/src/SarifCli/Rules/RuleResources.resx b/src/SarifCli/Rules/RuleResources.resx index 0f7127636..3327f1f90 100644 --- a/src/SarifCli/Rules/RuleResources.resx +++ b/src/SarifCli/Rules/RuleResources.resx @@ -180,4 +180,10 @@ If the "step" property is used on any annotatedCodeLocation in a code flow, then it must be present for every location in the code flow, its value must be 1 for the first location, and its value must increase by 1 for each succeeding location. + + In "{0}", at "{1}", the "step" property appears in an annotatedCodeLocation object which does not occur in a code flow. The "step" property must appear only in annotatedCodeLocation objects which occur within code flows. + + + The "step" property must appear only in annotatedCodeLocation objects which occur within code flows. + \ No newline at end of file diff --git a/src/SarifCli/Rules/StepMustAppearOnlyInCodeFlowLocations.cs b/src/SarifCli/Rules/StepMustAppearOnlyInCodeFlowLocations.cs new file mode 100644 index 000000000..e073731e8 --- /dev/null +++ b/src/SarifCli/Rules/StepMustAppearOnlyInCodeFlowLocations.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.Json.Pointer; +using Newtonsoft.Json.Linq; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules +{ + public class StepMustAppearOnlyInCodeFlowLocations : SarifValidationSkimmerBase + { + public override string FullDescription => RuleResources.SV0010_StepMustAppearOnlyInCodeFlowLocations; + + public override ResultLevel DefaultLevel => ResultLevel.Warning; + + /// + /// SV0010 + /// + public override string Id => RuleId.StepMustAppearOnlyInCodeFlowLocations; + + protected override IEnumerable FormatIds + { + get + { + return new string[] + { + nameof(RuleResources.SV0010_Default) + }; + } + } + + protected override void Analyze(AnnotatedCodeLocation annotatedCodeLocation, string annotatedCodeLocationPointer) + { + var pointer = new JsonPointer(annotatedCodeLocationPointer); + JToken token = pointer.Evaluate(Context.InputLogToken); + + if (token.Children().Any(jp => jp.Name.Equals(SarifPropertyName.Step, StringComparison.Ordinal))) + { + if (!annotatedCodeLocationPointer.Contains(SarifPropertyName.CodeFlows)) + { + string stepPointer = annotatedCodeLocationPointer.AtProperty(SarifPropertyName.Step); + + LogResult(stepPointer, nameof(RuleResources.SV0010_Default)); + } + } + } + } +} diff --git a/src/SarifCli/SarifCli.csproj b/src/SarifCli/SarifCli.csproj index b23db4a8b..28cdf9ff4 100644 --- a/src/SarifCli/SarifCli.csproj +++ b/src/SarifCli/SarifCli.csproj @@ -87,6 +87,7 @@ + From 88602d8ae5c108ddaf652605b75162a9525feb22 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Mon, 29 Aug 2016 10:37:24 -0700 Subject: [PATCH 43/51] SarifCli: Implement ImportanceMustAppearOnlyInCodeFlowLocations rule --- ...eMustAppearOnlyInCodeFlowLocationsTests.cs | 23 +++++ .../SarifCli.FunctionalTests.csproj | 13 +++ .../ImportanceAppearsInCodeFlow.sarif | 44 ++++++++++ ...ImportanceAppearsInCodeFlow_Expected.sarif | 46 ++++++++++ .../ImportanceAppearsInRelatedLocation.sarif | 39 +++++++++ ...nceAppearsInRelatedLocation_Expected.sarif | 83 +++++++++++++++++++ ...rtanceMustAppearOnlyInCodeFlowLocations.cs | 50 +++++++++++ src/SarifCli/Rules/RuleId.cs | 1 + src/SarifCli/Rules/RuleResources.Designer.cs | 18 ++++ src/SarifCli/Rules/RuleResources.resx | 6 ++ src/SarifCli/SarifCli.csproj | 1 + src/SarifCli/SarifPropertyName.cs | 1 + 12 files changed, 325 insertions(+) create mode 100644 src/SarifCli.FunctionalTests/Rules/ImportanceMustAppearOnlyInCodeFlowLocationsTests.cs create mode 100644 src/SarifCli.FunctionalTests/TestData/ImportanceMustAppearOnlyInCodeFlowLocations/ImportanceAppearsInCodeFlow.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/ImportanceMustAppearOnlyInCodeFlowLocations/ImportanceAppearsInCodeFlow_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/ImportanceMustAppearOnlyInCodeFlowLocations/ImportanceAppearsInRelatedLocation.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/ImportanceMustAppearOnlyInCodeFlowLocations/ImportanceAppearsInRelatedLocation_Expected.sarif create mode 100644 src/SarifCli/Rules/ImportanceMustAppearOnlyInCodeFlowLocations.cs diff --git a/src/SarifCli.FunctionalTests/Rules/ImportanceMustAppearOnlyInCodeFlowLocationsTests.cs b/src/SarifCli.FunctionalTests/Rules/ImportanceMustAppearOnlyInCodeFlowLocationsTests.cs new file mode 100644 index 000000000..61d9b1066 --- /dev/null +++ b/src/SarifCli.FunctionalTests/Rules/ImportanceMustAppearOnlyInCodeFlowLocationsTests.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.CodeAnalysis.Sarif.Cli.Rules; +using Xunit; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules +{ + public class ImportanceMustAppearOnlyInCodeFlowLocationsTests : SkimmerTestsBase + { + [Fact(DisplayName = nameof(ImportanceMustAppearOnlyInCodeFlowLocations_ImportanceAppearsInCodeFlow))] + public void ImportanceMustAppearOnlyInCodeFlowLocations_ImportanceAppearsInCodeFlow() + { + Verify(new ImportanceMustAppearOnlyInCodeFlowLocations(), "ImportanceAppearsInCodeFlow.sarif"); + } + + [Fact(DisplayName = nameof(ImportanceMustAppearOnlyInCodeFlowLocations_ImportanceAppearsInRelatedLocation))] + public void ImportanceMustAppearOnlyInCodeFlowLocations_ImportanceAppearsInRelatedLocation() + { + Verify(new ImportanceMustAppearOnlyInCodeFlowLocations(), "ImportanceAppearsInRelatedLocation.sarif"); + } + } +} diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj index da7a5d736..c2e54f7f9 100644 --- a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -86,6 +86,7 @@ + @@ -205,6 +206,18 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/src/SarifCli.FunctionalTests/TestData/ImportanceMustAppearOnlyInCodeFlowLocations/ImportanceAppearsInCodeFlow.sarif b/src/SarifCli.FunctionalTests/TestData/ImportanceMustAppearOnlyInCodeFlowLocations/ImportanceAppearsInCodeFlow.sarif new file mode 100644 index 000000000..0634d7c74 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/ImportanceMustAppearOnlyInCodeFlowLocations/ImportanceAppearsInCodeFlow.sarif @@ -0,0 +1,44 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "codeFlows": [ + { + "locations": [ + { + "importance": "essential", + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 42, + "startColumn": 12 + } + } + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/ImportanceMustAppearOnlyInCodeFlowLocations/ImportanceAppearsInCodeFlow_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/ImportanceMustAppearOnlyInCodeFlowLocations/ImportanceAppearsInCodeFlow_Expected.sarif new file mode 100644 index 000000000..a49820240 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/ImportanceMustAppearOnlyInCodeFlowLocations/ImportanceAppearsInCodeFlow_Expected.sarif @@ -0,0 +1,46 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "f6a2a2d6-6bb7-4414-bc6a-5a5dde691c1b", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/ImportanceMustAppearOnlyInCodeFlowLocations/ImportanceAppearsInCodeFlow.sarif" + }, + "message": "Analyzing 'ImportanceAppearsInCodeFlow.sarif'...", + "level": "note", + "time": "2016-08-29T17:33:46.605Z" + } + ], + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/ImportanceMustAppearOnlyInCodeFlowLocations/ImportanceAppearsInCodeFlow.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\ImportanceMustAppearOnlyInCodeFlowLocations\\ImportanceAppearsInCodeFlow.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\ImportanceMustAppearOnlyInCodeFlowLocations\\ImportanceAppearsInCodeFlow_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T17:33:46.509Z", + "endTime": "2016-08-29T17:33:46.865Z", + "processId": 20180, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/ImportanceMustAppearOnlyInCodeFlowLocations/ImportanceAppearsInRelatedLocation.sarif b/src/SarifCli.FunctionalTests/TestData/ImportanceMustAppearOnlyInCodeFlowLocations/ImportanceAppearsInRelatedLocation.sarif new file mode 100644 index 000000000..a56de65b6 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/ImportanceMustAppearOnlyInCodeFlowLocations/ImportanceAppearsInRelatedLocation.sarif @@ -0,0 +1,39 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "relatedLocations": [ + { + "importance": "essential", + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 2 + } + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/ImportanceMustAppearOnlyInCodeFlowLocations/ImportanceAppearsInRelatedLocation_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/ImportanceMustAppearOnlyInCodeFlowLocations/ImportanceAppearsInRelatedLocation_Expected.sarif new file mode 100644 index 000000000..2e72018e1 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/ImportanceMustAppearOnlyInCodeFlowLocations/ImportanceAppearsInRelatedLocation_Expected.sarif @@ -0,0 +1,83 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "12383704-8153-4818-94eb-6dc88ceff477", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0011", + "level": "warning", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "ImportanceAppearsInRelatedLocation.sarif", + "/runs/0/results/0/relatedLocations/0/importance" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/ImportanceMustAppearOnlyInCodeFlowLocations/ImportanceAppearsInRelatedLocation.sarif", + "region": { + "startLine": 26, + "startColumn": 40 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/ImportanceMustAppearOnlyInCodeFlowLocations/ImportanceAppearsInRelatedLocation.sarif" + }, + "message": "Analyzing 'ImportanceAppearsInRelatedLocation.sarif'...", + "level": "note", + "time": "2016-08-29T17:33:03.071Z" + } + ], + "rules": { + "SV0011": { + "id": "SV0011", + "name": "ImportanceMustAppearOnlyInCodeFlowLocations", + "shortDescription": "The \"importance\" property must appear only in annotatedCodeLocation objects which occur within code flows.", + "fullDescription": "The \"importance\" property must appear only in annotatedCodeLocation objects which occur within code flows.", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the \"importance\" property appears in an annotatedCodeLocation object which does not occur in a code flow. The \"importance\" property must appear only in annotatedCodeLocation objects which occur within code flows." + }, + "defaultLevel": "warning", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/ImportanceMustAppearOnlyInCodeFlowLocations/ImportanceAppearsInRelatedLocation.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\ImportanceMustAppearOnlyInCodeFlowLocations\\ImportanceAppearsInRelatedLocation.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\ImportanceMustAppearOnlyInCodeFlowLocations\\ImportanceAppearsInRelatedLocation_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T17:33:02.876Z", + "endTime": "2016-08-29T17:33:03.324Z", + "processId": 9608, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli/Rules/ImportanceMustAppearOnlyInCodeFlowLocations.cs b/src/SarifCli/Rules/ImportanceMustAppearOnlyInCodeFlowLocations.cs new file mode 100644 index 000000000..ade35273f --- /dev/null +++ b/src/SarifCli/Rules/ImportanceMustAppearOnlyInCodeFlowLocations.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.Json.Pointer; +using Newtonsoft.Json.Linq; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules +{ + public class ImportanceMustAppearOnlyInCodeFlowLocations : SarifValidationSkimmerBase + { + public override string FullDescription => RuleResources.SV0011_ImportanceMustAppearOnlyInCodeFlowLocations; + + public override ResultLevel DefaultLevel => ResultLevel.Warning; + + /// + /// SV0011 + /// + public override string Id => RuleId.ImportanceMustAppearOnlyInCodeFlowLocations; + + protected override IEnumerable FormatIds + { + get + { + return new string[] + { + nameof(RuleResources.SV0011_Default) + }; + } + } + + protected override void Analyze(AnnotatedCodeLocation annotatedCodeLocation, string annotatedCodeLocationPointer) + { + var pointer = new JsonPointer(annotatedCodeLocationPointer); + JToken token = pointer.Evaluate(Context.InputLogToken); + + if (token.Children().Any(jp => jp.Name.Equals(SarifPropertyName.Importance, StringComparison.Ordinal))) + { + if (!annotatedCodeLocationPointer.Contains(SarifPropertyName.CodeFlows)) + { + string importancePointer = annotatedCodeLocationPointer.AtProperty(SarifPropertyName.Importance); + + LogResult(importancePointer, nameof(RuleResources.SV0011_Default)); + } + } + } + } +} diff --git a/src/SarifCli/Rules/RuleId.cs b/src/SarifCli/Rules/RuleId.cs index da203ad5e..047070a66 100644 --- a/src/SarifCli/Rules/RuleId.cs +++ b/src/SarifCli/Rules/RuleId.cs @@ -15,5 +15,6 @@ public static class RuleId public const string MessagesShouldEndWithPeriod = "SV0008"; public const string StepValuesMustFormOneBasedSequence = "SV0009"; public const string StepMustAppearOnlyInCodeFlowLocations = "SV0010"; + public const string ImportanceMustAppearOnlyInCodeFlowLocations = "SV0011"; } } diff --git a/src/SarifCli/Rules/RuleResources.Designer.cs b/src/SarifCli/Rules/RuleResources.Designer.cs index fd099c154..d5e5d4a68 100644 --- a/src/SarifCli/Rules/RuleResources.Designer.cs +++ b/src/SarifCli/Rules/RuleResources.Designer.cs @@ -266,5 +266,23 @@ internal static string SV0010_StepMustAppearOnlyInCodeFlowLocations { return ResourceManager.GetString("SV0010_StepMustAppearOnlyInCodeFlowLocations", resourceCulture); } } + + /// + /// Looks up a localized string similar to In "{0}", at "{1}", the "importance" property appears in an annotatedCodeLocation object which does not occur in a code flow. The "importance" property must appear only in annotatedCodeLocation objects which occur within code flows.. + /// + internal static string SV0011_Default { + get { + return ResourceManager.GetString("SV0011_Default", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The "importance" property must appear only in annotatedCodeLocation objects which occur within code flows.. + /// + internal static string SV0011_ImportanceMustAppearOnlyInCodeFlowLocations { + get { + return ResourceManager.GetString("SV0011_ImportanceMustAppearOnlyInCodeFlowLocations", resourceCulture); + } + } } } diff --git a/src/SarifCli/Rules/RuleResources.resx b/src/SarifCli/Rules/RuleResources.resx index 3327f1f90..716bbd0fb 100644 --- a/src/SarifCli/Rules/RuleResources.resx +++ b/src/SarifCli/Rules/RuleResources.resx @@ -186,4 +186,10 @@ The "step" property must appear only in annotatedCodeLocation objects which occur within code flows. + + In "{0}", at "{1}", the "importance" property appears in an annotatedCodeLocation object which does not occur in a code flow. The "importance" property must appear only in annotatedCodeLocation objects which occur within code flows. + + + The "importance" property must appear only in annotatedCodeLocation objects which occur within code flows. + \ No newline at end of file diff --git a/src/SarifCli/SarifCli.csproj b/src/SarifCli/SarifCli.csproj index 28cdf9ff4..5e39370f5 100644 --- a/src/SarifCli/SarifCli.csproj +++ b/src/SarifCli/SarifCli.csproj @@ -87,6 +87,7 @@ + diff --git a/src/SarifCli/SarifPropertyName.cs b/src/SarifCli/SarifPropertyName.cs index d07a2113c..5a601663c 100644 --- a/src/SarifCli/SarifPropertyName.cs +++ b/src/SarifCli/SarifPropertyName.cs @@ -16,6 +16,7 @@ public static class SarifPropertyName public const string Frames = "frames"; public const string Hashes = "hashes"; public const string Id = "id"; + public const string Importance = "importance"; public const string Invocation = "invocation"; public const string Locations = "locations"; public const string Message = "message"; From 6d2129df3e2777c3b23662df645bca14b78bbee5 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Mon, 29 Aug 2016 12:28:53 -0700 Subject: [PATCH 44/51] SarifCli: Refactor: Introduce HasProperty extension method --- src/SarifCli/JTokenExtensions.cs | 18 ++++++++++++++++++ ...AnnotatedCodeLocationEssentialIsObsolete.cs | 2 +- ...ortanceMustAppearOnlyInCodeFlowLocations.cs | 2 +- .../StepMustAppearOnlyInCodeFlowLocations.cs | 2 +- .../StepValuesMustFormOneBasedSequence.cs | 7 +++---- src/SarifCli/SarifCli.csproj | 1 + 6 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 src/SarifCli/JTokenExtensions.cs diff --git a/src/SarifCli/JTokenExtensions.cs b/src/SarifCli/JTokenExtensions.cs new file mode 100644 index 000000000..96b61c0cc --- /dev/null +++ b/src/SarifCli/JTokenExtensions.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Linq; +using Newtonsoft.Json.Linq; + +namespace Microsoft.CodeAnalysis.Sarif.Cli +{ + public static class JTokenExtensions + { + public static bool HasProperty(this JToken token, string propertyName) + { + return token.Children() + .Any(jp => jp.Name.Equals(propertyName, StringComparison.Ordinal)); + } + } +} \ No newline at end of file diff --git a/src/SarifCli/Rules/AnnotatedCodeLocationEssentialIsObsolete.cs b/src/SarifCli/Rules/AnnotatedCodeLocationEssentialIsObsolete.cs index 3df79594f..2d1396b36 100644 --- a/src/SarifCli/Rules/AnnotatedCodeLocationEssentialIsObsolete.cs +++ b/src/SarifCli/Rules/AnnotatedCodeLocationEssentialIsObsolete.cs @@ -37,7 +37,7 @@ protected override void Analyze(AnnotatedCodeLocation annotatedCodeLocation, str var pointer = new JsonPointer(annotatedCodeLocationPointer); JToken token = pointer.Evaluate(Context.InputLogToken); - if (token.Children().Any(jp => jp.Name.Equals(SarifPropertyName.Essential, StringComparison.Ordinal))) + if (token.HasProperty(SarifPropertyName.Essential)) { string essentialPointer = annotatedCodeLocationPointer.AtProperty(SarifPropertyName.Essential); diff --git a/src/SarifCli/Rules/ImportanceMustAppearOnlyInCodeFlowLocations.cs b/src/SarifCli/Rules/ImportanceMustAppearOnlyInCodeFlowLocations.cs index ade35273f..41ee75b6a 100644 --- a/src/SarifCli/Rules/ImportanceMustAppearOnlyInCodeFlowLocations.cs +++ b/src/SarifCli/Rules/ImportanceMustAppearOnlyInCodeFlowLocations.cs @@ -36,7 +36,7 @@ protected override void Analyze(AnnotatedCodeLocation annotatedCodeLocation, str var pointer = new JsonPointer(annotatedCodeLocationPointer); JToken token = pointer.Evaluate(Context.InputLogToken); - if (token.Children().Any(jp => jp.Name.Equals(SarifPropertyName.Importance, StringComparison.Ordinal))) + if (token.HasProperty(SarifPropertyName.Importance)) { if (!annotatedCodeLocationPointer.Contains(SarifPropertyName.CodeFlows)) { diff --git a/src/SarifCli/Rules/StepMustAppearOnlyInCodeFlowLocations.cs b/src/SarifCli/Rules/StepMustAppearOnlyInCodeFlowLocations.cs index e073731e8..e63ad93d3 100644 --- a/src/SarifCli/Rules/StepMustAppearOnlyInCodeFlowLocations.cs +++ b/src/SarifCli/Rules/StepMustAppearOnlyInCodeFlowLocations.cs @@ -36,7 +36,7 @@ protected override void Analyze(AnnotatedCodeLocation annotatedCodeLocation, str var pointer = new JsonPointer(annotatedCodeLocationPointer); JToken token = pointer.Evaluate(Context.InputLogToken); - if (token.Children().Any(jp => jp.Name.Equals(SarifPropertyName.Step, StringComparison.Ordinal))) + if (token.HasProperty(SarifPropertyName.Step)) { if (!annotatedCodeLocationPointer.Contains(SarifPropertyName.CodeFlows)) { diff --git a/src/SarifCli/Rules/StepValuesMustFormOneBasedSequence.cs b/src/SarifCli/Rules/StepValuesMustFormOneBasedSequence.cs index 94cceba4c..08cc5c199 100644 --- a/src/SarifCli/Rules/StepValuesMustFormOneBasedSequence.cs +++ b/src/SarifCli/Rules/StepValuesMustFormOneBasedSequence.cs @@ -115,7 +115,7 @@ private int FindFirstLocationWithMissingStep(JObject[] annotatedCodeLocationObje for (int i = 0; i < annotatedCodeLocationObjects.Length; ++i) { - if (!annotatedCodeLocationObjects[i].Children().Any(prop => prop.Name.Equals(SarifPropertyName.Step, StringComparison.Ordinal))) + if (!annotatedCodeLocationObjects[i].HasProperty(SarifPropertyName.Step)) { index = i; break; @@ -134,8 +134,7 @@ private static JObject[] GetLocationsWithStep(JObject[] annotatedCodeLocationObj private static bool LocationHasStep(JObject loc) { - return loc.Children().Any( - prop => prop.Name.Equals(SarifPropertyName.Step, StringComparison.Ordinal)); + return loc.HasProperty(SarifPropertyName.Step); } } -} +} \ No newline at end of file diff --git a/src/SarifCli/SarifCli.csproj b/src/SarifCli/SarifCli.csproj index 5e39370f5..26f88c672 100644 --- a/src/SarifCli/SarifCli.csproj +++ b/src/SarifCli/SarifCli.csproj @@ -87,6 +87,7 @@ + From ddaaf13fce4318a7f7d3a230d779c618aa1750e2 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Mon, 29 Aug 2016 15:06:55 -0700 Subject: [PATCH 45/51] SarifCli: Implement EndLineMustNotBeLessThanStartLine rule --- .../EndLineMustNotBeLessThanStartLineTests.cs | 53 ++++++++++++ .../SarifCli.FunctionalTests.csproj | 43 ++++++++++ .../EndLineEqualsStartLine.sarif | 29 +++++++ .../EndLineEqualsStartLine_Expected.sarif | 46 ++++++++++ .../EndLineGreaterThanStartLine.sarif | 29 +++++++ ...EndLineGreaterThanStartLine_Expected.sarif | 46 ++++++++++ ...ineLessThanStartLineInAnalysisTarget.sarif | 29 +++++++ ...anStartLineInAnalysisTarget_Expected.sarif | 85 +++++++++++++++++++ .../EndLineLessThanStartLineInCodeFlow.sarif | 43 ++++++++++ ...LessThanStartLineInCodeFlow_Expected.sarif | 85 +++++++++++++++++++ ...neLessThanStartLineInRelatedLocation.sarif | 39 +++++++++ ...nStartLineInRelatedLocation_Expected.sarif | 85 +++++++++++++++++++ ...EndLineLessThanStartLineInResultFile.sarif | 29 +++++++ ...ssThanStartLineInResultFile_Expected.sarif | 85 +++++++++++++++++++ ...anStartLineInResultLocation_Expected.sarif | 85 +++++++++++++++++++ .../EndLineNotSpecified.sarif | 28 ++++++ .../EndLineNotSpecified_Expected.sarif | 46 ++++++++++ .../EndLineMustNotBeLessThanStartLine.cs | 51 +++++++++++ src/SarifCli/Rules/RuleId.cs | 1 + src/SarifCli/Rules/RuleResources.Designer.cs | 18 ++++ src/SarifCli/Rules/RuleResources.resx | 6 ++ .../Rules/SarifValidationSkimmerBase.cs | 16 ++++ src/SarifCli/SarifCli.csproj | 1 + src/SarifCli/SarifPropertyName.cs | 2 + 24 files changed, 980 insertions(+) create mode 100644 src/SarifCli.FunctionalTests/Rules/EndLineMustNotBeLessThanStartLineTests.cs create mode 100644 src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineEqualsStartLine.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineEqualsStartLine_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineGreaterThanStartLine.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineGreaterThanStartLine_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInAnalysisTarget.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInAnalysisTarget_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInCodeFlow.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInCodeFlow_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInRelatedLocation.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInRelatedLocation_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInResultFile.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInResultFile_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInResultLocation_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineNotSpecified.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineNotSpecified_Expected.sarif create mode 100644 src/SarifCli/Rules/EndLineMustNotBeLessThanStartLine.cs diff --git a/src/SarifCli.FunctionalTests/Rules/EndLineMustNotBeLessThanStartLineTests.cs b/src/SarifCli.FunctionalTests/Rules/EndLineMustNotBeLessThanStartLineTests.cs new file mode 100644 index 000000000..4204d4fbe --- /dev/null +++ b/src/SarifCli.FunctionalTests/Rules/EndLineMustNotBeLessThanStartLineTests.cs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.CodeAnalysis.Sarif.Cli.Rules; +using Xunit; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules +{ + public class EndLineMustNotBeLessThanStartLineTests : SkimmerTestsBase + { + [Fact(DisplayName = nameof(EndLineMustNotBeLessThanStartLine_EndLineEqualsStartLine))] + public void EndLineMustNotBeLessThanStartLine_EndLineEqualsStartLine() + { + Verify(new EndLineMustNotBeLessThanStartLine(), "EndLineEqualsStartLine.sarif"); + } + + [Fact(DisplayName = nameof(EndLineMustNotBeLessThanStartLine_EndLineGreaterThanStartLine))] + public void EndLineMustNotBeLessThanStartLine_EndLineGreaterThanStartLine() + { + Verify(new EndLineMustNotBeLessThanStartLine(), "EndLineGreaterThanStartLine.sarif"); + } + + [Fact(DisplayName = nameof(EndLineMustNotBeLessThanStartLine_EndLineLessThanStartLineInCodeFlow))] + public void EndLineMustNotBeLessThanStartLine_EndLineLessThanStartLineInCodeFlow() + { + Verify(new EndLineMustNotBeLessThanStartLine(), "EndLineLessThanStartLineInCodeFlow.sarif"); + } + + [Fact(DisplayName = nameof(EndLineMustNotBeLessThanStartLine_EndLineLessThanStartLineInRelatedLocation))] + public void EndLineMustNotBeLessThanStartLine_EndLineLessThanStartLineInRelatedLocation() + { + Verify(new EndLineMustNotBeLessThanStartLine(), "EndLineLessThanStartLineInRelatedLocation.sarif"); + } + + [Fact(DisplayName = nameof(EndLineMustNotBeLessThanStartLine_EndLineNotSpecified))] + public void EndLineMustNotBeLessThanStartLine_EndLineNotSpecified() + { + Verify(new EndLineMustNotBeLessThanStartLine(), "EndLineNotSpecified.sarif"); + } + + [Fact(DisplayName = nameof(EndLineMustNotBeLessThanStartLine_EndLineLessThanStartLineInAnalysisTarget))] + public void EndLineMustNotBeLessThanStartLine_EndLineLessThanStartLineInAnalysisTarget() + { + Verify(new EndLineMustNotBeLessThanStartLine(), "EndLineLessThanStartLineInAnalysisTarget.sarif"); + } + + [Fact(DisplayName = nameof(EndLineMustNotBeLessThanStartLine_EndLineLessThanStartLineInResultFile))] + public void EndLineMustNotBeLessThanStartLine_EndLineLessThanStartLineInResultFile() + { + Verify(new EndLineMustNotBeLessThanStartLine(), "EndLineLessThanStartLineInResultFile.sarif"); + } + } +} diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj index c2e54f7f9..520d269d9 100644 --- a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -86,6 +86,7 @@ + @@ -176,6 +177,48 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineEqualsStartLine.sarif b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineEqualsStartLine.sarif new file mode 100644 index 000000000..2fec37ad4 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineEqualsStartLine.sarif @@ -0,0 +1,29 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1, + "endLine": 1 + } + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineEqualsStartLine_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineEqualsStartLine_Expected.sarif new file mode 100644 index 000000000..8292ce44f --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineEqualsStartLine_Expected.sarif @@ -0,0 +1,46 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "a452680c-dd09-4644-90ec-0fc0f64edf77", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineEqualsStartLine.sarif" + }, + "message": "Analyzing 'EndLineEqualsStartLine.sarif'...", + "level": "note", + "time": "2016-08-29T21:52:27.769Z" + } + ], + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineEqualsStartLine.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineEqualsStartLine.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineEqualsStartLine_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T21:52:27.606Z", + "endTime": "2016-08-29T21:52:28.038Z", + "processId": 8304, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineGreaterThanStartLine.sarif b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineGreaterThanStartLine.sarif new file mode 100644 index 000000000..fd7c1afae --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineGreaterThanStartLine.sarif @@ -0,0 +1,29 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1, + "endLine": 2 + } + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineGreaterThanStartLine_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineGreaterThanStartLine_Expected.sarif new file mode 100644 index 000000000..53269fe80 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineGreaterThanStartLine_Expected.sarif @@ -0,0 +1,46 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "99acc70c-6c97-4490-af91-8181c5ed3759", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineGreaterThanStartLine.sarif" + }, + "message": "Analyzing 'EndLineGreaterThanStartLine.sarif'...", + "level": "note", + "time": "2016-08-29T21:53:35.930Z" + } + ], + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineGreaterThanStartLine.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineGreaterThanStartLine.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineGreaterThanStartLine_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T21:53:35.850Z", + "endTime": "2016-08-29T21:53:36.165Z", + "processId": 15636, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInAnalysisTarget.sarif b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInAnalysisTarget.sarif new file mode 100644 index 000000000..1491dfab9 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInAnalysisTarget.sarif @@ -0,0 +1,29 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 2, + "endLine": 1 + } + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInAnalysisTarget_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInAnalysisTarget_Expected.sarif new file mode 100644 index 000000000..a12fa9bb0 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInAnalysisTarget_Expected.sarif @@ -0,0 +1,85 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "d3877f93-40a9-481f-bfc4-4c9af1ef7525", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0012", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "EndLineLessThanStartLineInAnalysisTarget.sarif", + "/runs/0/results/0/locations/0/analysisTarget/region", + "1", + "2" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInAnalysisTarget.sarif", + "region": { + "startLine": 18, + "startColumn": 28 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInAnalysisTarget.sarif" + }, + "message": "Analyzing 'EndLineLessThanStartLineInAnalysisTarget.sarif'...", + "level": "note", + "time": "2016-08-29T21:58:42.606Z" + } + ], + "rules": { + "SV0012": { + "id": "SV0012", + "name": "EndLineMustNotBeLessThanStartLine", + "shortDescription": "The \"endLine\" property of a region object must not be less than the \"startLine\" property.", + "fullDescription": "The \"endLine\" property of a region object must not be less than the \"startLine\" property.", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the value of the \"endLine\" property is {2}, which is less than the value of the \"startLine\" property, which is {3}." + }, + "defaultLevel": "error", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInAnalysisTarget.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineLessThanStartLineInAnalysisTarget.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineLessThanStartLineInAnalysisTarget_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T21:58:42.526Z", + "endTime": "2016-08-29T21:58:42.868Z", + "processId": 12364, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInCodeFlow.sarif b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInCodeFlow.sarif new file mode 100644 index 000000000..8d7167f6f --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInCodeFlow.sarif @@ -0,0 +1,43 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "codeFlows": [ + { + "locations": [ + { + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 2, + "endLine": 1 + } + } + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInCodeFlow_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInCodeFlow_Expected.sarif new file mode 100644 index 000000000..53b106939 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInCodeFlow_Expected.sarif @@ -0,0 +1,85 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "61fd2bcd-971f-431d-8e48-3ec64da25223", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0012", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "EndLineLessThanStartLineInCodeFlow.sarif", + "/runs/0/results/0/codeFlows/0/locations/0/physicalLocation/region", + "1", + "2" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInCodeFlow.sarif", + "region": { + "startLine": 30, + "startColumn": 32 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInCodeFlow.sarif" + }, + "message": "Analyzing 'EndLineLessThanStartLineInCodeFlow.sarif'...", + "level": "note", + "time": "2016-08-29T21:54:11.473Z" + } + ], + "rules": { + "SV0012": { + "id": "SV0012", + "name": "EndLineMustNotBeLessThanStartLine", + "shortDescription": "The \"endLine\" property of a region object must not be less than the \"startLine\" property.", + "fullDescription": "The \"endLine\" property of a region object must not be less than the \"startLine\" property.", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the value of the \"endLine\" property is {2}, which is less than the value of the \"startLine\" property, which is {3}." + }, + "defaultLevel": "error", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInCodeFlow.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineLessThanStartLineInCodeFlow.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineLessThanStartLineInCodeFlow_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T21:54:11.377Z", + "endTime": "2016-08-29T21:54:11.739Z", + "processId": 19224, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInRelatedLocation.sarif b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInRelatedLocation.sarif new file mode 100644 index 000000000..d5a7c3732 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInRelatedLocation.sarif @@ -0,0 +1,39 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "relatedLocations": [ + { + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 2, + "endLine": 1 + } + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInRelatedLocation_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInRelatedLocation_Expected.sarif new file mode 100644 index 000000000..847137166 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInRelatedLocation_Expected.sarif @@ -0,0 +1,85 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "a3bd4e92-63cd-417a-b9ef-c347dee20dad", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0012", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "EndLineLessThanStartLineInRelatedLocation.sarif", + "/runs/0/results/0/relatedLocations/0/physicalLocation/region", + "1", + "2" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInRelatedLocation.sarif", + "region": { + "startLine": 28, + "startColumn": 28 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInRelatedLocation.sarif" + }, + "message": "Analyzing 'EndLineLessThanStartLineInRelatedLocation.sarif'...", + "level": "note", + "time": "2016-08-29T21:55:14.256Z" + } + ], + "rules": { + "SV0012": { + "id": "SV0012", + "name": "EndLineMustNotBeLessThanStartLine", + "shortDescription": "The \"endLine\" property of a region object must not be less than the \"startLine\" property.", + "fullDescription": "The \"endLine\" property of a region object must not be less than the \"startLine\" property.", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the value of the \"endLine\" property is {2}, which is less than the value of the \"startLine\" property, which is {3}." + }, + "defaultLevel": "error", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInRelatedLocation.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineLessThanStartLineInRelatedLocation.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineLessThanStartLineInRelatedLocation_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T21:55:14.176Z", + "endTime": "2016-08-29T21:55:14.518Z", + "processId": 20164, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInResultFile.sarif b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInResultFile.sarif new file mode 100644 index 000000000..0d3d8ac04 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInResultFile.sarif @@ -0,0 +1,29 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message.", + "locations": [ + { + "resultFile": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 2, + "endLine": 1 + } + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInResultFile_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInResultFile_Expected.sarif new file mode 100644 index 000000000..378090fc1 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInResultFile_Expected.sarif @@ -0,0 +1,85 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "5da3f6b6-a292-4792-ae36-344666c30b28", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0012", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "EndLineLessThanStartLineInResultFile.sarif", + "/runs/0/results/0/locations/0/resultFile/region", + "1", + "2" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInResultFile.sarif", + "region": { + "startLine": 18, + "startColumn": 28 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInResultFile.sarif" + }, + "message": "Analyzing 'EndLineLessThanStartLineInResultFile.sarif'...", + "level": "note", + "time": "2016-08-29T22:00:52.318Z" + } + ], + "rules": { + "SV0012": { + "id": "SV0012", + "name": "EndLineMustNotBeLessThanStartLine", + "shortDescription": "The \"endLine\" property of a region object must not be less than the \"startLine\" property.", + "fullDescription": "The \"endLine\" property of a region object must not be less than the \"startLine\" property.", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the value of the \"endLine\" property is {2}, which is less than the value of the \"startLine\" property, which is {3}." + }, + "defaultLevel": "error", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInResultFile.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineLessThanStartLineInResultFile.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineLessThanStartLineInResultFile_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T22:00:52.226Z", + "endTime": "2016-08-29T22:00:52.571Z", + "processId": 19896, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInResultLocation_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInResultLocation_Expected.sarif new file mode 100644 index 000000000..60702fd31 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInResultLocation_Expected.sarif @@ -0,0 +1,85 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "433c232f-5c94-481f-8d09-801cd7ab886b", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0012", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "EndLineLessThanStartLineInResultLocation.sarif", + "/runs/0/results/0/locations/0/analysisTarget/region", + "1", + "2" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInResultLocation.sarif", + "region": { + "startLine": 18, + "startColumn": 28 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInResultLocation.sarif" + }, + "message": "Analyzing 'EndLineLessThanStartLineInResultLocation.sarif'...", + "level": "note", + "time": "2016-08-29T21:57:37.433Z" + } + ], + "rules": { + "SV0012": { + "id": "SV0012", + "name": "EndLineMustNotBeLessThanStartLine", + "shortDescription": "The \"endLine\" property of a region object must not be less than the \"startLine\" property.", + "fullDescription": "The \"endLine\" property of a region object must not be less than the \"startLine\" property.", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the value of the \"endLine\" property is {2}, which is less than the value of the \"startLine\" property, which is {3}." + }, + "defaultLevel": "error", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInResultLocation.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineLessThanStartLineInResultLocation.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineLessThanStartLineInResultLocation_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T21:57:37.351Z", + "endTime": "2016-08-29T21:57:37.683Z", + "processId": 13632, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineNotSpecified.sarif b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineNotSpecified.sarif new file mode 100644 index 000000000..c6c6eeea6 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineNotSpecified.sarif @@ -0,0 +1,28 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineNotSpecified_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineNotSpecified_Expected.sarif new file mode 100644 index 000000000..898f37436 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineNotSpecified_Expected.sarif @@ -0,0 +1,46 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "7f8e843a-e181-4f76-84f6-ec63f9c48c46", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineNotSpecified.sarif" + }, + "message": "Analyzing 'EndLineNotSpecified.sarif'...", + "level": "note", + "time": "2016-08-29T21:56:01.857Z" + } + ], + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineNotSpecified.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineNotSpecified.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineNotSpecified_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T21:56:01.765Z", + "endTime": "2016-08-29T21:56:02.096Z", + "processId": 11996, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli/Rules/EndLineMustNotBeLessThanStartLine.cs b/src/SarifCli/Rules/EndLineMustNotBeLessThanStartLine.cs new file mode 100644 index 000000000..f3f8c1ae9 --- /dev/null +++ b/src/SarifCli/Rules/EndLineMustNotBeLessThanStartLine.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Collections.Generic; +using System.Globalization; +using Microsoft.Json.Pointer; +using Newtonsoft.Json.Linq; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules +{ + public class EndLineMustNotBeLessThanStartLine : SarifValidationSkimmerBase + { + public override string FullDescription => RuleResources.SV0012_EndLineMustNotBeLessThanStartLine; + + public override ResultLevel DefaultLevel => ResultLevel.Error; + + /// + /// SV0012 + /// + public override string Id => RuleId.EndLineMustNotBeLessThanStartLine; + + protected override IEnumerable FormatIds + { + get + { + return new string[] + { + nameof(RuleResources.SV0012_Default) + }; + } + } + + protected override void Analyze(Region region, string regionPointer) + { + var jsonPointer = new JsonPointer(regionPointer); + var regionToken = jsonPointer.Evaluate(Context.InputLogToken); + + if (regionToken.HasProperty(SarifPropertyName.EndLine) && + region.EndLine < region.StartLine) + { + string endLinePointer = regionPointer.AtProperty(SarifPropertyName.EndLine); + + LogResult( + regionPointer, + nameof(RuleResources.SV0012_Default), + region.EndLine.ToString(CultureInfo.InvariantCulture), + region.StartLine.ToString(CultureInfo.InvariantCulture)); + } + } + } +} diff --git a/src/SarifCli/Rules/RuleId.cs b/src/SarifCli/Rules/RuleId.cs index 047070a66..cb91c3051 100644 --- a/src/SarifCli/Rules/RuleId.cs +++ b/src/SarifCli/Rules/RuleId.cs @@ -16,5 +16,6 @@ public static class RuleId public const string StepValuesMustFormOneBasedSequence = "SV0009"; public const string StepMustAppearOnlyInCodeFlowLocations = "SV0010"; public const string ImportanceMustAppearOnlyInCodeFlowLocations = "SV0011"; + public const string EndLineMustNotBeLessThanStartLine = "SV0012"; } } diff --git a/src/SarifCli/Rules/RuleResources.Designer.cs b/src/SarifCli/Rules/RuleResources.Designer.cs index d5e5d4a68..bf3995a90 100644 --- a/src/SarifCli/Rules/RuleResources.Designer.cs +++ b/src/SarifCli/Rules/RuleResources.Designer.cs @@ -284,5 +284,23 @@ internal static string SV0011_ImportanceMustAppearOnlyInCodeFlowLocations { return ResourceManager.GetString("SV0011_ImportanceMustAppearOnlyInCodeFlowLocations", resourceCulture); } } + + /// + /// Looks up a localized string similar to In "{0}", at "{1}", the value of the "endLine" property is {2}, which is less than the value of the "startLine" property, which is {3}.. + /// + internal static string SV0012_Default { + get { + return ResourceManager.GetString("SV0012_Default", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The "endLine" property of a region object must not be less than the "startLine" property.. + /// + internal static string SV0012_EndLineMustNotBeLessThanStartLine { + get { + return ResourceManager.GetString("SV0012_EndLineMustNotBeLessThanStartLine", resourceCulture); + } + } } } diff --git a/src/SarifCli/Rules/RuleResources.resx b/src/SarifCli/Rules/RuleResources.resx index 716bbd0fb..2446e7c62 100644 --- a/src/SarifCli/Rules/RuleResources.resx +++ b/src/SarifCli/Rules/RuleResources.resx @@ -192,4 +192,10 @@ The "importance" property must appear only in annotatedCodeLocation objects which occur within code flows. + + In "{0}", at "{1}", the value of the "endLine" property is {2}, which is less than the value of the "startLine" property, which is {3}. + + + The "endLine" property of a region object must not be less than the "startLine" property. + \ No newline at end of file diff --git a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs index 39ff609c1..35c8933d3 100644 --- a/src/SarifCli/Rules/SarifValidationSkimmerBase.cs +++ b/src/SarifCli/Rules/SarifValidationSkimmerBase.cs @@ -75,6 +75,10 @@ protected virtual void Analyze(PhysicalLocation physicalLocation, string physica { } + protected virtual void Analyze(Region region, string regionPointer) + { + } + protected virtual void Analyze(Result result, string resultPointer) { } @@ -200,6 +204,18 @@ private void Visit(Notification notification, string notificationPointer) private void Visit(PhysicalLocation physicalLocation, string physicalLocationPointer) { Analyze(physicalLocation, physicalLocationPointer); + + if (physicalLocation.Region != null) + { + string regionPointer = physicalLocationPointer.AtProperty(SarifPropertyName.Region); + + Visit(physicalLocation.Region, regionPointer); + } + } + + private void Visit(Region region, string regionPointer) + { + Analyze(region, regionPointer); } private void Visit(Result result, string resultPointer) diff --git a/src/SarifCli/SarifCli.csproj b/src/SarifCli/SarifCli.csproj index 26f88c672..be2b302fc 100644 --- a/src/SarifCli/SarifCli.csproj +++ b/src/SarifCli/SarifCli.csproj @@ -88,6 +88,7 @@ + diff --git a/src/SarifCli/SarifPropertyName.cs b/src/SarifCli/SarifPropertyName.cs index 5a601663c..cb67d1065 100644 --- a/src/SarifCli/SarifPropertyName.cs +++ b/src/SarifCli/SarifPropertyName.cs @@ -8,6 +8,7 @@ public static class SarifPropertyName public const string AnalysisTarget = "analysisTarget"; public const string CodeFlows = "codeFlows"; public const string ConfigurationNotifications = "configurationNotifications"; + public const string EndLine = "endLine"; public const string EndTime = "endTime"; public const string Essential = "essential"; public const string FileChanges = "fileChanges"; @@ -22,6 +23,7 @@ public static class SarifPropertyName public const string Message = "message"; public const string MessageFormats = "messageFormats"; public const string PhysicalLocation = "physicalLocation"; + public const string Region = "region"; public const string RelatedLocations = "relatedLocations"; public const string ResultFile = "resultFile"; public const string Results = "results"; From 0e4089876e6b08401550e6f05dfc52aea0c84cca Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Mon, 29 Aug 2016 15:17:58 -0700 Subject: [PATCH 46/51] SarifCli: Refactor: Introduce ToInvariantString --- src/SarifCli/IntegerExtensions.cs | 15 +++++++++++++++ .../Rules/EndLineMustNotBeLessThanStartLine.cs | 6 ++---- .../Rules/StepValuesMustFormOneBasedSequence.cs | 5 ++--- src/SarifCli/SarifCli.csproj | 1 + 4 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 src/SarifCli/IntegerExtensions.cs diff --git a/src/SarifCli/IntegerExtensions.cs b/src/SarifCli/IntegerExtensions.cs new file mode 100644 index 000000000..a44e091f3 --- /dev/null +++ b/src/SarifCli/IntegerExtensions.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Globalization; + +namespace Microsoft.CodeAnalysis.Sarif.Cli +{ + internal static class IntegerExtensions + { + public static string ToInvariantString(this int n) + { + return n.ToString(CultureInfo.InvariantCulture); + } + } +} diff --git a/src/SarifCli/Rules/EndLineMustNotBeLessThanStartLine.cs b/src/SarifCli/Rules/EndLineMustNotBeLessThanStartLine.cs index f3f8c1ae9..d778735a8 100644 --- a/src/SarifCli/Rules/EndLineMustNotBeLessThanStartLine.cs +++ b/src/SarifCli/Rules/EndLineMustNotBeLessThanStartLine.cs @@ -2,9 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; -using System.Globalization; using Microsoft.Json.Pointer; -using Newtonsoft.Json.Linq; namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules { @@ -43,8 +41,8 @@ protected override void Analyze(Region region, string regionPointer) LogResult( regionPointer, nameof(RuleResources.SV0012_Default), - region.EndLine.ToString(CultureInfo.InvariantCulture), - region.StartLine.ToString(CultureInfo.InvariantCulture)); + region.EndLine.ToInvariantString(), + region.StartLine.ToInvariantString()); } } } diff --git a/src/SarifCli/Rules/StepValuesMustFormOneBasedSequence.cs b/src/SarifCli/Rules/StepValuesMustFormOneBasedSequence.cs index 08cc5c199..4fbe15ef2 100644 --- a/src/SarifCli/Rules/StepValuesMustFormOneBasedSequence.cs +++ b/src/SarifCli/Rules/StepValuesMustFormOneBasedSequence.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Globalization; using System.Linq; using Microsoft.Json.Pointer; using Newtonsoft.Json.Linq; @@ -79,8 +78,8 @@ private void ReportInvalidStepValues( LogResult( invalidStepPointer, nameof(RuleResources.SV0009_InvalidStepValue), - (i + 1).ToString(CultureInfo.InvariantCulture), - (locations[i].Step).ToString(CultureInfo.InvariantCulture)); + (i + 1).ToInvariantString(), + (locations[i].Step).ToInvariantString()); } } } diff --git a/src/SarifCli/SarifCli.csproj b/src/SarifCli/SarifCli.csproj index be2b302fc..e5bcbfcaa 100644 --- a/src/SarifCli/SarifCli.csproj +++ b/src/SarifCli/SarifCli.csproj @@ -86,6 +86,7 @@ + From 9e6ea5a13bed21384961fe33bd568e66534c0e87 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Mon, 29 Aug 2016 16:14:57 -0700 Subject: [PATCH 47/51] SarifCli: Implement EndColumnMustNotBeLessThanStartColumn rule --- ...ColumnMustNotBeLessThanStartColumnTests.cs | 65 ++++++++++++++ .../SarifCli.FunctionalTests.csproj | 55 ++++++++++++ .../EndColumnEqualsStartColumn.sarif | 31 +++++++ .../EndColumnEqualsStartColumnNoEndLine.sarif | 30 +++++++ ...nEqualsStartColumnNoEndLine_Expected.sarif | 46 ++++++++++ .../EndColumnEqualsStartColumn_Expected.sarif | 46 ++++++++++ .../EndColumnGreaterThanStartColumn.sarif | 30 +++++++ ...olumnGreaterThanStartColumn_Expected.sarif | 46 ++++++++++ ...nLessThanStartColumnInAnalysisTarget.sarif | 31 +++++++ ...StartColumnInAnalysisTargetNoEndLine.sarif | 30 +++++++ ...mnInAnalysisTargetNoEndLine_Expected.sarif | 85 +++++++++++++++++++ ...StartColumnInAnalysisTarget_Expected.sarif | 85 +++++++++++++++++++ ...dColumnLessThanStartColumnInCodeFlow.sarif | 44 ++++++++++ ...ssThanStartColumnInCodeFlow_Expected.sarif | 85 +++++++++++++++++++ ...LessThanStartColumnInRelatedLocation.sarif | 40 +++++++++ ...tartColumnInRelatedLocation_Expected.sarif | 85 +++++++++++++++++++ ...olumnLessThanStartColumnInResultFile.sarif | 30 +++++++ ...ThanStartColumnInResultFile_Expected.sarif | 85 +++++++++++++++++++ .../EndColumnNotSpecified.sarif | 29 +++++++ .../EndColumnNotSpecified_Expected.sarif | 46 ++++++++++ ...anStartLineInAnalysisTarget_Expected.sarif | 16 ++-- ...LessThanStartLineInCodeFlow_Expected.sarif | 16 ++-- ...nStartLineInRelatedLocation_Expected.sarif | 16 ++-- ...ssThanStartLineInResultFile_Expected.sarif | 16 ++-- .../EndColumnMustNotBeLessThanStartColumn.cs | 59 +++++++++++++ .../EndLineMustNotBeLessThanStartLine.cs | 2 +- src/SarifCli/Rules/RuleId.cs | 1 + src/SarifCli/Rules/RuleResources.Designer.cs | 18 ++++ src/SarifCli/Rules/RuleResources.resx | 6 ++ src/SarifCli/SarifCli.csproj | 4 + src/SarifCli/SarifPropertyName.cs | 1 + 31 files changed, 1146 insertions(+), 33 deletions(-) create mode 100644 src/SarifCli.FunctionalTests/Rules/EndColumnMustNotBeLessThanStartColumnTests.cs create mode 100644 src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnEqualsStartColumn.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnEqualsStartColumnNoEndLine.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnEqualsStartColumnNoEndLine_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnEqualsStartColumn_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnGreaterThanStartColumn.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnGreaterThanStartColumn_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInAnalysisTarget.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInAnalysisTargetNoEndLine.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInAnalysisTargetNoEndLine_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInAnalysisTarget_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInCodeFlow.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInCodeFlow_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInRelatedLocation.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInRelatedLocation_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInResultFile.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInResultFile_Expected.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnNotSpecified.sarif create mode 100644 src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnNotSpecified_Expected.sarif create mode 100644 src/SarifCli/Rules/EndColumnMustNotBeLessThanStartColumn.cs diff --git a/src/SarifCli.FunctionalTests/Rules/EndColumnMustNotBeLessThanStartColumnTests.cs b/src/SarifCli.FunctionalTests/Rules/EndColumnMustNotBeLessThanStartColumnTests.cs new file mode 100644 index 000000000..14fe59ab8 --- /dev/null +++ b/src/SarifCli.FunctionalTests/Rules/EndColumnMustNotBeLessThanStartColumnTests.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.CodeAnalysis.Sarif.Cli.Rules; +using Xunit; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.FunctionalTests.Rules +{ + public class EndColumnMustNotBeLessThanStartColumnTests : SkimmerTestsBase + { + [Fact(DisplayName = nameof(EndColumnMustNotBeLessThanStartColumn_EndColumnEqualsStartColumn))] + public void EndColumnMustNotBeLessThanStartColumn_EndColumnEqualsStartColumn() + { + Verify(new EndColumnMustNotBeLessThanStartColumn(), "EndColumnEqualsStartColumn.sarif"); + } + + [Fact(DisplayName = nameof(EndColumnMustNotBeLessThanStartColumn_EndColumnEqualsStartColumnNoEndLine))] + public void EndColumnMustNotBeLessThanStartColumn_EndColumnEqualsStartColumnNoEndLine() + { + Verify(new EndColumnMustNotBeLessThanStartColumn(), "EndColumnEqualsStartColumnNoEndLine.sarif"); + } + + [Fact(DisplayName = nameof(EndColumnMustNotBeLessThanStartColumn_EndColumnGreaterThanStartColumn))] + public void EndColumnMustNotBeLessThanStartColumn_EndColumnGreaterThanStartColumn() + { + Verify(new EndColumnMustNotBeLessThanStartColumn(), "EndColumnGreaterThanStartColumn.sarif"); + } + + [Fact(DisplayName = nameof(EndColumnMustNotBeLessThanStartColumn_EndColumnLessThanStartColumnInAnalysisTarget))] + public void EndColumnMustNotBeLessThanStartColumn_EndColumnLessThanStartColumnInAnalysisTarget() + { + Verify(new EndColumnMustNotBeLessThanStartColumn(), "EndColumnLessThanStartColumnInAnalysisTarget.sarif"); + } + + [Fact(DisplayName = nameof(EndColumnMustNotBeLessThanStartColumn_EndColumnLessThanStartColumnInAnalysisTargetNoEndLine))] + public void EndColumnMustNotBeLessThanStartColumn_EndColumnLessThanStartColumnInAnalysisTargetNoEndLine() + { + Verify(new EndColumnMustNotBeLessThanStartColumn(), "EndColumnLessThanStartColumnInAnalysisTargetNoEndLine.sarif"); + } + + [Fact(DisplayName = nameof(EndColumnMustNotBeLessThanStartColumn_EndColumnLessThanStartColumnInCodeFlow))] + public void EndColumnMustNotBeLessThanStartColumn_EndColumnLessThanStartColumnInCodeFlow() + { + Verify(new EndColumnMustNotBeLessThanStartColumn(), "EndColumnLessThanStartColumnInCodeFlow.sarif"); + } + + [Fact(DisplayName = nameof(EndColumnMustNotBeLessThanStartColumn_EndColumnLessThanStartColumnInRelatedLocation))] + public void EndColumnMustNotBeLessThanStartColumn_EndColumnLessThanStartColumnInRelatedLocation() + { + Verify(new EndColumnMustNotBeLessThanStartColumn(), "EndColumnLessThanStartColumnInRelatedLocation.sarif"); + } + + [Fact(DisplayName = nameof(EndColumnMustNotBeLessThanStartColumn_EndColumnLessThanStartColumnInResultFile))] + public void EndColumnMustNotBeLessThanStartColumn_EndColumnLessThanStartColumnInResultFile() + { + Verify(new EndColumnMustNotBeLessThanStartColumn(), "EndColumnLessThanStartColumnInResultFile.sarif"); + } + + [Fact(DisplayName = nameof(EndColumnMustNotBeLessThanStartColumn_EndColumnNotSpecified))] + public void EndColumnMustNotBeLessThanStartColumn_EndColumnNotSpecified() + { + Verify(new EndColumnMustNotBeLessThanStartColumn(), "EndColumnNotSpecified.sarif"); + } + } +} diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj index 520d269d9..5e537c73d 100644 --- a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -86,6 +86,7 @@ + @@ -177,6 +178,60 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnEqualsStartColumn.sarif b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnEqualsStartColumn.sarif new file mode 100644 index 000000000..875f68c79 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnEqualsStartColumn.sarif @@ -0,0 +1,31 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1, + "endLine": 1, + "startColumn": 5, + "endColumn": 5 + } + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnEqualsStartColumnNoEndLine.sarif b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnEqualsStartColumnNoEndLine.sarif new file mode 100644 index 000000000..8c19041f5 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnEqualsStartColumnNoEndLine.sarif @@ -0,0 +1,30 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1, + "startColumn": 5, + "endColumn": 5 + } + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnEqualsStartColumnNoEndLine_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnEqualsStartColumnNoEndLine_Expected.sarif new file mode 100644 index 000000000..554bd2faa --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnEqualsStartColumnNoEndLine_Expected.sarif @@ -0,0 +1,46 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "5d4a4af6-02ee-4c06-95c6-cdebe48131a3", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnEqualsStartColumnNoEndLine.sarif" + }, + "message": "Analyzing 'EndColumnEqualsStartColumnNoEndLine.sarif'...", + "level": "note", + "time": "2016-08-29T22:45:00.345Z" + } + ], + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnEqualsStartColumnNoEndLine.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndColumnMustNotBeLessThanStartColumn\\EndColumnEqualsStartColumnNoEndLine.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndColumnMustNotBeLessThanStartColumn\\EndColumnEqualsStartColumnNoEndLine_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T22:45:00.252Z", + "endTime": "2016-08-29T22:45:00.577Z", + "processId": 18692, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnEqualsStartColumn_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnEqualsStartColumn_Expected.sarif new file mode 100644 index 000000000..c555e2c92 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnEqualsStartColumn_Expected.sarif @@ -0,0 +1,46 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "180b373a-b1ed-4a13-87e4-8d45be979492", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnEqualsStartColumn.sarif" + }, + "message": "Analyzing 'EndColumnEqualsStartColumn.sarif'...", + "level": "note", + "time": "2016-08-29T22:43:23.693Z" + } + ], + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnEqualsStartColumn.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndColumnMustNotBeLessThanStartColumn\\EndColumnEqualsStartColumn.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndColumnMustNotBeLessThanStartColumn\\EndColumnEqualsStartColumn_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T22:43:23.457Z", + "endTime": "2016-08-29T22:43:23.973Z", + "processId": 11972, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnGreaterThanStartColumn.sarif b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnGreaterThanStartColumn.sarif new file mode 100644 index 000000000..148b2f678 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnGreaterThanStartColumn.sarif @@ -0,0 +1,30 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1, + "startColumn": 1, + "endColumn": 2 + } + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnGreaterThanStartColumn_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnGreaterThanStartColumn_Expected.sarif new file mode 100644 index 000000000..9739b569a --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnGreaterThanStartColumn_Expected.sarif @@ -0,0 +1,46 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "39ec3553-1ac6-46e8-acdd-74ab2aa8e9d7", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnGreaterThanStartColumn.sarif" + }, + "message": "Analyzing 'EndColumnGreaterThanStartColumn.sarif'...", + "level": "note", + "time": "2016-08-29T22:46:13.496Z" + } + ], + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnGreaterThanStartColumn.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndColumnMustNotBeLessThanStartColumn\\EndColumnGreaterThanStartColumn.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndColumnMustNotBeLessThanStartColumn\\EndColumnGreaterThanStartColumn_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T22:46:13.418Z", + "endTime": "2016-08-29T22:46:13.746Z", + "processId": 15640, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInAnalysisTarget.sarif b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInAnalysisTarget.sarif new file mode 100644 index 000000000..17f6c7570 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInAnalysisTarget.sarif @@ -0,0 +1,31 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 2, + "endLine": 2, + "startColumn": 2, + "endColumn": 1 + } + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInAnalysisTargetNoEndLine.sarif b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInAnalysisTargetNoEndLine.sarif new file mode 100644 index 000000000..5951ff773 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInAnalysisTargetNoEndLine.sarif @@ -0,0 +1,30 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 2, + "startColumn": 2, + "endColumn": 1 + } + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInAnalysisTargetNoEndLine_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInAnalysisTargetNoEndLine_Expected.sarif new file mode 100644 index 000000000..e32391013 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInAnalysisTargetNoEndLine_Expected.sarif @@ -0,0 +1,85 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "2d9f0c97-2380-49ef-912c-de278ff978ca", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0013", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "EndColumnLessThanStartColumnInAnalysisTargetNoEndLine.sarif", + "/runs/0/results/0/locations/0/analysisTarget/region/endColumn", + "1", + "2" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInAnalysisTargetNoEndLine.sarif", + "region": { + "startLine": 21, + "startColumn": 33 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInAnalysisTargetNoEndLine.sarif" + }, + "message": "Analyzing 'EndColumnLessThanStartColumnInAnalysisTargetNoEndLine.sarif'...", + "level": "note", + "time": "2016-08-29T22:55:15.445Z" + } + ], + "rules": { + "SV0013": { + "id": "SV0013", + "name": "EndColumnMustNotBeLessThanStartColumn", + "shortDescription": "The \"endColumn\" property of a region object must not be less than the \"startColumn\" property.", + "fullDescription": "The \"endColumn\" property of a region object must not be less than the \"startColumn\" property.", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the value of the \"endColumn\" property is {2}, which is less than the value of the \"startColumn\" property, which is {3}." + }, + "defaultLevel": "error", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInAnalysisTargetNoEndLine.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndColumnMustNotBeLessThanStartColumn\\EndColumnLessThanStartColumnInAnalysisTargetNoEndLine.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndColumnMustNotBeLessThanStartColumn\\EndColumnLessThanStartColumnInAnalysisTargetNoEndLine_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T22:55:15.365Z", + "endTime": "2016-08-29T22:55:15.699Z", + "processId": 8660, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInAnalysisTarget_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInAnalysisTarget_Expected.sarif new file mode 100644 index 000000000..2d503a8f6 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInAnalysisTarget_Expected.sarif @@ -0,0 +1,85 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "656db149-9960-4e66-8d52-01f025509706", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0013", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "EndColumnLessThanStartColumnInAnalysisTarget.sarif", + "/runs/0/results/0/locations/0/analysisTarget/region/endColumn", + "1", + "2" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInAnalysisTarget.sarif", + "region": { + "startLine": 22, + "startColumn": 33 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInAnalysisTarget.sarif" + }, + "message": "Analyzing 'EndColumnLessThanStartColumnInAnalysisTarget.sarif'...", + "level": "note", + "time": "2016-08-29T22:54:31.283Z" + } + ], + "rules": { + "SV0013": { + "id": "SV0013", + "name": "EndColumnMustNotBeLessThanStartColumn", + "shortDescription": "The \"endColumn\" property of a region object must not be less than the \"startColumn\" property.", + "fullDescription": "The \"endColumn\" property of a region object must not be less than the \"startColumn\" property.", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the value of the \"endColumn\" property is {2}, which is less than the value of the \"startColumn\" property, which is {3}." + }, + "defaultLevel": "error", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInAnalysisTarget.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndColumnMustNotBeLessThanStartColumn\\EndColumnLessThanStartColumnInAnalysisTarget.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndColumnMustNotBeLessThanStartColumn\\EndColumnLessThanStartColumnInAnalysisTarget_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T22:54:31.192Z", + "endTime": "2016-08-29T22:54:31.542Z", + "processId": 540, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInCodeFlow.sarif b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInCodeFlow.sarif new file mode 100644 index 000000000..009501417 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInCodeFlow.sarif @@ -0,0 +1,44 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "codeFlows": [ + { + "locations": [ + { + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 2, + "startColumn": 2, + "endColumn": 1 + } + } + } + ] + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInCodeFlow_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInCodeFlow_Expected.sarif new file mode 100644 index 000000000..4834e30b9 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInCodeFlow_Expected.sarif @@ -0,0 +1,85 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "07216c89-437f-4257-9332-a4654890e958", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0013", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "EndColumnLessThanStartColumnInCodeFlow.sarif", + "/runs/0/results/0/codeFlows/0/locations/0/physicalLocation/region/endColumn", + "1", + "2" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInCodeFlow.sarif", + "region": { + "startLine": 33, + "startColumn": 37 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInCodeFlow.sarif" + }, + "message": "Analyzing 'EndColumnLessThanStartColumnInCodeFlow.sarif'...", + "level": "note", + "time": "2016-08-29T22:56:07.975Z" + } + ], + "rules": { + "SV0013": { + "id": "SV0013", + "name": "EndColumnMustNotBeLessThanStartColumn", + "shortDescription": "The \"endColumn\" property of a region object must not be less than the \"startColumn\" property.", + "fullDescription": "The \"endColumn\" property of a region object must not be less than the \"startColumn\" property.", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the value of the \"endColumn\" property is {2}, which is less than the value of the \"startColumn\" property, which is {3}." + }, + "defaultLevel": "error", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInCodeFlow.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndColumnMustNotBeLessThanStartColumn\\EndColumnLessThanStartColumnInCodeFlow.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndColumnMustNotBeLessThanStartColumn\\EndColumnLessThanStartColumnInCodeFlow_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T22:56:07.896Z", + "endTime": "2016-08-29T22:56:08.240Z", + "processId": 9316, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInRelatedLocation.sarif b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInRelatedLocation.sarif new file mode 100644 index 000000000..dbd03defc --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInRelatedLocation.sarif @@ -0,0 +1,40 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1 + } + } + } + ], + "relatedLocations": [ + { + "physicalLocation": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 2, + "startColumn": 2, + "endColumn": 1 + } + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInRelatedLocation_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInRelatedLocation_Expected.sarif new file mode 100644 index 000000000..313af8ff0 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInRelatedLocation_Expected.sarif @@ -0,0 +1,85 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "9cff9928-f161-4658-9090-327b4a3e44bb", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0013", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "EndColumnLessThanStartColumnInRelatedLocation.sarif", + "/runs/0/results/0/relatedLocations/0/physicalLocation/region/endColumn", + "1", + "2" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInRelatedLocation.sarif", + "region": { + "startLine": 31, + "startColumn": 34 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInRelatedLocation.sarif" + }, + "message": "Analyzing 'EndColumnLessThanStartColumnInRelatedLocation.sarif'...", + "level": "note", + "time": "2016-08-29T23:11:40.966Z" + } + ], + "rules": { + "SV0013": { + "id": "SV0013", + "name": "EndColumnMustNotBeLessThanStartColumn", + "shortDescription": "The \"endColumn\" property of a region object must not be less than the \"startColumn\" property.", + "fullDescription": "The \"endColumn\" property of a region object must not be less than the \"startColumn\" property.", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the value of the \"endColumn\" property is {2}, which is less than the value of the \"startColumn\" property, which is {3}." + }, + "defaultLevel": "error", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInRelatedLocation.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndColumnMustNotBeLessThanStartColumn\\EndColumnLessThanStartColumnInRelatedLocation.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndColumnMustNotBeLessThanStartColumn\\EndColumnLessThanStartColumnInRelatedLocation_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T23:11:40.876Z", + "endTime": "2016-08-29T23:11:41.222Z", + "processId": 12580, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInResultFile.sarif b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInResultFile.sarif new file mode 100644 index 000000000..38a377058 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInResultFile.sarif @@ -0,0 +1,30 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message.", + "locations": [ + { + "resultFile": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 2, + "startColumn": 2, + "endColumn": 1 + } + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInResultFile_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInResultFile_Expected.sarif new file mode 100644 index 000000000..eb61180fe --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInResultFile_Expected.sarif @@ -0,0 +1,85 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "b4d344e3-cf08-40fb-a416-c7d691717d56", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "results": [ + { + "ruleId": "SV0013", + "level": "error", + "formattedRuleMessage": { + "formatId": "Default", + "arguments": [ + "EndColumnLessThanStartColumnInResultFile.sarif", + "/runs/0/results/0/locations/0/resultFile/region/endColumn", + "1", + "2" + ] + }, + "locations": [ + { + "analysisTarget": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInResultFile.sarif", + "region": { + "startLine": 21, + "startColumn": 33 + } + } + } + ] + } + ], + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInResultFile.sarif" + }, + "message": "Analyzing 'EndColumnLessThanStartColumnInResultFile.sarif'...", + "level": "note", + "time": "2016-08-29T23:11:08.694Z" + } + ], + "rules": { + "SV0013": { + "id": "SV0013", + "name": "EndColumnMustNotBeLessThanStartColumn", + "shortDescription": "The \"endColumn\" property of a region object must not be less than the \"startColumn\" property.", + "fullDescription": "The \"endColumn\" property of a region object must not be less than the \"startColumn\" property.", + "messageFormats": { + "Default": "In \"{0}\", at \"{1}\", the value of the \"endColumn\" property is {2}, which is less than the value of the \"startColumn\" property, which is {3}." + }, + "defaultLevel": "error", + "helpUri": "https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html" + } + }, + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnLessThanStartColumnInResultFile.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndColumnMustNotBeLessThanStartColumn\\EndColumnLessThanStartColumnInResultFile.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndColumnMustNotBeLessThanStartColumn\\EndColumnLessThanStartColumnInResultFile_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T23:11:08.603Z", + "endTime": "2016-08-29T23:11:08.949Z", + "processId": 3548, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnNotSpecified.sarif b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnNotSpecified.sarif new file mode 100644 index 000000000..e909f1aa8 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnNotSpecified.sarif @@ -0,0 +1,29 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "tool": { + "name": "CodeScanner" + }, + "results": [ + { + "ruleId": "TST0001", + "level": "error", + "message": "Result message.", + "locations": [ + { + "analysisTarget": { + "uri": "file:///c:/src/file.c", + "region": { + "startLine": 1, + "startColumn": 2 + } + } + } + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnNotSpecified_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnNotSpecified_Expected.sarif new file mode 100644 index 000000000..299deddf6 --- /dev/null +++ b/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnNotSpecified_Expected.sarif @@ -0,0 +1,46 @@ +{ + "$schema": "http://json.schemastore.org/sarif-1.0.0", + "version": "1.0.0", + "runs": [ + { + "id": "dc4a37c2-19b8-4db5-8d4b-93016a5b34ba", + "tool": { + "name": "SarifCli", + "fullName": "SarifCli 1.0.0.0", + "version": "1.0.0.0", + "semanticVersion": "1.0.0", + "sarifLoggerVersion": "1.5.27.0", + "language": "en-US", + "properties": { + "Comments": "Command line tool for working with SARIF log files.", + "CompanyName": "Microsoft Corporation", + "ProductName": "Microsoft SARIF SDK" + } + }, + "toolNotifications": [ + { + "id": "MSG001.AnalyzingTarget", + "physicalLocation": { + "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnNotSpecified.sarif" + }, + "message": "Analyzing 'EndColumnNotSpecified.sarif'...", + "level": "note", + "time": "2016-08-29T22:59:10.501Z" + } + ], + "files": { + "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndColumnMustNotBeLessThanStartColumn/EndColumnNotSpecified.sarif": { + "mimeType": "application/octet-stream" + } + }, + "invocation": { + "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndColumnMustNotBeLessThanStartColumn\\EndColumnNotSpecified.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndColumnMustNotBeLessThanStartColumn\\EndColumnNotSpecified_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", + "startTime": "2016-08-29T22:59:10.406Z", + "endTime": "2016-08-29T22:59:10.736Z", + "processId": 3772, + "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", + "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" + } + } + ] +} \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInAnalysisTarget_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInAnalysisTarget_Expected.sarif index a12fa9bb0..5c01e72a3 100644 --- a/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInAnalysisTarget_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInAnalysisTarget_Expected.sarif @@ -3,7 +3,7 @@ "version": "1.0.0", "runs": [ { - "id": "d3877f93-40a9-481f-bfc4-4c9af1ef7525", + "id": "3529dda6-e6ed-4bc3-b6fb-24d714a39183", "tool": { "name": "SarifCli", "fullName": "SarifCli 1.0.0.0", @@ -25,7 +25,7 @@ "formatId": "Default", "arguments": [ "EndLineLessThanStartLineInAnalysisTarget.sarif", - "/runs/0/results/0/locations/0/analysisTarget/region", + "/runs/0/results/0/locations/0/analysisTarget/region/endLine", "1", "2" ] @@ -35,8 +35,8 @@ "analysisTarget": { "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInAnalysisTarget.sarif", "region": { - "startLine": 18, - "startColumn": 28 + "startLine": 20, + "startColumn": 31 } } } @@ -51,7 +51,7 @@ }, "message": "Analyzing 'EndLineLessThanStartLineInAnalysisTarget.sarif'...", "level": "note", - "time": "2016-08-29T21:58:42.606Z" + "time": "2016-08-29T23:01:05.747Z" } ], "rules": { @@ -74,9 +74,9 @@ }, "invocation": { "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineLessThanStartLineInAnalysisTarget.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineLessThanStartLineInAnalysisTarget_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", - "startTime": "2016-08-29T21:58:42.526Z", - "endTime": "2016-08-29T21:58:42.868Z", - "processId": 12364, + "startTime": "2016-08-29T23:01:05.654Z", + "endTime": "2016-08-29T23:01:05.995Z", + "processId": 19144, "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" } diff --git a/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInCodeFlow_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInCodeFlow_Expected.sarif index 53b106939..b7bb4cb1c 100644 --- a/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInCodeFlow_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInCodeFlow_Expected.sarif @@ -3,7 +3,7 @@ "version": "1.0.0", "runs": [ { - "id": "61fd2bcd-971f-431d-8e48-3ec64da25223", + "id": "8cb0b1ed-810c-43f3-9121-ba39bcd1c0e5", "tool": { "name": "SarifCli", "fullName": "SarifCli 1.0.0.0", @@ -25,7 +25,7 @@ "formatId": "Default", "arguments": [ "EndLineLessThanStartLineInCodeFlow.sarif", - "/runs/0/results/0/codeFlows/0/locations/0/physicalLocation/region", + "/runs/0/results/0/codeFlows/0/locations/0/physicalLocation/region/endLine", "1", "2" ] @@ -35,8 +35,8 @@ "analysisTarget": { "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInCodeFlow.sarif", "region": { - "startLine": 30, - "startColumn": 32 + "startLine": 32, + "startColumn": 35 } } } @@ -51,7 +51,7 @@ }, "message": "Analyzing 'EndLineLessThanStartLineInCodeFlow.sarif'...", "level": "note", - "time": "2016-08-29T21:54:11.473Z" + "time": "2016-08-29T23:02:10.430Z" } ], "rules": { @@ -74,9 +74,9 @@ }, "invocation": { "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineLessThanStartLineInCodeFlow.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineLessThanStartLineInCodeFlow_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", - "startTime": "2016-08-29T21:54:11.377Z", - "endTime": "2016-08-29T21:54:11.739Z", - "processId": 19224, + "startTime": "2016-08-29T23:02:10.353Z", + "endTime": "2016-08-29T23:02:10.709Z", + "processId": 7948, "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" } diff --git a/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInRelatedLocation_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInRelatedLocation_Expected.sarif index 847137166..90f608b4a 100644 --- a/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInRelatedLocation_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInRelatedLocation_Expected.sarif @@ -3,7 +3,7 @@ "version": "1.0.0", "runs": [ { - "id": "a3bd4e92-63cd-417a-b9ef-c347dee20dad", + "id": "472f867a-692a-4dd8-96c0-7a8d6e787d6b", "tool": { "name": "SarifCli", "fullName": "SarifCli 1.0.0.0", @@ -25,7 +25,7 @@ "formatId": "Default", "arguments": [ "EndLineLessThanStartLineInRelatedLocation.sarif", - "/runs/0/results/0/relatedLocations/0/physicalLocation/region", + "/runs/0/results/0/relatedLocations/0/physicalLocation/region/endLine", "1", "2" ] @@ -35,8 +35,8 @@ "analysisTarget": { "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInRelatedLocation.sarif", "region": { - "startLine": 28, - "startColumn": 28 + "startLine": 30, + "startColumn": 32 } } } @@ -51,7 +51,7 @@ }, "message": "Analyzing 'EndLineLessThanStartLineInRelatedLocation.sarif'...", "level": "note", - "time": "2016-08-29T21:55:14.256Z" + "time": "2016-08-29T23:02:50.227Z" } ], "rules": { @@ -74,9 +74,9 @@ }, "invocation": { "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineLessThanStartLineInRelatedLocation.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineLessThanStartLineInRelatedLocation_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", - "startTime": "2016-08-29T21:55:14.176Z", - "endTime": "2016-08-29T21:55:14.518Z", - "processId": 20164, + "startTime": "2016-08-29T23:02:50.134Z", + "endTime": "2016-08-29T23:02:50.495Z", + "processId": 7572, "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" } diff --git a/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInResultFile_Expected.sarif b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInResultFile_Expected.sarif index 378090fc1..6754eced1 100644 --- a/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInResultFile_Expected.sarif +++ b/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInResultFile_Expected.sarif @@ -3,7 +3,7 @@ "version": "1.0.0", "runs": [ { - "id": "5da3f6b6-a292-4792-ae36-344666c30b28", + "id": "354bf806-7d23-41d9-854a-36cdfbcc91f5", "tool": { "name": "SarifCli", "fullName": "SarifCli 1.0.0.0", @@ -25,7 +25,7 @@ "formatId": "Default", "arguments": [ "EndLineLessThanStartLineInResultFile.sarif", - "/runs/0/results/0/locations/0/resultFile/region", + "/runs/0/results/0/locations/0/resultFile/region/endLine", "1", "2" ] @@ -35,8 +35,8 @@ "analysisTarget": { "uri": "file:///G:/Code/sarif-sdk/src/SarifCli.FunctionalTests/TestData/EndLineMustNotBeLessThanStartLine/EndLineLessThanStartLineInResultFile.sarif", "region": { - "startLine": 18, - "startColumn": 28 + "startLine": 20, + "startColumn": 31 } } } @@ -51,7 +51,7 @@ }, "message": "Analyzing 'EndLineLessThanStartLineInResultFile.sarif'...", "level": "note", - "time": "2016-08-29T22:00:52.318Z" + "time": "2016-08-29T23:03:12.459Z" } ], "rules": { @@ -74,9 +74,9 @@ }, "invocation": { "commandLine": "\"G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe\" validate G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineLessThanStartLineInResultFile.sarif -o G:\\Code\\sarif-sdk\\src\\SarifCli.FunctionalTests\\TestData\\EndLineMustNotBeLessThanStartLine\\EndLineLessThanStartLineInResultFile_Expected.sarif -j G:\\Code\\sarif-sdk\\src\\Sarif\\Schemata\\Sarif.schema.json ", - "startTime": "2016-08-29T22:00:52.226Z", - "endTime": "2016-08-29T22:00:52.571Z", - "processId": 19896, + "startTime": "2016-08-29T23:03:12.380Z", + "endTime": "2016-08-29T23:03:12.709Z", + "processId": 10512, "fileName": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug\\SarifCli.exe", "workingDirectory": "G:\\Code\\sarif-sdk\\bld\\bin\\SarifCli\\AnyCPU_Debug" } diff --git a/src/SarifCli/Rules/EndColumnMustNotBeLessThanStartColumn.cs b/src/SarifCli/Rules/EndColumnMustNotBeLessThanStartColumn.cs new file mode 100644 index 000000000..50f5c9ea2 --- /dev/null +++ b/src/SarifCli/Rules/EndColumnMustNotBeLessThanStartColumn.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using Microsoft.Json.Pointer; +using Newtonsoft.Json.Linq; + +namespace Microsoft.CodeAnalysis.Sarif.Cli.Rules +{ + public class EndColumnMustNotBeLessThanStartColumn : SarifValidationSkimmerBase + { + public override string FullDescription => RuleResources.SV0013_EndColumnMustNotBeLessThanStartColumn; + + public override ResultLevel DefaultLevel => ResultLevel.Error; + + /// + /// SV0013 + /// + public override string Id => RuleId.EndColumnMustNotBeLessThanStartColumn; + + protected override IEnumerable FormatIds + { + get + { + return new string[] + { + nameof(RuleResources.SV0013_Default) + }; + } + } + + protected override void Analyze(Region region, string regionPointer) + { + var jsonPointer = new JsonPointer(regionPointer); + var regionToken = jsonPointer.Evaluate(Context.InputLogToken); + + if (RegionIsOnOneLine(region, regionToken) && + regionToken.HasProperty(SarifPropertyName.EndColumn) && + region.EndColumn < region.StartColumn) + { + string endColumnPointer = regionPointer.AtProperty(SarifPropertyName.EndColumn); + + LogResult( + endColumnPointer, + nameof(RuleResources.SV0013_Default), + region.EndColumn.ToInvariantString(), + region.StartColumn.ToInvariantString()); + } + } + + private static bool RegionIsOnOneLine(Region region, JToken regionToken) + { + return regionToken.HasProperty(SarifPropertyName.EndLine) + ? region.StartLine == region.EndLine + : true; + } + } +} diff --git a/src/SarifCli/Rules/EndLineMustNotBeLessThanStartLine.cs b/src/SarifCli/Rules/EndLineMustNotBeLessThanStartLine.cs index d778735a8..a1d77e191 100644 --- a/src/SarifCli/Rules/EndLineMustNotBeLessThanStartLine.cs +++ b/src/SarifCli/Rules/EndLineMustNotBeLessThanStartLine.cs @@ -39,7 +39,7 @@ protected override void Analyze(Region region, string regionPointer) string endLinePointer = regionPointer.AtProperty(SarifPropertyName.EndLine); LogResult( - regionPointer, + endLinePointer, nameof(RuleResources.SV0012_Default), region.EndLine.ToInvariantString(), region.StartLine.ToInvariantString()); diff --git a/src/SarifCli/Rules/RuleId.cs b/src/SarifCli/Rules/RuleId.cs index cb91c3051..81e77de5f 100644 --- a/src/SarifCli/Rules/RuleId.cs +++ b/src/SarifCli/Rules/RuleId.cs @@ -17,5 +17,6 @@ public static class RuleId public const string StepMustAppearOnlyInCodeFlowLocations = "SV0010"; public const string ImportanceMustAppearOnlyInCodeFlowLocations = "SV0011"; public const string EndLineMustNotBeLessThanStartLine = "SV0012"; + public const string EndColumnMustNotBeLessThanStartColumn = "SV0013"; } } diff --git a/src/SarifCli/Rules/RuleResources.Designer.cs b/src/SarifCli/Rules/RuleResources.Designer.cs index bf3995a90..188fc1cbf 100644 --- a/src/SarifCli/Rules/RuleResources.Designer.cs +++ b/src/SarifCli/Rules/RuleResources.Designer.cs @@ -302,5 +302,23 @@ internal static string SV0012_EndLineMustNotBeLessThanStartLine { return ResourceManager.GetString("SV0012_EndLineMustNotBeLessThanStartLine", resourceCulture); } } + + /// + /// Looks up a localized string similar to In "{0}", at "{1}", the value of the "endColumn" property is {2}, which is less than the value of the "startColumn" property, which is {3}.. + /// + internal static string SV0013_Default { + get { + return ResourceManager.GetString("SV0013_Default", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to The "endColumn" property of a region object must not be less than the "startColumn" property.. + /// + internal static string SV0013_EndColumnMustNotBeLessThanStartColumn { + get { + return ResourceManager.GetString("SV0013_EndColumnMustNotBeLessThanStartColumn", resourceCulture); + } + } } } diff --git a/src/SarifCli/Rules/RuleResources.resx b/src/SarifCli/Rules/RuleResources.resx index 2446e7c62..716cc4afe 100644 --- a/src/SarifCli/Rules/RuleResources.resx +++ b/src/SarifCli/Rules/RuleResources.resx @@ -198,4 +198,10 @@ The "endLine" property of a region object must not be less than the "startLine" property. + + In "{0}", at "{1}", the value of the "endColumn" property is {2}, which is less than the value of the "startColumn" property, which is {3}. + + + The "endColumn" property of a region object must not be less than the "startColumn" property. + \ No newline at end of file diff --git a/src/SarifCli/SarifCli.csproj b/src/SarifCli/SarifCli.csproj index e5bcbfcaa..5b503d45a 100644 --- a/src/SarifCli/SarifCli.csproj +++ b/src/SarifCli/SarifCli.csproj @@ -26,6 +26,9 @@ true ..\..\GeneratedKey.snk + + true + v4.5.1 @@ -89,6 +92,7 @@ + diff --git a/src/SarifCli/SarifPropertyName.cs b/src/SarifCli/SarifPropertyName.cs index cb67d1065..8c87c861a 100644 --- a/src/SarifCli/SarifPropertyName.cs +++ b/src/SarifCli/SarifPropertyName.cs @@ -8,6 +8,7 @@ public static class SarifPropertyName public const string AnalysisTarget = "analysisTarget"; public const string CodeFlows = "codeFlows"; public const string ConfigurationNotifications = "configurationNotifications"; + public const string EndColumn = "endColumn"; public const string EndLine = "endLine"; public const string EndTime = "endTime"; public const string Essential = "essential"; From 3197e825ee323517b41e3dc873de352ceef497ad Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Tue, 30 Aug 2016 06:49:43 -0700 Subject: [PATCH 48/51] For some reason Autogenerated/TaintKind.cs had wrong version --- src/Sarif/Autogenerated/TaintKind.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sarif/Autogenerated/TaintKind.cs b/src/Sarif/Autogenerated/TaintKind.cs index 47a15d2a6..9bdf7badd 100644 --- a/src/Sarif/Autogenerated/TaintKind.cs +++ b/src/Sarif/Autogenerated/TaintKind.cs @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Values that classify the annotated code location in terms of a taint analysis. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.42.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] public enum TaintKind { Unknown, From c83acff3470ce560b46cf228be28c74b402a38ab Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Tue, 30 Aug 2016 07:30:05 -0700 Subject: [PATCH 49/51] Upgrade to SARIF 1.5.29 and JSchema 0.46.0 This will let us use IAnalyzeOptions.Quiet in the SarifCli.FunctionalTests. --- .../Sarif.ValidationTests.csproj | 8 ++++---- src/Sarif.ValidationTests/packages.config | 4 ++-- src/Sarif/Autogenerated/AlgorithmKind.cs | 2 +- src/Sarif/Autogenerated/AnnotatedCodeLocation.cs | 2 +- .../AnnotatedCodeLocationEqualityComparer.cs | 2 +- .../AnnotatedCodeLocationImportance.cs | 2 +- .../Autogenerated/AnnotatedCodeLocationKind.cs | 2 +- src/Sarif/Autogenerated/BaselineState.cs | 2 +- src/Sarif/Autogenerated/CodeFlow.cs | 2 +- .../Autogenerated/CodeFlowEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/ExceptionData.cs | 2 +- .../ExceptionDataEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/FileChange.cs | 2 +- .../Autogenerated/FileChangeEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/FileData.cs | 2 +- .../Autogenerated/FileDataEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/Fix.cs | 2 +- src/Sarif/Autogenerated/FixEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/FormattedRuleMessage.cs | 2 +- .../FormattedRuleMessageEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/Hash.cs | 2 +- src/Sarif/Autogenerated/HashEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/IRule.cs | 2 +- src/Sarif/Autogenerated/ISarifNode.cs | 2 +- src/Sarif/Autogenerated/Invocation.cs | 2 +- .../Autogenerated/InvocationEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/Location.cs | 2 +- .../Autogenerated/LocationEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/LogicalLocation.cs | 2 +- .../LogicalLocationEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/Notification.cs | 2 +- .../NotificationEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/NotificationLevel.cs | 2 +- src/Sarif/Autogenerated/PhysicalLocation.cs | 2 +- .../PhysicalLocationEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/Region.cs | 2 +- .../Autogenerated/RegionEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/Replacement.cs | 2 +- .../Autogenerated/ReplacementEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/Result.cs | 2 +- .../Autogenerated/ResultEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/ResultLevel.cs | 2 +- src/Sarif/Autogenerated/Rule.cs | 2 +- src/Sarif/Autogenerated/RuleEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/Run.cs | 2 +- src/Sarif/Autogenerated/RunEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/SarifLog.cs | 2 +- .../Autogenerated/SarifLogEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/SarifNodeKind.cs | 2 +- src/Sarif/Autogenerated/SarifRewritingVisitor.cs | 2 +- src/Sarif/Autogenerated/SarifVersion.cs | 2 +- src/Sarif/Autogenerated/Stack.cs | 2 +- src/Sarif/Autogenerated/StackEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/StackFrame.cs | 2 +- .../Autogenerated/StackFrameEqualityComparer.cs | 2 +- src/Sarif/Autogenerated/SuppressionStates.cs | 2 +- src/Sarif/Autogenerated/TaintKind.cs | 2 +- src/Sarif/Autogenerated/Tool.cs | 2 +- src/Sarif/Autogenerated/ToolEqualityComparer.cs | 2 +- src/Sarif/ToDotNet/ToDotNet.targets | 2 +- src/Sarif/ToDotNet/packages.config | 2 +- .../SarifCli.FunctionalTests.csproj | 8 ++++---- src/SarifCli.FunctionalTests/packages.config | 4 ++-- src/SarifCli/SarifCli.csproj | 16 ++++++++-------- src/SarifCli/SarifValidationContext.cs | 2 +- src/SarifCli/packages.config | 8 ++++---- 66 files changed, 84 insertions(+), 84 deletions(-) diff --git a/src/Sarif.ValidationTests/Sarif.ValidationTests.csproj b/src/Sarif.ValidationTests/Sarif.ValidationTests.csproj index 853a98d42..de86c425c 100644 --- a/src/Sarif.ValidationTests/Sarif.ValidationTests.csproj +++ b/src/Sarif.ValidationTests/Sarif.ValidationTests.csproj @@ -16,8 +16,8 @@ v4.5.1 - - ..\packages\Microsoft.Json.Schema.0.45.0\lib\net451\Microsoft.Json.Schema.dll + + ..\packages\Microsoft.Json.Schema.0.46.0\lib\net451\Microsoft.Json.Schema.dll True @@ -40,8 +40,8 @@ - - ..\packages\Sarif.Sdk.1.5.27\lib\net45\Sarif.dll + + ..\packages\Sarif.Sdk.1.5.29\lib\net45\Sarif.dll True diff --git a/src/Sarif.ValidationTests/packages.config b/src/Sarif.ValidationTests/packages.config index da9368289..a4a5ec8a9 100644 --- a/src/Sarif.ValidationTests/packages.config +++ b/src/Sarif.ValidationTests/packages.config @@ -2,8 +2,8 @@ - - + + diff --git a/src/Sarif/Autogenerated/AlgorithmKind.cs b/src/Sarif/Autogenerated/AlgorithmKind.cs index fe033e579..cd72579d0 100644 --- a/src/Sarif/Autogenerated/AlgorithmKind.cs +++ b/src/Sarif/Autogenerated/AlgorithmKind.cs @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Values specifying different hashing algorithms. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public enum AlgorithmKind { Unknown, diff --git a/src/Sarif/Autogenerated/AnnotatedCodeLocation.cs b/src/Sarif/Autogenerated/AnnotatedCodeLocation.cs index 56277d676..405c5afd1 100644 --- a/src/Sarif/Autogenerated/AnnotatedCodeLocation.cs +++ b/src/Sarif/Autogenerated/AnnotatedCodeLocation.cs @@ -14,7 +14,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// An annotation used to express code flows through a method or other locations that are related to a result. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public partial class AnnotatedCodeLocation : PropertyBagHolder, ISarifNode { public static IEqualityComparer ValueComparer => AnnotatedCodeLocationEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/AnnotatedCodeLocationEqualityComparer.cs b/src/Sarif/Autogenerated/AnnotatedCodeLocationEqualityComparer.cs index 3871e4020..a8a7f8e73 100644 --- a/src/Sarif/Autogenerated/AnnotatedCodeLocationEqualityComparer.cs +++ b/src/Sarif/Autogenerated/AnnotatedCodeLocationEqualityComparer.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type AnnotatedCodeLocation for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] internal sealed class AnnotatedCodeLocationEqualityComparer : IEqualityComparer { internal static readonly AnnotatedCodeLocationEqualityComparer Instance = new AnnotatedCodeLocationEqualityComparer(); diff --git a/src/Sarif/Autogenerated/AnnotatedCodeLocationImportance.cs b/src/Sarif/Autogenerated/AnnotatedCodeLocationImportance.cs index 8ba2c1928..933146cff 100644 --- a/src/Sarif/Autogenerated/AnnotatedCodeLocationImportance.cs +++ b/src/Sarif/Autogenerated/AnnotatedCodeLocationImportance.cs @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Values specifying the importance of an "annotatedCodeLocation" within the "codeFlow" in which it occurs /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public enum AnnotatedCodeLocationImportance { Important, diff --git a/src/Sarif/Autogenerated/AnnotatedCodeLocationKind.cs b/src/Sarif/Autogenerated/AnnotatedCodeLocationKind.cs index 21d21022a..f87fdc06c 100644 --- a/src/Sarif/Autogenerated/AnnotatedCodeLocationKind.cs +++ b/src/Sarif/Autogenerated/AnnotatedCodeLocationKind.cs @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Values specifying the kind of an annotated code location. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public enum AnnotatedCodeLocationKind { Unknown, diff --git a/src/Sarif/Autogenerated/BaselineState.cs b/src/Sarif/Autogenerated/BaselineState.cs index 7331c3bce..3364a311d 100644 --- a/src/Sarif/Autogenerated/BaselineState.cs +++ b/src/Sarif/Autogenerated/BaselineState.cs @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// The state of a result relative to a baseline of a previous run. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public enum BaselineState { None, diff --git a/src/Sarif/Autogenerated/CodeFlow.cs b/src/Sarif/Autogenerated/CodeFlow.cs index 7fbca6cf6..3a005c762 100644 --- a/src/Sarif/Autogenerated/CodeFlow.cs +++ b/src/Sarif/Autogenerated/CodeFlow.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif { [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public partial class CodeFlow : PropertyBagHolder, ISarifNode { public static IEqualityComparer ValueComparer => CodeFlowEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/CodeFlowEqualityComparer.cs b/src/Sarif/Autogenerated/CodeFlowEqualityComparer.cs index 4422a03ff..ab67c92d4 100644 --- a/src/Sarif/Autogenerated/CodeFlowEqualityComparer.cs +++ b/src/Sarif/Autogenerated/CodeFlowEqualityComparer.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type CodeFlow for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] internal sealed class CodeFlowEqualityComparer : IEqualityComparer { internal static readonly CodeFlowEqualityComparer Instance = new CodeFlowEqualityComparer(); diff --git a/src/Sarif/Autogenerated/ExceptionData.cs b/src/Sarif/Autogenerated/ExceptionData.cs index f5fbc3adb..992211453 100644 --- a/src/Sarif/Autogenerated/ExceptionData.cs +++ b/src/Sarif/Autogenerated/ExceptionData.cs @@ -9,7 +9,7 @@ namespace Microsoft.CodeAnalysis.Sarif { [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public partial class ExceptionData : ISarifNode { public static IEqualityComparer ValueComparer => ExceptionDataEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/ExceptionDataEqualityComparer.cs b/src/Sarif/Autogenerated/ExceptionDataEqualityComparer.cs index 48898aae1..5da078a42 100644 --- a/src/Sarif/Autogenerated/ExceptionDataEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ExceptionDataEqualityComparer.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type ExceptionData for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] internal sealed class ExceptionDataEqualityComparer : IEqualityComparer { internal static readonly ExceptionDataEqualityComparer Instance = new ExceptionDataEqualityComparer(); diff --git a/src/Sarif/Autogenerated/FileChange.cs b/src/Sarif/Autogenerated/FileChange.cs index d6fcbc3c3..d1ddf96b6 100644 --- a/src/Sarif/Autogenerated/FileChange.cs +++ b/src/Sarif/Autogenerated/FileChange.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// A change to a single file. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public partial class FileChange : ISarifNode { public static IEqualityComparer ValueComparer => FileChangeEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/FileChangeEqualityComparer.cs b/src/Sarif/Autogenerated/FileChangeEqualityComparer.cs index b284d66b4..f4898249e 100644 --- a/src/Sarif/Autogenerated/FileChangeEqualityComparer.cs +++ b/src/Sarif/Autogenerated/FileChangeEqualityComparer.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type FileChange for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] internal sealed class FileChangeEqualityComparer : IEqualityComparer { internal static readonly FileChangeEqualityComparer Instance = new FileChangeEqualityComparer(); diff --git a/src/Sarif/Autogenerated/FileData.cs b/src/Sarif/Autogenerated/FileData.cs index be100a5f8..38a677d1e 100644 --- a/src/Sarif/Autogenerated/FileData.cs +++ b/src/Sarif/Autogenerated/FileData.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// A single file. In some cases, this file might be nested within another file. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public partial class FileData : PropertyBagHolder, ISarifNode { public static IEqualityComparer ValueComparer => FileDataEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/FileDataEqualityComparer.cs b/src/Sarif/Autogenerated/FileDataEqualityComparer.cs index eb291e784..b9ee67c43 100644 --- a/src/Sarif/Autogenerated/FileDataEqualityComparer.cs +++ b/src/Sarif/Autogenerated/FileDataEqualityComparer.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type FileData for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] internal sealed class FileDataEqualityComparer : IEqualityComparer { internal static readonly FileDataEqualityComparer Instance = new FileDataEqualityComparer(); diff --git a/src/Sarif/Autogenerated/Fix.cs b/src/Sarif/Autogenerated/Fix.cs index 3b553289e..f0dd2627b 100644 --- a/src/Sarif/Autogenerated/Fix.cs +++ b/src/Sarif/Autogenerated/Fix.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// A proposed fix for the problem represented by a result object. A fix specifies a set of file to modify. For each file, it specifies a set of bytes to remove, and provides a set of new bytes to replace them. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public partial class Fix : ISarifNode { public static IEqualityComparer ValueComparer => FixEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/FixEqualityComparer.cs b/src/Sarif/Autogenerated/FixEqualityComparer.cs index 6de7ffa40..f960441af 100644 --- a/src/Sarif/Autogenerated/FixEqualityComparer.cs +++ b/src/Sarif/Autogenerated/FixEqualityComparer.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Fix for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] internal sealed class FixEqualityComparer : IEqualityComparer { internal static readonly FixEqualityComparer Instance = new FixEqualityComparer(); diff --git a/src/Sarif/Autogenerated/FormattedRuleMessage.cs b/src/Sarif/Autogenerated/FormattedRuleMessage.cs index 0178e70d8..52b500c77 100644 --- a/src/Sarif/Autogenerated/FormattedRuleMessage.cs +++ b/src/Sarif/Autogenerated/FormattedRuleMessage.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// Contains information that can be used to construct a formatted message that describes a result. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public partial class FormattedRuleMessage : ISarifNode { public static IEqualityComparer ValueComparer => FormattedRuleMessageEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/FormattedRuleMessageEqualityComparer.cs b/src/Sarif/Autogenerated/FormattedRuleMessageEqualityComparer.cs index 36df586c9..6d0c3b0c4 100644 --- a/src/Sarif/Autogenerated/FormattedRuleMessageEqualityComparer.cs +++ b/src/Sarif/Autogenerated/FormattedRuleMessageEqualityComparer.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type FormattedRuleMessage for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] internal sealed class FormattedRuleMessageEqualityComparer : IEqualityComparer { internal static readonly FormattedRuleMessageEqualityComparer Instance = new FormattedRuleMessageEqualityComparer(); diff --git a/src/Sarif/Autogenerated/Hash.cs b/src/Sarif/Autogenerated/Hash.cs index 7002b0a58..2625bae79 100644 --- a/src/Sarif/Autogenerated/Hash.cs +++ b/src/Sarif/Autogenerated/Hash.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// A hash value of some file or collection of files, together with the algorithm used to compute the hash. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public partial class Hash : ISarifNode { public static IEqualityComparer ValueComparer => HashEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/HashEqualityComparer.cs b/src/Sarif/Autogenerated/HashEqualityComparer.cs index aa52d8c76..57d03b7c2 100644 --- a/src/Sarif/Autogenerated/HashEqualityComparer.cs +++ b/src/Sarif/Autogenerated/HashEqualityComparer.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Hash for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] internal sealed class HashEqualityComparer : IEqualityComparer { internal static readonly HashEqualityComparer Instance = new HashEqualityComparer(); diff --git a/src/Sarif/Autogenerated/IRule.cs b/src/Sarif/Autogenerated/IRule.cs index f1add1c16..052f44feb 100644 --- a/src/Sarif/Autogenerated/IRule.cs +++ b/src/Sarif/Autogenerated/IRule.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Interface exposed by objects that provide information about analysis rules. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public partial interface IRule { /// diff --git a/src/Sarif/Autogenerated/ISarifNode.cs b/src/Sarif/Autogenerated/ISarifNode.cs index f68106099..0a0f398d7 100644 --- a/src/Sarif/Autogenerated/ISarifNode.cs +++ b/src/Sarif/Autogenerated/ISarifNode.cs @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// An interface for all types generated from the Sarif schema. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public interface ISarifNode { /// diff --git a/src/Sarif/Autogenerated/Invocation.cs b/src/Sarif/Autogenerated/Invocation.cs index 23a6af0e8..2cef493b2 100644 --- a/src/Sarif/Autogenerated/Invocation.cs +++ b/src/Sarif/Autogenerated/Invocation.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// The runtime environment of the analysis tool run. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public partial class Invocation : PropertyBagHolder, ISarifNode { public static IEqualityComparer ValueComparer => InvocationEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/InvocationEqualityComparer.cs b/src/Sarif/Autogenerated/InvocationEqualityComparer.cs index 78b066672..67eb00c61 100644 --- a/src/Sarif/Autogenerated/InvocationEqualityComparer.cs +++ b/src/Sarif/Autogenerated/InvocationEqualityComparer.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Invocation for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] internal sealed class InvocationEqualityComparer : IEqualityComparer { internal static readonly InvocationEqualityComparer Instance = new InvocationEqualityComparer(); diff --git a/src/Sarif/Autogenerated/Location.cs b/src/Sarif/Autogenerated/Location.cs index 1f225648a..c277a6615 100644 --- a/src/Sarif/Autogenerated/Location.cs +++ b/src/Sarif/Autogenerated/Location.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// The location where an analysis tool produced a result. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public partial class Location : PropertyBagHolder, ISarifNode { public static IEqualityComparer ValueComparer => LocationEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/LocationEqualityComparer.cs b/src/Sarif/Autogenerated/LocationEqualityComparer.cs index f9e645503..232a5d891 100644 --- a/src/Sarif/Autogenerated/LocationEqualityComparer.cs +++ b/src/Sarif/Autogenerated/LocationEqualityComparer.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Location for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] internal sealed class LocationEqualityComparer : IEqualityComparer { internal static readonly LocationEqualityComparer Instance = new LocationEqualityComparer(); diff --git a/src/Sarif/Autogenerated/LogicalLocation.cs b/src/Sarif/Autogenerated/LogicalLocation.cs index b4c95b958..49ac5bfb1 100644 --- a/src/Sarif/Autogenerated/LogicalLocation.cs +++ b/src/Sarif/Autogenerated/LogicalLocation.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// A logical location of a construct that produced a result. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public partial class LogicalLocation : ISarifNode { public static IEqualityComparer ValueComparer => LogicalLocationEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/LogicalLocationEqualityComparer.cs b/src/Sarif/Autogenerated/LogicalLocationEqualityComparer.cs index ae473d3b8..1a8e011d4 100644 --- a/src/Sarif/Autogenerated/LogicalLocationEqualityComparer.cs +++ b/src/Sarif/Autogenerated/LogicalLocationEqualityComparer.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type LogicalLocation for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] internal sealed class LogicalLocationEqualityComparer : IEqualityComparer { internal static readonly LogicalLocationEqualityComparer Instance = new LogicalLocationEqualityComparer(); diff --git a/src/Sarif/Autogenerated/Notification.cs b/src/Sarif/Autogenerated/Notification.cs index 4b14c1a4d..9fe34f8bf 100644 --- a/src/Sarif/Autogenerated/Notification.cs +++ b/src/Sarif/Autogenerated/Notification.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// Describes a condition relevant to the tool itself, as opposed to being relevant to a target being analyzed by the tool. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public partial class Notification : PropertyBagHolder, ISarifNode { public static IEqualityComparer ValueComparer => NotificationEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/NotificationEqualityComparer.cs b/src/Sarif/Autogenerated/NotificationEqualityComparer.cs index 7396c4c34..c14f3e569 100644 --- a/src/Sarif/Autogenerated/NotificationEqualityComparer.cs +++ b/src/Sarif/Autogenerated/NotificationEqualityComparer.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Notification for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] internal sealed class NotificationEqualityComparer : IEqualityComparer { internal static readonly NotificationEqualityComparer Instance = new NotificationEqualityComparer(); diff --git a/src/Sarif/Autogenerated/NotificationLevel.cs b/src/Sarif/Autogenerated/NotificationLevel.cs index bc3fe6199..2870157e4 100644 --- a/src/Sarif/Autogenerated/NotificationLevel.cs +++ b/src/Sarif/Autogenerated/NotificationLevel.cs @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Values specifying the level of a notification. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public enum NotificationLevel { Warning, diff --git a/src/Sarif/Autogenerated/PhysicalLocation.cs b/src/Sarif/Autogenerated/PhysicalLocation.cs index 0636e6f17..ddbb1c1db 100644 --- a/src/Sarif/Autogenerated/PhysicalLocation.cs +++ b/src/Sarif/Autogenerated/PhysicalLocation.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// A physical location relevant to a result. Specifies a reference to a programming artifact together with a range of bytes or characters within that artifact. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public partial class PhysicalLocation : ISarifNode { public static IEqualityComparer ValueComparer => PhysicalLocationEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/PhysicalLocationEqualityComparer.cs b/src/Sarif/Autogenerated/PhysicalLocationEqualityComparer.cs index fac642c5e..7a6d86be1 100644 --- a/src/Sarif/Autogenerated/PhysicalLocationEqualityComparer.cs +++ b/src/Sarif/Autogenerated/PhysicalLocationEqualityComparer.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type PhysicalLocation for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] internal sealed class PhysicalLocationEqualityComparer : IEqualityComparer { internal static readonly PhysicalLocationEqualityComparer Instance = new PhysicalLocationEqualityComparer(); diff --git a/src/Sarif/Autogenerated/Region.cs b/src/Sarif/Autogenerated/Region.cs index f336700a5..5b4728756 100644 --- a/src/Sarif/Autogenerated/Region.cs +++ b/src/Sarif/Autogenerated/Region.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// A region within a file where a result was detected. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public partial class Region : ISarifNode { public static IEqualityComparer ValueComparer => RegionEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/RegionEqualityComparer.cs b/src/Sarif/Autogenerated/RegionEqualityComparer.cs index f315c3a05..9d7350ee4 100644 --- a/src/Sarif/Autogenerated/RegionEqualityComparer.cs +++ b/src/Sarif/Autogenerated/RegionEqualityComparer.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Region for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] internal sealed class RegionEqualityComparer : IEqualityComparer { internal static readonly RegionEqualityComparer Instance = new RegionEqualityComparer(); diff --git a/src/Sarif/Autogenerated/Replacement.cs b/src/Sarif/Autogenerated/Replacement.cs index 0d5db93ef..47a7a47d1 100644 --- a/src/Sarif/Autogenerated/Replacement.cs +++ b/src/Sarif/Autogenerated/Replacement.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// The replacement of a single range of bytes in a file. Specifies the location within the file where the replacement is to be made, the number of bytes to remove at that location, and a sequence of bytes to insert at that location. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public partial class Replacement : ISarifNode { public static IEqualityComparer ValueComparer => ReplacementEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/ReplacementEqualityComparer.cs b/src/Sarif/Autogenerated/ReplacementEqualityComparer.cs index f1aae0fa3..1dbcfe456 100644 --- a/src/Sarif/Autogenerated/ReplacementEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ReplacementEqualityComparer.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Replacement for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] internal sealed class ReplacementEqualityComparer : IEqualityComparer { internal static readonly ReplacementEqualityComparer Instance = new ReplacementEqualityComparer(); diff --git a/src/Sarif/Autogenerated/Result.cs b/src/Sarif/Autogenerated/Result.cs index 6405cc5e1..14fc269f4 100644 --- a/src/Sarif/Autogenerated/Result.cs +++ b/src/Sarif/Autogenerated/Result.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// A result produced by an analysis tool. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public partial class Result : PropertyBagHolder, ISarifNode { public static IEqualityComparer ValueComparer => ResultEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/ResultEqualityComparer.cs b/src/Sarif/Autogenerated/ResultEqualityComparer.cs index 991664312..c1e21521d 100644 --- a/src/Sarif/Autogenerated/ResultEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ResultEqualityComparer.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Result for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] internal sealed class ResultEqualityComparer : IEqualityComparer { internal static readonly ResultEqualityComparer Instance = new ResultEqualityComparer(); diff --git a/src/Sarif/Autogenerated/ResultLevel.cs b/src/Sarif/Autogenerated/ResultLevel.cs index 44e9df26c..074185dfc 100644 --- a/src/Sarif/Autogenerated/ResultLevel.cs +++ b/src/Sarif/Autogenerated/ResultLevel.cs @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Values specifying the level of a result. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public enum ResultLevel { Default, diff --git a/src/Sarif/Autogenerated/Rule.cs b/src/Sarif/Autogenerated/Rule.cs index 1c5a49907..9bb561366 100644 --- a/src/Sarif/Autogenerated/Rule.cs +++ b/src/Sarif/Autogenerated/Rule.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// Describes an analysis rule. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public partial class Rule : PropertyBagHolder, IRule, ISarifNode { public static IEqualityComparer ValueComparer => RuleEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/RuleEqualityComparer.cs b/src/Sarif/Autogenerated/RuleEqualityComparer.cs index 83826ae01..2dbe88f4b 100644 --- a/src/Sarif/Autogenerated/RuleEqualityComparer.cs +++ b/src/Sarif/Autogenerated/RuleEqualityComparer.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Rule for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] internal sealed class RuleEqualityComparer : IEqualityComparer { internal static readonly RuleEqualityComparer Instance = new RuleEqualityComparer(); diff --git a/src/Sarif/Autogenerated/Run.cs b/src/Sarif/Autogenerated/Run.cs index c037f4294..ed84f7dea 100644 --- a/src/Sarif/Autogenerated/Run.cs +++ b/src/Sarif/Autogenerated/Run.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// Describes a single run of an analysis tool, and contains the output of that run. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public partial class Run : ISarifNode { public static IEqualityComparer ValueComparer => RunEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/RunEqualityComparer.cs b/src/Sarif/Autogenerated/RunEqualityComparer.cs index 917b8a628..fdd50a7d9 100644 --- a/src/Sarif/Autogenerated/RunEqualityComparer.cs +++ b/src/Sarif/Autogenerated/RunEqualityComparer.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Run for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] internal sealed class RunEqualityComparer : IEqualityComparer { internal static readonly RunEqualityComparer Instance = new RunEqualityComparer(); diff --git a/src/Sarif/Autogenerated/SarifLog.cs b/src/Sarif/Autogenerated/SarifLog.cs index b0bb58e3c..70f98cb2f 100644 --- a/src/Sarif/Autogenerated/SarifLog.cs +++ b/src/Sarif/Autogenerated/SarifLog.cs @@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// Static Analysis Results Format (SARIF) Version 1.0.0 JSON Schema: a standard format for the output of static analysis and other tools. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public partial class SarifLog : ISarifNode { public static IEqualityComparer ValueComparer => SarifLogEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/SarifLogEqualityComparer.cs b/src/Sarif/Autogenerated/SarifLogEqualityComparer.cs index 5be78c89d..c5df5b1f5 100644 --- a/src/Sarif/Autogenerated/SarifLogEqualityComparer.cs +++ b/src/Sarif/Autogenerated/SarifLogEqualityComparer.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type SarifLog for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] internal sealed class SarifLogEqualityComparer : IEqualityComparer { internal static readonly SarifLogEqualityComparer Instance = new SarifLogEqualityComparer(); diff --git a/src/Sarif/Autogenerated/SarifNodeKind.cs b/src/Sarif/Autogenerated/SarifNodeKind.cs index cef1d9533..999df5588 100644 --- a/src/Sarif/Autogenerated/SarifNodeKind.cs +++ b/src/Sarif/Autogenerated/SarifNodeKind.cs @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// A set of values for all the types that implement . /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public enum SarifNodeKind { /// diff --git a/src/Sarif/Autogenerated/SarifRewritingVisitor.cs b/src/Sarif/Autogenerated/SarifRewritingVisitor.cs index ea3537d19..2806f87cf 100644 --- a/src/Sarif/Autogenerated/SarifRewritingVisitor.cs +++ b/src/Sarif/Autogenerated/SarifRewritingVisitor.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Rewriting visitor for the Sarif object model. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public abstract class SarifRewritingVisitor { /// diff --git a/src/Sarif/Autogenerated/SarifVersion.cs b/src/Sarif/Autogenerated/SarifVersion.cs index 887b695da..c11e5a816 100644 --- a/src/Sarif/Autogenerated/SarifVersion.cs +++ b/src/Sarif/Autogenerated/SarifVersion.cs @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Possible values for the SARIF schema version. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public enum SarifVersion { Unknown, diff --git a/src/Sarif/Autogenerated/Stack.cs b/src/Sarif/Autogenerated/Stack.cs index 9a0576466..808dedaa9 100644 --- a/src/Sarif/Autogenerated/Stack.cs +++ b/src/Sarif/Autogenerated/Stack.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// A call stack that is relevant to a result. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public partial class Stack : PropertyBagHolder, ISarifNode { public static IEqualityComparer ValueComparer => StackEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/StackEqualityComparer.cs b/src/Sarif/Autogenerated/StackEqualityComparer.cs index 2aaaf48c2..7d9c3595f 100644 --- a/src/Sarif/Autogenerated/StackEqualityComparer.cs +++ b/src/Sarif/Autogenerated/StackEqualityComparer.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Stack for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] internal sealed class StackEqualityComparer : IEqualityComparer { internal static readonly StackEqualityComparer Instance = new StackEqualityComparer(); diff --git a/src/Sarif/Autogenerated/StackFrame.cs b/src/Sarif/Autogenerated/StackFrame.cs index ae9f0ff7d..81bf8485b 100644 --- a/src/Sarif/Autogenerated/StackFrame.cs +++ b/src/Sarif/Autogenerated/StackFrame.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// A function call within a stack trace. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public partial class StackFrame : PropertyBagHolder, ISarifNode { public static IEqualityComparer ValueComparer => StackFrameEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/StackFrameEqualityComparer.cs b/src/Sarif/Autogenerated/StackFrameEqualityComparer.cs index 41aac1330..96a779184 100644 --- a/src/Sarif/Autogenerated/StackFrameEqualityComparer.cs +++ b/src/Sarif/Autogenerated/StackFrameEqualityComparer.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type StackFrame for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] internal sealed class StackFrameEqualityComparer : IEqualityComparer { internal static readonly StackFrameEqualityComparer Instance = new StackFrameEqualityComparer(); diff --git a/src/Sarif/Autogenerated/SuppressionStates.cs b/src/Sarif/Autogenerated/SuppressionStates.cs index f64b87268..16e668992 100644 --- a/src/Sarif/Autogenerated/SuppressionStates.cs +++ b/src/Sarif/Autogenerated/SuppressionStates.cs @@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// The state of a result relative to a baseline of a previous run. /// [Flags] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public enum SuppressionStates { None, diff --git a/src/Sarif/Autogenerated/TaintKind.cs b/src/Sarif/Autogenerated/TaintKind.cs index 9bdf7badd..705edb7f5 100644 --- a/src/Sarif/Autogenerated/TaintKind.cs +++ b/src/Sarif/Autogenerated/TaintKind.cs @@ -8,7 +8,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Values that classify the annotated code location in terms of a taint analysis. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public enum TaintKind { Unknown, diff --git a/src/Sarif/Autogenerated/Tool.cs b/src/Sarif/Autogenerated/Tool.cs index 0903c0634..5b5b38164 100644 --- a/src/Sarif/Autogenerated/Tool.cs +++ b/src/Sarif/Autogenerated/Tool.cs @@ -13,7 +13,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// The analysis tool that was run. /// [DataContract] - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] public partial class Tool : PropertyBagHolder, ISarifNode { public static IEqualityComparer ValueComparer => ToolEqualityComparer.Instance; diff --git a/src/Sarif/Autogenerated/ToolEqualityComparer.cs b/src/Sarif/Autogenerated/ToolEqualityComparer.cs index 49422ac23..108dc6d57 100644 --- a/src/Sarif/Autogenerated/ToolEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ToolEqualityComparer.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Sarif /// /// Defines methods to support the comparison of objects of type Tool for equality. /// - [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.45.0.0")] + [GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.46.0.0")] internal sealed class ToolEqualityComparer : IEqualityComparer { internal static readonly ToolEqualityComparer Instance = new ToolEqualityComparer(); diff --git a/src/Sarif/ToDotNet/ToDotNet.targets b/src/Sarif/ToDotNet/ToDotNet.targets index 38a3ea7d4..68b631f9e 100644 --- a/src/Sarif/ToDotNet/ToDotNet.targets +++ b/src/Sarif/ToDotNet/ToDotNet.targets @@ -10,7 +10,7 @@ $(MSBuildProjectDirectory)\..\..\.nuget - ..\packages\Microsoft.Json.Schema.ToDotNet.0.45.0\tools\JsonSchemaToDotNet.exe + ..\packages\Microsoft.Json.Schema.ToDotNet.0.46.0\tools\JsonSchemaToDotNet.exe <_ObjectModelOutputDirectory>$(FlavorIndependentIntermediateOutputPath)Autogenerated diff --git a/src/Sarif/ToDotNet/packages.config b/src/Sarif/ToDotNet/packages.config index 8455bf13f..4adfcc039 100644 --- a/src/Sarif/ToDotNet/packages.config +++ b/src/Sarif/ToDotNet/packages.config @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj index 5e537c73d..f4c10be15 100644 --- a/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj +++ b/src/SarifCli.FunctionalTests/SarifCli.FunctionalTests.csproj @@ -30,12 +30,12 @@ ..\packages\Newtonsoft.Json.6.0.1\lib\net45\Newtonsoft.Json.dll True - - ..\packages\Sarif.Sdk.1.5.27\lib\net45\Sarif.dll + + ..\packages\Sarif.Sdk.1.5.29\lib\net45\Sarif.dll True - - ..\packages\Sarif.Driver.1.5.27\lib\net45\Sarif.Driver.dll + + ..\packages\Sarif.Driver.1.5.29\lib\net45\Sarif.Driver.dll True diff --git a/src/SarifCli.FunctionalTests/packages.config b/src/SarifCli.FunctionalTests/packages.config index 6586b6eec..c69b1fd20 100644 --- a/src/SarifCli.FunctionalTests/packages.config +++ b/src/SarifCli.FunctionalTests/packages.config @@ -3,8 +3,8 @@ - - + + diff --git a/src/SarifCli/SarifCli.csproj b/src/SarifCli/SarifCli.csproj index 5b503d45a..0fe603ce8 100644 --- a/src/SarifCli/SarifCli.csproj +++ b/src/SarifCli/SarifCli.csproj @@ -42,20 +42,20 @@ ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll True - - ..\packages\Sarif.Sdk.1.5.27\lib\net45\Sarif.dll + + ..\packages\Sarif.Sdk.1.5.29\lib\net45\Sarif.dll True - - ..\packages\Sarif.Driver.1.5.27\lib\net45\Sarif.Driver.dll + + ..\packages\Sarif.Driver.1.5.29\lib\net45\Sarif.Driver.dll True - - ..\packages\Microsoft.Json.Schema.0.45.0\lib\net451\Microsoft.Json.Schema.dll + + ..\packages\Microsoft.Json.Schema.0.46.0\lib\net451\Microsoft.Json.Schema.dll True - - ..\packages\Microsoft.Json.Pointer.0.45.0\lib\net451\Microsoft.Json.Pointer.dll + + ..\packages\Microsoft.Json.Pointer.0.46.0\lib\net451\Microsoft.Json.Pointer.dll True diff --git a/src/SarifCli/SarifValidationContext.cs b/src/SarifCli/SarifValidationContext.cs index 33b881dfa..dd9c59482 100644 --- a/src/SarifCli/SarifValidationContext.cs +++ b/src/SarifCli/SarifValidationContext.cs @@ -25,7 +25,7 @@ public string MimeType set { throw new InvalidOperationException(); } } - public PropertyBagDictionary Policy { get; set; } + public PropertiesDictionary Policy { get; set; } public IRule Rule { get; set; } diff --git a/src/SarifCli/packages.config b/src/SarifCli/packages.config index a22ee2baf..29f6f2702 100644 --- a/src/SarifCli/packages.config +++ b/src/SarifCli/packages.config @@ -2,9 +2,9 @@ - - + + - - + + \ No newline at end of file From d51cb4ab2b7abef2e7768dd5a8e12e38a1947a4e Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Tue, 30 Aug 2016 07:35:07 -0700 Subject: [PATCH 50/51] Use IAnalyzeOptions.Quiet in SarifCli.FunctionalTests --- src/SarifCli.FunctionalTests/AnalyzeCommandTests.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SarifCli.FunctionalTests/AnalyzeCommandTests.cs b/src/SarifCli.FunctionalTests/AnalyzeCommandTests.cs index e09aac703..75c141efe 100644 --- a/src/SarifCli.FunctionalTests/AnalyzeCommandTests.cs +++ b/src/SarifCli.FunctionalTests/AnalyzeCommandTests.cs @@ -33,7 +33,8 @@ private void Verify(string testFileName) { TargetFileSpecifiers = new[] { testFilePath }, OutputFilePath = actualFilePath, - SchemaFilePath = JsonSchemaFile + SchemaFilePath = JsonSchemaFile, + Quiet = true }; new AnalyzeCommand().Run(analyzeOptions); From e6f60299d3beefa94b861aeff5fa4b37b41cf4a5 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Thu, 1 Sep 2016 12:51:02 -0700 Subject: [PATCH 51/51] Add a comment. --- src/SarifCli/JPointerStringExtensions.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/SarifCli/JPointerStringExtensions.cs b/src/SarifCli/JPointerStringExtensions.cs index fe7d27749..5bba2460b 100644 --- a/src/SarifCli/JPointerStringExtensions.cs +++ b/src/SarifCli/JPointerStringExtensions.cs @@ -4,6 +4,7 @@ namespace Microsoft.CodeAnalysis.Sarif.Cli { // TODO: These methods belong in the Microsoft.Json.Pointer library. + // Filed https://github.com/Microsoft/sarif-sdk/issues/512 for this. internal static class JPointerStringExtensions { internal static string AtProperty(this string jPointer, string propertyName)