From 439258b08234cadbb30d92058c63bd6c76785fc1 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Mon, 19 Aug 2019 14:40:27 -0700 Subject: [PATCH] Fix #1584: Multitool Transform can't upgrade "http://json.schemastore.org/sarif-2.1.0-rtm.1" schema (#1652) --- src/ReleaseHistory.md | 1 + .../PrereleaseCompatibilityTransformer.cs | 5 +++++ .../Test.UnitTests.Sarif.csproj | 4 ++++ .../ExpectedOutputs/Rtm1SchemaLocation.sarif | 18 ++++++++++++++++++ .../Inputs/Rtm1SchemaLocation.sarif | 18 ++++++++++++++++++ .../PrereleaseCompatibilityTransformerTests.cs | 7 +++++++ 6 files changed, 53 insertions(+) create mode 100644 src/Test.UnitTests.Sarif/TestData/PrereleaseCompatibilityTransformer/ExpectedOutputs/Rtm1SchemaLocation.sarif create mode 100644 src/Test.UnitTests.Sarif/TestData/PrereleaseCompatibilityTransformer/Inputs/Rtm1SchemaLocation.sarif diff --git a/src/ReleaseHistory.md b/src/ReleaseHistory.md index e3ddf802f..59b75605c 100644 --- a/src/ReleaseHistory.md +++ b/src/ReleaseHistory.md @@ -448,6 +448,7 @@ * BUGFIX: Validation rule `SARIF1015` incorrectly required `originalUriBaseIds` to be contain URIs. https://github.com/microsoft/sarif-sdk/issues/1485 * BUGFIX: Multitool transform mishandled dottedQuadFileVersion. https://github.com/microsoft/sarif-sdk/issues/1532 * BUGFIX: Restore missing FxCop converter unit test. https://github.com/microsoft/sarif-sdk/issues/1575 +* BUGFIX: Multitool transform could not upgrade SARIF files from the sarif-2.1.0-rtm.1 schema. https://github.com/microsoft/sarif-sdk/issues/1584 * BUGFIX: Multitool merge command produced invalid SARIF if there were 0 input files. https://github.com/microsoft/sarif-sdk/issues/1592 * BUGFIX: FortifyFpr converter produced invalid SARIF. https://github.com/microsoft/sarif-sdk/issues/1593 * BUGFIX: FxCop converter produced empty `result.message` objects. https://github.com/microsoft/sarif-sdk/issues/1594 diff --git a/src/Sarif/Writers/PrereleaseCompatibilityTransformer.cs b/src/Sarif/Writers/PrereleaseCompatibilityTransformer.cs index 69242a99a..877d4143c 100644 --- a/src/Sarif/Writers/PrereleaseCompatibilityTransformer.cs +++ b/src/Sarif/Writers/PrereleaseCompatibilityTransformer.cs @@ -62,13 +62,18 @@ public static SarifLog UpdateToCurrentVersion( goto case "http://json.schemastore.org/sarif-2.1.0-rtm.0"; } case "http://json.schemastore.org/sarif-2.1.0-rtm.0": + case "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.0.json": { modifiedLog |= ApplyRtm1Changes(sarifLog); goto case "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.4.json"; } + case "http://json.schemastore.org/sarif-2.1.0-rtm.4": case "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.4.json": + case "http://json.schemastore.org/sarif-2.1.0-rtm.3": case "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.3.json": + case "http://json.schemastore.org/sarif-2.1.0-rtm.2": case "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.2.json": + case "http://json.schemastore.org/sarif-2.1.0-rtm.1": case "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.1.json": { modifiedLog |= ApplyRtm2and3Changes(sarifLog); diff --git a/src/Test.UnitTests.Sarif/Test.UnitTests.Sarif.csproj b/src/Test.UnitTests.Sarif/Test.UnitTests.Sarif.csproj index 7c47d8ae2..9ef2d3785 100644 --- a/src/Test.UnitTests.Sarif/Test.UnitTests.Sarif.csproj +++ b/src/Test.UnitTests.Sarif/Test.UnitTests.Sarif.csproj @@ -29,6 +29,7 @@ + @@ -44,6 +45,7 @@ + @@ -77,6 +79,8 @@ Never + + diff --git a/src/Test.UnitTests.Sarif/TestData/PrereleaseCompatibilityTransformer/ExpectedOutputs/Rtm1SchemaLocation.sarif b/src/Test.UnitTests.Sarif/TestData/PrereleaseCompatibilityTransformer/ExpectedOutputs/Rtm1SchemaLocation.sarif new file mode 100644 index 000000000..c6b592bbe --- /dev/null +++ b/src/Test.UnitTests.Sarif/TestData/PrereleaseCompatibilityTransformer/ExpectedOutputs/Rtm1SchemaLocation.sarif @@ -0,0 +1,18 @@ +{ + "$schema": "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.4.json", + "version": "2.1.0", + "runs": [ + { + "tool": { + "driver": { + "name": "CodeScanner" + } + }, + "results": [], + "columnKind": "utf16CodeUnits" + } + ], + "properties": { + "comment": "Regression test for #1584: Multitool Transform can't upgrade 'http://json.schemastore.org/sarif-2.1.0-rtm.1' schema" + } +} \ No newline at end of file diff --git a/src/Test.UnitTests.Sarif/TestData/PrereleaseCompatibilityTransformer/Inputs/Rtm1SchemaLocation.sarif b/src/Test.UnitTests.Sarif/TestData/PrereleaseCompatibilityTransformer/Inputs/Rtm1SchemaLocation.sarif new file mode 100644 index 000000000..ed127f615 --- /dev/null +++ b/src/Test.UnitTests.Sarif/TestData/PrereleaseCompatibilityTransformer/Inputs/Rtm1SchemaLocation.sarif @@ -0,0 +1,18 @@ +{ + "$schema": "http://json.schemastore.org/sarif-2.1.0-rtm.1", + "version": "2.1.0", + "runs": [ + { + "tool": { + "driver": { + "name": "CodeScanner" + } + }, + "results": [], + "columnKind": "utf16CodeUnits" + } + ], + "properties": { + "comment": "Regression test for #1584: Multitool Transform can't upgrade 'http://json.schemastore.org/sarif-2.1.0-rtm.1' schema" + } +} \ No newline at end of file diff --git a/src/Test.UnitTests.Sarif/Writers/PrereleaseCompatibilityTransformerTests.cs b/src/Test.UnitTests.Sarif/Writers/PrereleaseCompatibilityTransformerTests.cs index 6c03dc254..4f947a0ce 100644 --- a/src/Test.UnitTests.Sarif/Writers/PrereleaseCompatibilityTransformerTests.cs +++ b/src/Test.UnitTests.Sarif/Writers/PrereleaseCompatibilityTransformerTests.cs @@ -142,6 +142,13 @@ public void PrereleaseCompatibilityTransformer_ThreadFlowLocationWithKind() RunTest("ThreadFlowLocationWithKind.sarif"); } + [Fact] + [Trait(TestTraits.Bug, "1584")] + public void PrereleaseCompatibilityTransformer_Rtm1SchemaLocation() + { + RunTest("Rtm1SchemaLocation.sarif"); + } + [Fact] public void PrereleaseCompatibilityTransformer_FromSarifV1() {