From bab088ed0ea550cb5b9fda4d82b9b852913888c7 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Tue, 18 Dec 2018 14:59:13 -0800 Subject: [PATCH 1/3] Add result.rank. --- src/Sarif/Autogenerated/Result.cs | 18 ++++++++++++++---- .../Autogenerated/ResultEqualityComparer.cs | 6 ++++++ .../ResultEqualityComparer.cs | 6 ++++++ src/Sarif/Schemata/sarif-schema.json | 8 ++++++++ 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/Sarif/Autogenerated/Result.cs b/src/Sarif/Autogenerated/Result.cs index b4bfcdc30..1e2ffc290 100644 --- a/src/Sarif/Autogenerated/Result.cs +++ b/src/Sarif/Autogenerated/Result.cs @@ -138,6 +138,12 @@ public SarifNodeKind SarifNodeKind [JsonConverter(typeof(EnumConverter))] public BaselineState BaselineState { get; set; } + /// + /// A number representing the priority or importance of the result. + /// + [DataMember(Name = "rank", IsRequired = false, EmitDefaultValue = false)] + public double Rank { get; set; } + /// /// A set of files relevant to the result. /// @@ -237,6 +243,9 @@ public Result() /// /// An initialization value for the property. /// + /// + /// An initialization value for the property. + /// /// /// An initialization value for the property. /// @@ -255,9 +264,9 @@ public Result() /// /// An initialization value for the property. /// - public Result(string ruleId, ResultLevel level, Message message, FileLocation analysisTarget, IEnumerable locations, string instanceGuid, string correlationGuid, int occurrenceCount, IDictionary partialFingerprints, IDictionary fingerprints, IEnumerable stacks, IEnumerable codeFlows, IDictionary graphs, IEnumerable graphTraversals, IEnumerable relatedLocations, SuppressionStates suppressionStates, BaselineState baselineState, IEnumerable attachments, Uri hostedViewerUri, IEnumerable workItemUris, IEnumerable conversionProvenance, IEnumerable fixes, IDictionary properties) + public Result(string ruleId, ResultLevel level, Message message, FileLocation analysisTarget, IEnumerable locations, string instanceGuid, string correlationGuid, int occurrenceCount, IDictionary partialFingerprints, IDictionary fingerprints, IEnumerable stacks, IEnumerable codeFlows, IDictionary graphs, IEnumerable graphTraversals, IEnumerable relatedLocations, SuppressionStates suppressionStates, BaselineState baselineState, double rank, IEnumerable attachments, Uri hostedViewerUri, IEnumerable workItemUris, IEnumerable conversionProvenance, IEnumerable fixes, IDictionary properties) { - Init(ruleId, level, message, analysisTarget, locations, instanceGuid, correlationGuid, occurrenceCount, partialFingerprints, fingerprints, stacks, codeFlows, graphs, graphTraversals, relatedLocations, suppressionStates, baselineState, attachments, hostedViewerUri, workItemUris, conversionProvenance, fixes, properties); + Init(ruleId, level, message, analysisTarget, locations, instanceGuid, correlationGuid, occurrenceCount, partialFingerprints, fingerprints, stacks, codeFlows, graphs, graphTraversals, relatedLocations, suppressionStates, baselineState, rank, attachments, hostedViewerUri, workItemUris, conversionProvenance, fixes, properties); } /// @@ -276,7 +285,7 @@ public Result(Result other) throw new ArgumentNullException(nameof(other)); } - Init(other.RuleId, other.Level, other.Message, other.AnalysisTarget, other.Locations, other.InstanceGuid, other.CorrelationGuid, other.OccurrenceCount, other.PartialFingerprints, other.Fingerprints, other.Stacks, other.CodeFlows, other.Graphs, other.GraphTraversals, other.RelatedLocations, other.SuppressionStates, other.BaselineState, other.Attachments, other.HostedViewerUri, other.WorkItemUris, other.ConversionProvenance, other.Fixes, other.Properties); + Init(other.RuleId, other.Level, other.Message, other.AnalysisTarget, other.Locations, other.InstanceGuid, other.CorrelationGuid, other.OccurrenceCount, other.PartialFingerprints, other.Fingerprints, other.Stacks, other.CodeFlows, other.Graphs, other.GraphTraversals, other.RelatedLocations, other.SuppressionStates, other.BaselineState, other.Rank, other.Attachments, other.HostedViewerUri, other.WorkItemUris, other.ConversionProvenance, other.Fixes, other.Properties); } ISarifNode ISarifNode.DeepClone() @@ -297,7 +306,7 @@ private ISarifNode DeepCloneCore() return new Result(this); } - private void Init(string ruleId, ResultLevel level, Message message, FileLocation analysisTarget, IEnumerable locations, string instanceGuid, string correlationGuid, int occurrenceCount, IDictionary partialFingerprints, IDictionary fingerprints, IEnumerable stacks, IEnumerable codeFlows, IDictionary graphs, IEnumerable graphTraversals, IEnumerable relatedLocations, SuppressionStates suppressionStates, BaselineState baselineState, IEnumerable attachments, Uri hostedViewerUri, IEnumerable workItemUris, IEnumerable conversionProvenance, IEnumerable fixes, IDictionary properties) + private void Init(string ruleId, ResultLevel level, Message message, FileLocation analysisTarget, IEnumerable locations, string instanceGuid, string correlationGuid, int occurrenceCount, IDictionary partialFingerprints, IDictionary fingerprints, IEnumerable stacks, IEnumerable codeFlows, IDictionary graphs, IEnumerable graphTraversals, IEnumerable relatedLocations, SuppressionStates suppressionStates, BaselineState baselineState, double rank, IEnumerable attachments, Uri hostedViewerUri, IEnumerable workItemUris, IEnumerable conversionProvenance, IEnumerable fixes, IDictionary properties) { RuleId = ruleId; Level = level; @@ -425,6 +434,7 @@ private void Init(string ruleId, ResultLevel level, Message message, FileLocatio SuppressionStates = suppressionStates; BaselineState = baselineState; + Rank = rank; if (attachments != null) { var destination_5 = new List(); diff --git a/src/Sarif/Autogenerated/ResultEqualityComparer.cs b/src/Sarif/Autogenerated/ResultEqualityComparer.cs index e0dc1d684..73d3b7a08 100644 --- a/src/Sarif/Autogenerated/ResultEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ResultEqualityComparer.cs @@ -252,6 +252,11 @@ public bool Equals(Result left, Result right) return false; } + if (left.Rank != right.Rank) + { + return false; + } + if (!object.ReferenceEquals(left.Attachments, right.Attachments)) { if (left.Attachments == null || right.Attachments == null) @@ -520,6 +525,7 @@ public int GetHashCode(Result obj) result = (result * 31) + obj.SuppressionStates.GetHashCode(); result = (result * 31) + obj.BaselineState.GetHashCode(); + result = (result * 31) + obj.Rank.GetHashCode(); if (obj.Attachments != null) { foreach (var value_16 in obj.Attachments) diff --git a/src/Sarif/NotYetAutoGenerated/ResultEqualityComparer.cs b/src/Sarif/NotYetAutoGenerated/ResultEqualityComparer.cs index e0dc1d684..73d3b7a08 100644 --- a/src/Sarif/NotYetAutoGenerated/ResultEqualityComparer.cs +++ b/src/Sarif/NotYetAutoGenerated/ResultEqualityComparer.cs @@ -252,6 +252,11 @@ public bool Equals(Result left, Result right) return false; } + if (left.Rank != right.Rank) + { + return false; + } + if (!object.ReferenceEquals(left.Attachments, right.Attachments)) { if (left.Attachments == null || right.Attachments == null) @@ -520,6 +525,7 @@ public int GetHashCode(Result obj) result = (result * 31) + obj.SuppressionStates.GetHashCode(); result = (result * 31) + obj.BaselineState.GetHashCode(); + result = (result * 31) + obj.Rank.GetHashCode(); if (obj.Attachments != null) { foreach (var value_16 in obj.Attachments) diff --git a/src/Sarif/Schemata/sarif-schema.json b/src/Sarif/Schemata/sarif-schema.json index 736b995d8..9276e3f7c 100644 --- a/src/Sarif/Schemata/sarif-schema.json +++ b/src/Sarif/Schemata/sarif-schema.json @@ -1306,6 +1306,14 @@ ] }, + "rank": { + "description": "A number representing the priority or importance of the result.", + "type":"number", + "minimum": 0.0, + "maximum": 100.0, + "default": 0.0 + }, + "attachments": { "description": "A set of files relevant to the result.", "type": "array", From 857f0f29ca0a590dba801d750f63a9782fa33e37 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Tue, 18 Dec 2018 15:08:34 -0800 Subject: [PATCH 2/3] Add ruleConfiguration.defaultRank. --- src/Sarif/Autogenerated/RuleConfiguration.cs | 18 ++++++++++++++---- .../RuleConfigurationEqualityComparer.cs | 6 ++++++ src/Sarif/Schemata/sarif-schema.json | 11 +++++++++-- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/Sarif/Autogenerated/RuleConfiguration.cs b/src/Sarif/Autogenerated/RuleConfiguration.cs index 1a84b4c7f..d1a3ecc4b 100644 --- a/src/Sarif/Autogenerated/RuleConfiguration.cs +++ b/src/Sarif/Autogenerated/RuleConfiguration.cs @@ -46,6 +46,12 @@ public SarifNodeKind SarifNodeKind [JsonConverter(typeof(EnumConverter))] public RuleConfigurationDefaultLevel DefaultLevel { get; set; } + /// + /// Specifies the default priority or importance of the result. + /// + [DataMember(Name = "defaultRank", IsRequired = false, EmitDefaultValue = false)] + public double DefaultRank { get; set; } + /// /// Contains configuration information specific to this rule. /// @@ -74,15 +80,18 @@ public RuleConfiguration() /// /// An initialization value for the property. /// + /// + /// An initialization value for the property. + /// /// /// An initialization value for the property. /// /// /// An initialization value for the property. /// - public RuleConfiguration(bool enabled, RuleConfigurationDefaultLevel defaultLevel, IDictionary parameters, IDictionary properties) + public RuleConfiguration(bool enabled, RuleConfigurationDefaultLevel defaultLevel, double defaultRank, IDictionary parameters, IDictionary properties) { - Init(enabled, defaultLevel, parameters, properties); + Init(enabled, defaultLevel, defaultRank, parameters, properties); } /// @@ -101,7 +110,7 @@ public RuleConfiguration(RuleConfiguration other) throw new ArgumentNullException(nameof(other)); } - Init(other.Enabled, other.DefaultLevel, other.Parameters, other.Properties); + Init(other.Enabled, other.DefaultLevel, other.DefaultRank, other.Parameters, other.Properties); } ISarifNode ISarifNode.DeepClone() @@ -122,10 +131,11 @@ private ISarifNode DeepCloneCore() return new RuleConfiguration(this); } - private void Init(bool enabled, RuleConfigurationDefaultLevel defaultLevel, IDictionary parameters, IDictionary properties) + private void Init(bool enabled, RuleConfigurationDefaultLevel defaultLevel, double defaultRank, IDictionary parameters, IDictionary properties) { Enabled = enabled; DefaultLevel = defaultLevel; + DefaultRank = defaultRank; if (parameters != null) { Parameters = new Dictionary(parameters); diff --git a/src/Sarif/Autogenerated/RuleConfigurationEqualityComparer.cs b/src/Sarif/Autogenerated/RuleConfigurationEqualityComparer.cs index d275424f4..e1a4b02a1 100644 --- a/src/Sarif/Autogenerated/RuleConfigurationEqualityComparer.cs +++ b/src/Sarif/Autogenerated/RuleConfigurationEqualityComparer.cs @@ -38,6 +38,11 @@ public bool Equals(RuleConfiguration left, RuleConfiguration right) return false; } + if (left.DefaultRank != right.DefaultRank) + { + return false; + } + if (!object.ReferenceEquals(left.Parameters, right.Parameters)) { if (left.Parameters == null || right.Parameters == null || left.Parameters.Count != right.Parameters.Count) @@ -97,6 +102,7 @@ public int GetHashCode(RuleConfiguration obj) { result = (result * 31) + obj.Enabled.GetHashCode(); result = (result * 31) + obj.DefaultLevel.GetHashCode(); + result = (result * 31) + obj.DefaultRank.GetHashCode(); if (obj.Parameters != null) { // Use xor for dictionaries to be order-independent. diff --git a/src/Sarif/Schemata/sarif-schema.json b/src/Sarif/Schemata/sarif-schema.json index 9276e3f7c..2365c9e9a 100644 --- a/src/Sarif/Schemata/sarif-schema.json +++ b/src/Sarif/Schemata/sarif-schema.json @@ -1310,8 +1310,7 @@ "description": "A number representing the priority or importance of the result.", "type":"number", "minimum": 0.0, - "maximum": 100.0, - "default": 0.0 + "maximum": 100.0 }, "attachments": { @@ -1451,6 +1450,14 @@ "enum": [ "note", "warning", "error" ] }, + "defaultRank": { + "description": "Specifies the default priority or importance of the result.", + "type":"number", + "minimum": 0.0, + "maximum": 100.0, + "default": 0.0 + }, + "parameters": { "description": "Contains configuration information specific to this rule.", "$ref": "#/definitions/propertyBag" From 2b4a85049b2761448f55e01babaaf75d6e0b3467 Mon Sep 17 00:00:00 2001 From: Larry Golding Date: Tue, 18 Dec 2018 16:31:23 -0800 Subject: [PATCH 3/3] Improve comments for ruleConfiguration.default{Level,Rank} --- src/Sarif/Schemata/sarif-schema.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Sarif/Schemata/sarif-schema.json b/src/Sarif/Schemata/sarif-schema.json index 2365c9e9a..725697dd5 100644 --- a/src/Sarif/Schemata/sarif-schema.json +++ b/src/Sarif/Schemata/sarif-schema.json @@ -1445,13 +1445,13 @@ }, "defaultLevel": { - "description": "Specifies the default severity level of the result.", + "description": "Specifies the default severity level for results generated by this rule.", "default": "warning", "enum": [ "note", "warning", "error" ] }, "defaultRank": { - "description": "Specifies the default priority or importance of the result.", + "description": "Specifies the default priority or importance for results generated by this rule.", "type":"number", "minimum": 0.0, "maximum": 100.0,