From ef7bde7bba08b8ada3e75480f4f716680be25994 Mon Sep 17 00:00:00 2001 From: Harleen Kaur Kohli Date: Fri, 19 Jun 2020 15:50:39 -0700 Subject: [PATCH] rule 1007 (combine) --- src/Sarif.Multitool/Rules/RuleId.cs | 3 +- .../Rules/RuleResources.Designer.cs | 72 ++--- src/Sarif.Multitool/Rules/RuleResources.resx | 21 +- ...F1007.RegionPropertiesMustBeConsistent.cs} | 24 +- ...F1012.EndLineMustNotBeLessThanStartLine.cs | 43 --- .../Multitool/ValidateCommandTests.cs | 14 +- ...onPropertiesMustBeConsistent_Invalid.sarif | 258 ++++++++++++++++++ ...ionPropertiesMustBeConsistent_Valid.sarif} | 2 +- ...ndLineMustNotBeLessThanStart_Invalid.sarif | 151 ---------- ....EndLineMustNotBeLessThanStart_Valid.sarif | 28 -- ...ColumnMustNotBeLessThanStart_Invalid.sarif | 151 ---------- ...nPropertiesMustBeConsistent_Invalid.sarif} | 87 ++++++ ...ionPropertiesMustBeConsistent_Valid.sarif} | 50 ++++ ...ColumnMustNotBeLessThanStart_Invalid.sarif | 103 ------- ...ndColumnMustNotBeLessThanStart_Valid.sarif | 66 ----- 15 files changed, 459 insertions(+), 614 deletions(-) rename src/Sarif.Multitool/Rules/{SARIF1013.EndColumnMustNotBeLessThanStartColumn.cs => SARIF1007.RegionPropertiesMustBeConsistent.cs} (57%) delete mode 100644 src/Sarif.Multitool/Rules/SARIF1012.EndLineMustNotBeLessThanStartLine.cs create mode 100644 src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/ExpectedOutputs/SARIF1007.RegionPropertiesMustBeConsistent_Invalid.sarif rename src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/ExpectedOutputs/{SARIF1013.EndColumnMustNotBeLessThanStart_Valid.sarif => SARIF1007.RegionPropertiesMustBeConsistent_Valid.sarif} (91%) delete mode 100644 src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/ExpectedOutputs/SARIF1012.EndLineMustNotBeLessThanStart_Invalid.sarif delete mode 100644 src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/ExpectedOutputs/SARIF1012.EndLineMustNotBeLessThanStart_Valid.sarif delete mode 100644 src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/ExpectedOutputs/SARIF1013.EndColumnMustNotBeLessThanStart_Invalid.sarif rename src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/Inputs/{SARIF1012.EndLineMustNotBeLessThanStart_Invalid.sarif => SARIF1007.RegionPropertiesMustBeConsistent_Invalid.sarif} (54%) rename src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/Inputs/{SARIF1012.EndLineMustNotBeLessThanStart_Valid.sarif => SARIF1007.RegionPropertiesMustBeConsistent_Valid.sarif} (62%) delete mode 100644 src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/Inputs/SARIF1013.EndColumnMustNotBeLessThanStart_Invalid.sarif delete mode 100644 src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/Inputs/SARIF1013.EndColumnMustNotBeLessThanStart_Valid.sarif diff --git a/src/Sarif.Multitool/Rules/RuleId.cs b/src/Sarif.Multitool/Rules/RuleId.cs index 7c629f313..9d4816de4 100644 --- a/src/Sarif.Multitool/Rules/RuleId.cs +++ b/src/Sarif.Multitool/Rules/RuleId.cs @@ -9,8 +9,7 @@ public static class RuleId public const string UrisMustBeValid = "SARIF1002"; public const string InvocationPropertiesMustBeConsistent = "SARIF1006"; public const string AuthorHighQualityMessages = "SARIF2001"; - public const string EndLineMustNotBeLessThanStartLine = "SARIF1012"; - public const string EndColumnMustNotBeLessThanStartColumn = "SARIF1013"; + public const string RegionPropertiesMustBeConsistent = "SARIF1007"; public const string UriBaseIdRequiresRelativeUri = "SARIF1014"; public const string UriMustBeAbsolute = "SARIF1005"; public const string PhysicalLocationPropertiesMustBeConsistent = "SARIF1008"; diff --git a/src/Sarif.Multitool/Rules/RuleResources.Designer.cs b/src/Sarif.Multitool/Rules/RuleResources.Designer.cs index 209fe19f5..e878b8b77 100644 --- a/src/Sarif.Multitool/Rules/RuleResources.Designer.cs +++ b/src/Sarif.Multitool/Rules/RuleResources.Designer.cs @@ -133,13 +133,39 @@ internal static string SARIF1006_InvocationPropertiesMustBeConsistent_FullDescri } } + /// + /// Looks up a localized string similar to {0}: The value of the "endColumn" property is {1}, which is less than the value of the "startColumn" property, which is {2}.. + /// + internal static string SARIF1007_RegionPropertiesMustBeConsistent_Error_EndColumnMustNotPrecedeStartColumn_Text { + get { + return ResourceManager.GetString("SARIF1007_RegionPropertiesMustBeConsistent_Error_EndColumnMustNotPrecedeStartColumn_Text", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0}: The value of the "endLine" property is {1}, which is less than the value of the "startLine" property, which is {2}.. + /// + internal static string SARIF1007_RegionPropertiesMustBeConsistent_Error_EndLineMustNotPrecedeStartLine_Text { + get { + return ResourceManager.GetString("SARIF1007_RegionPropertiesMustBeConsistent_Error_EndLineMustNotPrecedeStartLine_Text", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Placeholder_SARIF1007_RegionPropertiesMustBeConsistent_FullDescription_Text. + /// + internal static string SARIF1007_RegionPropertiesMustBeConsistent_FullDescription_Text { + get { + return ResourceManager.GetString("SARIF1007_RegionPropertiesMustBeConsistent_FullDescription_Text", resourceCulture); + } + } + /// /// Looks up a localized string similar to {0}: This "physicalLocation" object contains a "contextRegion" property, but it does not contain a "region" property.. /// internal static string SARIF1008_PhysicalLocationPropertiesMustBeConsistent_Error_ContextRegionRequiresRegion_Text { get { - return ResourceManager.GetString("SARIF1008_PhysicalLocationPropertiesMustBeConsistent_Error_ContextRegionRequiresR" + - "egion_Text", resourceCulture); + return ResourceManager.GetString("SARIF1008_PhysicalLocationPropertiesMustBeConsistent_Error_ContextRegionRequiresRegion_Text", resourceCulture); } } @@ -157,8 +183,7 @@ internal static string SARIF1008_PhysicalLocationPropertiesMustBeConsistent_Full /// internal static string SARIF1009_IndexPropertiesMustBeConsistentWithArrays_Error_TargetArrayMustBeLongEnough_Text { get { - return ResourceManager.GetString("SARIF1009_IndexPropertiesMustBeConsistentWithArrays_Error_TargetArrayMustBeLongEn" + - "ough_Text", resourceCulture); + return ResourceManager.GetString("SARIF1009_IndexPropertiesMustBeConsistentWithArrays_Error_TargetArrayMustBeLongEnough_Text", resourceCulture); } } @@ -167,8 +192,7 @@ internal static string SARIF1009_IndexPropertiesMustBeConsistentWithArrays_Error /// internal static string SARIF1009_IndexPropertiesMustBeConsistentWithArrays_Error_TargetArrayMustExist_Text { get { - return ResourceManager.GetString("SARIF1009_IndexPropertiesMustBeConsistentWithArrays_Error_TargetArrayMustExist_Te" + - "xt", resourceCulture); + return ResourceManager.GetString("SARIF1009_IndexPropertiesMustBeConsistentWithArrays_Error_TargetArrayMustExist_Text", resourceCulture); } } @@ -226,42 +250,6 @@ internal static string SARIF1011_ReferenceFinalSchema_FullDescription_Text { } } - /// - /// Looks up a localized string similar to {0}: The value of the "endLine" property is {1}, which is less than the value of the "startLine" property, which is {2}.. - /// - internal static string SARIF1012_Default { - get { - return ResourceManager.GetString("SARIF1012_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 SARIF1012_EndLineMustNotBeLessThanStartLine { - get { - return ResourceManager.GetString("SARIF1012_EndLineMustNotBeLessThanStartLine", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to {0}: The value of the "endColumn" property is {1}, which is less than the value of the "startColumn" property, which is {2}.. - /// - internal static string SARIF1013_Default { - get { - return ResourceManager.GetString("SARIF1013_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 SARIF1013_EndColumnMustNotBeLessThanStartColumn { - get { - return ResourceManager.GetString("SARIF1013_EndColumnMustNotBeLessThanStartColumn", resourceCulture); - } - } - /// /// Looks up a localized string similar to {0}: This fileLocation object contains a "uriBaseId" property, which means that the value of the "uri" property must be a relative URI reference, but "{1}" is an absolute URI reference.. /// diff --git a/src/Sarif.Multitool/Rules/RuleResources.resx b/src/Sarif.Multitool/Rules/RuleResources.resx index dffc227ee..5bee270fe 100644 --- a/src/Sarif.Multitool/Rules/RuleResources.resx +++ b/src/Sarif.Multitool/Rules/RuleResources.resx @@ -141,18 +141,6 @@ Messages should consist of one or more complete sentences, ending with a period. - - {0}: The value of the "endLine" property is {1}, which is less than the value of the "startLine" property, which is {2}. - - - The "endLine" property of a region object must not be less than the "startLine" property. - - - {0}: The value of the "endColumn" property is {1}, which is less than the value of the "startColumn" property, which is {2}. - - - The "endColumn" property of a region object must not be less than the "startColumn" property. - {0}: This fileLocation object contains a "uriBaseId" property, which means that the value of the "uri" property must be a relative URI reference, but "{1}" is an absolute URI reference. @@ -210,4 +198,13 @@ {0}: The SARIF log file does not contain a $schema property. Add a $schema property that refers to the final version of the SARIF 2.1.0 schema. This enables IDEs to provide Intellisense for SARIF log files. + + {0}: The value of the "endColumn" property is {1}, which is less than the value of the "startColumn" property, which is {2}. + + + {0}: The value of the "endLine" property is {1}, which is less than the value of the "startLine" property, which is {2}. + + + Placeholder_SARIF1007_RegionPropertiesMustBeConsistent_FullDescription_Text + \ No newline at end of file diff --git a/src/Sarif.Multitool/Rules/SARIF1013.EndColumnMustNotBeLessThanStartColumn.cs b/src/Sarif.Multitool/Rules/SARIF1007.RegionPropertiesMustBeConsistent.cs similarity index 57% rename from src/Sarif.Multitool/Rules/SARIF1013.EndColumnMustNotBeLessThanStartColumn.cs rename to src/Sarif.Multitool/Rules/SARIF1007.RegionPropertiesMustBeConsistent.cs index dc71327fe..a31534edb 100644 --- a/src/Sarif.Multitool/Rules/SARIF1013.EndColumnMustNotBeLessThanStartColumn.cs +++ b/src/Sarif.Multitool/Rules/SARIF1007.RegionPropertiesMustBeConsistent.cs @@ -7,20 +7,21 @@ namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules { - public class EndColumnMustNotBeLessThanStartColumn : SarifValidationSkimmerBase + public class RegionPropertiesMustBeConsistent : SarifValidationSkimmerBase { public override MultiformatMessageString FullDescription => new MultiformatMessageString { - Text = RuleResources.SARIF1013_EndColumnMustNotBeLessThanStartColumn + Text = RuleResources.SARIF1007_RegionPropertiesMustBeConsistent_FullDescription_Text }; public override FailureLevel DefaultLevel => FailureLevel.Error; - public override string Id => RuleId.EndColumnMustNotBeLessThanStartColumn; + public override string Id => RuleId.RegionPropertiesMustBeConsistent; protected override IEnumerable MessageResourceNames => new string[] { - nameof(RuleResources.SARIF1013_Default) + nameof(RuleResources.SARIF1007_RegionPropertiesMustBeConsistent_Error_EndLineMustNotPrecedeStartLine_Text), + nameof(RuleResources.SARIF1007_RegionPropertiesMustBeConsistent_Error_EndColumnMustNotPrecedeStartColumn_Text) }; protected override void Analyze(Region region, string regionPointer) @@ -28,6 +29,19 @@ protected override void Analyze(Region region, string regionPointer) var jsonPointer = new JsonPointer(regionPointer); JToken regionToken = jsonPointer.Evaluate(Context.InputLogToken); + if (regionToken.HasProperty(SarifPropertyName.EndLine) && + region.EndLine < region.StartLine) + { + string endLinePointer = regionPointer.AtProperty(SarifPropertyName.EndLine); + + LogResult( + endLinePointer, + nameof(RuleResources.SARIF1007_RegionPropertiesMustBeConsistent_Error_EndLineMustNotPrecedeStartLine_Text), + region.EndLine.ToInvariantString(), + region.StartLine.ToInvariantString()); + } + + if (RegionIsOnOneLine(region, regionToken) && regionToken.HasProperty(SarifPropertyName.EndColumn) && region.EndColumn < region.StartColumn) @@ -36,7 +50,7 @@ protected override void Analyze(Region region, string regionPointer) LogResult( endColumnPointer, - nameof(RuleResources.SARIF1013_Default), + nameof(RuleResources.SARIF1007_RegionPropertiesMustBeConsistent_Error_EndColumnMustNotPrecedeStartColumn_Text), region.EndColumn.ToInvariantString(), region.StartColumn.ToInvariantString()); } diff --git a/src/Sarif.Multitool/Rules/SARIF1012.EndLineMustNotBeLessThanStartLine.cs b/src/Sarif.Multitool/Rules/SARIF1012.EndLineMustNotBeLessThanStartLine.cs deleted file mode 100644 index e03b763e1..000000000 --- a/src/Sarif.Multitool/Rules/SARIF1012.EndLineMustNotBeLessThanStartLine.cs +++ /dev/null @@ -1,43 +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.Collections.Generic; -using Microsoft.Json.Pointer; - -namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules -{ - public class EndLineMustNotBeLessThanStartLine : SarifValidationSkimmerBase - { - public override MultiformatMessageString FullDescription => new MultiformatMessageString - { - Text = RuleResources.SARIF1012_EndLineMustNotBeLessThanStartLine - }; - - public override FailureLevel DefaultLevel => FailureLevel.Error; - - public override string Id => RuleId.EndLineMustNotBeLessThanStartLine; - - protected override IEnumerable MessageResourceNames => new string[] - { - nameof(RuleResources.SARIF1012_Default) - }; - - protected override void Analyze(Region region, string regionPointer) - { - var jsonPointer = new JsonPointer(regionPointer); - Newtonsoft.Json.Linq.JToken regionToken = jsonPointer.Evaluate(Context.InputLogToken); - - if (regionToken.HasProperty(SarifPropertyName.EndLine) && - region.EndLine < region.StartLine) - { - string endLinePointer = regionPointer.AtProperty(SarifPropertyName.EndLine); - - LogResult( - endLinePointer, - nameof(RuleResources.SARIF1012_Default), - region.EndLine.ToInvariantString(), - region.StartLine.ToInvariantString()); - } - } - } -} diff --git a/src/Test.FunctionalTests.Sarif/Multitool/ValidateCommandTests.cs b/src/Test.FunctionalTests.Sarif/Multitool/ValidateCommandTests.cs index f6ddfb18b..e4f14f192 100644 --- a/src/Test.FunctionalTests.Sarif/Multitool/ValidateCommandTests.cs +++ b/src/Test.FunctionalTests.Sarif/Multitool/ValidateCommandTests.cs @@ -70,19 +70,13 @@ public void SARIF2001_AuthorHighQualityMessages_Invalid() * test file names in TestData\Inputs and TestData\ExpectedOutputs. ******************/ [Fact] - public void SARIF1012_EndLineMustNotBeLessThanStartLine_Valid() - => RunTest(MakeValidTestFileName(RuleId.EndLineMustNotBeLessThanStartLine, "EndLineMustNotBeLessThanStart")); + public void SARIF1007_RegionPropertiesMustBeConsistent_Valid() + => RunTest(MakeValidTestFileName(RuleId.RegionPropertiesMustBeConsistent, "RegionPropertiesMustBeConsistent")); [Fact] - public void SARIF1012_EndLineMustNotBeLessThanStartLine_Invalid() - => RunTest(MakeInvalidTestFileName(RuleId.EndLineMustNotBeLessThanStartLine, "EndLineMustNotBeLessThanStart")); - [Fact] - public void SARIF1013_EndColumnMustNotBeLessThanStartColumn_Valid() - => RunTest(MakeValidTestFileName(RuleId.EndColumnMustNotBeLessThanStartColumn, "EndColumnMustNotBeLessThanStart")); + public void SARIF1007_RegionPropertiesMustBeConsistent_Invalid() + => RunTest(MakeInvalidTestFileName(RuleId.RegionPropertiesMustBeConsistent, "RegionPropertiesMustBeConsistent")); - [Fact] - public void SARIF1013_EndColumnMustNotBeLessThanStartColumn_Invalid() - => RunTest(MakeInvalidTestFileName(RuleId.EndColumnMustNotBeLessThanStartColumn, "EndColumnMustNotBeLessThanStart")); /********** END PROBLEMATIC TESTS*******/ [Fact] diff --git a/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/ExpectedOutputs/SARIF1007.RegionPropertiesMustBeConsistent_Invalid.sarif b/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/ExpectedOutputs/SARIF1007.RegionPropertiesMustBeConsistent_Invalid.sarif new file mode 100644 index 000000000..575570037 --- /dev/null +++ b/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/ExpectedOutputs/SARIF1007.RegionPropertiesMustBeConsistent_Invalid.sarif @@ -0,0 +1,258 @@ +{ + "$schema": "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.5.json", + "version": "2.1.0", + "runs": [ + { + "tool": { + "driver": { + "name": "SARIF Functional Testing", + "rules": [ + { + "id": "SARIF1007", + "name": "RegionPropertiesMustBeConsistent", + "shortDescription": { + "text": "Placeholder_SARIF1007_RegionPropertiesMustBeConsistent_FullDescription_Text." + }, + "fullDescription": { + "text": "Placeholder_SARIF1007_RegionPropertiesMustBeConsistent_FullDescription_Text" + }, + "messageStrings": { + "Error_EndLineMustNotPrecedeStartLine": { + "text": "{0}: The value of the \"endLine\" property is {1}, which is less than the value of the \"startLine\" property, which is {2}." + }, + "Error_EndColumnMustNotPrecedeStartColumn": { + "text": "{0}: The value of the \"endColumn\" property is {1}, which is less than the value of the \"startColumn\" property, which is {2}." + } + }, + "helpUri": "http://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html" + } + ] + } + }, + "invocations": [ + { + "executionSuccessful": true + } + ], + "artifacts": [ + { + "location": { + "uri": "FunctionalTestOutput.ValidateCommand/Inputs.SARIF1007.RegionPropertiesMustBeConsistent_Invalid.sarif", + "uriBaseId": "TEST_DIR" + } + } + ], + "results": [ + { + "ruleId": "SARIF1007", + "ruleIndex": 0, + "level": "error", + "message": { + "id": "Error_EndColumnMustNotPrecedeStartColumn", + "arguments": [ + "runs[0].results[0].locations[0].physicalLocation.region.endColumn", + "1", + "2" + ] + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "index": 0 + }, + "region": { + "startLine": 27, + "startColumn": 32 + } + } + } + ] + }, + { + "ruleId": "SARIF1007", + "ruleIndex": 0, + "level": "error", + "message": { + "id": "Error_EndColumnMustNotPrecedeStartColumn", + "arguments": [ + "runs[0].results[0].codeFlows[0].threadFlows[0].locations[0].location.physicalLocation.region.endColumn", + "1", + "2" + ] + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "index": 0 + }, + "region": { + "startLine": 72, + "startColumn": 42 + } + } + } + ] + }, + { + "ruleId": "SARIF1007", + "ruleIndex": 0, + "level": "error", + "message": { + "id": "Error_EndColumnMustNotPrecedeStartColumn", + "arguments": [ + "runs[0].results[0].stacks[0].frames[0].location.physicalLocation.region.endColumn", + "1", + "2" + ] + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "index": 0 + }, + "region": { + "startLine": 47, + "startColumn": 38 + } + } + } + ] + }, + { + "ruleId": "SARIF1007", + "ruleIndex": 0, + "level": "error", + "message": { + "id": "Error_EndColumnMustNotPrecedeStartColumn", + "arguments": [ + "runs[0].results[0].relatedLocations[0].physicalLocation.region.endColumn", + "1", + "2" + ] + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "index": 0 + }, + "region": { + "startLine": 94, + "startColumn": 32 + } + } + } + ] + }, + { + "ruleId": "SARIF1007", + "ruleIndex": 0, + "level": "error", + "message": { + "id": "Error_EndLineMustNotPrecedeStartLine", + "arguments": [ + "runs[0].results[1].locations[0].physicalLocation.region.endLine", + "1", + "2" + ] + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "index": 0 + }, + "region": { + "startLine": 117, + "startColumn": 30 + } + } + } + ] + }, + { + "ruleId": "SARIF1007", + "ruleIndex": 0, + "level": "error", + "message": { + "id": "Error_EndLineMustNotPrecedeStartLine", + "arguments": [ + "runs[0].results[1].codeFlows[0].threadFlows[0].locations[0].location.physicalLocation.region.endLine", + "1", + "2" + ] + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "index": 0 + }, + "region": { + "startLine": 160, + "startColumn": 40 + } + } + } + ] + }, + { + "ruleId": "SARIF1007", + "ruleIndex": 0, + "level": "error", + "message": { + "id": "Error_EndLineMustNotPrecedeStartLine", + "arguments": [ + "runs[0].results[1].stacks[0].frames[0].location.physicalLocation.region.endLine", + "1", + "2" + ] + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "index": 0 + }, + "region": { + "startLine": 136, + "startColumn": 36 + } + } + } + ] + }, + { + "ruleId": "SARIF1007", + "ruleIndex": 0, + "level": "error", + "message": { + "id": "Error_EndLineMustNotPrecedeStartLine", + "arguments": [ + "runs[0].results[1].relatedLocations[0].physicalLocation.region.endLine", + "1", + "2" + ] + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "index": 0 + }, + "region": { + "startLine": 181, + "startColumn": 30 + } + } + } + ] + } + ], + "columnKind": "utf16CodeUnits" + } + ] +} \ No newline at end of file diff --git a/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/ExpectedOutputs/SARIF1013.EndColumnMustNotBeLessThanStart_Valid.sarif b/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/ExpectedOutputs/SARIF1007.RegionPropertiesMustBeConsistent_Valid.sarif similarity index 91% rename from src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/ExpectedOutputs/SARIF1013.EndColumnMustNotBeLessThanStart_Valid.sarif rename to src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/ExpectedOutputs/SARIF1007.RegionPropertiesMustBeConsistent_Valid.sarif index 99aea32af..22cf245f5 100644 --- a/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/ExpectedOutputs/SARIF1013.EndColumnMustNotBeLessThanStart_Valid.sarif +++ b/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/ExpectedOutputs/SARIF1007.RegionPropertiesMustBeConsistent_Valid.sarif @@ -16,7 +16,7 @@ "artifacts": [ { "location": { - "uri": "FunctionalTestOutput.ValidateCommand/Inputs.SARIF1013.EndColumnMustNotBeLessThanStart_Valid.sarif", + "uri": "FunctionalTestOutput.ValidateCommand/Inputs.SARIF1007.RegionPropertiesMustBeConsistent_Valid.sarif", "uriBaseId": "TEST_DIR" } } diff --git a/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/ExpectedOutputs/SARIF1012.EndLineMustNotBeLessThanStart_Invalid.sarif b/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/ExpectedOutputs/SARIF1012.EndLineMustNotBeLessThanStart_Invalid.sarif deleted file mode 100644 index 21dbb2c98..000000000 --- a/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/ExpectedOutputs/SARIF1012.EndLineMustNotBeLessThanStart_Invalid.sarif +++ /dev/null @@ -1,151 +0,0 @@ -{ - "$schema": "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.5.json", - "version": "2.1.0", - "runs": [ - { - "tool": { - "driver": { - "name": "SARIF Functional Testing", - "rules": [ - { - "id": "SARIF1013", - "name": "EndColumnMustNotBeLessThanStartColumn", - "shortDescription": { - "text": "The \"endColumn\" property of a region object must not be less than the \"startColumn\" property." - }, - "fullDescription": { - "text": "The \"endColumn\" property of a region object must not be less than the \"startColumn\" property." - }, - "messageStrings": { - "Default": { - "text": "{0}: The value of the \"endColumn\" property is {1}, which is less than the value of the \"startColumn\" property, which is {2}." - } - }, - "helpUri": "http://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html" - } - ] - } - }, - "invocations": [ - { - "executionSuccessful": true - } - ], - "artifacts": [ - { - "location": { - "uri": "FunctionalTestOutput.ValidateCommand/Inputs.SARIF1012.EndLineMustNotBeLessThanStart_Invalid.sarif", - "uriBaseId": "TEST_DIR" - } - } - ], - "results": [ - { - "ruleId": "SARIF1013", - "ruleIndex": 0, - "level": "error", - "message": { - "id": "Default", - "arguments": [ - "runs[0].results[0].locations[0].physicalLocation.region.endColumn", - "1", - "2" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 27, - "startColumn": 32 - } - } - } - ] - }, - { - "ruleId": "SARIF1013", - "ruleIndex": 0, - "level": "error", - "message": { - "id": "Default", - "arguments": [ - "runs[0].results[0].codeFlows[0].threadFlows[0].locations[0].location.physicalLocation.region.endColumn", - "1", - "2" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 72, - "startColumn": 42 - } - } - } - ] - }, - { - "ruleId": "SARIF1013", - "ruleIndex": 0, - "level": "error", - "message": { - "id": "Default", - "arguments": [ - "runs[0].results[0].stacks[0].frames[0].location.physicalLocation.region.endColumn", - "1", - "2" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 47, - "startColumn": 38 - } - } - } - ] - }, - { - "ruleId": "SARIF1013", - "ruleIndex": 0, - "level": "error", - "message": { - "id": "Default", - "arguments": [ - "runs[0].results[0].relatedLocations[0].physicalLocation.region.endColumn", - "1", - "2" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 94, - "startColumn": 32 - } - } - } - ] - } - ], - "columnKind": "utf16CodeUnits" - } - ] -} \ No newline at end of file diff --git a/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/ExpectedOutputs/SARIF1012.EndLineMustNotBeLessThanStart_Valid.sarif b/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/ExpectedOutputs/SARIF1012.EndLineMustNotBeLessThanStart_Valid.sarif deleted file mode 100644 index bdaba0c76..000000000 --- a/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/ExpectedOutputs/SARIF1012.EndLineMustNotBeLessThanStart_Valid.sarif +++ /dev/null @@ -1,28 +0,0 @@ -{ - "$schema": "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.5.json", - "version": "2.1.0", - "runs": [ - { - "tool": { - "driver": { - "name": "SARIF Functional Testing" - } - }, - "invocations": [ - { - "executionSuccessful": true - } - ], - "artifacts": [ - { - "location": { - "uri": "FunctionalTestOutput.ValidateCommand/Inputs.SARIF1012.EndLineMustNotBeLessThanStart_Valid.sarif", - "uriBaseId": "TEST_DIR" - } - } - ], - "results": [], - "columnKind": "utf16CodeUnits" - } - ] -} \ No newline at end of file diff --git a/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/ExpectedOutputs/SARIF1013.EndColumnMustNotBeLessThanStart_Invalid.sarif b/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/ExpectedOutputs/SARIF1013.EndColumnMustNotBeLessThanStart_Invalid.sarif deleted file mode 100644 index 6893145f0..000000000 --- a/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/ExpectedOutputs/SARIF1013.EndColumnMustNotBeLessThanStart_Invalid.sarif +++ /dev/null @@ -1,151 +0,0 @@ -{ - "$schema": "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.5.json", - "version": "2.1.0", - "runs": [ - { - "tool": { - "driver": { - "name": "SARIF Functional Testing", - "rules": [ - { - "id": "SARIF1012", - "name": "EndLineMustNotBeLessThanStartLine", - "shortDescription": { - "text": "The \"endLine\" property of a region object must not be less than the \"startLine\" property." - }, - "fullDescription": { - "text": "The \"endLine\" property of a region object must not be less than the \"startLine\" property." - }, - "messageStrings": { - "Default": { - "text": "{0}: The value of the \"endLine\" property is {1}, which is less than the value of the \"startLine\" property, which is {2}." - } - }, - "helpUri": "http://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html" - } - ] - } - }, - "invocations": [ - { - "executionSuccessful": true - } - ], - "artifacts": [ - { - "location": { - "uri": "FunctionalTestOutput.ValidateCommand/Inputs.SARIF1013.EndColumnMustNotBeLessThanStart_Invalid.sarif", - "uriBaseId": "TEST_DIR" - } - } - ], - "results": [ - { - "ruleId": "SARIF1012", - "ruleIndex": 0, - "level": "error", - "message": { - "id": "Default", - "arguments": [ - "runs[0].results[0].locations[0].physicalLocation.region.endLine", - "1", - "2" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 26, - "startColumn": 30 - } - } - } - ] - }, - { - "ruleId": "SARIF1012", - "ruleIndex": 0, - "level": "error", - "message": { - "id": "Default", - "arguments": [ - "runs[0].results[0].codeFlows[0].threadFlows[0].locations[0].location.physicalLocation.region.endLine", - "1", - "2" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 69, - "startColumn": 40 - } - } - } - ] - }, - { - "ruleId": "SARIF1012", - "ruleIndex": 0, - "level": "error", - "message": { - "id": "Default", - "arguments": [ - "runs[0].results[0].stacks[0].frames[0].location.physicalLocation.region.endLine", - "1", - "2" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 45, - "startColumn": 36 - } - } - } - ] - }, - { - "ruleId": "SARIF1012", - "ruleIndex": 0, - "level": "error", - "message": { - "id": "Default", - "arguments": [ - "runs[0].results[0].relatedLocations[0].physicalLocation.region.endLine", - "1", - "2" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 90, - "startColumn": 30 - } - } - } - ] - } - ], - "columnKind": "utf16CodeUnits" - } - ] -} \ No newline at end of file diff --git a/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/Inputs/SARIF1012.EndLineMustNotBeLessThanStart_Invalid.sarif b/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/Inputs/SARIF1007.RegionPropertiesMustBeConsistent_Invalid.sarif similarity index 54% rename from src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/Inputs/SARIF1012.EndLineMustNotBeLessThanStart_Invalid.sarif rename to src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/Inputs/SARIF1007.RegionPropertiesMustBeConsistent_Invalid.sarif index b738f5d6a..f9b942eff 100644 --- a/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/Inputs/SARIF1012.EndLineMustNotBeLessThanStart_Invalid.sarif +++ b/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/Inputs/SARIF1007.RegionPropertiesMustBeConsistent_Invalid.sarif @@ -99,6 +99,93 @@ } } ] + }, + { + "ruleId": "TST0001", + "level": "error", + "message": { + "text": "Result message." + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "file:///c:/src/file.c" + }, + "region": { + "startLine": 2, + "endLine": 1 + } + }, + "message": { + "text": "endLine less than startLine in result location." + } + } + ], + "stacks": [ + { + "frames": [ + { + "location": { + "physicalLocation": { + "artifactLocation": { + "uri": "file:///c:/src/file.c" + }, + "region": { + "startLine": 2, + "endLine": 1 + } + }, + "message": { + "text": "endLine less than startLine in stackFrame." + } + } + } + ] + } + ], + "codeFlows": [ + { + "threadFlows": [ + { + "locations": [ + { + "location": { + "physicalLocation": { + "artifactLocation": { + "uri": "file:///c:/src/file.c" + }, + "region": { + "startLine": 2, + "endLine": 1 + } + }, + "message": { + "text": "endLine less than startLine in threadFlow location." + } + } + } + ] + } + ] + } + ], + "relatedLocations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "file:///c:/src/file.c" + }, + "region": { + "startLine": 2, + "endLine": 1 + } + }, + "message": { + "text": "endLine less than startLine in related location." + } + } + ] } ], "columnKind": "utf16CodeUnits" diff --git a/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/Inputs/SARIF1012.EndLineMustNotBeLessThanStart_Valid.sarif b/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/Inputs/SARIF1007.RegionPropertiesMustBeConsistent_Valid.sarif similarity index 62% rename from src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/Inputs/SARIF1012.EndLineMustNotBeLessThanStart_Valid.sarif rename to src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/Inputs/SARIF1007.RegionPropertiesMustBeConsistent_Valid.sarif index 1f490b966..944a43aa4 100644 --- a/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/Inputs/SARIF1012.EndLineMustNotBeLessThanStart_Valid.sarif +++ b/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/Inputs/SARIF1007.RegionPropertiesMustBeConsistent_Valid.sarif @@ -77,6 +77,56 @@ } } ] + }, + { + "ruleId": "TST0001", + "level": "error", + "message": { + "text": "Result message." + }, + "locations": [ + { + "physicalLocation": { + "artifactLocation": { + "uri": "file:///c:/src/file.c" + }, + "region": { + "startLine": 1, + "endLine": 1 + } + }, + "message": { + "text": "endLine equals startLine." + } + }, + { + "physicalLocation": { + "artifactLocation": { + "uri": "file:///c:/src/file.c" + }, + "region": { + "startLine": 1, + "endLine": 2 + } + }, + "message": { + "text": "endLine greater than startLine." + } + }, + { + "physicalLocation": { + "artifactLocation": { + "uri": "file:///c:/src/file.c" + }, + "region": { + "startLine": 1 + } + }, + "message": { + "text": "endLine not specified." + } + } + ] } ], "columnKind": "utf16CodeUnits" diff --git a/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/Inputs/SARIF1013.EndColumnMustNotBeLessThanStart_Invalid.sarif b/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/Inputs/SARIF1013.EndColumnMustNotBeLessThanStart_Invalid.sarif deleted file mode 100644 index aded91e74..000000000 --- a/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/Inputs/SARIF1013.EndColumnMustNotBeLessThanStart_Invalid.sarif +++ /dev/null @@ -1,103 +0,0 @@ -{ - "$schema": "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.5.json", - "version": "2.1.0", - "runs": [ - { - "tool": { - "driver": { - "name": "CodeScanner" - } - }, - "results": [ - { - "ruleId": "TST0001", - "level": "error", - "message": { - "text": "Result message." - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "uri": "file:///c:/src/file.c" - }, - "region": { - "startLine": 2, - "endLine": 1 - } - }, - "message": { - "text": "endLine less than startLine in result location." - } - } - ], - "stacks": [ - { - "frames": [ - { - "location": { - "physicalLocation": { - "artifactLocation": { - "uri": "file:///c:/src/file.c" - }, - "region": { - "startLine": 2, - "endLine": 1 - } - }, - "message": { - "text": "endLine less than startLine in stackFrame." - } - } - } - ] - } - ], - "codeFlows": [ - { - "threadFlows": [ - { - "locations": [ - { - "location": { - "physicalLocation": { - "artifactLocation": { - "uri": "file:///c:/src/file.c" - }, - "region": { - "startLine": 2, - "endLine": 1 - } - }, - "message": { - "text": "endLine less than startLine in threadFlow location." - } - } - } - ] - } - ] - } - ], - "relatedLocations": [ - { - "physicalLocation": { - "artifactLocation": { - "uri": "file:///c:/src/file.c" - }, - "region": { - "startLine": 2, - "endLine": 1 - } - }, - "message": { - "text": "endLine less than startLine in related location." - } - } - ] - } - ], - "columnKind": "utf16CodeUnits" - } - ] -} \ No newline at end of file diff --git a/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/Inputs/SARIF1013.EndColumnMustNotBeLessThanStart_Valid.sarif b/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/Inputs/SARIF1013.EndColumnMustNotBeLessThanStart_Valid.sarif deleted file mode 100644 index f007b3de4..000000000 --- a/src/Test.FunctionalTests.Sarif/TestData/Multitool/ValidateCommand/Inputs/SARIF1013.EndColumnMustNotBeLessThanStart_Valid.sarif +++ /dev/null @@ -1,66 +0,0 @@ -{ - "$schema": "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.5.json", - "version": "2.1.0", - "runs": [ - { - "tool": { - "driver": { - "name": "CodeScanner" - } - }, - "results": [ - { - "ruleId": "TST0001", - "level": "error", - "message": { - "text": "Result message." - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "uri": "file:///c:/src/file.c" - }, - "region": { - "startLine": 1, - "endLine": 1 - } - }, - "message": { - "text": "endLine equals startLine." - } - }, - { - "physicalLocation": { - "artifactLocation": { - "uri": "file:///c:/src/file.c" - }, - "region": { - "startLine": 1, - "endLine": 2 - } - }, - "message": { - "text": "endLine greater than startLine." - } - }, - { - "physicalLocation": { - "artifactLocation": { - "uri": "file:///c:/src/file.c" - }, - "region": { - "startLine": 1 - } - }, - "message": { - "text": "endLine not specified." - } - } - ] - } - ], - "columnKind": "utf16CodeUnits" - } - ] -} \ No newline at end of file