Skip to content

Commit

Permalink
Fix #1557: current-to-v1 converter drops run.id and emits empty stabl…
Browse files Browse the repository at this point in the history
…eId.

Also:
- Fix Sarif project file that made ReleaseHistory.md show up in the VS editor with a file name of "false".
  • Loading branch information
Larry Golding committed Jul 1, 2019
1 parent 4e984e3 commit 31b4c05
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/ReleaseHistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,4 +415,5 @@
* BUGFIX: Pre-release transformer does not upgrade schema uri if input version is higher than rtm.1.

## **v2.1.7** [Sdk](https://www.nuget.org/packages/Sarif.Sdk/2.1.7) | [Driver](https://www.nuget.org/packages/Sarif.Driver/2.1.7) | [Converters](https://www.nuget.org/packages/Sarif.Converters/2.1.7) | [Multitool](https://www.nuget.org/packages/Sarif.Multitool/2.1.7)
* BUGFIX: The `SarifCurrentToVersionOneVisitor` was not translating v2 `result.partialFingerprints` to v1 `result.toolFingerprintContribution`. https://github.com/microsoft/sarif-sdk/issues/1556
* BUGFIX: The `SarifCurrentToVersionOneVisitor` was not translating v2 `result.partialFingerprints` to v1 `result.toolFingerprintContribution`. https://github.com/microsoft/sarif-sdk/issues/1556
* BUGFIX: The `SarifCurrentToVersionOneVisitor` was dropping `run.id` and emitting an empty `run.stableId`. https://github.com/microsoft/sarif-sdk/issues/1557
2 changes: 1 addition & 1 deletion src/Sarif/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static string InstanceIdLogicalComponent(this RunAutomationDetails runAut

if (!instanceId.Contains("/"))
{
return String.Empty;
return null;
}

return instanceId.Substring(0, instanceId.LastIndexOf('/'));
Expand Down
3 changes: 1 addition & 2 deletions src/Sarif/Sarif.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@
<Content Include="Schemata\sarif-$(SchemaVersionAsPublishedToSchemaStoreOrg).json" />
<Content Include="Schemata\sarif-external-property-file-$(SchemaVersionAsPublishedToSchemaStoreOrg).json" />

<!-- Link=false: Don't display this item in Solution Explorer. -->
<!-- This item will be added to the NuGet package, however. -->
<Content Include="..\ReleaseHistory.md" Link="false" />
<Content Include="..\ReleaseHistory.md" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Sarif/Visitors/SarifCurrentToVersionOneVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ internal RunVersionOne CreateRunVersionOne(Run v2Run)

run.BaselineId = v2Run.BaselineGuid;
run.Files = CreateFileDataVersionOneDictionary();
run.Id = v2Run.AutomationDetails?.Guid;
run.Id = v2Run.AutomationDetails?.Id;
run.AutomationId = v2Run.RunAggregates?.FirstOrDefault()?.Id;

run.StableId = v2Run.AutomationDetails?.InstanceIdLogicalComponent();
Expand Down
2 changes: 2 additions & 0 deletions src/Test.UnitTests.Sarif/Test.UnitTests.Sarif.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
<EmbeddedResource Include="TestData\SarifCurrentToVersionOneVisitor\ExpectedOutputs\Minimum.sarif" />
<EmbeddedResource Include="TestData\SarifCurrentToVersionOneVisitor\ExpectedOutputs\MinimumWithTwoRuns.sarif" />
<EmbeddedResource Include="TestData\SarifCurrentToVersionOneVisitor\ExpectedOutputs\NotificationExceptionWithStack.sarif" />
<EmbeddedResource Include="TestData\SarifCurrentToVersionOneVisitor\ExpectedOutputs\OneRunWithAutomationDetails.sarif" />
<EmbeddedResource Include="TestData\SarifCurrentToVersionOneVisitor\ExpectedOutputs\OneRunWithBasicInvocation.sarif" />
<EmbeddedResource Include="TestData\SarifCurrentToVersionOneVisitor\ExpectedOutputs\OneRunWithFiles.sarif" />
<EmbeddedResource Include="TestData\SarifCurrentToVersionOneVisitor\ExpectedOutputs\OneRunWithNotificationTime.sarif" />
Expand All @@ -148,6 +149,7 @@
<EmbeddedResource Include="TestData\SarifCurrentToVersionOneVisitor\Inputs\Minimum.sarif" />
<EmbeddedResource Include="TestData\SarifCurrentToVersionOneVisitor\Inputs\MinimumWithTwoRuns.sarif" />
<EmbeddedResource Include="TestData\SarifCurrentToVersionOneVisitor\Inputs\NotificationExceptionWithStack.sarif" />
<EmbeddedResource Include="TestData\SarifCurrentToVersionOneVisitor\Inputs\OneRunWithAutomationDetails.sarif" />
<EmbeddedResource Include="TestData\SarifCurrentToVersionOneVisitor\Inputs\OneRunWithBasicInvocation.sarif" />
<EmbeddedResource Include="TestData\SarifCurrentToVersionOneVisitor\Inputs\OneRunWithFiles.sarif" />
<EmbeddedResource Include="TestData\SarifCurrentToVersionOneVisitor\Inputs\OneRunWithNotificationTime.sarif" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://schemastore.azurewebsites.net/schemas/json/sarif-1.0.0.json",
"version": "1.0.0",
"runs": [
{
"tool": {
"name": "CodeScanner",
"semanticVersion": "2.1.0",
"language": "en-US"
},
"results": [],
"id": "Nightly security tools run/master/x86/debug/2018-10-05",
"stableId": "Nightly security tools run/master/x86/debug"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "http://json.schemastore.org/sarif-2.1.0-rtm.3",
"version": "2.1.0",
"runs": [
{
"tool": {
"driver": {
"name": "CodeScanner",
"semanticVersion": "2.1.0"
}
},
"results": [],
"automationDetails": {
"id": "Nightly security tools run/master/x86/debug/2018-10-05"
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,8 @@ protected override string ConstructTestOutputFromInputResource(string inputResou

[Fact]
public void SarifTransformerTests_ToVersionOne_TwoPartialPartialFingerprints() => RunTest("ResultWithTwoPartialFingerprints.sarif");

[Fact]
public void SarifTransformerTests_ToVersionOne_PopulatesRunIdAndStableId() => RunTest("OneRunWithAutomationDetails.sarif");
}
}

0 comments on commit 31b4c05

Please sign in to comment.