Skip to content

Commit

Permalink
Prep for 2018-11-28 schema update. Remove run.architecture. (#1145)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelcfanning authored Dec 5, 2018
1 parent b389a3e commit 7536475
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 46 deletions.
5 changes: 5 additions & 0 deletions src/ReleaseHistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,8 @@
* BREAKING: run.automationLogicalId subsumed by run.aggregateIds, an array of 'runAutomationDetails' objects.
* BREAKING: Remove threadFlowLocation.step
* Add result.occurrenceCount (denotes # of occurrences of an identical results within an analysisRun)

## **v2.0.0-csd.2.beta.2018.11.28** [Sdk](https://www.nuget.org/packages/Sarif.Sdk/2.0.0-csd.2.beta.2018.11.28) | [Driver](https://www.nuget.org/packages/Sarif.Driver/2.0.0-csd.2.beta.2018.11.28) | [Converters](https://www.nuget.org/packages/Sarif.Converters/2.0.0-csd.2.beta.2018.11.28)) | [Multitool](https://www.nuget.org/packages/Sarif.Multitool/2.0.0-csd.2.beta.2018.11.28))
* Result matching improvements
* Fortify FPR converter improvements
* BREAKING: remove run.architecture https://github.com/oasis-tcs/sarif-spec/issues/262
3 changes: 0 additions & 3 deletions src/Sarif.UnitTests/Writers/SarifLoggerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ public void SarifLogger_WritesRunProperties()
};

run.BaselineInstanceGuid = baselineInstanceGuid;
run.Architecture = architecture;
run.Conversion = conversion;
run.VersionControlProvenance = new[] { versionControlDetails };
run.OriginalUriBaseIds = originalUriBaseIds;
Expand All @@ -255,9 +254,7 @@ public void SarifLogger_WritesRunProperties()
run.Id.InstanceGuid.Should().Be(runInstanceGuid);
run.BaselineInstanceGuid.Should().Be(baselineInstanceGuid);
run.Id.InstanceId.Should().Be(runInstanceId);
run.Architecture.Should().Be(architecture);
run.Conversion.Tool.Should().BeEquivalentTo(DefaultTool);
//run.VersionControlProvenance[0].Timestamp.Should().BeEquivalentTo(utcNow);
run.VersionControlProvenance[0].RepositoryUri.Should().BeEquivalentTo(versionControlUri);
run.OriginalUriBaseIds[originalUriBaseIdKey].Uri.Should().Be(originalUriBaseIdValue);
run.DefaultFileEncoding.Should().Be(defaultFileEncoding);
Expand Down
18 changes: 4 additions & 14 deletions src/Sarif/Autogenerated/Run.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,6 @@ public SarifNodeKind SarifNodeKind
[DataMember(Name = "baselineInstanceGuid", IsRequired = false, EmitDefaultValue = false)]
public string BaselineInstanceGuid { get; set; }

/// <summary>
/// The hardware architecture for which the run was targeted.
/// </summary>
[DataMember(Name = "architecture", IsRequired = false, EmitDefaultValue = false)]
public string Architecture { get; set; }

/// <summary>
/// The MIME type of all rich text message properties in the run. Default: "text/markdown;variant=GFM"
/// </summary>
Expand Down Expand Up @@ -195,9 +189,6 @@ public Run()
/// <param name="baselineInstanceGuid">
/// An initialization value for the <see cref="P: BaselineInstanceGuid" /> property.
/// </param>
/// <param name="architecture">
/// An initialization value for the <see cref="P: Architecture" /> property.
/// </param>
/// <param name="richMessageMimeType">
/// An initialization value for the <see cref="P: RichMessageMimeType" /> property.
/// </param>
Expand All @@ -213,9 +204,9 @@ public Run()
/// <param name="properties">
/// An initialization value for the <see cref="P: Properties" /> property.
/// </param>
public Run(Tool tool, IEnumerable<Invocation> invocations, Conversion conversion, IEnumerable<VersionControlDetails> versionControlProvenance, IDictionary<string, FileLocation> originalUriBaseIds, IDictionary<string, FileData> files, IDictionary<string, LogicalLocation> logicalLocations, IDictionary<string, Graph> graphs, IEnumerable<Result> results, Resources resources, RunAutomationDetails id, IEnumerable<RunAutomationDetails> aggregateIds, string baselineInstanceGuid, string architecture, string richMessageMimeType, string redactionToken, string defaultFileEncoding, ColumnKind columnKind, IDictionary<string, SerializedPropertyInfo> properties)
public Run(Tool tool, IEnumerable<Invocation> invocations, Conversion conversion, IEnumerable<VersionControlDetails> versionControlProvenance, IDictionary<string, FileLocation> originalUriBaseIds, IDictionary<string, FileData> files, IDictionary<string, LogicalLocation> logicalLocations, IDictionary<string, Graph> graphs, IEnumerable<Result> results, Resources resources, RunAutomationDetails id, IEnumerable<RunAutomationDetails> aggregateIds, string baselineInstanceGuid, string richMessageMimeType, string redactionToken, string defaultFileEncoding, ColumnKind columnKind, IDictionary<string, SerializedPropertyInfo> properties)
{
Init(tool, invocations, conversion, versionControlProvenance, originalUriBaseIds, files, logicalLocations, graphs, results, resources, id, aggregateIds, baselineInstanceGuid, architecture, richMessageMimeType, redactionToken, defaultFileEncoding, columnKind, properties);
Init(tool, invocations, conversion, versionControlProvenance, originalUriBaseIds, files, logicalLocations, graphs, results, resources, id, aggregateIds, baselineInstanceGuid, richMessageMimeType, redactionToken, defaultFileEncoding, columnKind, properties);
}

/// <summary>
Expand All @@ -234,7 +225,7 @@ public Run(Run other)
throw new ArgumentNullException(nameof(other));
}

Init(other.Tool, other.Invocations, other.Conversion, other.VersionControlProvenance, other.OriginalUriBaseIds, other.Files, other.LogicalLocations, other.Graphs, other.Results, other.Resources, other.Id, other.AggregateIds, other.BaselineInstanceGuid, other.Architecture, other.RichMessageMimeType, other.RedactionToken, other.DefaultFileEncoding, other.ColumnKind, other.Properties);
Init(other.Tool, other.Invocations, other.Conversion, other.VersionControlProvenance, other.OriginalUriBaseIds, other.Files, other.LogicalLocations, other.Graphs, other.Results, other.Resources, other.Id, other.AggregateIds, other.BaselineInstanceGuid, other.RichMessageMimeType, other.RedactionToken, other.DefaultFileEncoding, other.ColumnKind, other.Properties);
}

ISarifNode ISarifNode.DeepClone()
Expand All @@ -255,7 +246,7 @@ private ISarifNode DeepCloneCore()
return new Run(this);
}

private void Init(Tool tool, IEnumerable<Invocation> invocations, Conversion conversion, IEnumerable<VersionControlDetails> versionControlProvenance, IDictionary<string, FileLocation> originalUriBaseIds, IDictionary<string, FileData> files, IDictionary<string, LogicalLocation> logicalLocations, IDictionary<string, Graph> graphs, IEnumerable<Result> results, Resources resources, RunAutomationDetails id, IEnumerable<RunAutomationDetails> aggregateIds, string baselineInstanceGuid, string architecture, string richMessageMimeType, string redactionToken, string defaultFileEncoding, ColumnKind columnKind, IDictionary<string, SerializedPropertyInfo> properties)
private void Init(Tool tool, IEnumerable<Invocation> invocations, Conversion conversion, IEnumerable<VersionControlDetails> versionControlProvenance, IDictionary<string, FileLocation> originalUriBaseIds, IDictionary<string, FileData> files, IDictionary<string, LogicalLocation> logicalLocations, IDictionary<string, Graph> graphs, IEnumerable<Result> results, Resources resources, RunAutomationDetails id, IEnumerable<RunAutomationDetails> aggregateIds, string baselineInstanceGuid, string richMessageMimeType, string redactionToken, string defaultFileEncoding, ColumnKind columnKind, IDictionary<string, SerializedPropertyInfo> properties)
{
if (tool != null)
{
Expand Down Expand Up @@ -386,7 +377,6 @@ private void Init(Tool tool, IEnumerable<Invocation> invocations, Conversion con
}

BaselineInstanceGuid = baselineInstanceGuid;
Architecture = architecture;
RichMessageMimeType = richMessageMimeType;
RedactionToken = redactionToken;
DefaultFileEncoding = defaultFileEncoding;
Expand Down
10 changes: 0 additions & 10 deletions src/Sarif/Autogenerated/RunEqualityComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,11 +225,6 @@ public bool Equals(Run left, Run right)
return false;
}

if (left.Architecture != right.Architecture)
{
return false;
}

if (left.RichMessageMimeType != right.RichMessageMimeType)
{
return false;
Expand Down Expand Up @@ -422,11 +417,6 @@ public int GetHashCode(Run obj)
result = (result * 31) + obj.BaselineInstanceGuid.GetHashCode();
}

if (obj.Architecture != null)
{
result = (result * 31) + obj.Architecture.GetHashCode();
}

if (obj.RichMessageMimeType != null)
{
result = (result * 31) + obj.RichMessageMimeType.GetHashCode();
Expand Down
2 changes: 1 addition & 1 deletion src/Sarif/Autogenerated/SarifLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Microsoft.CodeAnalysis.Sarif
{
/// <summary>
/// Static Analysis Results Format (SARIF) Version 2.0.0-csd.2.beta-2018-10-10 JSON Schema: a standard format for the output of static analysis tools.
/// Static Analysis Results Format (SARIF) Version 2.0.0-csd.2.beta-2018-11-28 JSON Schema: a standard format for the output of static analysis tools.
/// </summary>
[DataContract]
[GeneratedCode("Microsoft.Json.Schema.ToDotNet", "0.58.0.0")]
Expand Down
9 changes: 2 additions & 7 deletions src/Sarif/Schemata/sarif-schema.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Static Analysis Results Format (SARIF) Version 2.0.0-csd.2.beta.2018-10-10 JSON Schema",
"description": "Static Analysis Results Format (SARIF) Version 2.0.0-csd.2.beta-2018-10-10 JSON Schema: a standard format for the output of static analysis tools.",
"description": "Static Analysis Results Format (SARIF) Version 2.0.0-csd.2.beta-2018-11-28 JSON Schema: a standard format for the output of static analysis tools.",
"additionalProperties": false,
"type": "object",
"properties": {
Expand All @@ -14,7 +14,7 @@

"version": {
"description": "The SARIF format version of this log file.",
"enum": [ "2.0.0-csd.2.beta.2018-10-10" ]
"enum": [ "2.0.0-csd.2.beta.2018-11-28" ]
},

"runs": {
Expand Down Expand Up @@ -1555,11 +1555,6 @@
"type": "string"
},

"architecture": {
"description": "The hardware architecture for which the run was targeted.",
"type": "string"
},

"richMessageMimeType": {
"description": "The MIME type of all rich text message properties in the run. Default: \"text/markdown;variant=GFM\"",
"type": "string",
Expand Down
2 changes: 1 addition & 1 deletion src/Sarif/VersionConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Microsoft.CodeAnalysis.Sarif
{
public static class VersionConstants
{
public const string Prerelease = "csd.2.beta.2018-10-10";
public const string Prerelease = "csd.2.beta.2018-11-28";
public const string AssemblyVersion = "2.0.0";
public const string FileVersion = AssemblyVersion + ".0";
}
Expand Down
1 change: 0 additions & 1 deletion src/Sarif/Visitors/SarifCurrentToVersionOneVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,6 @@ internal RunVersionOne CreateRun(Run v2Run)
run = new RunVersionOne();
_currentRun = run;

run.Architecture = v2Run.Architecture;
run.BaselineId = v2Run.BaselineInstanceGuid;
run.Files = v2Run.Files?.ToDictionary(v => v.Key, v => CreateFileData(v.Value));

Expand Down
1 change: 0 additions & 1 deletion src/Sarif/Visitors/SarifVersionOneToCurrentVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,6 @@ internal Run CreateRun(RunVersionOne v1Run)

run = new Run()
{
Architecture = v1Run.Architecture,
Id = id,
AggregateIds = aggregateIds,
BaselineInstanceGuid = v1Run.BaselineId,
Expand Down
36 changes: 35 additions & 1 deletion src/Sarif/Writers/PrereleaseCompatibilityTransformer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,57 @@ public static string UpdateToCurrentVersion(string prereleaseSarifLog, bool forc

switch (version)
{
case "2.0.0-csd.2.beta.2018-11-28":
{
// SARIF TC28. Nothing to do.
break;
}

case "2.0.0-csd.2.beta.2018-10-10":
{
// Nothing to do, this is current
// 2.0.0-csd.2.beta.2018-10-10 == changes through SARIF TC #25
modifiedLog |= ApplyChangesFromTC25ThroughTC28(sarifLog);
break;
}

default:
{
modifiedLog |= ApplyCoreTransformations(sarifLog);
modifiedLog |= ApplyChangesFromTC25ThroughTC28(sarifLog);
break;
}
}

return modifiedLog ? sarifLog.ToString(formatting) : prereleaseSarifLog;
}

private static bool ApplyChangesFromTC25ThroughTC28(JObject sarifLog)
{
bool modifiedLog = UpdateSarifLogVersion(sarifLog);

var runs = (JArray)sarifLog["runs"];

if (runs != null)
{
foreach (JObject run in runs)
{
// Delete run.architecture. This data could, arguably, be transferred into the run logical
// identifier or we could drop it into a property bag, but realistically, we don't expect
// sufficient existing utilization of this property to warrant preserving it.

// Remove run.architecture: https://github.com/oasis-tcs/sarif-spec/issues/262
JToken architecture = run[nameof(architecture)];
if (architecture != null)
{
run.Remove(nameof(architecture));
modifiedLog = true;
}
}
}

return modifiedLog;
}

private static bool ApplyCoreTransformations(JObject sarifLog)
{
bool modifiedLog = UpdateSarifLogVersion(sarifLog);
Expand Down
6 changes: 0 additions & 6 deletions src/Sarif/Writers/ResultLogJsonWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ public void Initialize(Run run)
_serializer.Serialize(_jsonWriter, run.AggregateIds);
}

if (!string.IsNullOrEmpty(run.Architecture))
{
_jsonWriter.WritePropertyName("architecture");
_serializer.Serialize(_jsonWriter, run.Architecture);
}

if (run.Tool != null)
{
_jsonWriter.WritePropertyName("tool");
Expand Down
2 changes: 1 addition & 1 deletion src/build.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Product Condition=" '$(Product)' == '' ">Microsoft SARIF SDK</Product>
<Copyright Condition=" '$(Copyright)' == '' ">© Microsoft Corporation. All rights reserved.</Copyright>
<VersionPrefix Condition=" '$(VersionPrefix)' == ''">2.0.0</VersionPrefix>
<VersionSuffix Condition=" '$(VersionSuffix)' == ''">csd.2.beta.2018-10-10</VersionSuffix>
<VersionSuffix Condition=" '$(VersionSuffix)' == ''">csd.2.beta.2018-11-28</VersionSuffix>

<!--
Whenever you increment VersionPrefix or VersionSuffix, copy the old value(s)
Expand Down

0 comments on commit 7536475

Please sign in to comment.