From f6a32c6860710ce44eddb98acef2273e05615620 Mon Sep 17 00:00:00 2001 From: Chris Meyer Date: Tue, 27 Feb 2024 15:23:56 -1000 Subject: [PATCH 01/19] Fix MessageResourceNames merging (#2793) * Update for release 4.5.2 * Update package links * Update MessageResourceNames architecture + misc. fixes --- ReleaseHistory.md | 3 +++ .../Rules/ADO1011.ReferenceFinalSchema.cs | 5 +++++ .../ADO1013.ProvideRequiredSarifLogProperties.cs | 5 +++++ .../Rules/ADO1014.ProvideRequiredRunProperties.cs | 11 +++++++++-- .../ADO1015.ProvideRequiredResultProperties.cs | 9 ++++++++- .../ADO1016.ProvideRequiredLocationProperties.cs | 10 +++++++++- ...7.ProvideRequiredPhysicalLocationProperties.cs | 5 +++++ .../ADO1018.ProvideRequiredToolProperties.cs | 11 +++++++++-- ...rovideRequiredReportingDescriptorProperties.cs | 9 ++++++++- .../Rules/Base1011.ReferenceFinalSchema.cs | 4 ++-- .../Base1013.ProvideRequiredSarifLogProperties.cs | 4 +++- .../Base1014.ProvideRequiredRunProperties.cs | 4 ++-- .../Base1015.ProvideRequiredResultProperties.cs | 5 ++--- .../Base1016.ProvideRequiredLocationProperties.cs | 4 ++-- ...7.ProvideRequiredPhysicalLocationProperties.cs | 4 ++-- .../Base1018.ProvideRequiredToolProperties.cs | 4 ++-- ...rovideRequiredReportingDescriptorProperties.cs | 4 ++-- .../Rules/GH1011.ReferenceFinalSchema.cs | 5 +++++ .../GH1013.ProvideRequiredSarifLogProperties.cs | 5 +++++ .../Rules/GH1014.ProvideRequiredRunProperties.cs | 5 +++++ .../GH1015.ProvideRequiredResultProperties.cs | 5 +++++ .../GH1016.ProvideRequiredLocationProperties.cs | 11 ++++++++--- ...7.ProvideRequiredPhysicalLocationProperties.cs | 7 ++++++- .../Rules/GH1018.ProvideRequiredToolProperties.cs | 5 +++++ ...rovideRequiredReportingDescriptorProperties.cs | 15 +++++++++++---- src/build.props | 4 ++-- 26 files changed, 130 insertions(+), 33 deletions(-) diff --git a/ReleaseHistory.md b/ReleaseHistory.md index d74093f29..1ea303003 100644 --- a/ReleaseHistory.md +++ b/ReleaseHistory.md @@ -1,4 +1,7 @@ # SARIF Package Release History (SDK, Driver, Converters, and Multitool) +## **v4.5.3 [Sdk](https://www.nuget.org/packages/Sarif.Sdk/v4.5.3) | [Driver](https://www.nuget.org/packages/Sarif.Driver/v4.5.3) | [Converters](https://www.nuget.org/packages/Sarif.Converters/v4.5.3) | [Multitool](https://www.nuget.org/packages/Sarif.Multitool/v4.5.3) | [Multitool Library](https://www.nuget.org/packages/Sarif.Multitool.Library/v4.5.3) +* BUG: Restructure shared MessageResourceNames collections to ensure return of correct error messages. + ## **v4.5.2 [Sdk](https://www.nuget.org/packages/Sarif.Sdk/v4.5.2) | [Driver](https://www.nuget.org/packages/Sarif.Driver/v4.5.2) | [Converters](https://www.nuget.org/packages/Sarif.Converters/v4.5.2) | [Multitool](https://www.nuget.org/packages/Sarif.Multitool/v4.5.2) | [Multitool Library](https://www.nuget.org/packages/Sarif.Multitool.Library/v4.5.2) * BUG: Update Skimmer stack in Multitool.Library to support shared MessageResourceNames collections between base rules and their derivatives. * BUG: Fix message strings to always assume {1} is reserved for the rule's service name. diff --git a/src/Sarif.Multitool.Library/Rules/ADO1011.ReferenceFinalSchema.cs b/src/Sarif.Multitool.Library/Rules/ADO1011.ReferenceFinalSchema.cs index 6c47baa00..1233ea597 100644 --- a/src/Sarif.Multitool.Library/Rules/ADO1011.ReferenceFinalSchema.cs +++ b/src/Sarif.Multitool.Library/Rules/ADO1011.ReferenceFinalSchema.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; +using System.Linq; namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules { @@ -15,6 +16,10 @@ public class AdoReferenceFinalSchema public override MultiformatMessageString FullDescription => new MultiformatMessageString() { Text = RuleResources.ADO1011_ReferenceFinalSchema_FullDescription_Text }; + private readonly List _messageResourceNames = new List(); + + protected override ICollection MessageResourceNames => _messageResourceNames.Concat(BaseMessageResourceNames).ToList(); + public override HashSet RuleKinds => new HashSet(new[] { RuleKind.Ado }); protected override string ServiceName => RuleResources.ServiceName_ADO; diff --git a/src/Sarif.Multitool.Library/Rules/ADO1013.ProvideRequiredSarifLogProperties.cs b/src/Sarif.Multitool.Library/Rules/ADO1013.ProvideRequiredSarifLogProperties.cs index 7a3ec0f61..f89ff356b 100644 --- a/src/Sarif.Multitool.Library/Rules/ADO1013.ProvideRequiredSarifLogProperties.cs +++ b/src/Sarif.Multitool.Library/Rules/ADO1013.ProvideRequiredSarifLogProperties.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; +using System.Linq; namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules { @@ -15,6 +16,10 @@ public class AdoProvideRequiredSarifLogProperties public override MultiformatMessageString FullDescription => new MultiformatMessageString() { Text = RuleResources.ADO1013_ProvideRequiredSarifLogProperties_FullDescription_Text }; + private readonly List _messageResourceNames = new List(); + + protected override ICollection MessageResourceNames => _messageResourceNames.Concat(BaseMessageResourceNames).ToList(); + public override HashSet RuleKinds => new HashSet(new[] { RuleKind.Ado }); protected override string ServiceName => RuleResources.ServiceName_ADO; diff --git a/src/Sarif.Multitool.Library/Rules/ADO1014.ProvideRequiredRunProperties.cs b/src/Sarif.Multitool.Library/Rules/ADO1014.ProvideRequiredRunProperties.cs index bd4f1cfad..163711dc1 100644 --- a/src/Sarif.Multitool.Library/Rules/ADO1014.ProvideRequiredRunProperties.cs +++ b/src/Sarif.Multitool.Library/Rules/ADO1014.ProvideRequiredRunProperties.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; +using System.Linq; namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules { @@ -15,6 +16,14 @@ public class AdoProvideRequiredRunProperties public override MultiformatMessageString FullDescription => new MultiformatMessageString() { Text = RuleResources.ADO1014_ProvideRequiredRunProperties_FullDescription_Text }; + private readonly List _messageResourceNames = new List() + { + nameof(RuleResources.ADO1014_AdoProvideRequiredRunProperties_Error_MissingAutomationDetails_Text), + nameof(RuleResources.ADO1014_AdoProvideRequiredRunProperties_Error_MissingAutomationDetailsId_Text) + }; + + protected override ICollection MessageResourceNames => _messageResourceNames.Concat(BaseMessageResourceNames).ToList(); + public override HashSet RuleKinds => new HashSet(new[] { RuleKind.Ado }); protected override string ServiceName => RuleResources.ServiceName_ADO; @@ -22,8 +31,6 @@ public class AdoProvideRequiredRunProperties public AdoProvideRequiredRunProperties() { this.DefaultConfiguration.Level = FailureLevel.Error; - this.MessageResourceNames.Add(nameof(RuleResources.ADO1014_AdoProvideRequiredRunProperties_Error_MissingAutomationDetails_Text)); - this.MessageResourceNames.Add(nameof(RuleResources.ADO1014_AdoProvideRequiredRunProperties_Error_MissingAutomationDetailsId_Text)); } protected override void Analyze(Run run, string runPointer) diff --git a/src/Sarif.Multitool.Library/Rules/ADO1015.ProvideRequiredResultProperties.cs b/src/Sarif.Multitool.Library/Rules/ADO1015.ProvideRequiredResultProperties.cs index 60224f488..4a69eb901 100644 --- a/src/Sarif.Multitool.Library/Rules/ADO1015.ProvideRequiredResultProperties.cs +++ b/src/Sarif.Multitool.Library/Rules/ADO1015.ProvideRequiredResultProperties.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; +using System.Linq; namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules { @@ -15,6 +16,13 @@ public class AdoProvideRequiredResultProperties public override MultiformatMessageString FullDescription => new MultiformatMessageString() { Text = RuleResources.ADO1015_ProvideRequiredResultProperties_FullDescription_Text }; + private readonly List _messageResourceNames = new List() + { + nameof(RuleResources.ADO1015_ProvideRequiredResultProperties_Error_MissingRuleId_Text) + }; + + protected override ICollection MessageResourceNames => _messageResourceNames.Concat(BaseMessageResourceNames).ToList(); + public override HashSet RuleKinds => new(new[] { RuleKind.Ado }); protected override string ServiceName => RuleResources.ServiceName_ADO; @@ -22,7 +30,6 @@ public class AdoProvideRequiredResultProperties public AdoProvideRequiredResultProperties() { this.DefaultConfiguration.Level = FailureLevel.Error; - this.MessageResourceNames.Add(nameof(RuleResources.ADO1015_ProvideRequiredResultProperties_Error_MissingRuleId_Text)); } protected override void Analyze(Result result, string resultPointer) diff --git a/src/Sarif.Multitool.Library/Rules/ADO1016.ProvideRequiredLocationProperties.cs b/src/Sarif.Multitool.Library/Rules/ADO1016.ProvideRequiredLocationProperties.cs index 25ebd4f1d..44f18af7e 100644 --- a/src/Sarif.Multitool.Library/Rules/ADO1016.ProvideRequiredLocationProperties.cs +++ b/src/Sarif.Multitool.Library/Rules/ADO1016.ProvideRequiredLocationProperties.cs @@ -2,16 +2,24 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; +using System.Linq; namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules { public class AdoProvideRequiredLocationProperties - : SarifValidationSkimmerBase + : BaseProvideRequiredLocationProperties { + /// + /// ADO1016 + /// public override string Id => RuleId.ADOProvideRequiredLocationProperties; public override MultiformatMessageString FullDescription => new MultiformatMessageString() { Text = RuleResources.ADO1016_ProvideRequiredLocationProperties_FullDescription_Text }; + private readonly List _messageResourceNames = new List(); + + protected override ICollection MessageResourceNames => _messageResourceNames.Concat(BaseMessageResourceNames).ToList(); + public override HashSet RuleKinds => new HashSet(new[] { RuleKind.Ado }); public AdoProvideRequiredLocationProperties() diff --git a/src/Sarif.Multitool.Library/Rules/ADO1017.ProvideRequiredPhysicalLocationProperties.cs b/src/Sarif.Multitool.Library/Rules/ADO1017.ProvideRequiredPhysicalLocationProperties.cs index fdff6f78e..5dd9e0242 100644 --- a/src/Sarif.Multitool.Library/Rules/ADO1017.ProvideRequiredPhysicalLocationProperties.cs +++ b/src/Sarif.Multitool.Library/Rules/ADO1017.ProvideRequiredPhysicalLocationProperties.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; +using System.Linq; namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules { @@ -15,6 +16,10 @@ public class AdoProvideRequiredPhysicalLocationProperties public override MultiformatMessageString FullDescription => new MultiformatMessageString() { Text = RuleResources.ADO1017_ProvideRequiredPhysicalLocationProperties_FullDescription_Text }; + private readonly List _messageResourceNames = new List(); + + protected override ICollection MessageResourceNames => _messageResourceNames.Concat(BaseMessageResourceNames).ToList(); + public override HashSet RuleKinds => new HashSet(new[] { RuleKind.Ado }); protected override string ServiceName => RuleResources.ServiceName_ADO; diff --git a/src/Sarif.Multitool.Library/Rules/ADO1018.ProvideRequiredToolProperties.cs b/src/Sarif.Multitool.Library/Rules/ADO1018.ProvideRequiredToolProperties.cs index 25e606681..d8f1794c2 100644 --- a/src/Sarif.Multitool.Library/Rules/ADO1018.ProvideRequiredToolProperties.cs +++ b/src/Sarif.Multitool.Library/Rules/ADO1018.ProvideRequiredToolProperties.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; +using System.Linq; using Microsoft.Json.Pointer; @@ -11,12 +12,19 @@ public class AdoProvideRequiredToolProperties : BaseProvideRequiredToolProperties { /// - /// ADO1003 + /// ADO1018 /// public override string Id => RuleId.ADOProvideToolDriverProperties; public override MultiformatMessageString FullDescription => new MultiformatMessageString() { Text = RuleResources.ADO1018_ProvideRequiredToolProperties_FullDescription_Text }; + private readonly List _messageResourceNames = new List() + { + nameof(RuleResources.ADO1018_ProvideRequiredToolProperties_Error_MissingDriverFullName_Text) + }; + + protected override ICollection MessageResourceNames => _messageResourceNames.Concat(BaseMessageResourceNames).ToList(); + public override HashSet RuleKinds => new HashSet(new[] { RuleKind.Ado }); protected override string ServiceName => RuleResources.ServiceName_ADO; @@ -24,7 +32,6 @@ public class AdoProvideRequiredToolProperties public AdoProvideRequiredToolProperties() { this.DefaultConfiguration.Level = FailureLevel.Error; - this.MessageResourceNames.Add(nameof(RuleResources.ADO1018_ProvideRequiredToolProperties_Error_MissingDriverFullName_Text)); } protected override void Analyze(Run run, string runPointer) diff --git a/src/Sarif.Multitool.Library/Rules/ADO2012.ProvideRequiredReportingDescriptorProperties.cs b/src/Sarif.Multitool.Library/Rules/ADO2012.ProvideRequiredReportingDescriptorProperties.cs index 1de420512..604523339 100644 --- a/src/Sarif.Multitool.Library/Rules/ADO2012.ProvideRequiredReportingDescriptorProperties.cs +++ b/src/Sarif.Multitool.Library/Rules/ADO2012.ProvideRequiredReportingDescriptorProperties.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; +using System.Linq; namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules { @@ -15,6 +16,13 @@ public class AdoProvideRequiredReportingDescriptorProperties public override MultiformatMessageString FullDescription => new MultiformatMessageString { Text = RuleResources.ADO2012_ProvideRequiredReportingDescriptorProperties_FullDescription_Text }; + private readonly List _messageResourceNames = new List() + { + nameof(RuleResources.ADO2012_ProvideRequiredResultProperties_Error_MissingName_Text) + }; + + protected override ICollection MessageResourceNames => _messageResourceNames.Concat(BaseMessageResourceNames).ToList(); + public override HashSet RuleKinds => new HashSet(new[] { RuleKind.Ado }); protected override string ServiceName => RuleResources.ServiceName_ADO; @@ -22,7 +30,6 @@ public class AdoProvideRequiredReportingDescriptorProperties public AdoProvideRequiredReportingDescriptorProperties() { this.DefaultConfiguration.Level = FailureLevel.Error; - this.MessageResourceNames.Add(nameof(RuleResources.ADO2012_ProvideRequiredResultProperties_Error_MissingName_Text)); } protected override void Analyze(ReportingDescriptor reportingDescriptor, string reportingDescriptorPointer) diff --git a/src/Sarif.Multitool.Library/Rules/Base1011.ReferenceFinalSchema.cs b/src/Sarif.Multitool.Library/Rules/Base1011.ReferenceFinalSchema.cs index 3b154bc2f..b00cd019b 100644 --- a/src/Sarif.Multitool.Library/Rules/Base1011.ReferenceFinalSchema.cs +++ b/src/Sarif.Multitool.Library/Rules/Base1011.ReferenceFinalSchema.cs @@ -24,12 +24,12 @@ public class BaseReferenceFinalSchema : SarifValidationSkimmerBase /// public override MultiformatMessageString FullDescription => new MultiformatMessageString(); - private readonly List _messageResourceNames = new List + private readonly List _baseMessageResourceNames = new List { nameof(RuleResources.Base1011_ReferenceFinalSchema_Error_Default_Text) }; - protected override ICollection MessageResourceNames => _messageResourceNames; + protected ICollection BaseMessageResourceNames => _baseMessageResourceNames; protected override void Analyze(SarifLog log, string logPointer) { diff --git a/src/Sarif.Multitool.Library/Rules/Base1013.ProvideRequiredSarifLogProperties.cs b/src/Sarif.Multitool.Library/Rules/Base1013.ProvideRequiredSarifLogProperties.cs index db33c7df7..dec8ca525 100644 --- a/src/Sarif.Multitool.Library/Rules/Base1013.ProvideRequiredSarifLogProperties.cs +++ b/src/Sarif.Multitool.Library/Rules/Base1013.ProvideRequiredSarifLogProperties.cs @@ -14,13 +14,15 @@ public class BaseProvideRequiredSarifLogProperties public override MultiformatMessageString FullDescription => new MultiformatMessageString(); - protected override ICollection MessageResourceNames => new List { + private readonly List _baseMessageResourceNames = new List + { nameof(RuleResources.Base1013_MaximumRunsCount_Note_Default_Text), nameof(RuleResources.Base1013_ProvideSchemaVersion_Warning_Default_Text), nameof(RuleResources.Base1013_ProvideSchema_Warning_Default_Text), nameof(RuleResources.Base1013_ReferenceFinalSchema_Error_Default_Text), nameof(RuleResources.Base1013_SarifLogRunsArray_Note_Default_Text) }; + protected ICollection BaseMessageResourceNames => _baseMessageResourceNames; public virtual int MaximumRuns { get; set; } = int.MaxValue; diff --git a/src/Sarif.Multitool.Library/Rules/Base1014.ProvideRequiredRunProperties.cs b/src/Sarif.Multitool.Library/Rules/Base1014.ProvideRequiredRunProperties.cs index 1816f092a..b74b3f51a 100644 --- a/src/Sarif.Multitool.Library/Rules/Base1014.ProvideRequiredRunProperties.cs +++ b/src/Sarif.Multitool.Library/Rules/Base1014.ProvideRequiredRunProperties.cs @@ -10,13 +10,13 @@ public class BaseProvideRequiredRunProperties { public override string Id => string.Empty; - private readonly List _messageResourceNames = new List + private readonly List _baseMessageResourceNames = new List { nameof(RuleResources.Base1014_ProvideRequiredRunProperties_Error_MissingResultsArray_Text), nameof(RuleResources.Base1014_ProvideRequiredRunProperties_Error_MissingTool_Text) }; - protected override ICollection MessageResourceNames => _messageResourceNames; + protected ICollection BaseMessageResourceNames => _baseMessageResourceNames; public override HashSet RuleKinds => new HashSet(); diff --git a/src/Sarif.Multitool.Library/Rules/Base1015.ProvideRequiredResultProperties.cs b/src/Sarif.Multitool.Library/Rules/Base1015.ProvideRequiredResultProperties.cs index d6ddb00aa..7df7c8fe6 100644 --- a/src/Sarif.Multitool.Library/Rules/Base1015.ProvideRequiredResultProperties.cs +++ b/src/Sarif.Multitool.Library/Rules/Base1015.ProvideRequiredResultProperties.cs @@ -12,8 +12,7 @@ public class BaseProvideRequiredResultProperties { public override string Id => string.Empty; - - private readonly List _messageResourceNames = new List + private readonly List _baseMessageResourceNames = new List { nameof(RuleResources.Base1015_ProvideRequiredResultProperties_Error_EmptyLocationsArray_Text), nameof(RuleResources.Base1015_ProvideRequiredResultProperties_Error_MissingLocationsArray_Text), @@ -22,7 +21,7 @@ public class BaseProvideRequiredResultProperties nameof(RuleResources.Base1015_ProvideRequiredResultProperties_Error_MissingPartialFingerprints_Text) }; - protected override ICollection MessageResourceNames => _messageResourceNames; + protected ICollection BaseMessageResourceNames => _baseMessageResourceNames; public override HashSet RuleKinds => new HashSet(); diff --git a/src/Sarif.Multitool.Library/Rules/Base1016.ProvideRequiredLocationProperties.cs b/src/Sarif.Multitool.Library/Rules/Base1016.ProvideRequiredLocationProperties.cs index 4e840715c..9cd14a5e8 100644 --- a/src/Sarif.Multitool.Library/Rules/Base1016.ProvideRequiredLocationProperties.cs +++ b/src/Sarif.Multitool.Library/Rules/Base1016.ProvideRequiredLocationProperties.cs @@ -10,12 +10,12 @@ public class BaseProvideRequiredLocationProperties { public override string Id => string.Empty; - private readonly List _messageResourceNames = new List + private readonly List _baseMessageResourceNames = new List { nameof(RuleResources.Base1016_ProvideRequiredLocationProperties_Error_MissingPhysicalLocation_Text) }; - protected override ICollection MessageResourceNames => _messageResourceNames; + protected ICollection BaseMessageResourceNames => _baseMessageResourceNames; public override HashSet RuleKinds => new HashSet(); diff --git a/src/Sarif.Multitool.Library/Rules/Base1017.ProvideRequiredPhysicalLocationProperties.cs b/src/Sarif.Multitool.Library/Rules/Base1017.ProvideRequiredPhysicalLocationProperties.cs index b544c9673..c4c8479b0 100644 --- a/src/Sarif.Multitool.Library/Rules/Base1017.ProvideRequiredPhysicalLocationProperties.cs +++ b/src/Sarif.Multitool.Library/Rules/Base1017.ProvideRequiredPhysicalLocationProperties.cs @@ -14,7 +14,7 @@ public class BaseProvideRequiredPhysicalLocationProperties { public override string Id => string.Empty; - private readonly List _messageResourceNames = new List + private readonly List _baseMessageResourceNames = new List { nameof(RuleResources.Base1017_ProvideRequiredPhysicalLocationProperties_Error_MissingArtifactLocation_Text), nameof(RuleResources.Base1017_ProvideRequiredPhysicalLocationProperties_Error_MissingRegion_Text), @@ -23,7 +23,7 @@ public class BaseProvideRequiredPhysicalLocationProperties nameof(RuleResources.SARIF1007_RegionPropertiesMustBeConsistent_Error_RegionStartPropertyMustBePresent_Text) }; - protected override ICollection MessageResourceNames => _messageResourceNames; + private ICollection BaseMessageResourceNames => _baseMessageResourceNames; public override HashSet RuleKinds => new HashSet(); diff --git a/src/Sarif.Multitool.Library/Rules/Base1018.ProvideRequiredToolProperties.cs b/src/Sarif.Multitool.Library/Rules/Base1018.ProvideRequiredToolProperties.cs index c35274d38..5db25fb9e 100644 --- a/src/Sarif.Multitool.Library/Rules/Base1018.ProvideRequiredToolProperties.cs +++ b/src/Sarif.Multitool.Library/Rules/Base1018.ProvideRequiredToolProperties.cs @@ -12,14 +12,14 @@ public class BaseProvideRequiredToolProperties { public override string Id => string.Empty; - private readonly List _messageResourceNames = new List + private readonly List _baseMessageResourceNames = new List { nameof(RuleResources.Base1018_ProvideRequiredToolProperties_Error_MissingDriverName_Text), nameof(RuleResources.Base1018_ProvideRequiredToolProperties_Error_MissingDriverRules_Text), nameof(RuleResources.Base1018_ProvideRequiredToolProperties_Error_MissingDriver_Text), }; - protected override ICollection MessageResourceNames => _messageResourceNames; + protected ICollection BaseMessageResourceNames => _baseMessageResourceNames; public override HashSet RuleKinds => new HashSet(); diff --git a/src/Sarif.Multitool.Library/Rules/Base2012.ProvideRequiredReportingDescriptorProperties.cs b/src/Sarif.Multitool.Library/Rules/Base2012.ProvideRequiredReportingDescriptorProperties.cs index 1cb4dbd91..873b2eef0 100644 --- a/src/Sarif.Multitool.Library/Rules/Base2012.ProvideRequiredReportingDescriptorProperties.cs +++ b/src/Sarif.Multitool.Library/Rules/Base2012.ProvideRequiredReportingDescriptorProperties.cs @@ -10,12 +10,12 @@ public class Base2012ProvideRequiredReportingDescriptorProperties { public override string Id => string.Empty; - private readonly List _messageResourceNames = new List + private readonly List _baseMessageResourceNames = new List { nameof(RuleResources.Base2012_ProvideRequiredReportingDescriptorProperties_Error_MissingIdProperty_Text) }; - protected override ICollection MessageResourceNames => _messageResourceNames; + private ICollection BaseMessageResourceNames => _baseMessageResourceNames; public override HashSet RuleKinds => new HashSet(); diff --git a/src/Sarif.Multitool.Library/Rules/GH1011.ReferenceFinalSchema.cs b/src/Sarif.Multitool.Library/Rules/GH1011.ReferenceFinalSchema.cs index 57e2ec5ea..0d16de115 100644 --- a/src/Sarif.Multitool.Library/Rules/GH1011.ReferenceFinalSchema.cs +++ b/src/Sarif.Multitool.Library/Rules/GH1011.ReferenceFinalSchema.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; +using System.Linq; namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules { @@ -15,6 +16,10 @@ public class GhasReferenceFinalSchema public override MultiformatMessageString FullDescription => new MultiformatMessageString() { Text = RuleResources.GH1011_ReferenceFinalSchema }; + private readonly List _messageResourceNames = new List(); + + protected override ICollection MessageResourceNames => _messageResourceNames.Concat(BaseMessageResourceNames).ToList(); + public override HashSet RuleKinds => new HashSet(new[] { RuleKind.Ghas }); protected override string ServiceName => RuleResources.ServiceName_GHAS; diff --git a/src/Sarif.Multitool.Library/Rules/GH1013.ProvideRequiredSarifLogProperties.cs b/src/Sarif.Multitool.Library/Rules/GH1013.ProvideRequiredSarifLogProperties.cs index 9037a9ba6..9fc15dba4 100644 --- a/src/Sarif.Multitool.Library/Rules/GH1013.ProvideRequiredSarifLogProperties.cs +++ b/src/Sarif.Multitool.Library/Rules/GH1013.ProvideRequiredSarifLogProperties.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; +using System.Linq; namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules { @@ -15,6 +16,10 @@ public class GhProvideRequiredSarifLogProperties public override MultiformatMessageString FullDescription => new MultiformatMessageString() { Text = RuleResources.GH1013_ProvideRequiredSarifLogProperties_FullDescription_Text }; + private readonly List _messageResourceNames = new List(); + + protected override ICollection MessageResourceNames => _messageResourceNames.Concat(BaseMessageResourceNames).ToList(); + public override HashSet RuleKinds => new HashSet(new[] { RuleKind.Ghas }); protected override string ServiceName => RuleResources.ServiceName_GHAS; diff --git a/src/Sarif.Multitool.Library/Rules/GH1014.ProvideRequiredRunProperties.cs b/src/Sarif.Multitool.Library/Rules/GH1014.ProvideRequiredRunProperties.cs index 6934bff99..2563009a8 100644 --- a/src/Sarif.Multitool.Library/Rules/GH1014.ProvideRequiredRunProperties.cs +++ b/src/Sarif.Multitool.Library/Rules/GH1014.ProvideRequiredRunProperties.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; +using System.Linq; namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules { @@ -15,6 +16,10 @@ public class GhasProvideRequiredRunProperties public override MultiformatMessageString FullDescription => new MultiformatMessageString() { Text = RuleResources.GH1014_ProvideRequiredRunProperties_FullDescription_Text }; + private readonly List _messageResourceNames = new List(); + + protected override ICollection MessageResourceNames => _messageResourceNames.Concat(BaseMessageResourceNames).ToList(); + public override HashSet RuleKinds => new HashSet(new[] { RuleKind.Ghas }); protected override string ServiceName => RuleResources.ServiceName_GHAS; diff --git a/src/Sarif.Multitool.Library/Rules/GH1015.ProvideRequiredResultProperties.cs b/src/Sarif.Multitool.Library/Rules/GH1015.ProvideRequiredResultProperties.cs index 714d0d868..667a8c0d5 100644 --- a/src/Sarif.Multitool.Library/Rules/GH1015.ProvideRequiredResultProperties.cs +++ b/src/Sarif.Multitool.Library/Rules/GH1015.ProvideRequiredResultProperties.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; +using System.Linq; namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules { @@ -15,6 +16,10 @@ public class GhasProvideRequiredResultProperties public override MultiformatMessageString FullDescription => new MultiformatMessageString() { Text = RuleResources.GH1015_ProvideRequiredResultProperties_FullDescription_Text }; + private readonly List _messageResourceNames = new List(); + + protected override ICollection MessageResourceNames => _messageResourceNames.Concat(BaseMessageResourceNames).ToList(); + public override HashSet RuleKinds => new HashSet(new[] { RuleKind.Ghas }); protected override string ServiceName => RuleResources.ServiceName_GHAS; diff --git a/src/Sarif.Multitool.Library/Rules/GH1016.ProvideRequiredLocationProperties.cs b/src/Sarif.Multitool.Library/Rules/GH1016.ProvideRequiredLocationProperties.cs index 76fc64060..0b64da2ea 100644 --- a/src/Sarif.Multitool.Library/Rules/GH1016.ProvideRequiredLocationProperties.cs +++ b/src/Sarif.Multitool.Library/Rules/GH1016.ProvideRequiredLocationProperties.cs @@ -2,11 +2,12 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; +using System.Linq; namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules { - public class GHASProvideRequiredLocationProperties - : SarifValidationSkimmerBase + public class GhasProvideRequiredLocationProperties + : BaseProvideRequiredLocationProperties { /// /// GH1016 @@ -15,11 +16,15 @@ public class GHASProvideRequiredLocationProperties public override MultiformatMessageString FullDescription => new MultiformatMessageString() { Text = RuleResources.GH1016_ProvideRequiredLocationProperties_FullDescription_Text }; + private readonly List _messageResourceNames = new List(); + + protected override ICollection MessageResourceNames => _messageResourceNames.Concat(BaseMessageResourceNames).ToList(); + public override HashSet RuleKinds => new HashSet(new[] { RuleKind.Ghas }); protected override string ServiceName => RuleResources.ServiceName_GHAS; - public GHASProvideRequiredLocationProperties() + public GhasProvideRequiredLocationProperties() { this.DefaultConfiguration.Level = FailureLevel.Error; } diff --git a/src/Sarif.Multitool.Library/Rules/GH1017.ProvideRequiredPhysicalLocationProperties.cs b/src/Sarif.Multitool.Library/Rules/GH1017.ProvideRequiredPhysicalLocationProperties.cs index 5e744234b..f21368690 100644 --- a/src/Sarif.Multitool.Library/Rules/GH1017.ProvideRequiredPhysicalLocationProperties.cs +++ b/src/Sarif.Multitool.Library/Rules/GH1017.ProvideRequiredPhysicalLocationProperties.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; +using System.Linq; using Microsoft.Json.Pointer; @@ -17,6 +18,10 @@ public class GhasProvideRequiredPhysicalLocationProperties public override MultiformatMessageString FullDescription => new MultiformatMessageString() { Text = RuleResources.GH1017_ProvideRequiredPhysicalLocationProperties_FullDescription_Text }; + private readonly List _messageResourceNames = new List(); + + protected override ICollection MessageResourceNames => _messageResourceNames.Concat(BaseMessageResourceNames).ToList(); + public override HashSet RuleKinds => new HashSet(new[] { RuleKind.Ghas }); protected override string ServiceName => RuleResources.ServiceName_GHAS; @@ -24,7 +29,7 @@ public class GhasProvideRequiredPhysicalLocationProperties public GhasProvideRequiredPhysicalLocationProperties() { this.DefaultConfiguration.Level = FailureLevel.Error; - this.MessageResourceNames.Add(nameof(RuleResources.GH1017_ProvideRequiredPhysicalLocationProperties_Error_MissingArtifactLocationUri_Text)); + this._messageResourceNames.Add(nameof(RuleResources.GH1017_ProvideRequiredPhysicalLocationProperties_Error_MissingArtifactLocationUri_Text)); } protected override void Analyze(PhysicalLocation physicalLocation, string physicalLocationPointer) diff --git a/src/Sarif.Multitool.Library/Rules/GH1018.ProvideRequiredToolProperties.cs b/src/Sarif.Multitool.Library/Rules/GH1018.ProvideRequiredToolProperties.cs index e2f129ee2..eb4441e42 100644 --- a/src/Sarif.Multitool.Library/Rules/GH1018.ProvideRequiredToolProperties.cs +++ b/src/Sarif.Multitool.Library/Rules/GH1018.ProvideRequiredToolProperties.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; +using System.Linq; namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules { @@ -15,6 +16,10 @@ public class GhasProvideToolDriver public override MultiformatMessageString FullDescription => new MultiformatMessageString() { Text = RuleResources.GH1018_ProvideRequiredToolProperties_FullDescription_Text }; + private readonly List _messageResourceNames = new List(); + + protected override ICollection MessageResourceNames => _messageResourceNames.Concat(BaseMessageResourceNames).ToList(); + public override HashSet RuleKinds => new HashSet(new[] { RuleKind.Ghas }); protected override string ServiceName => RuleResources.ServiceName_GHAS; diff --git a/src/Sarif.Multitool.Library/Rules/GH2012.ProvideRequiredReportingDescriptorProperties.cs b/src/Sarif.Multitool.Library/Rules/GH2012.ProvideRequiredReportingDescriptorProperties.cs index d709be616..5fd13f593 100644 --- a/src/Sarif.Multitool.Library/Rules/GH2012.ProvideRequiredReportingDescriptorProperties.cs +++ b/src/Sarif.Multitool.Library/Rules/GH2012.ProvideRequiredReportingDescriptorProperties.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; +using System.Linq; using Microsoft.Json.Pointer; @@ -17,6 +18,16 @@ public class GhasProvideRequiredReportingDescriptorProperties public override MultiformatMessageString FullDescription => new MultiformatMessageString() { Text = RuleResources.GH2012_ProvideRequiredReportingDescriptorProperties_FullDescription_Text }; + private readonly List _messageResourceNames = new List() + { + nameof(RuleResources.GH2012_ProvideRequiredReportingDescriptorProperties_Error_MissingFullDescription_Text), + nameof(RuleResources.GH2012_ProvideRequiredReportingDescriptorProperties_Error_MissingHelpText_Text), + nameof(RuleResources.GH2012_ProvideRequiredReportingDescriptorProperties_Error_MissingHelp_Text), + nameof(RuleResources.GH2012_ProvideRequiredReportingDescriptorProperties_Error_MissingShortDescription_Text) + }; + + protected override ICollection MessageResourceNames => _messageResourceNames.Concat(BaseMessageResourceNames).ToList(); + public override HashSet RuleKinds => new HashSet(new[] { RuleKind.Ghas }); protected override string ServiceName => RuleResources.ServiceName_GHAS; @@ -24,10 +35,6 @@ public class GhasProvideRequiredReportingDescriptorProperties public GhasProvideRequiredReportingDescriptorProperties() { this.DefaultConfiguration.Level = FailureLevel.Error; - this.MessageResourceNames.Add(nameof(RuleResources.GH2012_ProvideRequiredReportingDescriptorProperties_Error_MissingFullDescription_Text)); - this.MessageResourceNames.Add(nameof(RuleResources.GH2012_ProvideRequiredReportingDescriptorProperties_Error_MissingHelpText_Text)); - this.MessageResourceNames.Add(nameof(RuleResources.GH2012_ProvideRequiredReportingDescriptorProperties_Error_MissingHelp_Text)); - this.MessageResourceNames.Add(nameof(RuleResources.GH2012_ProvideRequiredReportingDescriptorProperties_Error_MissingShortDescription_Text)); } protected override void Analyze(ReportingDescriptor reportingDescriptor, string reportingDescriptorPointer) diff --git a/src/build.props b/src/build.props index b1112a480..28667d6e3 100644 --- a/src/build.props +++ b/src/build.props @@ -10,8 +10,8 @@ Microsoft Microsoft SARIF SDK © Microsoft Corporation. All rights reserved. - 4.5.2 - 4.5.1 + 4.5.3 + 4.5.2 2.1.0-rtm.6 From 23dfdcfafd6371cbb8322831627e4ba40d178bdb Mon Sep 17 00:00:00 2001 From: Chris Meyer Date: Thu, 29 Feb 2024 09:27:16 -1000 Subject: [PATCH 02/19] Rule fix + rebase test data (#2797) * Fixes * Rebase test data due to ADO2012 base class fix --- ...deRequiredReportingDescriptorProperties.cs | 2 +- ...deRequiredReportingDescriptorProperties.cs | 4 +- .../TEST1001.ValidateWithBaseline.sarif | 313 +++--------------- .../TEST1002.ValidateBaseline.NoResults.sarif | 313 +++--------------- ...T1003.ValidateBaseline.AbsentResults.sarif | 313 +++--------------- ...TEST1004.ValidateBaseline.NewResults.sarif | 313 +++--------------- ...05.ValidateBaseline.UnchangedResults.sarif | 313 +++--------------- ...1006.ValidateBaseline.UpdatedResults.sarif | 313 +++--------------- ...dateBaseline.LessResultsThanBaseline.sarif | 311 +++-------------- ...ST1008.ValidateBaseline.InlineUpdate.sarif | 313 +++--------------- 10 files changed, 434 insertions(+), 2074 deletions(-) diff --git a/src/Sarif.Multitool.Library/Rules/ADO2012.ProvideRequiredReportingDescriptorProperties.cs b/src/Sarif.Multitool.Library/Rules/ADO2012.ProvideRequiredReportingDescriptorProperties.cs index 604523339..b07e68431 100644 --- a/src/Sarif.Multitool.Library/Rules/ADO2012.ProvideRequiredReportingDescriptorProperties.cs +++ b/src/Sarif.Multitool.Library/Rules/ADO2012.ProvideRequiredReportingDescriptorProperties.cs @@ -7,7 +7,7 @@ namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules { public class AdoProvideRequiredReportingDescriptorProperties - : BaseProvideRequiredResultProperties + : BaseProvideRequiredReportingDescriptorProperties { /// /// ADO2012 diff --git a/src/Sarif.Multitool.Library/Rules/Base2012.ProvideRequiredReportingDescriptorProperties.cs b/src/Sarif.Multitool.Library/Rules/Base2012.ProvideRequiredReportingDescriptorProperties.cs index 873b2eef0..dd2dc8db1 100644 --- a/src/Sarif.Multitool.Library/Rules/Base2012.ProvideRequiredReportingDescriptorProperties.cs +++ b/src/Sarif.Multitool.Library/Rules/Base2012.ProvideRequiredReportingDescriptorProperties.cs @@ -5,7 +5,7 @@ namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules { - public class Base2012ProvideRequiredReportingDescriptorProperties + public class BaseProvideRequiredReportingDescriptorProperties : SarifValidationSkimmerBase { public override string Id => string.Empty; @@ -15,7 +15,7 @@ public class Base2012ProvideRequiredReportingDescriptorProperties nameof(RuleResources.Base2012_ProvideRequiredReportingDescriptorProperties_Error_MissingIdProperty_Text) }; - private ICollection BaseMessageResourceNames => _baseMessageResourceNames; + protected ICollection BaseMessageResourceNames => _baseMessageResourceNames; public override HashSet RuleKinds => new HashSet(); diff --git a/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1001.ValidateWithBaseline.sarif b/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1001.ValidateWithBaseline.sarif index 45e7fb445..a40bed8cb 100644 --- a/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1001.ValidateWithBaseline.sarif +++ b/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1001.ValidateWithBaseline.sarif @@ -30,6 +30,9 @@ "text": "The Result object represents an analysis finding and should provide details describing the nature of the problem along with its location in the scan target.\r\n\r\nProvide the 'ruleId' property, which is the unique identifier of the analysis rule that was violated. This property is required by the ADO Advanced Security service.\r\n\r\nProvide the 'message' property, which is a user-facing explanation of the result occurrence. The message's 'text' property is required by the ADO Advanced Security service.\r\n\r\nProvide the 'locations' array, which must contain at least one location object.\r\n\r\nProvide the 'partialFingerprints' dictionary. This property is required by the ADO Advanced Security service." }, "messageStrings": { + "Error_MissingRuleId": { + "text": "{0}: This 'result' object does not provide a 'ruleId' value. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -44,9 +47,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingRuleId": { - "text": "{0}: This 'result' object does not provide a 'ruleId' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -82,37 +82,6 @@ }, "helpUri": "http://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html" }, - { - "id": "ADO2012", - "name": "AdoProvideRequiredReportingDescriptorProperties", - "fullDescription": { - "text": "Rule metadata should provide information that makes it easy to understand and fix the problem.\r\nrule.id\r\n\r\nProvide the 'id' property whose value is a stable identifier for the rule.\r\n\r\nProvide the 'name' property, which contains a \"friendly name\" that helps users see at a glance the purpose of the rule. For uniformity of experience across all tools that produce SARIF, the friendly name should be a single Pascal-case identifier, for example, 'ProvideRuleFriendlyName'." - }, - "messageStrings": { - "Error_EmptyLocationsArray": { - "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." - }, - "Error_MissingLocationsArray": { - "text": "{0}: This 'result' object does not provide a 'locations' array. This property is required by the {1} service." - }, - "Error_MissingMessageText": { - "text": "{0}: The 'message' object on this 'result' object does not provide a 'text' property. This property is required by the {1} service." - }, - "Error_MissingMessage": { - "text": "{0}: This 'result' object does not provide a 'message' object. This property is required by the {1} service." - }, - "Error_MissingPartialFingerprints": { - "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingName": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'name' value. This property is required by the {1} service." - } - }, - "defaultConfiguration": { - "level": "error" - }, - "helpUri": "http://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html" - }, { "id": "GH1015", "name": "GhasProvideRequiredResultProperties", @@ -148,6 +117,9 @@ "text": "Provide the 'region' property, along with the appropriate region properties. This property is required by the GitHub Advanced Security service.\r\n\r\nProvide the 'artifactLocation' property. This property is required by the GitHub Advanced Security service." }, "messageStrings": { + "Error_MissingArtifactLocationUri": { + "text": "{0}: The 'artifactLocation' object on this 'physicalLocation' object does not provide a 'uri' object. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -162,9 +134,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingArtifactLocationUri": { - "text": "{0}: The 'artifactLocation' object on this 'physicalLocation' object does not provide a 'uri' object. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -179,6 +148,18 @@ "text": "Rule metadata should provide information that makes it easy to understand and fix the problem.\r\n\r\nProvide the 'id' property whose value is a stable identifier for the rule.\r\n\r\nProvide the 'shortDescription' and 'fullDescription' properties.\r\n\r\nProvide the 'help' property and populate the 'text' property with information about the rule." }, "messageStrings": { + "Error_MissingFullDescription": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'fullDescription' value. This property is required by the {1} service." + }, + "Error_MissingHelpText": { + "text": "{0}: This 'help' object does not provide a 'text' value. This property is required by the {1} service." + }, + "Error_MissingHelp": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'help' object. This property is required by the {1} service." + }, + "Error_MissingShortDescription": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'shortDescription' value. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -193,18 +174,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingFullDescription": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'fullDescription' value. This property is required by the {1} service." - }, - "Error_MissingHelpText": { - "text": "{0}: This 'help' object does not provide a 'text' value. This property is required by the {1} service." - }, - "Error_MissingHelp": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'help' object. This property is required by the {1} service." - }, - "Error_MissingShortDescription": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'shortDescription' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -235,6 +204,9 @@ "text": "Provide information that makes it easy to identify the name and version of your tool.\r\n\r\nProvide the 'driver' property. This property is required by the ADO Advanced Security service.\r\n\r\nProvide the driver's 'name' and 'fullName' properties.\r\n\r\nProvide the driver's 'rules' array." }, "messageStrings": { + "Error_MissingDriverFullName": { + "text": "{0}: This 'driver' object does not provide a 'fullName' value. This property is required by the {1} service." + }, "Error_MissingDriverName": { "text": "{0}: The 'driver' object in this tool does not provide a 'name' value. This property is required by the {1} service." }, @@ -243,9 +215,6 @@ }, "Error_MissingDriver": { "text": "{0}: This 'tool' object does not provide a 'driver' object. This property is required by the {1} service." - }, - "Error_MissingDriverFullName": { - "text": "{0}: This 'driver' object does not provide a 'fullName' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -487,67 +456,9 @@ "ResultMatching": {} } }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[0]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 7, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingLocationsArray", - "arguments": [ - "runs[0].results[0]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 7, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -576,7 +487,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -605,7 +516,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -634,7 +545,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -663,10 +574,10 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[0]", "GitHub Advanced Security" @@ -692,10 +603,10 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { - "id": "Error_MissingPartialFingerprints", + "id": "Error_MissingLocationsArray", "arguments": [ "runs[0].results[0]", "GitHub Advanced Security" @@ -721,7 +632,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 7, + "ruleIndex": 6, "level": "note", "message": { "id": "Note_Default", @@ -864,69 +775,11 @@ } }, { - "ruleId": "ADO2012", + "ruleId": "GH1015", "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingLocationsArray", - "arguments": [ - "runs[0].results[1]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 13, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[1]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 13, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "GH1015", - "ruleIndex": 4, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[1]", "GitHub Advanced Security" @@ -952,10 +805,10 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[1]", "GitHub Advanced Security" @@ -981,7 +834,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1010,7 +863,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1039,7 +892,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1068,7 +921,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1097,7 +950,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 7, + "ruleIndex": 6, "level": "note", "message": { "id": "Note_Default", @@ -1128,7 +981,7 @@ "ruleIndex": 1, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[2]", "Azure DevOps Advanced Security" @@ -1156,35 +1009,6 @@ "ruleId": "ADO1015", "ruleIndex": 1, "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[2]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 19, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO1017", - "ruleIndex": 2, - "level": "error", "message": { "id": "Error_MissingLocationsArray", "arguments": [ @@ -1240,37 +1064,8 @@ } }, { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[2]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 19, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, + "ruleId": "ADO1017", + "ruleIndex": 2, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1299,7 +1094,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1328,7 +1123,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1357,7 +1152,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1386,7 +1181,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1415,7 +1210,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1444,7 +1239,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1473,7 +1268,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 7, + "ruleIndex": 6, "level": "note", "message": { "id": "Note_Default", @@ -1501,7 +1296,7 @@ }, { "ruleId": "ADO1018", - "ruleIndex": 8, + "ruleIndex": 7, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1530,7 +1325,7 @@ }, { "ruleId": "ADO1018", - "ruleIndex": 8, + "ruleIndex": 7, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1559,7 +1354,7 @@ }, { "ruleId": "GH1018", - "ruleIndex": 9, + "ruleIndex": 8, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1588,7 +1383,7 @@ }, { "ruleId": "SARIF2005", - "ruleIndex": 10, + "ruleIndex": 9, "message": { "id": "Warning_ProvideToolVersion", "arguments": [ @@ -1617,7 +1412,7 @@ }, { "ruleId": "SARIF2005", - "ruleIndex": 10, + "ruleIndex": 9, "message": { "id": "Warning_ProvideToolnformationUri", "arguments": [ @@ -1645,7 +1440,7 @@ }, { "ruleId": "SARIF2012", - "ruleIndex": 11, + "ruleIndex": 10, "level": "note", "message": { "id": "Note_ProvideMetadataForAllViolatedRules", diff --git a/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1002.ValidateBaseline.NoResults.sarif b/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1002.ValidateBaseline.NoResults.sarif index 45e7fb445..a40bed8cb 100644 --- a/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1002.ValidateBaseline.NoResults.sarif +++ b/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1002.ValidateBaseline.NoResults.sarif @@ -30,6 +30,9 @@ "text": "The Result object represents an analysis finding and should provide details describing the nature of the problem along with its location in the scan target.\r\n\r\nProvide the 'ruleId' property, which is the unique identifier of the analysis rule that was violated. This property is required by the ADO Advanced Security service.\r\n\r\nProvide the 'message' property, which is a user-facing explanation of the result occurrence. The message's 'text' property is required by the ADO Advanced Security service.\r\n\r\nProvide the 'locations' array, which must contain at least one location object.\r\n\r\nProvide the 'partialFingerprints' dictionary. This property is required by the ADO Advanced Security service." }, "messageStrings": { + "Error_MissingRuleId": { + "text": "{0}: This 'result' object does not provide a 'ruleId' value. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -44,9 +47,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingRuleId": { - "text": "{0}: This 'result' object does not provide a 'ruleId' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -82,37 +82,6 @@ }, "helpUri": "http://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html" }, - { - "id": "ADO2012", - "name": "AdoProvideRequiredReportingDescriptorProperties", - "fullDescription": { - "text": "Rule metadata should provide information that makes it easy to understand and fix the problem.\r\nrule.id\r\n\r\nProvide the 'id' property whose value is a stable identifier for the rule.\r\n\r\nProvide the 'name' property, which contains a \"friendly name\" that helps users see at a glance the purpose of the rule. For uniformity of experience across all tools that produce SARIF, the friendly name should be a single Pascal-case identifier, for example, 'ProvideRuleFriendlyName'." - }, - "messageStrings": { - "Error_EmptyLocationsArray": { - "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." - }, - "Error_MissingLocationsArray": { - "text": "{0}: This 'result' object does not provide a 'locations' array. This property is required by the {1} service." - }, - "Error_MissingMessageText": { - "text": "{0}: The 'message' object on this 'result' object does not provide a 'text' property. This property is required by the {1} service." - }, - "Error_MissingMessage": { - "text": "{0}: This 'result' object does not provide a 'message' object. This property is required by the {1} service." - }, - "Error_MissingPartialFingerprints": { - "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingName": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'name' value. This property is required by the {1} service." - } - }, - "defaultConfiguration": { - "level": "error" - }, - "helpUri": "http://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html" - }, { "id": "GH1015", "name": "GhasProvideRequiredResultProperties", @@ -148,6 +117,9 @@ "text": "Provide the 'region' property, along with the appropriate region properties. This property is required by the GitHub Advanced Security service.\r\n\r\nProvide the 'artifactLocation' property. This property is required by the GitHub Advanced Security service." }, "messageStrings": { + "Error_MissingArtifactLocationUri": { + "text": "{0}: The 'artifactLocation' object on this 'physicalLocation' object does not provide a 'uri' object. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -162,9 +134,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingArtifactLocationUri": { - "text": "{0}: The 'artifactLocation' object on this 'physicalLocation' object does not provide a 'uri' object. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -179,6 +148,18 @@ "text": "Rule metadata should provide information that makes it easy to understand and fix the problem.\r\n\r\nProvide the 'id' property whose value is a stable identifier for the rule.\r\n\r\nProvide the 'shortDescription' and 'fullDescription' properties.\r\n\r\nProvide the 'help' property and populate the 'text' property with information about the rule." }, "messageStrings": { + "Error_MissingFullDescription": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'fullDescription' value. This property is required by the {1} service." + }, + "Error_MissingHelpText": { + "text": "{0}: This 'help' object does not provide a 'text' value. This property is required by the {1} service." + }, + "Error_MissingHelp": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'help' object. This property is required by the {1} service." + }, + "Error_MissingShortDescription": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'shortDescription' value. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -193,18 +174,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingFullDescription": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'fullDescription' value. This property is required by the {1} service." - }, - "Error_MissingHelpText": { - "text": "{0}: This 'help' object does not provide a 'text' value. This property is required by the {1} service." - }, - "Error_MissingHelp": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'help' object. This property is required by the {1} service." - }, - "Error_MissingShortDescription": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'shortDescription' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -235,6 +204,9 @@ "text": "Provide information that makes it easy to identify the name and version of your tool.\r\n\r\nProvide the 'driver' property. This property is required by the ADO Advanced Security service.\r\n\r\nProvide the driver's 'name' and 'fullName' properties.\r\n\r\nProvide the driver's 'rules' array." }, "messageStrings": { + "Error_MissingDriverFullName": { + "text": "{0}: This 'driver' object does not provide a 'fullName' value. This property is required by the {1} service." + }, "Error_MissingDriverName": { "text": "{0}: The 'driver' object in this tool does not provide a 'name' value. This property is required by the {1} service." }, @@ -243,9 +215,6 @@ }, "Error_MissingDriver": { "text": "{0}: This 'tool' object does not provide a 'driver' object. This property is required by the {1} service." - }, - "Error_MissingDriverFullName": { - "text": "{0}: This 'driver' object does not provide a 'fullName' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -487,67 +456,9 @@ "ResultMatching": {} } }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[0]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 7, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingLocationsArray", - "arguments": [ - "runs[0].results[0]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 7, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -576,7 +487,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -605,7 +516,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -634,7 +545,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -663,10 +574,10 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[0]", "GitHub Advanced Security" @@ -692,10 +603,10 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { - "id": "Error_MissingPartialFingerprints", + "id": "Error_MissingLocationsArray", "arguments": [ "runs[0].results[0]", "GitHub Advanced Security" @@ -721,7 +632,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 7, + "ruleIndex": 6, "level": "note", "message": { "id": "Note_Default", @@ -864,69 +775,11 @@ } }, { - "ruleId": "ADO2012", + "ruleId": "GH1015", "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingLocationsArray", - "arguments": [ - "runs[0].results[1]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 13, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[1]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 13, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "GH1015", - "ruleIndex": 4, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[1]", "GitHub Advanced Security" @@ -952,10 +805,10 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[1]", "GitHub Advanced Security" @@ -981,7 +834,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1010,7 +863,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1039,7 +892,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1068,7 +921,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1097,7 +950,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 7, + "ruleIndex": 6, "level": "note", "message": { "id": "Note_Default", @@ -1128,7 +981,7 @@ "ruleIndex": 1, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[2]", "Azure DevOps Advanced Security" @@ -1156,35 +1009,6 @@ "ruleId": "ADO1015", "ruleIndex": 1, "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[2]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 19, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO1017", - "ruleIndex": 2, - "level": "error", "message": { "id": "Error_MissingLocationsArray", "arguments": [ @@ -1240,37 +1064,8 @@ } }, { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[2]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 19, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, + "ruleId": "ADO1017", + "ruleIndex": 2, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1299,7 +1094,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1328,7 +1123,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1357,7 +1152,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1386,7 +1181,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1415,7 +1210,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1444,7 +1239,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1473,7 +1268,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 7, + "ruleIndex": 6, "level": "note", "message": { "id": "Note_Default", @@ -1501,7 +1296,7 @@ }, { "ruleId": "ADO1018", - "ruleIndex": 8, + "ruleIndex": 7, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1530,7 +1325,7 @@ }, { "ruleId": "ADO1018", - "ruleIndex": 8, + "ruleIndex": 7, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1559,7 +1354,7 @@ }, { "ruleId": "GH1018", - "ruleIndex": 9, + "ruleIndex": 8, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1588,7 +1383,7 @@ }, { "ruleId": "SARIF2005", - "ruleIndex": 10, + "ruleIndex": 9, "message": { "id": "Warning_ProvideToolVersion", "arguments": [ @@ -1617,7 +1412,7 @@ }, { "ruleId": "SARIF2005", - "ruleIndex": 10, + "ruleIndex": 9, "message": { "id": "Warning_ProvideToolnformationUri", "arguments": [ @@ -1645,7 +1440,7 @@ }, { "ruleId": "SARIF2012", - "ruleIndex": 11, + "ruleIndex": 10, "level": "note", "message": { "id": "Note_ProvideMetadataForAllViolatedRules", diff --git a/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1003.ValidateBaseline.AbsentResults.sarif b/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1003.ValidateBaseline.AbsentResults.sarif index 45e7fb445..a40bed8cb 100644 --- a/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1003.ValidateBaseline.AbsentResults.sarif +++ b/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1003.ValidateBaseline.AbsentResults.sarif @@ -30,6 +30,9 @@ "text": "The Result object represents an analysis finding and should provide details describing the nature of the problem along with its location in the scan target.\r\n\r\nProvide the 'ruleId' property, which is the unique identifier of the analysis rule that was violated. This property is required by the ADO Advanced Security service.\r\n\r\nProvide the 'message' property, which is a user-facing explanation of the result occurrence. The message's 'text' property is required by the ADO Advanced Security service.\r\n\r\nProvide the 'locations' array, which must contain at least one location object.\r\n\r\nProvide the 'partialFingerprints' dictionary. This property is required by the ADO Advanced Security service." }, "messageStrings": { + "Error_MissingRuleId": { + "text": "{0}: This 'result' object does not provide a 'ruleId' value. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -44,9 +47,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingRuleId": { - "text": "{0}: This 'result' object does not provide a 'ruleId' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -82,37 +82,6 @@ }, "helpUri": "http://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html" }, - { - "id": "ADO2012", - "name": "AdoProvideRequiredReportingDescriptorProperties", - "fullDescription": { - "text": "Rule metadata should provide information that makes it easy to understand and fix the problem.\r\nrule.id\r\n\r\nProvide the 'id' property whose value is a stable identifier for the rule.\r\n\r\nProvide the 'name' property, which contains a \"friendly name\" that helps users see at a glance the purpose of the rule. For uniformity of experience across all tools that produce SARIF, the friendly name should be a single Pascal-case identifier, for example, 'ProvideRuleFriendlyName'." - }, - "messageStrings": { - "Error_EmptyLocationsArray": { - "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." - }, - "Error_MissingLocationsArray": { - "text": "{0}: This 'result' object does not provide a 'locations' array. This property is required by the {1} service." - }, - "Error_MissingMessageText": { - "text": "{0}: The 'message' object on this 'result' object does not provide a 'text' property. This property is required by the {1} service." - }, - "Error_MissingMessage": { - "text": "{0}: This 'result' object does not provide a 'message' object. This property is required by the {1} service." - }, - "Error_MissingPartialFingerprints": { - "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingName": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'name' value. This property is required by the {1} service." - } - }, - "defaultConfiguration": { - "level": "error" - }, - "helpUri": "http://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html" - }, { "id": "GH1015", "name": "GhasProvideRequiredResultProperties", @@ -148,6 +117,9 @@ "text": "Provide the 'region' property, along with the appropriate region properties. This property is required by the GitHub Advanced Security service.\r\n\r\nProvide the 'artifactLocation' property. This property is required by the GitHub Advanced Security service." }, "messageStrings": { + "Error_MissingArtifactLocationUri": { + "text": "{0}: The 'artifactLocation' object on this 'physicalLocation' object does not provide a 'uri' object. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -162,9 +134,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingArtifactLocationUri": { - "text": "{0}: The 'artifactLocation' object on this 'physicalLocation' object does not provide a 'uri' object. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -179,6 +148,18 @@ "text": "Rule metadata should provide information that makes it easy to understand and fix the problem.\r\n\r\nProvide the 'id' property whose value is a stable identifier for the rule.\r\n\r\nProvide the 'shortDescription' and 'fullDescription' properties.\r\n\r\nProvide the 'help' property and populate the 'text' property with information about the rule." }, "messageStrings": { + "Error_MissingFullDescription": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'fullDescription' value. This property is required by the {1} service." + }, + "Error_MissingHelpText": { + "text": "{0}: This 'help' object does not provide a 'text' value. This property is required by the {1} service." + }, + "Error_MissingHelp": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'help' object. This property is required by the {1} service." + }, + "Error_MissingShortDescription": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'shortDescription' value. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -193,18 +174,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingFullDescription": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'fullDescription' value. This property is required by the {1} service." - }, - "Error_MissingHelpText": { - "text": "{0}: This 'help' object does not provide a 'text' value. This property is required by the {1} service." - }, - "Error_MissingHelp": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'help' object. This property is required by the {1} service." - }, - "Error_MissingShortDescription": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'shortDescription' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -235,6 +204,9 @@ "text": "Provide information that makes it easy to identify the name and version of your tool.\r\n\r\nProvide the 'driver' property. This property is required by the ADO Advanced Security service.\r\n\r\nProvide the driver's 'name' and 'fullName' properties.\r\n\r\nProvide the driver's 'rules' array." }, "messageStrings": { + "Error_MissingDriverFullName": { + "text": "{0}: This 'driver' object does not provide a 'fullName' value. This property is required by the {1} service." + }, "Error_MissingDriverName": { "text": "{0}: The 'driver' object in this tool does not provide a 'name' value. This property is required by the {1} service." }, @@ -243,9 +215,6 @@ }, "Error_MissingDriver": { "text": "{0}: This 'tool' object does not provide a 'driver' object. This property is required by the {1} service." - }, - "Error_MissingDriverFullName": { - "text": "{0}: This 'driver' object does not provide a 'fullName' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -487,67 +456,9 @@ "ResultMatching": {} } }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[0]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 7, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingLocationsArray", - "arguments": [ - "runs[0].results[0]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 7, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -576,7 +487,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -605,7 +516,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -634,7 +545,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -663,10 +574,10 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[0]", "GitHub Advanced Security" @@ -692,10 +603,10 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { - "id": "Error_MissingPartialFingerprints", + "id": "Error_MissingLocationsArray", "arguments": [ "runs[0].results[0]", "GitHub Advanced Security" @@ -721,7 +632,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 7, + "ruleIndex": 6, "level": "note", "message": { "id": "Note_Default", @@ -864,69 +775,11 @@ } }, { - "ruleId": "ADO2012", + "ruleId": "GH1015", "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingLocationsArray", - "arguments": [ - "runs[0].results[1]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 13, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[1]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 13, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "GH1015", - "ruleIndex": 4, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[1]", "GitHub Advanced Security" @@ -952,10 +805,10 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[1]", "GitHub Advanced Security" @@ -981,7 +834,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1010,7 +863,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1039,7 +892,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1068,7 +921,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1097,7 +950,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 7, + "ruleIndex": 6, "level": "note", "message": { "id": "Note_Default", @@ -1128,7 +981,7 @@ "ruleIndex": 1, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[2]", "Azure DevOps Advanced Security" @@ -1156,35 +1009,6 @@ "ruleId": "ADO1015", "ruleIndex": 1, "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[2]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 19, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO1017", - "ruleIndex": 2, - "level": "error", "message": { "id": "Error_MissingLocationsArray", "arguments": [ @@ -1240,37 +1064,8 @@ } }, { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[2]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 19, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, + "ruleId": "ADO1017", + "ruleIndex": 2, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1299,7 +1094,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1328,7 +1123,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1357,7 +1152,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1386,7 +1181,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1415,7 +1210,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1444,7 +1239,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1473,7 +1268,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 7, + "ruleIndex": 6, "level": "note", "message": { "id": "Note_Default", @@ -1501,7 +1296,7 @@ }, { "ruleId": "ADO1018", - "ruleIndex": 8, + "ruleIndex": 7, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1530,7 +1325,7 @@ }, { "ruleId": "ADO1018", - "ruleIndex": 8, + "ruleIndex": 7, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1559,7 +1354,7 @@ }, { "ruleId": "GH1018", - "ruleIndex": 9, + "ruleIndex": 8, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1588,7 +1383,7 @@ }, { "ruleId": "SARIF2005", - "ruleIndex": 10, + "ruleIndex": 9, "message": { "id": "Warning_ProvideToolVersion", "arguments": [ @@ -1617,7 +1412,7 @@ }, { "ruleId": "SARIF2005", - "ruleIndex": 10, + "ruleIndex": 9, "message": { "id": "Warning_ProvideToolnformationUri", "arguments": [ @@ -1645,7 +1440,7 @@ }, { "ruleId": "SARIF2012", - "ruleIndex": 11, + "ruleIndex": 10, "level": "note", "message": { "id": "Note_ProvideMetadataForAllViolatedRules", diff --git a/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1004.ValidateBaseline.NewResults.sarif b/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1004.ValidateBaseline.NewResults.sarif index a27e82c46..cd122f5d8 100644 --- a/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1004.ValidateBaseline.NewResults.sarif +++ b/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1004.ValidateBaseline.NewResults.sarif @@ -30,6 +30,9 @@ "text": "The Result object represents an analysis finding and should provide details describing the nature of the problem along with its location in the scan target.\r\n\r\nProvide the 'ruleId' property, which is the unique identifier of the analysis rule that was violated. This property is required by the ADO Advanced Security service.\r\n\r\nProvide the 'message' property, which is a user-facing explanation of the result occurrence. The message's 'text' property is required by the ADO Advanced Security service.\r\n\r\nProvide the 'locations' array, which must contain at least one location object.\r\n\r\nProvide the 'partialFingerprints' dictionary. This property is required by the ADO Advanced Security service." }, "messageStrings": { + "Error_MissingRuleId": { + "text": "{0}: This 'result' object does not provide a 'ruleId' value. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -44,9 +47,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingRuleId": { - "text": "{0}: This 'result' object does not provide a 'ruleId' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -82,37 +82,6 @@ }, "helpUri": "http://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html" }, - { - "id": "ADO2012", - "name": "AdoProvideRequiredReportingDescriptorProperties", - "fullDescription": { - "text": "Rule metadata should provide information that makes it easy to understand and fix the problem.\r\nrule.id\r\n\r\nProvide the 'id' property whose value is a stable identifier for the rule.\r\n\r\nProvide the 'name' property, which contains a \"friendly name\" that helps users see at a glance the purpose of the rule. For uniformity of experience across all tools that produce SARIF, the friendly name should be a single Pascal-case identifier, for example, 'ProvideRuleFriendlyName'." - }, - "messageStrings": { - "Error_EmptyLocationsArray": { - "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." - }, - "Error_MissingLocationsArray": { - "text": "{0}: This 'result' object does not provide a 'locations' array. This property is required by the {1} service." - }, - "Error_MissingMessageText": { - "text": "{0}: The 'message' object on this 'result' object does not provide a 'text' property. This property is required by the {1} service." - }, - "Error_MissingMessage": { - "text": "{0}: This 'result' object does not provide a 'message' object. This property is required by the {1} service." - }, - "Error_MissingPartialFingerprints": { - "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingName": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'name' value. This property is required by the {1} service." - } - }, - "defaultConfiguration": { - "level": "error" - }, - "helpUri": "http://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html" - }, { "id": "GH1015", "name": "GhasProvideRequiredResultProperties", @@ -148,6 +117,9 @@ "text": "Provide the 'region' property, along with the appropriate region properties. This property is required by the GitHub Advanced Security service.\r\n\r\nProvide the 'artifactLocation' property. This property is required by the GitHub Advanced Security service." }, "messageStrings": { + "Error_MissingArtifactLocationUri": { + "text": "{0}: The 'artifactLocation' object on this 'physicalLocation' object does not provide a 'uri' object. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -162,9 +134,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingArtifactLocationUri": { - "text": "{0}: The 'artifactLocation' object on this 'physicalLocation' object does not provide a 'uri' object. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -179,6 +148,18 @@ "text": "Rule metadata should provide information that makes it easy to understand and fix the problem.\r\n\r\nProvide the 'id' property whose value is a stable identifier for the rule.\r\n\r\nProvide the 'shortDescription' and 'fullDescription' properties.\r\n\r\nProvide the 'help' property and populate the 'text' property with information about the rule." }, "messageStrings": { + "Error_MissingFullDescription": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'fullDescription' value. This property is required by the {1} service." + }, + "Error_MissingHelpText": { + "text": "{0}: This 'help' object does not provide a 'text' value. This property is required by the {1} service." + }, + "Error_MissingHelp": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'help' object. This property is required by the {1} service." + }, + "Error_MissingShortDescription": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'shortDescription' value. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -193,18 +174,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingFullDescription": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'fullDescription' value. This property is required by the {1} service." - }, - "Error_MissingHelpText": { - "text": "{0}: This 'help' object does not provide a 'text' value. This property is required by the {1} service." - }, - "Error_MissingHelp": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'help' object. This property is required by the {1} service." - }, - "Error_MissingShortDescription": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'shortDescription' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -235,6 +204,9 @@ "text": "Provide information that makes it easy to identify the name and version of your tool.\r\n\r\nProvide the 'driver' property. This property is required by the ADO Advanced Security service.\r\n\r\nProvide the driver's 'name' and 'fullName' properties.\r\n\r\nProvide the driver's 'rules' array." }, "messageStrings": { + "Error_MissingDriverFullName": { + "text": "{0}: This 'driver' object does not provide a 'fullName' value. This property is required by the {1} service." + }, "Error_MissingDriverName": { "text": "{0}: The 'driver' object in this tool does not provide a 'name' value. This property is required by the {1} service." }, @@ -243,9 +215,6 @@ }, "Error_MissingDriver": { "text": "{0}: This 'tool' object does not provide a 'driver' object. This property is required by the {1} service." - }, - "Error_MissingDriverFullName": { - "text": "{0}: This 'driver' object does not provide a 'fullName' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -487,67 +456,9 @@ "ResultMatching": {} } }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[0]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 7, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingLocationsArray", - "arguments": [ - "runs[0].results[0]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 7, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -576,7 +487,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -605,7 +516,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -634,7 +545,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -663,10 +574,10 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[0]", "GitHub Advanced Security" @@ -692,10 +603,10 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { - "id": "Error_MissingPartialFingerprints", + "id": "Error_MissingLocationsArray", "arguments": [ "runs[0].results[0]", "GitHub Advanced Security" @@ -721,7 +632,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 7, + "ruleIndex": 6, "level": "note", "message": { "id": "Note_Default", @@ -864,69 +775,11 @@ } }, { - "ruleId": "ADO2012", + "ruleId": "GH1015", "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingLocationsArray", - "arguments": [ - "runs[0].results[1]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 13, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[1]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 13, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "GH1015", - "ruleIndex": 4, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[1]", "GitHub Advanced Security" @@ -952,10 +805,10 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[1]", "GitHub Advanced Security" @@ -981,7 +834,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1010,7 +863,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1039,7 +892,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1068,7 +921,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1097,7 +950,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 7, + "ruleIndex": 6, "level": "note", "message": { "id": "Note_Default", @@ -1128,7 +981,7 @@ "ruleIndex": 1, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[2]", "Azure DevOps Advanced Security" @@ -1156,35 +1009,6 @@ "ruleId": "ADO1015", "ruleIndex": 1, "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[2]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 19, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO1017", - "ruleIndex": 2, - "level": "error", "message": { "id": "Error_MissingLocationsArray", "arguments": [ @@ -1240,37 +1064,8 @@ } }, { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[2]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 19, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, + "ruleId": "ADO1017", + "ruleIndex": 2, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1299,7 +1094,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1328,7 +1123,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1357,7 +1152,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1386,7 +1181,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1415,7 +1210,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1444,7 +1239,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1473,7 +1268,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 7, + "ruleIndex": 6, "level": "note", "message": { "id": "Note_Default", @@ -1501,7 +1296,7 @@ }, { "ruleId": "ADO1018", - "ruleIndex": 8, + "ruleIndex": 7, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1530,7 +1325,7 @@ }, { "ruleId": "ADO1018", - "ruleIndex": 8, + "ruleIndex": 7, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1559,7 +1354,7 @@ }, { "ruleId": "GH1018", - "ruleIndex": 9, + "ruleIndex": 8, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1588,7 +1383,7 @@ }, { "ruleId": "SARIF2005", - "ruleIndex": 10, + "ruleIndex": 9, "message": { "id": "Warning_ProvideToolVersion", "arguments": [ @@ -1617,7 +1412,7 @@ }, { "ruleId": "SARIF2005", - "ruleIndex": 10, + "ruleIndex": 9, "message": { "id": "Warning_ProvideToolnformationUri", "arguments": [ @@ -1645,7 +1440,7 @@ }, { "ruleId": "SARIF2012", - "ruleIndex": 11, + "ruleIndex": 10, "level": "note", "message": { "id": "Note_ProvideMetadataForAllViolatedRules", diff --git a/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1005.ValidateBaseline.UnchangedResults.sarif b/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1005.ValidateBaseline.UnchangedResults.sarif index a27e82c46..cd122f5d8 100644 --- a/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1005.ValidateBaseline.UnchangedResults.sarif +++ b/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1005.ValidateBaseline.UnchangedResults.sarif @@ -30,6 +30,9 @@ "text": "The Result object represents an analysis finding and should provide details describing the nature of the problem along with its location in the scan target.\r\n\r\nProvide the 'ruleId' property, which is the unique identifier of the analysis rule that was violated. This property is required by the ADO Advanced Security service.\r\n\r\nProvide the 'message' property, which is a user-facing explanation of the result occurrence. The message's 'text' property is required by the ADO Advanced Security service.\r\n\r\nProvide the 'locations' array, which must contain at least one location object.\r\n\r\nProvide the 'partialFingerprints' dictionary. This property is required by the ADO Advanced Security service." }, "messageStrings": { + "Error_MissingRuleId": { + "text": "{0}: This 'result' object does not provide a 'ruleId' value. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -44,9 +47,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingRuleId": { - "text": "{0}: This 'result' object does not provide a 'ruleId' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -82,37 +82,6 @@ }, "helpUri": "http://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html" }, - { - "id": "ADO2012", - "name": "AdoProvideRequiredReportingDescriptorProperties", - "fullDescription": { - "text": "Rule metadata should provide information that makes it easy to understand and fix the problem.\r\nrule.id\r\n\r\nProvide the 'id' property whose value is a stable identifier for the rule.\r\n\r\nProvide the 'name' property, which contains a \"friendly name\" that helps users see at a glance the purpose of the rule. For uniformity of experience across all tools that produce SARIF, the friendly name should be a single Pascal-case identifier, for example, 'ProvideRuleFriendlyName'." - }, - "messageStrings": { - "Error_EmptyLocationsArray": { - "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." - }, - "Error_MissingLocationsArray": { - "text": "{0}: This 'result' object does not provide a 'locations' array. This property is required by the {1} service." - }, - "Error_MissingMessageText": { - "text": "{0}: The 'message' object on this 'result' object does not provide a 'text' property. This property is required by the {1} service." - }, - "Error_MissingMessage": { - "text": "{0}: This 'result' object does not provide a 'message' object. This property is required by the {1} service." - }, - "Error_MissingPartialFingerprints": { - "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingName": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'name' value. This property is required by the {1} service." - } - }, - "defaultConfiguration": { - "level": "error" - }, - "helpUri": "http://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html" - }, { "id": "GH1015", "name": "GhasProvideRequiredResultProperties", @@ -148,6 +117,9 @@ "text": "Provide the 'region' property, along with the appropriate region properties. This property is required by the GitHub Advanced Security service.\r\n\r\nProvide the 'artifactLocation' property. This property is required by the GitHub Advanced Security service." }, "messageStrings": { + "Error_MissingArtifactLocationUri": { + "text": "{0}: The 'artifactLocation' object on this 'physicalLocation' object does not provide a 'uri' object. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -162,9 +134,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingArtifactLocationUri": { - "text": "{0}: The 'artifactLocation' object on this 'physicalLocation' object does not provide a 'uri' object. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -179,6 +148,18 @@ "text": "Rule metadata should provide information that makes it easy to understand and fix the problem.\r\n\r\nProvide the 'id' property whose value is a stable identifier for the rule.\r\n\r\nProvide the 'shortDescription' and 'fullDescription' properties.\r\n\r\nProvide the 'help' property and populate the 'text' property with information about the rule." }, "messageStrings": { + "Error_MissingFullDescription": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'fullDescription' value. This property is required by the {1} service." + }, + "Error_MissingHelpText": { + "text": "{0}: This 'help' object does not provide a 'text' value. This property is required by the {1} service." + }, + "Error_MissingHelp": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'help' object. This property is required by the {1} service." + }, + "Error_MissingShortDescription": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'shortDescription' value. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -193,18 +174,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingFullDescription": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'fullDescription' value. This property is required by the {1} service." - }, - "Error_MissingHelpText": { - "text": "{0}: This 'help' object does not provide a 'text' value. This property is required by the {1} service." - }, - "Error_MissingHelp": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'help' object. This property is required by the {1} service." - }, - "Error_MissingShortDescription": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'shortDescription' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -235,6 +204,9 @@ "text": "Provide information that makes it easy to identify the name and version of your tool.\r\n\r\nProvide the 'driver' property. This property is required by the ADO Advanced Security service.\r\n\r\nProvide the driver's 'name' and 'fullName' properties.\r\n\r\nProvide the driver's 'rules' array." }, "messageStrings": { + "Error_MissingDriverFullName": { + "text": "{0}: This 'driver' object does not provide a 'fullName' value. This property is required by the {1} service." + }, "Error_MissingDriverName": { "text": "{0}: The 'driver' object in this tool does not provide a 'name' value. This property is required by the {1} service." }, @@ -243,9 +215,6 @@ }, "Error_MissingDriver": { "text": "{0}: This 'tool' object does not provide a 'driver' object. This property is required by the {1} service." - }, - "Error_MissingDriverFullName": { - "text": "{0}: This 'driver' object does not provide a 'fullName' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -487,67 +456,9 @@ "ResultMatching": {} } }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[0]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 7, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingLocationsArray", - "arguments": [ - "runs[0].results[0]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 7, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -576,7 +487,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -605,7 +516,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -634,7 +545,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -663,10 +574,10 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[0]", "GitHub Advanced Security" @@ -692,10 +603,10 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { - "id": "Error_MissingPartialFingerprints", + "id": "Error_MissingLocationsArray", "arguments": [ "runs[0].results[0]", "GitHub Advanced Security" @@ -721,7 +632,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 7, + "ruleIndex": 6, "level": "note", "message": { "id": "Note_Default", @@ -864,69 +775,11 @@ } }, { - "ruleId": "ADO2012", + "ruleId": "GH1015", "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingLocationsArray", - "arguments": [ - "runs[0].results[1]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 13, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[1]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 13, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "GH1015", - "ruleIndex": 4, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[1]", "GitHub Advanced Security" @@ -952,10 +805,10 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[1]", "GitHub Advanced Security" @@ -981,7 +834,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1010,7 +863,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1039,7 +892,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1068,7 +921,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1097,7 +950,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 7, + "ruleIndex": 6, "level": "note", "message": { "id": "Note_Default", @@ -1128,7 +981,7 @@ "ruleIndex": 1, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[2]", "Azure DevOps Advanced Security" @@ -1156,35 +1009,6 @@ "ruleId": "ADO1015", "ruleIndex": 1, "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[2]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 19, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO1017", - "ruleIndex": 2, - "level": "error", "message": { "id": "Error_MissingLocationsArray", "arguments": [ @@ -1240,37 +1064,8 @@ } }, { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[2]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 19, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, + "ruleId": "ADO1017", + "ruleIndex": 2, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1299,7 +1094,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1328,7 +1123,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1357,7 +1152,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1386,7 +1181,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1415,7 +1210,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1444,7 +1239,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1473,7 +1268,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 7, + "ruleIndex": 6, "level": "note", "message": { "id": "Note_Default", @@ -1501,7 +1296,7 @@ }, { "ruleId": "ADO1018", - "ruleIndex": 8, + "ruleIndex": 7, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1530,7 +1325,7 @@ }, { "ruleId": "ADO1018", - "ruleIndex": 8, + "ruleIndex": 7, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1559,7 +1354,7 @@ }, { "ruleId": "GH1018", - "ruleIndex": 9, + "ruleIndex": 8, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1588,7 +1383,7 @@ }, { "ruleId": "SARIF2005", - "ruleIndex": 10, + "ruleIndex": 9, "message": { "id": "Warning_ProvideToolVersion", "arguments": [ @@ -1617,7 +1412,7 @@ }, { "ruleId": "SARIF2005", - "ruleIndex": 10, + "ruleIndex": 9, "message": { "id": "Warning_ProvideToolnformationUri", "arguments": [ @@ -1645,7 +1440,7 @@ }, { "ruleId": "SARIF2012", - "ruleIndex": 11, + "ruleIndex": 10, "level": "note", "message": { "id": "Note_ProvideMetadataForAllViolatedRules", diff --git a/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1006.ValidateBaseline.UpdatedResults.sarif b/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1006.ValidateBaseline.UpdatedResults.sarif index 05cf02955..2a004c9b2 100644 --- a/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1006.ValidateBaseline.UpdatedResults.sarif +++ b/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1006.ValidateBaseline.UpdatedResults.sarif @@ -30,6 +30,9 @@ "text": "The Result object represents an analysis finding and should provide details describing the nature of the problem along with its location in the scan target.\r\n\r\nProvide the 'ruleId' property, which is the unique identifier of the analysis rule that was violated. This property is required by the ADO Advanced Security service.\r\n\r\nProvide the 'message' property, which is a user-facing explanation of the result occurrence. The message's 'text' property is required by the ADO Advanced Security service.\r\n\r\nProvide the 'locations' array, which must contain at least one location object.\r\n\r\nProvide the 'partialFingerprints' dictionary. This property is required by the ADO Advanced Security service." }, "messageStrings": { + "Error_MissingRuleId": { + "text": "{0}: This 'result' object does not provide a 'ruleId' value. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -44,9 +47,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingRuleId": { - "text": "{0}: This 'result' object does not provide a 'ruleId' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -82,37 +82,6 @@ }, "helpUri": "http://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html" }, - { - "id": "ADO2012", - "name": "AdoProvideRequiredReportingDescriptorProperties", - "fullDescription": { - "text": "Rule metadata should provide information that makes it easy to understand and fix the problem.\r\nrule.id\r\n\r\nProvide the 'id' property whose value is a stable identifier for the rule.\r\n\r\nProvide the 'name' property, which contains a \"friendly name\" that helps users see at a glance the purpose of the rule. For uniformity of experience across all tools that produce SARIF, the friendly name should be a single Pascal-case identifier, for example, 'ProvideRuleFriendlyName'." - }, - "messageStrings": { - "Error_EmptyLocationsArray": { - "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." - }, - "Error_MissingLocationsArray": { - "text": "{0}: This 'result' object does not provide a 'locations' array. This property is required by the {1} service." - }, - "Error_MissingMessageText": { - "text": "{0}: The 'message' object on this 'result' object does not provide a 'text' property. This property is required by the {1} service." - }, - "Error_MissingMessage": { - "text": "{0}: This 'result' object does not provide a 'message' object. This property is required by the {1} service." - }, - "Error_MissingPartialFingerprints": { - "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingName": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'name' value. This property is required by the {1} service." - } - }, - "defaultConfiguration": { - "level": "error" - }, - "helpUri": "http://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html" - }, { "id": "GH1015", "name": "GhasProvideRequiredResultProperties", @@ -148,6 +117,9 @@ "text": "Provide the 'region' property, along with the appropriate region properties. This property is required by the GitHub Advanced Security service.\r\n\r\nProvide the 'artifactLocation' property. This property is required by the GitHub Advanced Security service." }, "messageStrings": { + "Error_MissingArtifactLocationUri": { + "text": "{0}: The 'artifactLocation' object on this 'physicalLocation' object does not provide a 'uri' object. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -162,9 +134,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingArtifactLocationUri": { - "text": "{0}: The 'artifactLocation' object on this 'physicalLocation' object does not provide a 'uri' object. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -179,6 +148,18 @@ "text": "Rule metadata should provide information that makes it easy to understand and fix the problem.\r\n\r\nProvide the 'id' property whose value is a stable identifier for the rule.\r\n\r\nProvide the 'shortDescription' and 'fullDescription' properties.\r\n\r\nProvide the 'help' property and populate the 'text' property with information about the rule." }, "messageStrings": { + "Error_MissingFullDescription": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'fullDescription' value. This property is required by the {1} service." + }, + "Error_MissingHelpText": { + "text": "{0}: This 'help' object does not provide a 'text' value. This property is required by the {1} service." + }, + "Error_MissingHelp": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'help' object. This property is required by the {1} service." + }, + "Error_MissingShortDescription": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'shortDescription' value. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -193,18 +174,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingFullDescription": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'fullDescription' value. This property is required by the {1} service." - }, - "Error_MissingHelpText": { - "text": "{0}: This 'help' object does not provide a 'text' value. This property is required by the {1} service." - }, - "Error_MissingHelp": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'help' object. This property is required by the {1} service." - }, - "Error_MissingShortDescription": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'shortDescription' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -235,6 +204,9 @@ "text": "Provide information that makes it easy to identify the name and version of your tool.\r\n\r\nProvide the 'driver' property. This property is required by the ADO Advanced Security service.\r\n\r\nProvide the driver's 'name' and 'fullName' properties.\r\n\r\nProvide the driver's 'rules' array." }, "messageStrings": { + "Error_MissingDriverFullName": { + "text": "{0}: This 'driver' object does not provide a 'fullName' value. This property is required by the {1} service." + }, "Error_MissingDriverName": { "text": "{0}: The 'driver' object in this tool does not provide a 'name' value. This property is required by the {1} service." }, @@ -243,9 +215,6 @@ }, "Error_MissingDriver": { "text": "{0}: This 'tool' object does not provide a 'driver' object. This property is required by the {1} service." - }, - "Error_MissingDriverFullName": { - "text": "{0}: This 'driver' object does not provide a 'fullName' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -487,67 +456,9 @@ "ResultMatching": {} } }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[0]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 7, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingLocationsArray", - "arguments": [ - "runs[0].results[0]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 7, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -576,7 +487,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -605,7 +516,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -634,7 +545,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -663,10 +574,10 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[0]", "GitHub Advanced Security" @@ -692,10 +603,10 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { - "id": "Error_MissingPartialFingerprints", + "id": "Error_MissingLocationsArray", "arguments": [ "runs[0].results[0]", "GitHub Advanced Security" @@ -721,7 +632,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 7, + "ruleIndex": 6, "level": "note", "message": { "id": "Note_Default", @@ -864,69 +775,11 @@ } }, { - "ruleId": "ADO2012", + "ruleId": "GH1015", "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingLocationsArray", - "arguments": [ - "runs[0].results[1]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 13, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[1]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 13, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "GH1015", - "ruleIndex": 4, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[1]", "GitHub Advanced Security" @@ -952,10 +805,10 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[1]", "GitHub Advanced Security" @@ -981,7 +834,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1010,7 +863,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1039,7 +892,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1068,7 +921,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1097,7 +950,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 7, + "ruleIndex": 6, "level": "note", "message": { "id": "Note_Default", @@ -1128,7 +981,7 @@ "ruleIndex": 1, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[2]", "Azure DevOps Advanced Security" @@ -1156,35 +1009,6 @@ "ruleId": "ADO1015", "ruleIndex": 1, "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[2]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 19, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO1017", - "ruleIndex": 2, - "level": "error", "message": { "id": "Error_MissingLocationsArray", "arguments": [ @@ -1240,37 +1064,8 @@ } }, { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[2]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 19, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, + "ruleId": "ADO1017", + "ruleIndex": 2, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1299,7 +1094,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1328,7 +1123,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1357,7 +1152,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1386,7 +1181,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1415,7 +1210,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1444,7 +1239,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1473,7 +1268,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 7, + "ruleIndex": 6, "level": "note", "message": { "id": "Note_Default", @@ -1501,7 +1296,7 @@ }, { "ruleId": "ADO1018", - "ruleIndex": 8, + "ruleIndex": 7, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1530,7 +1325,7 @@ }, { "ruleId": "ADO1018", - "ruleIndex": 8, + "ruleIndex": 7, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1559,7 +1354,7 @@ }, { "ruleId": "GH1018", - "ruleIndex": 9, + "ruleIndex": 8, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1588,7 +1383,7 @@ }, { "ruleId": "SARIF2005", - "ruleIndex": 10, + "ruleIndex": 9, "message": { "id": "Warning_ProvideToolVersion", "arguments": [ @@ -1617,7 +1412,7 @@ }, { "ruleId": "SARIF2005", - "ruleIndex": 10, + "ruleIndex": 9, "message": { "id": "Warning_ProvideToolnformationUri", "arguments": [ @@ -1645,7 +1440,7 @@ }, { "ruleId": "SARIF2012", - "ruleIndex": 11, + "ruleIndex": 10, "level": "note", "message": { "id": "Note_ProvideMetadataForAllViolatedRules", diff --git a/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1007.ValidateBaseline.LessResultsThanBaseline.sarif b/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1007.ValidateBaseline.LessResultsThanBaseline.sarif index b6096438a..d3a3221d7 100644 --- a/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1007.ValidateBaseline.LessResultsThanBaseline.sarif +++ b/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1007.ValidateBaseline.LessResultsThanBaseline.sarif @@ -58,6 +58,9 @@ "text": "The Result object represents an analysis finding and should provide details describing the nature of the problem along with its location in the scan target.\r\n\r\nProvide the 'ruleId' property, which is the unique identifier of the analysis rule that was violated. This property is required by the ADO Advanced Security service.\r\n\r\nProvide the 'message' property, which is a user-facing explanation of the result occurrence. The message's 'text' property is required by the ADO Advanced Security service.\r\n\r\nProvide the 'locations' array, which must contain at least one location object.\r\n\r\nProvide the 'partialFingerprints' dictionary. This property is required by the ADO Advanced Security service." }, "messageStrings": { + "Error_MissingRuleId": { + "text": "{0}: This 'result' object does not provide a 'ruleId' value. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -72,9 +75,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingRuleId": { - "text": "{0}: This 'result' object does not provide a 'ruleId' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -110,37 +110,6 @@ }, "helpUri": "http://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html" }, - { - "id": "ADO2012", - "name": "AdoProvideRequiredReportingDescriptorProperties", - "fullDescription": { - "text": "Rule metadata should provide information that makes it easy to understand and fix the problem.\r\nrule.id\r\n\r\nProvide the 'id' property whose value is a stable identifier for the rule.\r\n\r\nProvide the 'name' property, which contains a \"friendly name\" that helps users see at a glance the purpose of the rule. For uniformity of experience across all tools that produce SARIF, the friendly name should be a single Pascal-case identifier, for example, 'ProvideRuleFriendlyName'." - }, - "messageStrings": { - "Error_EmptyLocationsArray": { - "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." - }, - "Error_MissingLocationsArray": { - "text": "{0}: This 'result' object does not provide a 'locations' array. This property is required by the {1} service." - }, - "Error_MissingMessageText": { - "text": "{0}: The 'message' object on this 'result' object does not provide a 'text' property. This property is required by the {1} service." - }, - "Error_MissingMessage": { - "text": "{0}: This 'result' object does not provide a 'message' object. This property is required by the {1} service." - }, - "Error_MissingPartialFingerprints": { - "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingName": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'name' value. This property is required by the {1} service." - } - }, - "defaultConfiguration": { - "level": "error" - }, - "helpUri": "http://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html" - }, { "id": "GH1015", "name": "GhasProvideRequiredResultProperties", @@ -176,6 +145,9 @@ "text": "Provide the 'region' property, along with the appropriate region properties. This property is required by the GitHub Advanced Security service.\r\n\r\nProvide the 'artifactLocation' property. This property is required by the GitHub Advanced Security service." }, "messageStrings": { + "Error_MissingArtifactLocationUri": { + "text": "{0}: The 'artifactLocation' object on this 'physicalLocation' object does not provide a 'uri' object. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -190,9 +162,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingArtifactLocationUri": { - "text": "{0}: The 'artifactLocation' object on this 'physicalLocation' object does not provide a 'uri' object. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -207,6 +176,18 @@ "text": "Rule metadata should provide information that makes it easy to understand and fix the problem.\r\n\r\nProvide the 'id' property whose value is a stable identifier for the rule.\r\n\r\nProvide the 'shortDescription' and 'fullDescription' properties.\r\n\r\nProvide the 'help' property and populate the 'text' property with information about the rule." }, "messageStrings": { + "Error_MissingFullDescription": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'fullDescription' value. This property is required by the {1} service." + }, + "Error_MissingHelpText": { + "text": "{0}: This 'help' object does not provide a 'text' value. This property is required by the {1} service." + }, + "Error_MissingHelp": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'help' object. This property is required by the {1} service." + }, + "Error_MissingShortDescription": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'shortDescription' value. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -221,18 +202,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingFullDescription": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'fullDescription' value. This property is required by the {1} service." - }, - "Error_MissingHelpText": { - "text": "{0}: This 'help' object does not provide a 'text' value. This property is required by the {1} service." - }, - "Error_MissingHelp": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'help' object. This property is required by the {1} service." - }, - "Error_MissingShortDescription": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'shortDescription' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -263,6 +232,9 @@ "text": "Provide information that makes it easy to identify the name and version of your tool.\r\n\r\nProvide the 'driver' property. This property is required by the ADO Advanced Security service.\r\n\r\nProvide the driver's 'name' and 'fullName' properties.\r\n\r\nProvide the driver's 'rules' array." }, "messageStrings": { + "Error_MissingDriverFullName": { + "text": "{0}: This 'driver' object does not provide a 'fullName' value. This property is required by the {1} service." + }, "Error_MissingDriverName": { "text": "{0}: The 'driver' object in this tool does not provide a 'name' value. This property is required by the {1} service." }, @@ -271,9 +243,6 @@ }, "Error_MissingDriver": { "text": "{0}: This 'tool' object does not provide a 'driver' object. This property is required by the {1} service." - }, - "Error_MissingDriverFullName": { - "text": "{0}: This 'driver' object does not provide a 'fullName' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -522,67 +491,9 @@ "ResultMatching": {} } }, - { - "ruleId": "ADO2012", - "ruleIndex": 4, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[0]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 1 - }, - "region": { - "startLine": 7, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 4, - "level": "error", - "message": { - "id": "Error_MissingLocationsArray", - "arguments": [ - "runs[0].results[0]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 1 - }, - "region": { - "startLine": 7, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, { "ruleId": "GH1015", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -611,7 +522,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -640,7 +551,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -669,7 +580,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -698,10 +609,10 @@ }, { "ruleId": "GH2012", - "ruleIndex": 7, + "ruleIndex": 6, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[0]", "GitHub Advanced Security" @@ -727,10 +638,10 @@ }, { "ruleId": "GH2012", - "ruleIndex": 7, + "ruleIndex": 6, "level": "error", "message": { - "id": "Error_MissingPartialFingerprints", + "id": "Error_MissingLocationsArray", "arguments": [ "runs[0].results[0]", "GitHub Advanced Security" @@ -756,7 +667,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 8, + "ruleIndex": 7, "level": "note", "message": { "id": "Note_Default", @@ -899,69 +810,11 @@ } }, { - "ruleId": "ADO2012", + "ruleId": "GH1015", "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", - "arguments": [ - "runs[0].results[1]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 1 - }, - "region": { - "startLine": 13, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 4, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[1]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 1 - }, - "region": { - "startLine": 13, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "GH1015", - "ruleIndex": 5, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[1]", "GitHub Advanced Security" @@ -987,10 +840,10 @@ }, { "ruleId": "GH1015", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[1]", "GitHub Advanced Security" @@ -1016,7 +869,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1045,7 +898,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1074,7 +927,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 7, + "ruleIndex": 6, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1103,7 +956,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 7, + "ruleIndex": 6, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1132,7 +985,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 8, + "ruleIndex": 7, "level": "note", "message": { "id": "Note_Default", @@ -1163,7 +1016,7 @@ "ruleIndex": 2, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[2]", "Azure DevOps Advanced Security" @@ -1191,35 +1044,6 @@ "ruleId": "ADO1015", "ruleIndex": 2, "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[2]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 1 - }, - "region": { - "startLine": 19, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO1017", - "ruleIndex": 3, - "level": "error", "message": { "id": "Error_MissingLocationsArray", "arguments": [ @@ -1275,37 +1099,8 @@ } }, { - "ruleId": "ADO2012", - "ruleIndex": 4, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[2]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 1 - }, - "region": { - "startLine": 19, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 4, + "ruleId": "ADO1017", + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1334,7 +1129,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1363,7 +1158,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1392,7 +1187,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1421,7 +1216,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1450,7 +1245,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 7, + "ruleIndex": 6, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1479,7 +1274,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 7, + "ruleIndex": 6, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1508,7 +1303,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 8, + "ruleIndex": 7, "level": "note", "message": { "id": "Note_Default", @@ -1536,7 +1331,7 @@ }, { "ruleId": "ADO1018", - "ruleIndex": 9, + "ruleIndex": 8, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1565,7 +1360,7 @@ }, { "ruleId": "ADO1018", - "ruleIndex": 9, + "ruleIndex": 8, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1594,7 +1389,7 @@ }, { "ruleId": "GH1018", - "ruleIndex": 10, + "ruleIndex": 9, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1623,7 +1418,7 @@ }, { "ruleId": "SARIF2005", - "ruleIndex": 11, + "ruleIndex": 10, "message": { "id": "Warning_ProvideToolVersion", "arguments": [ @@ -1652,7 +1447,7 @@ }, { "ruleId": "SARIF2005", - "ruleIndex": 11, + "ruleIndex": 10, "message": { "id": "Warning_ProvideToolnformationUri", "arguments": [ diff --git a/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1008.ValidateBaseline.InlineUpdate.sarif b/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1008.ValidateBaseline.InlineUpdate.sarif index 15f9d4fce..a0c56af66 100644 --- a/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1008.ValidateBaseline.InlineUpdate.sarif +++ b/src/Test.FunctionalTests.Sarif/TestData/Multitool/BaselineOption/ExpectedOutputs/TEST1008.ValidateBaseline.InlineUpdate.sarif @@ -30,6 +30,9 @@ "text": "The Result object represents an analysis finding and should provide details describing the nature of the problem along with its location in the scan target.\r\n\r\nProvide the 'ruleId' property, which is the unique identifier of the analysis rule that was violated. This property is required by the ADO Advanced Security service.\r\n\r\nProvide the 'message' property, which is a user-facing explanation of the result occurrence. The message's 'text' property is required by the ADO Advanced Security service.\r\n\r\nProvide the 'locations' array, which must contain at least one location object.\r\n\r\nProvide the 'partialFingerprints' dictionary. This property is required by the ADO Advanced Security service." }, "messageStrings": { + "Error_MissingRuleId": { + "text": "{0}: This 'result' object does not provide a 'ruleId' value. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -44,9 +47,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingRuleId": { - "text": "{0}: This 'result' object does not provide a 'ruleId' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -82,37 +82,6 @@ }, "helpUri": "http://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html" }, - { - "id": "ADO2012", - "name": "AdoProvideRequiredReportingDescriptorProperties", - "fullDescription": { - "text": "Rule metadata should provide information that makes it easy to understand and fix the problem.\r\nrule.id\r\n\r\nProvide the 'id' property whose value is a stable identifier for the rule.\r\n\r\nProvide the 'name' property, which contains a \"friendly name\" that helps users see at a glance the purpose of the rule. For uniformity of experience across all tools that produce SARIF, the friendly name should be a single Pascal-case identifier, for example, 'ProvideRuleFriendlyName'." - }, - "messageStrings": { - "Error_EmptyLocationsArray": { - "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." - }, - "Error_MissingLocationsArray": { - "text": "{0}: This 'result' object does not provide a 'locations' array. This property is required by the {1} service." - }, - "Error_MissingMessageText": { - "text": "{0}: The 'message' object on this 'result' object does not provide a 'text' property. This property is required by the {1} service." - }, - "Error_MissingMessage": { - "text": "{0}: This 'result' object does not provide a 'message' object. This property is required by the {1} service." - }, - "Error_MissingPartialFingerprints": { - "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingName": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'name' value. This property is required by the {1} service." - } - }, - "defaultConfiguration": { - "level": "error" - }, - "helpUri": "http://docs.oasis-open.org/sarif/sarif/v2.1.0/sarif-v2.1.0.html" - }, { "id": "GH1015", "name": "GhasProvideRequiredResultProperties", @@ -148,6 +117,9 @@ "text": "Provide the 'region' property, along with the appropriate region properties. This property is required by the GitHub Advanced Security service.\r\n\r\nProvide the 'artifactLocation' property. This property is required by the GitHub Advanced Security service." }, "messageStrings": { + "Error_MissingArtifactLocationUri": { + "text": "{0}: The 'artifactLocation' object on this 'physicalLocation' object does not provide a 'uri' object. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -162,9 +134,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingArtifactLocationUri": { - "text": "{0}: The 'artifactLocation' object on this 'physicalLocation' object does not provide a 'uri' object. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -179,6 +148,18 @@ "text": "Rule metadata should provide information that makes it easy to understand and fix the problem.\r\n\r\nProvide the 'id' property whose value is a stable identifier for the rule.\r\n\r\nProvide the 'shortDescription' and 'fullDescription' properties.\r\n\r\nProvide the 'help' property and populate the 'text' property with information about the rule." }, "messageStrings": { + "Error_MissingFullDescription": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'fullDescription' value. This property is required by the {1} service." + }, + "Error_MissingHelpText": { + "text": "{0}: This 'help' object does not provide a 'text' value. This property is required by the {1} service." + }, + "Error_MissingHelp": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'help' object. This property is required by the {1} service." + }, + "Error_MissingShortDescription": { + "text": "{0}: This 'reportingDescriptor' object does not provide a 'shortDescription' value. This property is required by the {1} service." + }, "Error_EmptyLocationsArray": { "text": "{0}: The 'locations' array on this 'result' object is empty. This property is required by the {1} service." }, @@ -193,18 +174,6 @@ }, "Error_MissingPartialFingerprints": { "text": "{0}: This 'result' object does not provide a 'partialFingerprints' dictionary. This property is required by the {1} service." - }, - "Error_MissingFullDescription": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'fullDescription' value. This property is required by the {1} service." - }, - "Error_MissingHelpText": { - "text": "{0}: This 'help' object does not provide a 'text' value. This property is required by the {1} service." - }, - "Error_MissingHelp": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'help' object. This property is required by the {1} service." - }, - "Error_MissingShortDescription": { - "text": "{0}: This 'reportingDescriptor' object does not provide a 'shortDescription' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -235,6 +204,9 @@ "text": "Provide information that makes it easy to identify the name and version of your tool.\r\n\r\nProvide the 'driver' property. This property is required by the ADO Advanced Security service.\r\n\r\nProvide the driver's 'name' and 'fullName' properties.\r\n\r\nProvide the driver's 'rules' array." }, "messageStrings": { + "Error_MissingDriverFullName": { + "text": "{0}: This 'driver' object does not provide a 'fullName' value. This property is required by the {1} service." + }, "Error_MissingDriverName": { "text": "{0}: The 'driver' object in this tool does not provide a 'name' value. This property is required by the {1} service." }, @@ -243,9 +215,6 @@ }, "Error_MissingDriver": { "text": "{0}: This 'tool' object does not provide a 'driver' object. This property is required by the {1} service." - }, - "Error_MissingDriverFullName": { - "text": "{0}: This 'driver' object does not provide a 'fullName' value. This property is required by the {1} service." } }, "defaultConfiguration": { @@ -487,67 +456,9 @@ "ResultMatching": {} } }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[0]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 7, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingLocationsArray", - "arguments": [ - "runs[0].results[0]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 7, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -576,7 +487,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -605,7 +516,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -634,7 +545,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -663,10 +574,10 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[0]", "GitHub Advanced Security" @@ -692,10 +603,10 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { - "id": "Error_MissingPartialFingerprints", + "id": "Error_MissingLocationsArray", "arguments": [ "runs[0].results[0]", "GitHub Advanced Security" @@ -721,7 +632,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 7, + "ruleIndex": 6, "level": "note", "message": { "id": "Note_Default", @@ -864,69 +775,11 @@ } }, { - "ruleId": "ADO2012", + "ruleId": "GH1015", "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingLocationsArray", - "arguments": [ - "runs[0].results[1]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 13, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[1]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 13, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "GH1015", - "ruleIndex": 4, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[1]", "GitHub Advanced Security" @@ -952,10 +805,10 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[1]", "GitHub Advanced Security" @@ -981,7 +834,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1010,7 +863,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1039,7 +892,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1068,7 +921,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1097,7 +950,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 7, + "ruleIndex": 6, "level": "note", "message": { "id": "Note_Default", @@ -1128,7 +981,7 @@ "ruleIndex": 1, "level": "error", "message": { - "id": "Error_MissingLocationsArray", + "id": "Error_MissingPartialFingerprints", "arguments": [ "runs[0].results[2]", "Azure DevOps Advanced Security" @@ -1156,35 +1009,6 @@ "ruleId": "ADO1015", "ruleIndex": 1, "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[2]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 19, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO1017", - "ruleIndex": 2, - "level": "error", "message": { "id": "Error_MissingLocationsArray", "arguments": [ @@ -1240,37 +1064,8 @@ } }, { - "ruleId": "ADO2012", - "ruleIndex": 3, - "level": "error", - "message": { - "id": "Error_MissingPartialFingerprints", - "arguments": [ - "runs[0].results[2]", - "Azure DevOps Advanced Security" - ] - }, - "locations": [ - { - "physicalLocation": { - "artifactLocation": { - "index": 0 - }, - "region": { - "startLine": 19, - "startColumn": 9 - } - } - } - ], - "baselineState": "new", - "properties": { - "ResultMatching": {} - } - }, - { - "ruleId": "ADO2012", - "ruleIndex": 3, + "ruleId": "ADO1017", + "ruleIndex": 2, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1299,7 +1094,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1328,7 +1123,7 @@ }, { "ruleId": "GH1015", - "ruleIndex": 4, + "ruleIndex": 3, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1357,7 +1152,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1386,7 +1181,7 @@ }, { "ruleId": "GH1017", - "ruleIndex": 5, + "ruleIndex": 4, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1415,7 +1210,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingLocationsArray", @@ -1444,7 +1239,7 @@ }, { "ruleId": "GH2012", - "ruleIndex": 6, + "ruleIndex": 5, "level": "error", "message": { "id": "Error_MissingPartialFingerprints", @@ -1473,7 +1268,7 @@ }, { "ruleId": "SARIF2002", - "ruleIndex": 7, + "ruleIndex": 6, "level": "note", "message": { "id": "Note_Default", @@ -1501,7 +1296,7 @@ }, { "ruleId": "ADO1018", - "ruleIndex": 8, + "ruleIndex": 7, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1530,7 +1325,7 @@ }, { "ruleId": "ADO1018", - "ruleIndex": 8, + "ruleIndex": 7, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1559,7 +1354,7 @@ }, { "ruleId": "GH1018", - "ruleIndex": 9, + "ruleIndex": 8, "level": "error", "message": { "id": "Error_MissingDriverRules", @@ -1588,7 +1383,7 @@ }, { "ruleId": "SARIF2005", - "ruleIndex": 10, + "ruleIndex": 9, "message": { "id": "Warning_ProvideToolVersion", "arguments": [ @@ -1617,7 +1412,7 @@ }, { "ruleId": "SARIF2005", - "ruleIndex": 10, + "ruleIndex": 9, "message": { "id": "Warning_ProvideToolnformationUri", "arguments": [ @@ -1645,7 +1440,7 @@ }, { "ruleId": "SARIF2012", - "ruleIndex": 11, + "ruleIndex": 10, "level": "note", "message": { "id": "Note_ProvideMetadataForAllViolatedRules", From d6d80621aa032c80bec392f9e925b7e7799ca671 Mon Sep 17 00:00:00 2001 From: Chris Meyer Date: Thu, 29 Feb 2024 10:30:04 -1000 Subject: [PATCH 03/19] Release v4.5.4 (#2798) * Release v4.5.4 * Update ReleaseHistory.md --- ReleaseHistory.md | 4 +++- src/build.props | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ReleaseHistory.md b/ReleaseHistory.md index 1ea303003..2d169fffe 100644 --- a/ReleaseHistory.md +++ b/ReleaseHistory.md @@ -1,4 +1,7 @@ # SARIF Package Release History (SDK, Driver, Converters, and Multitool) +## **v4.5.4 [Sdk](https://www.nuget.org/packages/Sarif.Sdk/v4.5.4) | [Driver](https://www.nuget.org/packages/Sarif.Driver/v4.5.4) | [Converters](https://www.nuget.org/packages/Sarif.Converters/v4.5.4) | [Multitool](https://www.nuget.org/packages/Sarif.Multitool/v4.5.4) | [Multitool Library](https://www.nuget.org/packages/Sarif.Multitool.Library/v4.5.4) +* BUG: Fix incorrect base class in rule ADO2012. + ## **v4.5.3 [Sdk](https://www.nuget.org/packages/Sarif.Sdk/v4.5.3) | [Driver](https://www.nuget.org/packages/Sarif.Driver/v4.5.3) | [Converters](https://www.nuget.org/packages/Sarif.Converters/v4.5.3) | [Multitool](https://www.nuget.org/packages/Sarif.Multitool/v4.5.3) | [Multitool Library](https://www.nuget.org/packages/Sarif.Multitool.Library/v4.5.3) * BUG: Restructure shared MessageResourceNames collections to ensure return of correct error messages. @@ -7,7 +10,6 @@ * BUG: Fix message strings to always assume {1} is reserved for the rule's service name. * BUG: Clean up unused resource strings in Multitool.Library.Rules.RuleResources.resx. -# SARIF Package Release History (SDK, Driver, Converters, and Multitool) ## **v4.5.1 [Sdk](https://www.nuget.org/packages/Sarif.Sdk/v4.5.1) | [Driver](https://www.nuget.org/packages/Sarif.Driver/v4.5.1) | [Converters](https://www.nuget.org/packages/Sarif.Converters/v4.5.1) | [Multitool](https://www.nuget.org/packages/Sarif.Multitool/v4.5.1) | [Multitool Library](https://www.nuget.org/packages/Sarif.Multitool.Library/v4.5.1) * DEP: Add explicit package references to `Sarif` and `Sarif.Driver` to resolve version conflict build error. `System.Diagnostics.Debug` 4.3.0, diff --git a/src/build.props b/src/build.props index 28667d6e3..3f03201f8 100644 --- a/src/build.props +++ b/src/build.props @@ -10,8 +10,8 @@ Microsoft Microsoft SARIF SDK © Microsoft Corporation. All rights reserved. - 4.5.3 - 4.5.2 + 4.5.4 + 4.5.3 2.1.0-rtm.6 From a61cf945a714eb875a4b35bab1f7f1497e4456a3 Mon Sep 17 00:00:00 2001 From: Shaopeng <81775155+shaopeng-gh@users.noreply.github.com> Date: Thu, 14 Mar 2024 18:16:02 -0700 Subject: [PATCH 04/19] Fix hangs when file path is provided with wildcard without recurse flag (#2800) * * BUG: Resolve hangs when file path is provided with wildchar but without `-r` (recurse) flag during multithreaded analysis file enumeration phase. * update release notes * fix release note * update release note * Use only one try block * Add test * Use `#if DEBUG` since the `analyze-test` is under that flag. * use ChannelCapacity --- ReleaseHistory.md | 4 ++ src/Sarif.Driver/OrderedFileSpecifier.cs | 27 ++++---- .../MultitoolCommandLineTests.cs | 64 +++++++++++++++++++ 3 files changed, 80 insertions(+), 15 deletions(-) diff --git a/ReleaseHistory.md b/ReleaseHistory.md index 2d169fffe..b3818a721 100644 --- a/ReleaseHistory.md +++ b/ReleaseHistory.md @@ -1,4 +1,8 @@ # SARIF Package Release History (SDK, Driver, Converters, and Multitool) + +## UNRELEASED +* BUG: Resolve process hangs when a file path is provided with a wildcard, but without a `-r` (recurse) flag during the multi-threaded analysis file enumeration phase. + ## **v4.5.4 [Sdk](https://www.nuget.org/packages/Sarif.Sdk/v4.5.4) | [Driver](https://www.nuget.org/packages/Sarif.Driver/v4.5.4) | [Converters](https://www.nuget.org/packages/Sarif.Converters/v4.5.4) | [Multitool](https://www.nuget.org/packages/Sarif.Multitool/v4.5.4) | [Multitool Library](https://www.nuget.org/packages/Sarif.Multitool.Library/v4.5.4) * BUG: Fix incorrect base class in rule ADO2012. diff --git a/src/Sarif.Driver/OrderedFileSpecifier.cs b/src/Sarif.Driver/OrderedFileSpecifier.cs index 5f3dc78c1..0498d8e2e 100644 --- a/src/Sarif.Driver/OrderedFileSpecifier.cs +++ b/src/Sarif.Driver/OrderedFileSpecifier.cs @@ -26,7 +26,7 @@ public OrderedFileSpecifier(string specifier, FileSystem = fileSystem ?? Sarif.FileSystem.Instance; } - private const int ChannelCapacity = 10 * 1024; // max ~2.5 MB memory given 256 char max path length. + internal const int ChannelCapacity = 10 * 1024; // max ~2.5 MB memory given 256 char max path length. private readonly bool recurse; private readonly string specifier; private readonly long maxFileSizeInKilobytes; @@ -87,27 +87,24 @@ private IEnumerable EnumeratedArtifacts() Task directoryEnumerationTask; - if (this.recurse) + directoryEnumerationTask = Task.Run(() => { - directoryEnumerationTask = Task.Run(() => + try { - try + if (this.recurse) { EnqueueAllFilesUnderDirectory(directory, filesToProcessChannel.Writer, filter, new SortedSet(StringComparer.Ordinal)); } - finally + else { - filesToProcessChannel.Writer.Complete(); + WriteFilesInDirectoryToChannel(directory, filesToProcessChannel, filter, new SortedSet(StringComparer.Ordinal)); } - }); - } - else - { - WriteFilesInDirectoryToChannel(directory, filesToProcessChannel, filter, new SortedSet(StringComparer.Ordinal)); - - filesToProcessChannel.Writer.Complete(); - directoryEnumerationTask = Task.CompletedTask; - } + } + finally + { + filesToProcessChannel.Writer.Complete(); + } + }); ChannelReader reader = filesToProcessChannel.Reader; while (!reader.Completion.IsCompleted) diff --git a/src/Test.FunctionalTests.Sarif/MultitoolCommandLineTests.cs b/src/Test.FunctionalTests.Sarif/MultitoolCommandLineTests.cs index 1b7691c1a..0fd37f4ff 100644 --- a/src/Test.FunctionalTests.Sarif/MultitoolCommandLineTests.cs +++ b/src/Test.FunctionalTests.Sarif/MultitoolCommandLineTests.cs @@ -5,6 +5,9 @@ using System.IO; using FluentAssertions; +using FluentAssertions.Execution; + +using Microsoft.CodeAnalysis.Sarif.Driver; using Xunit; @@ -35,5 +38,66 @@ public void Multitool_LaunchesAndRunsSuccessfully() process.ExitCode.Should().Be(0); } } + +#if DEBUG + [Fact] + [Trait(TestTraits.WindowsOnly, "true")] + public void Multitool_LaunchesAndRunsSuccessfully_WithNumberOfFilesExceedingChannelCapacity() + { + using var assertionScope = new AssertionScope(); + + string multitoolPath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), + @"..\..\Sarif.Multitool\netcoreapp3.1\Sarif.Multitool.exe")); + + string directoryPath = Path.Combine(Path.GetTempPath(), "SarifMultitoolTestFilesWithNumberOfFilesExceedingChannelCapacity"); + + if (Directory.Exists(directoryPath)) + { + Directory.Delete(directoryPath, true); + } + + Directory.CreateDirectory(directoryPath); + + int fileCount = OrderedFileSpecifier.ChannelCapacity + 1; + + for (int i = 1; i <= fileCount; i++) + { + string filename = $"file_{i}.txt"; + string filepath = Path.Combine(directoryPath, filename); + File.WriteAllText(filepath, " "); + } + + var startInfo = new ProcessStartInfo(multitoolPath, $@"analyze-test {directoryPath}\*") + { + WindowStyle = ProcessWindowStyle.Hidden, + CreateNoWindow = true, + RedirectStandardOutput = true, + UseShellExecute = false + }; + + using (var process = Process.Start(startInfo)) + { + var timer = new System.Timers.Timer(30000); // 30 seconds. + timer.Elapsed += (sender, e) => + { + if (!process.HasExited) + { + process.Kill(); + } + }; + timer.Start(); + string output = process.StandardOutput.ReadToEnd(); + process.WaitForExit(); + timer.Stop(); + process.ExitCode.Should().Be(0); + output.Should().Contain( + $"Done. {fileCount:n0} files scanned.", + $"analyzing {fileCount:n0} small files should not result in freezing and should finish within 30 seconds, " + + "typically completing in just 5 seconds"); + } + + Directory.Delete(directoryPath, true); + } +#endif } } From 1ddaf2a87f45ddeeafaa38c15fe55c7e16fbb6aa Mon Sep 17 00:00:00 2001 From: scottoneil-ms <145607305+scottoneil-ms@users.noreply.github.com> Date: Fri, 19 Apr 2024 16:20:34 -0700 Subject: [PATCH 05/19] Expose utility method for building a disabled skimmers set. (#2787) * make the code for building the disabled skimmers set into public utility code * fixups * buildFix * fix pr comment --- ReleaseHistory.md | 1 + .../Sdk/MultithreadedAnalyzeCommandBase.cs | 25 ++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ReleaseHistory.md b/ReleaseHistory.md index b3818a721..9979d179d 100644 --- a/ReleaseHistory.md +++ b/ReleaseHistory.md @@ -19,6 +19,7 @@ `System.Diagnostics.Debug` 4.3.0, `System.IO.FileSystem.Primitives` 4.3.0, `System.Text.Encoding.Extensions` 4.3.0. +* NEW: Expose `MultithreadedAnalyzeCommandBase.BuildDisabledSkimmersSet`, a utility function which extracts a disabled skimmer set from a `TContext`. ## **v4.5.0 [Sdk](https://www.nuget.org/packages/Sarif.Sdk/v4.5.0) | [Driver](https://www.nuget.org/packages/Sarif.Driver/v4.5.0) | [Converters](https://www.nuget.org/packages/Sarif.Converters/v4.5.0) | [Multitool](https://www.nuget.org/packages/Sarif.Multitool/v4.5.0) | [Multitool Library](https://www.nuget.org/packages/Sarif.Multitool.Library/v4.5.0) * DEP: Downgrade `System.Text.Encoding.CodePages` from 8.0.0 to 4.3.0 in `Sarif`. diff --git a/src/Sarif.Driver/Sdk/MultithreadedAnalyzeCommandBase.cs b/src/Sarif.Driver/Sdk/MultithreadedAnalyzeCommandBase.cs index 7e3ab3a95..704dc6291 100644 --- a/src/Sarif.Driver/Sdk/MultithreadedAnalyzeCommandBase.cs +++ b/src/Sarif.Driver/Sdk/MultithreadedAnalyzeCommandBase.cs @@ -1075,6 +1075,21 @@ protected virtual void AnalyzeTargets(TContext context, ThrowExitApplicationException(ExitReason.NoRulesLoaded); } + ISet disabledSkimmers = BuildDisabledSkimmersSet(context, skimmers); + + if (disabledSkimmers.Count == skimmers.Count()) + { + Errors.LogAllRulesExplicitlyDisabled(context); + ThrowExitApplicationException(ExitReason.NoRulesLoaded); + } + + this.CheckIncompatibleRules(skimmers, context, disabledSkimmers); + + MultithreadedAnalyzeTargets(context, skimmers, disabledSkimmers); + } + + public static ISet BuildDisabledSkimmersSet(TContext context, IEnumerable> skimmers) + { var disabledSkimmers = new SortedSet(); foreach (Skimmer skimmer in skimmers) @@ -1108,15 +1123,7 @@ protected virtual void AnalyzeTargets(TContext context, } } - if (disabledSkimmers.Count == skimmers.Count()) - { - Errors.LogAllRulesExplicitlyDisabled(context); - ThrowExitApplicationException(ExitReason.NoRulesLoaded); - } - - this.CheckIncompatibleRules(skimmers, context, disabledSkimmers); - - MultithreadedAnalyzeTargets(context, skimmers, disabledSkimmers); + return disabledSkimmers; } protected virtual TContext DetermineApplicabilityAndAnalyze(TContext context, From 9e95888f74d0e23a782d864674a044ddc1604ee1 Mon Sep 17 00:00:00 2001 From: Shaopeng <81775155+shaopeng-gh@users.noreply.github.com> Date: Fri, 26 Apr 2024 12:57:32 -0700 Subject: [PATCH 06/19] Fix error `ERR997.NoValidAnalysisTargets` when scanning symbolic link files (#2801) * Add IsSymbolicLink * Use Mock * release note * Add IsSymbolicLinkTestCases * Add comment * Use FileStreamLength * Revert change in RetrieveDataFromStream * Use old syntax for new string[] {} --------- Co-authored-by: Michael C. Fanning --- ReleaseHistory.md | 1 + src/Sarif/EnumeratedArtifact.cs | 4 +- src/Sarif/FileSystem.cs | 33 +++++++ src/Sarif/IFileSystem.cs | 22 +++++ .../Sdk/AnalyzeCommandBaseTests.cs | 95 ++++++++++++++++--- src/Test.UnitTests.Sarif/FileSystemTests.cs | 78 +++++++++++++++ 6 files changed, 220 insertions(+), 13 deletions(-) create mode 100644 src/Test.UnitTests.Sarif/FileSystemTests.cs diff --git a/ReleaseHistory.md b/ReleaseHistory.md index 9979d179d..b321e5171 100644 --- a/ReleaseHistory.md +++ b/ReleaseHistory.md @@ -2,6 +2,7 @@ ## UNRELEASED * BUG: Resolve process hangs when a file path is provided with a wildcard, but without a `-r` (recurse) flag during the multi-threaded analysis file enumeration phase. +* BUG: Fix error `ERR997.NoValidAnalysisTargets` when scanning symbolic link files. ## **v4.5.4 [Sdk](https://www.nuget.org/packages/Sarif.Sdk/v4.5.4) | [Driver](https://www.nuget.org/packages/Sarif.Driver/v4.5.4) | [Converters](https://www.nuget.org/packages/Sarif.Converters/v4.5.4) | [Multitool](https://www.nuget.org/packages/Sarif.Multitool/v4.5.4) | [Multitool Library](https://www.nuget.org/packages/Sarif.Multitool.Library/v4.5.4) * BUG: Fix incorrect base class in rule ADO2012. diff --git a/src/Sarif/EnumeratedArtifact.cs b/src/Sarif/EnumeratedArtifact.cs index b4610a36d..ca37ce503 100644 --- a/src/Sarif/EnumeratedArtifact.cs +++ b/src/Sarif/EnumeratedArtifact.cs @@ -164,7 +164,9 @@ public long? SizeInBytes } else if (Uri != null && Uri.IsAbsoluteUri && Uri.IsFile) { - this.sizeInBytes = (long)FileSystem.FileInfoLength(Uri.LocalPath); + this.sizeInBytes = FileSystem.IsSymbolicLink(Uri.LocalPath) + ? (long)FileSystem.FileStreamLength(Uri.LocalPath) + : (long)FileSystem.FileInfoLength(Uri.LocalPath); } else if (this.Contents != null) { diff --git a/src/Sarif/FileSystem.cs b/src/Sarif/FileSystem.cs index 165a55937..515538578 100644 --- a/src/Sarif/FileSystem.cs +++ b/src/Sarif/FileSystem.cs @@ -189,6 +189,21 @@ public string FileReadAllText(string path) return textReader.ReadToEnd(); } + /// + /// Uses to get the size of a file in bytes. + /// + /// + /// The fully qualified name or relative name of the file. + /// + /// + /// A long representing the size of the file in bytes. + /// + public long FileStreamLength(string path) + { + using var fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); + return fileStream.Length; + } + /// /// Opens a text file, reads all text in the file as a single string using the specified /// encoding, and then closes the file. @@ -388,6 +403,24 @@ public long FileInfoLength(string path) return fileInfo.Length; } + /// + /// Uses to determine whether a file is a symbolic link. + /// + /// + /// The fully qualified name or relative path of the file. + /// + /// + /// A boolean value indicating whether the file is a symbolic link. + /// + public bool IsSymbolicLink(string path) + { + // https://learn.microsoft.com/en-us/dotnet/api/system.io.fileattributes + // While symbolic links will have the ReparsePoint flag set, not all reparse points represent symbolic links. + // This is a basic implementation. + var fileInfo = new FileInfo(path); + return (fileInfo.Attributes & FileAttributes.ReparsePoint) == FileAttributes.ReparsePoint; + } + /// /// Returns a representing the version information associated with the specified file. /// diff --git a/src/Sarif/IFileSystem.cs b/src/Sarif/IFileSystem.cs index 50dc477e7..0f763b57f 100644 --- a/src/Sarif/IFileSystem.cs +++ b/src/Sarif/IFileSystem.cs @@ -237,6 +237,17 @@ public interface IFileSystem /// string FileReadAllText(string path); + /// + /// Uses to get the size of a file in bytes. + /// + /// + /// The fully qualified name or relative name of the file. + /// + /// + /// A long representing the size of the file in bytes. + /// + long FileStreamLength(string path); + /// /// Opens a text file, reads all text in the file as a single string using the specified /// encoding, and then closes the file. @@ -312,6 +323,17 @@ public interface IFileSystem /// long FileInfoLength(string path); + /// + /// Uses to determine whether a file is a symbolic link. + /// + /// + /// The fully qualified name or relative path of the file. + /// + /// + /// A boolean value indicating whether the file is a symbolic link. + /// + bool IsSymbolicLink(string path); + /// /// Returns a representing the version information associated with the specified file. /// diff --git a/src/Test.UnitTests.Sarif.Driver/Sdk/AnalyzeCommandBaseTests.cs b/src/Test.UnitTests.Sarif.Driver/Sdk/AnalyzeCommandBaseTests.cs index b4f9ea699..1d37641ad 100644 --- a/src/Test.UnitTests.Sarif.Driver/Sdk/AnalyzeCommandBaseTests.cs +++ b/src/Test.UnitTests.Sarif.Driver/Sdk/AnalyzeCommandBaseTests.cs @@ -1099,62 +1099,100 @@ public void MultithreadedAnalyzeCommandBase_TargetFileSizeTestCases() new { expectedExitReason = ExitReason.NoValidAnalysisTargets, fileSizeInBytes = (long)1023, - maxFileSizeInKB = (long)0 + maxFileSizeInKB = (long)0, + isSymbolicLink = false, + actualFileContent = (string)null }, new { expectedExitReason = ExitReason.NoValidAnalysisTargets, fileSizeInBytes =(long)0, - maxFileSizeInKB = (long)0 + maxFileSizeInKB = (long)0, + isSymbolicLink = false, + actualFileContent = (string)null }, new { expectedExitReason = ExitReason.None, fileSizeInBytes = (long)ulong.MinValue + 1, - maxFileSizeInKB = (long)1 + maxFileSizeInKB = (long)1, + isSymbolicLink = false, + actualFileContent = (string)null }, new { expectedExitReason = ExitReason.None, fileSizeInBytes = (long)ulong.MinValue + 1, - maxFileSizeInKB = (long)2000 + maxFileSizeInKB = (long)2000, + isSymbolicLink = false, + actualFileContent = (string)null }, new { expectedExitReason = ExitReason.NoValidAnalysisTargets, fileSizeInBytes = (long)ulong.MinValue, - maxFileSizeInKB = (long)1000 + maxFileSizeInKB = (long)1000, + isSymbolicLink = false, + actualFileContent = (string)null }, new { expectedExitReason = ExitReason.NoValidAnalysisTargets, fileSizeInBytes = (long)ulong.MinValue, - maxFileSizeInKB = long.MaxValue + maxFileSizeInKB = long.MaxValue, + isSymbolicLink = false, + actualFileContent = (string)null + }, + new { + expectedExitReason = ExitReason.None, + fileSizeInBytes = (long)ulong.MinValue, + maxFileSizeInKB = long.MaxValue, + isSymbolicLink = true, + actualFileContent = "ABC123" + }, + new { + expectedExitReason = ExitReason.NoValidAnalysisTargets, + fileSizeInBytes = (long)ulong.MinValue, + maxFileSizeInKB = long.MaxValue, + isSymbolicLink = true, + actualFileContent = "" }, new { expectedExitReason = ExitReason.NoValidAnalysisTargets, fileSizeInBytes = (long)(1024 * 2), - maxFileSizeInKB = (long)1 + maxFileSizeInKB = (long)1, + isSymbolicLink = false, + actualFileContent = (string)null }, new { expectedExitReason = ExitReason.None, fileSizeInBytes = (long)(1024 * 2), - maxFileSizeInKB = (long)3 + maxFileSizeInKB = (long)3, + isSymbolicLink = false, + actualFileContent = (string)null }, new { expectedExitReason = ExitReason.None, fileSizeInBytes = (long)20000, - maxFileSizeInKB = long.MaxValue + maxFileSizeInKB = long.MaxValue, + isSymbolicLink = false, + actualFileContent = (string)null }, new { expectedExitReason = ExitReason.None, fileSizeInBytes = (long)1024, - maxFileSizeInKB = (long)1 + maxFileSizeInKB = (long)1, + isSymbolicLink = false, + actualFileContent = (string)null }, new { expectedExitReason = ExitReason.NoValidAnalysisTargets, fileSizeInBytes = long.MaxValue, - maxFileSizeInKB = (long)0 + maxFileSizeInKB = (long)0, + isSymbolicLink = false, + actualFileContent = (string)null }, new { expectedExitReason = ExitReason.None, fileSizeInBytes =long.MaxValue - 1, - maxFileSizeInKB = long.MaxValue + maxFileSizeInKB = long.MaxValue, + isSymbolicLink = false, + actualFileContent = (string)null }, }; @@ -1182,6 +1220,38 @@ public void MultithreadedAnalyzeCommandBase_TargetFileSizeTestCases() mockStream.Setup(m => m.ReadByte()).Returns('a'); var mockFileSystem = new Mock(); + + if (testCase.actualFileContent != null) + { + byte[] dataBytes = Encoding.UTF8.GetBytes(testCase.actualFileContent); + mockStream.Setup(m => m.Length).Returns(dataBytes.Length); + mockFileSystem.Setup(x => x.FileStreamLength(It.IsAny())).Returns(dataBytes.Length); + int invocationCount = 0; + + mockStream.Setup(stream => stream.Seek(0, SeekOrigin.Begin)) + .Callback(() => + { + invocationCount = 0; + }); + + mockStream.Setup(stream => stream.Read(It.IsAny(), It.IsAny(), It.IsAny())) + .Returns((byte[] buffer, int offset, int count) => + { + if (invocationCount < dataBytes.Length) + { + Array.Copy(dataBytes, invocationCount, buffer, offset, Math.Min(count, dataBytes.Length - invocationCount)); + int bytesRead = Math.Min(count, dataBytes.Length - invocationCount); + invocationCount += bytesRead; + return bytesRead; + } + else + { + invocationCount = 0; + return 0; + } + }); + } + mockFileSystem.Setup(x => x.DirectoryExists(It.IsAny())).Returns(true); mockFileSystem.Setup(x => x.DirectoryGetFiles(It.IsAny(), specifier)).Returns(files); mockFileSystem.Setup(x => x.FileExists(It.Is(s => s.EndsWith(specifier)))).Returns(true); @@ -1191,6 +1261,7 @@ public void MultithreadedAnalyzeCommandBase_TargetFileSizeTestCases() mockFileSystem.Setup(x => x.FileOpenRead(It.IsAny())).Returns(mockStream.Object); mockFileSystem.Setup(x => x.FileExists(tempFile.Name)).Returns(true); mockFileSystem.Setup(x => x.FileInfoLength(It.IsAny())).Returns((long)testCase.fileSizeInBytes); + mockFileSystem.Setup(x => x.IsSymbolicLink(It.IsAny())).Returns((bool)testCase.isSymbolicLink); bool expectedToBeWithinLimits = testCase.fileSizeInBytes != 0 && diff --git a/src/Test.UnitTests.Sarif/FileSystemTests.cs b/src/Test.UnitTests.Sarif/FileSystemTests.cs new file mode 100644 index 000000000..4dff5773e --- /dev/null +++ b/src/Test.UnitTests.Sarif/FileSystemTests.cs @@ -0,0 +1,78 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.IO; + +using FluentAssertions; + +using Xunit; + +namespace Microsoft.CodeAnalysis.Sarif +{ + + public class FileSystemTests + { + [Fact] + [Trait(TestTraits.WindowsOnly, "true")] + public void FileSystem_IsSymbolicLinkTestCases() + { + var mockFileSystem = new FileSystem(); + + mockFileSystem.IsSymbolicLink(Environment.SystemDirectory).Should().BeFalse(); + mockFileSystem.IsSymbolicLink(Path.Combine(Environment.SystemDirectory, "notepad.exe")).Should().BeFalse(); + + string tempFolder = Path.GetTempPath(); + string folderTarget = Path.Combine(tempFolder, "symbolicLinkFolderTarget"); + string folderSource = Path.Combine(tempFolder, "symbolicLinkFolderSource"); + string fileTarget = Path.Combine(tempFolder, "symbolicLinkFileTarget.txt"); + string fileSource = Path.Combine(tempFolder, "symbolicLinkFileSource.txt"); + + CleanupDirectoryOrFile(new string[] { folderTarget, folderSource, fileTarget, fileSource }); + + Directory.CreateDirectory(folderTarget); + File.WriteAllText(fileTarget, "This is the target file."); + + CreateSymbolicLink(folderSource, folderTarget, isDirectory: true); + CreateSymbolicLink(fileSource, fileTarget, isDirectory: false); + + mockFileSystem.IsSymbolicLink(folderSource).Should().BeTrue(); + mockFileSystem.IsSymbolicLink(folderTarget).Should().BeFalse(); + mockFileSystem.IsSymbolicLink(fileSource).Should().BeTrue(); + mockFileSystem.IsSymbolicLink(fileTarget).Should().BeFalse(); + + CleanupDirectoryOrFile(new string[] { folderTarget, folderSource, fileTarget, fileSource }); + } + + private void CreateSymbolicLink(string linkPath, string targetPath, bool isDirectory) + { + string targetType = isDirectory ? "/D" : ""; + var processStartInfo = new System.Diagnostics.ProcessStartInfo + { + FileName = "cmd.exe", + Arguments = $"/c mklink {targetType} \"{linkPath}\" \"{targetPath}\"", + UseShellExecute = false, + CreateNoWindow = true + }; + using (var process = System.Diagnostics.Process.Start(processStartInfo)) + { + process.WaitForExit(); + } + } + + private void CleanupDirectoryOrFile(string[] paths) + { + foreach (string path in paths) + { + if (Directory.Exists(path)) + { + Directory.Delete(path, true); + } + else if (File.Exists(path)) + { + File.Delete(path); + } + } + } + } +} From ab7f7b1925e6657a00434c64d6d233c205b3fca7 Mon Sep 17 00:00:00 2001 From: LingZhou-gh <119978670+LingZhou-gh@users.noreply.github.com> Date: Tue, 30 Apr 2024 14:03:43 -0700 Subject: [PATCH 07/19] Update `Azure.Identity` reference from 1.10.2 to 1.11.0 in `WorkItems` and `Sarif.Multitool.Library` to resolve [CVE-2024-29992] (#2809) Co-authored-by: Ling Zhou --- ReleaseHistory.md | 1 + src/Sarif.Multitool.Library/Sarif.Multitool.Library.csproj | 2 +- src/WorkItems/WorkItems.csproj | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ReleaseHistory.md b/ReleaseHistory.md index b321e5171..d3cf0cf1e 100644 --- a/ReleaseHistory.md +++ b/ReleaseHistory.md @@ -1,6 +1,7 @@ # SARIF Package Release History (SDK, Driver, Converters, and Multitool) ## UNRELEASED +* DEP: Update `Azure.Identity` reference from 1.10.2 to 1.11.0 in `WorkItems` and `Sarif.Multitool.Library` to resolve [CVE-2024-29992](https://github.com/advisories/GHSA-wvxc-855f-jvrv). * BUG: Resolve process hangs when a file path is provided with a wildcard, but without a `-r` (recurse) flag during the multi-threaded analysis file enumeration phase. * BUG: Fix error `ERR997.NoValidAnalysisTargets` when scanning symbolic link files. diff --git a/src/Sarif.Multitool.Library/Sarif.Multitool.Library.csproj b/src/Sarif.Multitool.Library/Sarif.Multitool.Library.csproj index e81ca0d69..1d0e8a7d8 100644 --- a/src/Sarif.Multitool.Library/Sarif.Multitool.Library.csproj +++ b/src/Sarif.Multitool.Library/Sarif.Multitool.Library.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/WorkItems/WorkItems.csproj b/src/WorkItems/WorkItems.csproj index ba7461325..9fc085373 100644 --- a/src/WorkItems/WorkItems.csproj +++ b/src/WorkItems/WorkItems.csproj @@ -24,7 +24,7 @@ - + From cdc9e157cdb9f1030eeaded961359653f7b0c9c7 Mon Sep 17 00:00:00 2001 From: Marco Gario Date: Mon, 24 Jun 2024 20:53:50 +0200 Subject: [PATCH 08/19] Remove unused rule from github.config.xml (#2813) The rule is now checking for more than just the HelpUri. Specifically, it requires the name of the rule to use PascalCase. This is confusing because this is not a requirement we have in Code Scanning. Because Code Scanning do not show the HelpUri in the UI and it is only provided in the API for backwards compatibility, this commit removes the rule altogether. --- policies/github.config.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/policies/github.config.xml b/policies/github.config.xml index f29db5a9b..43acbac4b 100644 --- a/policies/github.config.xml +++ b/policies/github.config.xml @@ -4,10 +4,6 @@ - - - - From c403cd930a2cc79d6a458ffae9c4159277b71737 Mon Sep 17 00:00:00 2001 From: Ross Wollman Date: Mon, 15 Jul 2024 11:16:12 -0700 Subject: [PATCH 09/19] chore: remove unused coyote bits (#2816) --- .../CoyoteTestOutputLogger.cs | 160 ------------------ .../Test.UnitTests.Sarif.Driver.csproj | 9 +- .../rewrite.coyote.Windows.Debug.json | 4 - .../rewrite.coyote.Windows.Release.json | 4 - .../rewrite.coyote.nonWindows.Debug.json | 4 - .../rewrite.coyote.nonWindows.Release.json | 4 - .../rewriteUnitTests.ps1 | 12 -- 7 files changed, 1 insertion(+), 196 deletions(-) delete mode 100644 src/Test.UnitTests.Sarif.Driver/CoyoteTestOutputLogger.cs delete mode 100644 src/Test.UnitTests.Sarif.Driver/rewrite.coyote.Windows.Debug.json delete mode 100644 src/Test.UnitTests.Sarif.Driver/rewrite.coyote.Windows.Release.json delete mode 100644 src/Test.UnitTests.Sarif.Driver/rewrite.coyote.nonWindows.Debug.json delete mode 100644 src/Test.UnitTests.Sarif.Driver/rewrite.coyote.nonWindows.Release.json delete mode 100644 src/Test.UnitTests.Sarif.Driver/rewriteUnitTests.ps1 diff --git a/src/Test.UnitTests.Sarif.Driver/CoyoteTestOutputLogger.cs b/src/Test.UnitTests.Sarif.Driver/CoyoteTestOutputLogger.cs deleted file mode 100644 index ce2c235db..000000000 --- a/src/Test.UnitTests.Sarif.Driver/CoyoteTestOutputLogger.cs +++ /dev/null @@ -1,160 +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; -using System.IO; -using System.Text; - -using Microsoft.Coyote.Logging; - -using Xunit.Abstractions; - -namespace Microsoft.CodeAnalysis.Sarif.Driver -{ - /// - /// Logger that writes to the test output. - /// - public sealed class CoyoteTestOutputLogger : TextWriter, ILogger - { - /// - /// Underlying test output. - /// - private readonly ITestOutputHelper TestOutput; - - /// - /// Saves the log until the end of the test. - /// - private readonly StringBuilder Log; - - /// - /// Serializes access to the string writer. - /// - private readonly object Lock; - - /// - public TextWriter TextWriter => this; - - /// - public override Encoding Encoding => Encoding.Unicode; - - /// - /// True if this logger is disposed, else false. - /// - private bool IsDisposed; - - /// - /// Initializes a new instance of the class. - /// - /// The test output helper. - public CoyoteTestOutputLogger(ITestOutputHelper output) - { - this.TestOutput = output; - this.Log = new StringBuilder(); - this.Lock = new object(); - this.IsDisposed = false; - } - - /// - public override void Write(string value) => - this.Write(LogSeverity.Info, value); - - /// - public override void Write(string format, params object[] args) => - this.Write(LogSeverity.Info, string.Format(format, args)); - - public void Write(LogSeverity severity, string value) - { - lock (this.Lock) - { - if (!this.IsDisposed) - { - this.Log.Append(value); - } - } - } - - /// - public void Write(LogSeverity severity, string format, params object[] args) => - this.Write(severity, string.Format(format, args)); - - /// - public override void WriteLine(string value) => this.WriteLine(LogSeverity.Info, value); - - /// - public override void WriteLine(string format, params object[] args) => - this.WriteLine(LogSeverity.Info, string.Format(format, args)); - - /// - public void WriteLine(LogSeverity severity, string value) - { - lock (this.Lock) - { - if (!this.IsDisposed) - { - this.Log.AppendLine(value); - } - } - } - - /// - public void WriteLine(LogSeverity severity, string format, params object[] args) => - this.WriteLine(severity, string.Format(format, args)); - - /// - /// Write all buffered log to the test output logger. - /// - private void FlushLog() - { - if (this.Log.Length > 0) - { - this.TestOutput.WriteLine(this.Log.ToString()); - this.Log.Clear(); - } - } - - /// - protected override void Dispose(bool disposing) - { - lock (this.Lock) - { - if (!this.IsDisposed) - { - this.FlushLog(); - this.IsDisposed = true; - } - } - - base.Dispose(disposing); - } - - public void Write(LogSeverity severity, string format, object arg0) - { - throw new NotImplementedException(); - } - - public void Write(LogSeverity severity, string format, object arg0, object arg1) - { - throw new NotImplementedException(); - } - - public void Write(LogSeverity severity, string format, object arg0, object arg1, object arg2) - { - throw new NotImplementedException(); - } - - public void WriteLine(LogSeverity severity, string format, object arg0) - { - throw new NotImplementedException(); - } - - public void WriteLine(LogSeverity severity, string format, object arg0, object arg1) - { - throw new NotImplementedException(); - } - - public void WriteLine(LogSeverity severity, string format, object arg0, object arg1, object arg2) - { - throw new NotImplementedException(); - } - } -} diff --git a/src/Test.UnitTests.Sarif.Driver/Test.UnitTests.Sarif.Driver.csproj b/src/Test.UnitTests.Sarif.Driver/Test.UnitTests.Sarif.Driver.csproj index dcb5e10b9..c2f5dc8ca 100644 --- a/src/Test.UnitTests.Sarif.Driver/Test.UnitTests.Sarif.Driver.csproj +++ b/src/Test.UnitTests.Sarif.Driver/Test.UnitTests.Sarif.Driver.csproj @@ -11,7 +11,6 @@ net6.0 false true - 1.7.3 powershell pwsh \ @@ -20,7 +19,7 @@ - $(PowershellExecutable) -executionpolicy bypass -command ".$(PathSeparator)rewriteUnitTests.ps1 -Configuration $(Configuration) -CoyoteVersion $(CoyoteVersion) -TargetFramework $(TargetFramework)" + $(PowershellExecutable) -executionpolicy bypass -command ".$(PathSeparator)rewriteUnitTests.ps1 -Configuration $(Configuration) -TargetFramework $(TargetFramework)" @@ -32,8 +31,6 @@ - - @@ -69,8 +66,4 @@ Microsoft.CodeAnalysis.Sarif.Driver.Sdk - - - - diff --git a/src/Test.UnitTests.Sarif.Driver/rewrite.coyote.Windows.Debug.json b/src/Test.UnitTests.Sarif.Driver/rewrite.coyote.Windows.Debug.json deleted file mode 100644 index 4542ffb52..000000000 --- a/src/Test.UnitTests.Sarif.Driver/rewrite.coyote.Windows.Debug.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "AssembliesPath": "..\\..\\bld\\bin\\AnyCPU_Debug\\Test.UnitTests.Sarif.Driver\\netcoreapp3.1", - "Assemblies": [ "Sarif.Driver.dll", "Sarif.dll", "Test.UnitTests.Sarif.Driver.dll" ] -} diff --git a/src/Test.UnitTests.Sarif.Driver/rewrite.coyote.Windows.Release.json b/src/Test.UnitTests.Sarif.Driver/rewrite.coyote.Windows.Release.json deleted file mode 100644 index aed2391f3..000000000 --- a/src/Test.UnitTests.Sarif.Driver/rewrite.coyote.Windows.Release.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "AssembliesPath": "..\\..\\bld\\bin\\AnyCPU_Release\\Test.UnitTests.Sarif.Driver\\netcoreapp3.1", - "Assemblies": [ "Sarif.Driver.dll", "Sarif.dll", "Test.UnitTests.Sarif.Driver.dll" ] -} diff --git a/src/Test.UnitTests.Sarif.Driver/rewrite.coyote.nonWindows.Debug.json b/src/Test.UnitTests.Sarif.Driver/rewrite.coyote.nonWindows.Debug.json deleted file mode 100644 index 107424bbf..000000000 --- a/src/Test.UnitTests.Sarif.Driver/rewrite.coyote.nonWindows.Debug.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "AssembliesPath": "../../bld/bin/AnyCPU_Debug/Test.UnitTests.Sarif.Driver/netcoreapp3.1", - "Assemblies": [ "Sarif.Driver.dll", "Sarif.dll", "Test.UnitTests.Sarif.Driver.dll" ] -} diff --git a/src/Test.UnitTests.Sarif.Driver/rewrite.coyote.nonWindows.Release.json b/src/Test.UnitTests.Sarif.Driver/rewrite.coyote.nonWindows.Release.json deleted file mode 100644 index 883c1dd28..000000000 --- a/src/Test.UnitTests.Sarif.Driver/rewrite.coyote.nonWindows.Release.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "AssembliesPath": "../../bld/bin/AnyCPU_Release/Test.UnitTests.Sarif.Driver/netcoreapp3.1", - "Assemblies": [ "Sarif.Driver.dll", "Sarif.dll", "Test.UnitTests.Sarif.Driver.dll" ] -} diff --git a/src/Test.UnitTests.Sarif.Driver/rewriteUnitTests.ps1 b/src/Test.UnitTests.Sarif.Driver/rewriteUnitTests.ps1 deleted file mode 100644 index c9e600701..000000000 --- a/src/Test.UnitTests.Sarif.Driver/rewriteUnitTests.ps1 +++ /dev/null @@ -1,12 +0,0 @@ -param( - [Parameter(Mandatory=$true)][string]$CoyoteVersion="", - [Parameter(Mandatory=$true)][string]$Configuration, - [Parameter(Mandatory=$true)][string]$TargetFramework -) - -Write-Output "Rewrite Unit Tests with Coyote" -if ($ENV:OS) { - dotnet ../../packages/microsoft.coyote.test/$CoyoteVersion/lib/$TargetFramework/coyote.dll rewrite rewrite.coyote.Windows.$Configuration.json -} else { - dotnet ../../packages/microsoft.coyote.test/$CoyoteVersion/lib/$TargetFramework/coyote.dll rewrite rewrite.coyote.nonWindows.$Configuration.json -} From 29f145ec78cd31ff7b4e4b8fd34976b8c991788f Mon Sep 17 00:00:00 2001 From: Ross Wollman Date: Mon, 15 Jul 2024 11:37:39 -0700 Subject: [PATCH 10/19] chore: remove unused Kusto command and dep (#2815) Cleanup removing code that is not known to be used for a few years and also allows removal of NuGet dependencies from the project. --- ReleaseHistory.md | 2 + src/Sarif.Multitool.Library/KustoCommand.cs | 328 ------------------ src/Sarif.Multitool.Library/KustoOptions.cs | 55 --- .../Sarif.Multitool.Library.csproj | 1 - src/Sarif.Multitool/Program.cs | 2 - .../RewriteCommandTests.cs | 2 - .../CommandLineParameterTests.cs | 1 - src/WorkItems/WorkItems.csproj | 1 - 8 files changed, 2 insertions(+), 390 deletions(-) delete mode 100644 src/Sarif.Multitool.Library/KustoCommand.cs delete mode 100644 src/Sarif.Multitool.Library/KustoOptions.cs diff --git a/ReleaseHistory.md b/ReleaseHistory.md index d3cf0cf1e..621f326ba 100644 --- a/ReleaseHistory.md +++ b/ReleaseHistory.md @@ -1,6 +1,8 @@ # SARIF Package Release History (SDK, Driver, Converters, and Multitool) ## UNRELEASED +* BRK: Remove defunct and unsupported `kusto` command in `Sarif.Multitool`. +* DEP: Remove dependency on `Microsoft.Azure.Kusto.Data`. * DEP: Update `Azure.Identity` reference from 1.10.2 to 1.11.0 in `WorkItems` and `Sarif.Multitool.Library` to resolve [CVE-2024-29992](https://github.com/advisories/GHSA-wvxc-855f-jvrv). * BUG: Resolve process hangs when a file path is provided with a wildcard, but without a `-r` (recurse) flag during the multi-threaded analysis file enumeration phase. * BUG: Fix error `ERR997.NoValidAnalysisTargets` when scanning symbolic link files. diff --git a/src/Sarif.Multitool.Library/KustoCommand.cs b/src/Sarif.Multitool.Library/KustoCommand.cs deleted file mode 100644 index b3c9f84ab..000000000 --- a/src/Sarif.Multitool.Library/KustoCommand.cs +++ /dev/null @@ -1,328 +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; -using System.Collections.Generic; -using System.Data; -using System.Linq; - -using Kusto.Data; -using Kusto.Data.Common; -using Kusto.Data.Net.Client; - -using Microsoft.CodeAnalysis.Sarif.Driver; - -using Newtonsoft.Json; - -namespace Microsoft.CodeAnalysis.Sarif.Multitool -{ - public class KustoCommand : CommandBase - { - private ICslQueryProvider _kustoClient; - private KustoOptions _options; - - public int Run(KustoOptions options) - { - try - { - if (!options.Validate()) - { - return FAILURE; - } - - _options = options; - - InitializeKustoClient(); - - (List, List) sarifResults = RetrieveResultsFromKusto(); - var sarifLog = new SarifLog - { - Runs = new[] - { - new Run - { - Tool = new Tool - { - Driver = new ToolComponent - { - Name = "spam", - Rules = sarifResults.Item2, - } - }, - Results = sarifResults.Item1, - } - } - }; - - WriteSarifFile(FileSystem, sarifLog, options.OutputFilePath, options.Minify); - } - catch (Exception ex) - { - Console.WriteLine(ex); - return FAILURE; - } - finally - { - _kustoClient?.Dispose(); - } - return SUCCESS; - } - - private void InitializeKustoClient() - { - KustoConnectionStringBuilder connection = new KustoConnectionStringBuilder(_options.HostAddress) - .WithAadApplicationKeyAuthentication( - Environment.GetEnvironmentVariable("AppClientId"), - Environment.GetEnvironmentVariable("AppSecret"), - Environment.GetEnvironmentVariable("AuthorityId")); - - _kustoClient = KustoClientFactory.CreateCslQueryProvider(connection); - } - - private (List, List) RetrieveResultsFromKusto() - { - var dataReaderIndex = new Dictionary(); - var results = new List(); - var rules = new Dictionary(); - - using IDataReader dataReader = _kustoClient.ExecuteQuery( - _options.Database, - _options.Query, - new ClientRequestProperties { ClientRequestId = Guid.NewGuid().ToString() }); - while (dataReader.Read()) - { - try - { - string itemPath = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "ItemPath")); - string itemPathUri = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "ItemPathUri")); - string organizationName = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "OrganizationName")); - string projectName = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "ProjectName")); - string projectId = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "ProjectId")); - string repositoryName = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "RepositoryName")); - string repositoryId = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "RepositoryId")); - string regionSnippet = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "RegionSnippet")); - string validationFingerprint = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "ValidationFingerprint")); - string validationFingerprintHash = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "ValidationFingerprintHash")); - string globalFingerprint = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "GlobalFingerprint")); - string ruleId = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "RuleId")); - string ruleName = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "RuleName")); - string resultKind = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "ResultKind")); - string level = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "Level")); - string resultMessageText = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "ResultMessageText")); - string result = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "Result")); - string etlEntity = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "EtlEntity")); - - string contextRegionSnippet = null; - if (GetIndex(dataReader, dataReaderIndex, "ContextRegionSnippet") != -1) - { - contextRegionSnippet = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "ContextRegionSnippet")); - } - - string assetFingerprint = null; - if (GetIndex(dataReader, dataReaderIndex, "AssetFingerprint") != -1) - { - assetFingerprint = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "AssetFingerprint")); - } - - bool? onDemandValidated = null; - if (GetIndex(dataReader, dataReaderIndex, "OnDemandValidated") != -1) - { - onDemandValidated = (sbyte)dataReader.GetValue(GetIndex(dataReader, dataReaderIndex, "OnDemandValidated")) == 1; - } - - string subscriptionId = null; - if (GetIndex(dataReader, dataReaderIndex, "SubscriptionId") != -1) - { - subscriptionId = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "SubscriptionId")); - } - - string subscriptionName = null; - if (GetIndex(dataReader, dataReaderIndex, "SubscriptionName") != -1) - { - subscriptionName = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "SubscriptionName")); - } - - if (!string.IsNullOrEmpty(subscriptionId) && !string.IsNullOrEmpty(subscriptionName)) - { - resultMessageText += $" The resource is in the '[{subscriptionName}](https://portal.azure.com/#resource/subscriptions/{subscriptionId}/overview)' subscription."; - } - - string serviceName = null; - if (GetIndex(dataReader, dataReaderIndex, "STServiceName") != -1) - { - serviceName = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "STServiceName")); - if (!string.IsNullOrEmpty(serviceName)) - { - var owners = new HashSet(StringComparer.OrdinalIgnoreCase); - resultMessageText += $" The subscription backing this Azure resource is associated with the '{serviceName}'"; - - string serviceOwner = null; - if (GetIndex(dataReader, dataReaderIndex, "STOwner") != -1) - { - serviceOwner = dataReader.GetString(GetIndex(dataReader, dataReaderIndex, "STOwner")); - if (!string.IsNullOrEmpty(serviceOwner)) - { - owners.Add(serviceOwner); - } - } - - if (GetIndex(dataReader, dataReaderIndex, "STAllOwners") != -1) - { - var STAllOwners = dataReader.GetValue(GetIndex(dataReader, dataReaderIndex, "STAllOwners")) as Newtonsoft.Json.Linq.JArray; - if (STAllOwners?.Count > 0) - { - List ownersList = STAllOwners.ToObject>(); - ownersList.ForEach((o) => owners.Add(o)); - } - } - - if (owners.Count > 0) - { - string emails = string.Join(";", owners.Select(o => $"{o}@microsoft.com")); - resultMessageText += $" which is owned by '[{string.Join(";", owners)}](mailto:{emails})'."; - } - } - } - - if (etlEntity == "Build" || etlEntity == "BuildDefinition" || - etlEntity == "Release" || etlEntity == "ReleaseDefinition" || - etlEntity == "WorkItem") - { - itemPath = itemPath.Replace("vsrm.dev.azure.com", "dev.azure.com"); - itemPath = itemPath.Replace("_apis/wit/workItems/", "_workitems/edit/"); - itemPath = itemPath.Replace("vsrm.visualstudio.com", "visualstudio.com"); - itemPath = itemPath.Replace("_apis/build/Definitions/", "_build?definitionId="); - itemPath = itemPath.Replace("_apis/Release/definitions/", "_release?_a=releases&view=mine&definitionId="); - - resultMessageText += $" The raw data that was scanned for this finding can be viewed [here]({itemPathUri})."; - - itemPathUri = itemPath; - } - - Result resultObj = JsonConvert.DeserializeObject(result); - resultObj.Message = new Message - { - Text = resultMessageText - }; - // Removing this, because the ruleIndex might not be in the correct place. - resultObj.RuleIndex = -1; - resultObj.Level = (FailureLevel)Enum.Parse(typeof(FailureLevel), level); - resultObj.Kind = (ResultKind)Enum.Parse(typeof(ResultKind), resultKind); - - if (onDemandValidated.HasValue) - { - // If on demand is true, it means that we searched validated that credential - // and that returned that the credential is not valid anymore. - resultObj.BaselineState = onDemandValidated.Value - ? BaselineState.Absent - : BaselineState.New; - } - - if (resultObj?.Locations.Count > 0) - { - resultObj.Locations[0].PhysicalLocation.ArtifactLocation.Uri = new Uri(itemPathUri); - resultObj.Locations[0].PhysicalLocation.Region.Snippet = new ArtifactContent - { - Text = regionSnippet - }; - - if (!string.IsNullOrEmpty(contextRegionSnippet)) - { - resultObj.Locations[0].PhysicalLocation.ContextRegion.Snippet = new ArtifactContent - { - Text = contextRegionSnippet - }; - } - } - else - { - int regionStartLine = dataReader.GetInt32(GetIndex(dataReader, dataReaderIndex, "RegionStartLine")); - int regionEndLine = dataReader.GetInt32(GetIndex(dataReader, dataReaderIndex, "RegionEndLine")); - int regionStartColumn = dataReader.GetInt32(GetIndex(dataReader, dataReaderIndex, "RegionStartColumn")); - int regionEndColumn = dataReader.GetInt32(GetIndex(dataReader, dataReaderIndex, "RegionEndColumn")); - int regionCharOffset = dataReader.GetInt32(GetIndex(dataReader, dataReaderIndex, "RegionCharOffset")); - int regionCharLength = dataReader.GetInt32(GetIndex(dataReader, dataReaderIndex, "RegionCharLength")); - resultObj.Locations.Add(new Location - { - PhysicalLocation = new PhysicalLocation - { - Region = new Region - { - CharLength = regionCharLength, - CharOffset = regionCharOffset, - StartColumn = regionStartColumn, - StartLine = regionStartLine, - EndColumn = regionEndColumn, - EndLine = regionEndLine, - Snippet = new ArtifactContent - { - Text = regionSnippet - } - }, - ContextRegion = string.IsNullOrEmpty(contextRegionSnippet) - ? null - : new Region - { - Snippet = new ArtifactContent - { - Text = contextRegionSnippet - } - }, - ArtifactLocation = new ArtifactLocation - { - Uri = new Uri(itemPathUri) - } - }, - }); - } - - resultObj.SetProperty("organizationName", organizationName); - resultObj.SetProperty("projectName", projectName); - resultObj.SetProperty("projectId", projectId); - resultObj.SetProperty("repositoryName", repositoryName); - resultObj.SetProperty("repositoryId", repositoryId); - resultObj.Fingerprints.Add("AssetFingerprint/v1", assetFingerprint); - resultObj.Fingerprints.Add("GlobalFingerprint/v1", globalFingerprint); - resultObj.Fingerprints.Add("ValidationFingerprint/v1", validationFingerprint); - resultObj.Fingerprints.Add("ValidationFingerprintHash/v1", validationFingerprintHash); - - if (!rules.ContainsKey(ruleId)) - { - rules.Add(ruleId, new ReportingDescriptor - { - Id = ruleId, - Name = ruleName, - }); - } - - results.Add(resultObj); - } - catch (Exception ex) - { - Console.WriteLine(ex); - } - } - - return (results, rules.Values.ToList()); - } - - private static int GetIndex(IDataReader dataReader, Dictionary dataReaderIndex, string key) - { - int index; - try - { - if (!dataReaderIndex.TryGetValue(key, out index)) - { - dataReaderIndex[key] = index = dataReader.GetOrdinal(key); - } - } - catch (ArgumentException) - { - // When we don't find, let's set to -1. - dataReaderIndex[key] = index = -1; - } - - return index; - } - } -} diff --git a/src/Sarif.Multitool.Library/KustoOptions.cs b/src/Sarif.Multitool.Library/KustoOptions.cs deleted file mode 100644 index d859fb3f9..000000000 --- a/src/Sarif.Multitool.Library/KustoOptions.cs +++ /dev/null @@ -1,55 +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; - -using CommandLine; - -using Microsoft.CodeAnalysis.Sarif.Driver; - -namespace Microsoft.CodeAnalysis.Sarif.Multitool -{ - [Verb("kusto", HelpText = "Export a SARIF file from a kusto query.")] - public class KustoOptions : CommonOptionsBase - { - [Value( - 0, - HelpText = "Output path for exported SARIF", - Required = true)] - public string OutputFilePath { get; set; } - - [Option( - "host-address", - HelpText = "The host address from where we will fetch the data.", - Required = true)] - public string HostAddress { get; set; } - - [Option( - "database", - HelpText = "The database that we will connect.", - Required = true)] - public string Database { get; set; } - - [Option( - "query", - HelpText = "The query that will be used to generate the SARIF.", - Required = true)] - public string Query { get; set; } - - public bool Validate() - { - string appClientId = Environment.GetEnvironmentVariable("AppClientId"); - string appSecret = Environment.GetEnvironmentVariable("AppSecret"); - string authorityId = Environment.GetEnvironmentVariable("AuthorityId"); - - if (string.IsNullOrEmpty(appClientId) || - string.IsNullOrEmpty(appSecret) || - string.IsNullOrEmpty(authorityId)) - { - return false; - } - - return true; - } - } -} diff --git a/src/Sarif.Multitool.Library/Sarif.Multitool.Library.csproj b/src/Sarif.Multitool.Library/Sarif.Multitool.Library.csproj index 1d0e8a7d8..1398d093c 100644 --- a/src/Sarif.Multitool.Library/Sarif.Multitool.Library.csproj +++ b/src/Sarif.Multitool.Library/Sarif.Multitool.Library.csproj @@ -16,7 +16,6 @@ - diff --git a/src/Sarif.Multitool/Program.cs b/src/Sarif.Multitool/Program.cs index c820295bd..0cf31ce01 100644 --- a/src/Sarif.Multitool/Program.cs +++ b/src/Sarif.Multitool/Program.cs @@ -30,7 +30,6 @@ public static int Main(string[] args) ExportValidationConfigurationOptions, ExportValidationRulesMetadataOptions, FileWorkItemsOptions, - KustoOptions, ResultMatchingOptions, MergeOptions, PageOptions, @@ -66,7 +65,6 @@ public static int Main(string[] args) (ExportValidationConfigurationOptions options) => new ExportValidationConfigurationCommand().Run(options), (ExportValidationRulesMetadataOptions options) => new ExportValidationRulesMetadataCommand().Run(options), (FileWorkItemsOptions fileWorkItemsOptions) => new FileWorkItemsCommand().Run(fileWorkItemsOptions), - (KustoOptions options) => new KustoCommand().Run(options), (ResultMatchingOptions baselineOptions) => new ResultMatchingCommand().Run(baselineOptions), (MergeOptions mergeOptions) => new MergeCommand().Run(mergeOptions), (PageOptions pageOptions) => new PageCommand().Run(pageOptions), diff --git a/src/Test.UnitTests.Sarif.Multitool.Library/RewriteCommandTests.cs b/src/Test.UnitTests.Sarif.Multitool.Library/RewriteCommandTests.cs index 520289bea..de341e381 100644 --- a/src/Test.UnitTests.Sarif.Multitool.Library/RewriteCommandTests.cs +++ b/src/Test.UnitTests.Sarif.Multitool.Library/RewriteCommandTests.cs @@ -8,8 +8,6 @@ using FluentAssertions; -using Kusto.Cloud.Platform.Utils; - using Microsoft.CodeAnalysis.Sarif.Readers; using Microsoft.CodeAnalysis.Sarif.VersionOne; diff --git a/src/Test.UnitTests.Sarif.Multitool/CommandLineParameterTests.cs b/src/Test.UnitTests.Sarif.Multitool/CommandLineParameterTests.cs index bc415a016..27d009f4c 100644 --- a/src/Test.UnitTests.Sarif.Multitool/CommandLineParameterTests.cs +++ b/src/Test.UnitTests.Sarif.Multitool/CommandLineParameterTests.cs @@ -55,7 +55,6 @@ private T CommandLineTestHelper(IEnumerable args, bool valid) ExportValidationConfigurationOptions, ExportValidationRulesMetadataOptions, FileWorkItemsOptions, - KustoOptions, ResultMatchingOptions, MergeOptions, PageOptions, diff --git a/src/WorkItems/WorkItems.csproj b/src/WorkItems/WorkItems.csproj index 9fc085373..33f7ce29c 100644 --- a/src/WorkItems/WorkItems.csproj +++ b/src/WorkItems/WorkItems.csproj @@ -25,7 +25,6 @@ - From 03b4ef493a9145d2829f45f7e49003385972c9a8 Mon Sep 17 00:00:00 2001 From: "Michael C. Fanning" Date: Wed, 24 Jul 2024 09:26:06 -0700 Subject: [PATCH 11/19] Update code to use 'var' where type is explicit. (#2817) * Update code to use 'var' where type is explicit. * Formatting updates. * Disable autogeneration of SARIF core code from json schema. * More automatically enforced style updates. * Further style updates and command-line enforcement. --- scripts/BuildAndTest.ps1 | 19 ++++--- src/.editorconfig | 4 +- .../AndroidStudioConverter.cs | 6 +-- src/Sarif.Converters/AndroidStudioProblem.cs | 2 +- .../ClangAnalyzerConverter.cs | 6 +-- src/Sarif.Converters/ClangTidyConverter.cs | 18 +++---- .../ContrastSecurityConverter.cs | 34 ++++++------ src/Sarif.Converters/CppCheckConverter.cs | 4 +- src/Sarif.Converters/FortifyConverter.cs | 6 +-- src/Sarif.Converters/FortifyFprConverter.cs | 14 ++--- src/Sarif.Converters/FortifyIssue.cs | 2 +- src/Sarif.Converters/FxCopConverter.cs | 44 ++++++++-------- src/Sarif.Converters/PREFastConverter.cs | 2 +- src/Sarif.Converters/PylintConverter.cs | 2 +- src/Sarif.Converters/SemmleQlConverter.cs | 2 +- src/Sarif.Converters/SparseReader.cs | 2 + src/Sarif.Converters/TSLintConverter.cs | 12 ++--- src/Sarif.Converters/TSLintLogReader.cs | 2 +- src/Sarif.Driver/EnumerableExtensions.cs | 2 +- src/Sarif.Driver/Sdk/CommandBase.cs | 4 +- src/Sarif.Driver/Sdk/EntryPointUtilities.cs | 2 +- .../Sdk/ExportRulesMetadataCommandBase.cs | 4 +- src/Sarif.Driver/SemanticVersion.cs | 4 +- src/Sarif.Driver/StringExtensions.cs | 2 +- .../ApplyPolicyCommand.cs | 2 +- src/Sarif.Multitool.Library/ConvertCommand.cs | 8 +-- src/Sarif.Multitool.Library/MergeCommand.cs | 2 +- src/Sarif.Multitool.Library/PageCommand.cs | 4 +- src/Sarif.Multitool.Library/QueryCommand.cs | 4 +- src/Sarif.Multitool.Library/RewriteCommand.cs | 4 +- .../Rules/SARIF1005.UriMustBeAbsolute.cs | 2 +- .../Rules/SARIF2004.OptimizeFileSize.cs | 8 ++- .../Rules/SARIF2006.UrisShouldBeReachable.cs | 2 +- src/Sarif.Multitool/AnalyzeTestCommand.cs | 1 - src/Sarif.Multitool/AnalyzeTestContext.cs | 2 - src/Sarif.Multitool/Program.cs | 2 +- src/Sarif/ArtifactProvider.cs | 3 -- src/Sarif/Autogenerated/Address.cs | 2 +- src/Sarif/Autogenerated/AddressComparer.cs | 5 +- .../Autogenerated/AddressEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/Artifact.cs | 5 +- src/Sarif/Autogenerated/ArtifactChange.cs | 4 +- .../Autogenerated/ArtifactChangeComparer.cs | 5 +- .../ArtifactChangeEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/ArtifactComparer.cs | 5 +- src/Sarif/Autogenerated/ArtifactContent.cs | 4 +- .../Autogenerated/ArtifactContentComparer.cs | 5 +- .../ArtifactContentEqualityComparer.cs | 5 +- .../Autogenerated/ArtifactEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/ArtifactLocation.cs | 5 +- .../Autogenerated/ArtifactLocationComparer.cs | 5 +- .../ArtifactLocationEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/ArtifactRoles.cs | 4 +- src/Sarif/Autogenerated/Attachment.cs | 5 +- src/Sarif/Autogenerated/AttachmentComparer.cs | 5 +- .../AttachmentEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/BaselineState.cs | 4 +- src/Sarif/Autogenerated/CodeFlow.cs | 6 +-- src/Sarif/Autogenerated/CodeFlowComparer.cs | 5 +- .../Autogenerated/CodeFlowEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/ColumnKind.cs | 4 +- src/Sarif/Autogenerated/ComparerExtensions.cs | 4 +- .../Autogenerated/ConfigurationOverride.cs | 4 +- .../ConfigurationOverrideComparer.cs | 5 +- .../ConfigurationOverrideEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/Conversion.cs | 5 +- src/Sarif/Autogenerated/ConversionComparer.cs | 5 +- .../ConversionEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/Edge.cs | 4 +- src/Sarif/Autogenerated/EdgeComparer.cs | 5 +- .../Autogenerated/EdgeEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/EdgeTraversal.cs | 4 +- .../Autogenerated/EdgeTraversalComparer.cs | 5 +- .../EdgeTraversalEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/ExceptionData.cs | 7 +-- .../Autogenerated/ExceptionDataComparer.cs | 5 +- .../ExceptionDataEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/ExternalProperties.cs | 5 +- .../ExternalPropertiesComparer.cs | 5 +- .../ExternalPropertiesEqualityComparer.cs | 5 +- .../ExternalPropertyFileReference.cs | 5 +- .../ExternalPropertyFileReferenceComparer.cs | 5 +- ...alPropertyFileReferenceEqualityComparer.cs | 5 +- .../ExternalPropertyFileReferences.cs | 5 +- .../ExternalPropertyFileReferencesComparer.cs | 5 +- ...lPropertyFileReferencesEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/FailureLevel.cs | 4 +- src/Sarif/Autogenerated/Fix.cs | 4 +- src/Sarif/Autogenerated/FixComparer.cs | 5 +- .../Autogenerated/FixEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/Graph.cs | 5 +- src/Sarif/Autogenerated/GraphComparer.cs | 5 +- .../Autogenerated/GraphEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/GraphTraversal.cs | 5 +- .../Autogenerated/GraphTraversalComparer.cs | 5 +- .../GraphTraversalEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/ISarifNode.cs | 4 +- src/Sarif/Autogenerated/Invocation.cs | 14 ++--- src/Sarif/Autogenerated/InvocationComparer.cs | 5 +- .../InvocationEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/Location.cs | 8 +-- src/Sarif/Autogenerated/LocationComparer.cs | 5 +- .../Autogenerated/LocationEqualityComparer.cs | 5 +- .../Autogenerated/LocationRelationship.cs | 5 +- .../LocationRelationshipComparer.cs | 5 +- .../LocationRelationshipEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/LogicalLocation.cs | 5 +- .../Autogenerated/LogicalLocationComparer.cs | 5 +- .../LogicalLocationEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/Message.cs | 7 +-- src/Sarif/Autogenerated/MessageComparer.cs | 5 +- .../Autogenerated/MessageEqualityComparer.cs | 5 +- .../Autogenerated/MultiformatMessageString.cs | 4 +- .../MultiformatMessageStringComparer.cs | 5 +- ...ultiformatMessageStringEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/Node.cs | 5 +- src/Sarif/Autogenerated/NodeComparer.cs | 5 +- .../Autogenerated/NodeEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/Notification.cs | 7 +-- .../Autogenerated/NotificationComparer.cs | 5 +- .../NotificationEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/PhysicalLocation.cs | 4 +- .../Autogenerated/PhysicalLocationComparer.cs | 5 +- .../PhysicalLocationEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/PropertyBag.cs | 5 +- .../Autogenerated/PropertyBagComparer.cs | 5 +- .../PropertyBagEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/Rectangle.cs | 4 +- src/Sarif/Autogenerated/RectangleComparer.cs | 5 +- .../RectangleEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/Region.cs | 5 +- src/Sarif/Autogenerated/RegionComparer.cs | 5 +- .../Autogenerated/RegionEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/Replacement.cs | 4 +- .../Autogenerated/ReplacementComparer.cs | 5 +- .../ReplacementEqualityComparer.cs | 5 +- .../Autogenerated/ReportingConfiguration.cs | 4 +- .../ReportingConfigurationComparer.cs | 13 +++-- .../ReportingConfigurationEqualityComparer.cs | 13 +++-- .../Autogenerated/ReportingDescriptor.cs | 12 ++--- .../ReportingDescriptorComparer.cs | 5 +- .../ReportingDescriptorEqualityComparer.cs | 5 +- .../ReportingDescriptorReference.cs | 5 +- .../ReportingDescriptorReferenceComparer.cs | 5 +- ...tingDescriptorReferenceEqualityComparer.cs | 5 +- .../ReportingDescriptorRelationship.cs | 5 +- ...ReportingDescriptorRelationshipComparer.cs | 5 +- ...gDescriptorRelationshipEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/Result.cs | 24 ++++----- src/Sarif/Autogenerated/ResultComparer.cs | 5 +- .../Autogenerated/ResultEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/ResultKind.cs | 4 +- src/Sarif/Autogenerated/ResultProvenance.cs | 5 +- .../Autogenerated/ResultProvenanceComparer.cs | 5 +- .../ResultProvenanceEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/Run.cs | 36 ++++++------- .../Autogenerated/RunAutomationDetails.cs | 4 +- .../RunAutomationDetailsComparer.cs | 5 +- .../RunAutomationDetailsEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/RunComparer.cs | 5 +- .../Autogenerated/RunEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/SarifLog.cs | 6 +-- src/Sarif/Autogenerated/SarifLogComparer.cs | 5 +- .../Autogenerated/SarifLogEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/SarifNodeKind.cs | 4 +- .../Autogenerated/SarifRewritingVisitor.cs | 5 +- src/Sarif/Autogenerated/SarifVersion.cs | 4 +- src/Sarif/Autogenerated/SpecialLocations.cs | 4 +- .../Autogenerated/SpecialLocationsComparer.cs | 5 +- .../SpecialLocationsEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/Stack.cs | 6 +-- src/Sarif/Autogenerated/StackComparer.cs | 5 +- .../Autogenerated/StackEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/StackFrame.cs | 7 +-- src/Sarif/Autogenerated/StackFrameComparer.cs | 5 +- .../StackFrameEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/Suppression.cs | 5 +- .../Autogenerated/SuppressionComparer.cs | 5 +- .../SuppressionEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/SuppressionKind.cs | 4 +- src/Sarif/Autogenerated/SuppressionStatus.cs | 4 +- src/Sarif/Autogenerated/ThreadFlow.cs | 6 +-- src/Sarif/Autogenerated/ThreadFlowComparer.cs | 5 +- .../ThreadFlowEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/ThreadFlowLocation.cs | 11 ++-- .../ThreadFlowLocationComparer.cs | 5 +- .../ThreadFlowLocationEqualityComparer.cs | 5 +- .../ThreadFlowLocationImportance.cs | 4 +- src/Sarif/Autogenerated/Tool.cs | 7 +-- src/Sarif/Autogenerated/ToolComparer.cs | 5 +- src/Sarif/Autogenerated/ToolComponent.cs | 17 +++--- .../Autogenerated/ToolComponentComparer.cs | 5 +- .../Autogenerated/ToolComponentContents.cs | 4 +- .../ToolComponentEqualityComparer.cs | 5 +- .../Autogenerated/ToolComponentReference.cs | 5 +- .../ToolComponentReferenceComparer.cs | 5 +- .../ToolComponentReferenceEqualityComparer.cs | 5 +- .../Autogenerated/ToolEqualityComparer.cs | 5 +- .../Autogenerated/TranslationMetadata.cs | 4 +- .../TranslationMetadataComparer.cs | 5 +- .../TranslationMetadataEqualityComparer.cs | 5 +- .../Autogenerated/VersionControlDetails.cs | 5 +- .../VersionControlDetailsComparer.cs | 5 +- .../VersionControlDetailsEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/WebRequest.cs | 5 +- src/Sarif/Autogenerated/WebRequestComparer.cs | 5 +- .../WebRequestEqualityComparer.cs | 5 +- src/Sarif/Autogenerated/WebResponse.cs | 5 +- .../Autogenerated/WebResponseComparer.cs | 5 +- .../WebResponseEqualityComparer.cs | 5 +- .../DataStructures/MatchedResults.cs | 2 +- .../FullFingerprintResultMatcher.cs | 8 +-- .../ExactMatchers/IdenticalResultMatcher.cs | 4 +- .../ContextRegionHeuristicMatcher.cs | 2 +- .../HeuristicMatchers/HeuristicMatcher.cs | 2 +- .../ResultMatching/SarifLogResultMatcher.cs | 4 +- src/Sarif/Baseline/V2/TrustMap.cs | 2 +- src/Sarif/Baseline/V2/V2ResultMatcher.cs | 8 +-- src/Sarif/Baseline/V2/WhereComparer.cs | 2 +- src/Sarif/Core/Notification.cs | 8 +-- src/Sarif/Core/PropertyBagHolder.cs | 2 +- src/Sarif/Core/Run.cs | 4 +- src/Sarif/Core/Stack.cs | 4 +- src/Sarif/Core/StackFrame.cs | 2 +- src/Sarif/Core/Tool.cs | 2 +- src/Sarif/ExternalProcess.cs | 4 +- src/Sarif/HashUtilities.cs | 2 +- src/Sarif/LineInfo.cs | 2 +- src/Sarif/Map/JsonMapBuilder.cs | 6 +-- src/Sarif/Map/JsonMapNode.cs | 2 +- src/Sarif/Map/LongArrayDeltaConverter.cs | 4 +- src/Sarif/OffsetInfo.cs | 2 +- .../Generic/GenericMappingAction.cs | 2 +- src/Sarif/PropertiesDictionary.cs | 4 +- src/Sarif/Query/BitArrayExtensions.cs | 2 +- .../Query/Evaluators/ExpressionEvaluators.cs | 4 +- .../PropertyBagPropertyEvaluator.cs | 12 ++++- src/Sarif/Query/ExpressionParser.cs | 8 +-- src/Sarif/Query/Expressions.cs | 2 +- src/Sarif/Readers/DeferredDictionary.cs | 4 +- src/Sarif/Readers/DeferredList.cs | 6 +-- src/Sarif/Readers/SarifContractResolver.cs | 24 +++++++++ .../SerializedPropertyInfoConverter.cs | 6 +-- src/Sarif/Readers/VersionConverter.cs | 2 +- src/Sarif/RuleUtilities.cs | 2 +- src/Sarif/Sarif.csproj | 11 +++- .../TypedPropertiesDictionaryConverter.cs | 2 +- src/Sarif/UriHelper.cs | 2 +- .../Core/PropertyBagHolderVersionOne.cs | 2 +- .../SarifContractResolverVersionOne.cs | 26 ++++++++++ src/Sarif/Visitors/PartitioningVisitor.cs | 2 +- .../SarifCurrentToVersionOneVisitor.cs | 2 +- .../SarifVersionOneToCurrentVisitor.cs | 2 +- src/Sarif/Writers/MemoryStreamSarifLogger.cs | 2 +- .../PrereleaseCompatibilityTransformer.cs | 34 ++++++------ src/Sarif/Writers/SarifConsolidator.cs | 8 +-- src/Sarif/Writers/SarifOneZeroZeroLogger.cs | 2 +- .../BaseliningDetailEnricher.cs | 5 +- .../BaseliningDetailLogger.cs | 2 +- .../BaseliningSummary.cs | 2 +- .../BaseliningTester.cs | 24 ++++----- src/Test.EndToEnd.Baselining/Program.cs | 8 +-- .../MultitoolCommandLineTests.cs | 8 +-- .../PropertyBagConverterTests.cs | 2 +- .../SarifConverterTests.cs | 2 +- .../SarifLogEqualityComparerTests.cs | 1 - .../BuiltinConverterFactoryTests.cs | 3 +- .../ClangAnalyzerConverterTests.cs | 18 +++---- .../CppCheckConverterTests.cs | 6 +-- .../FortifyFprConverterTests.cs | 4 +- .../FortifyIssueTests.cs | 12 ++--- .../PylintConverterTests.cs | 2 +- .../TSLintConverterTests.cs | 12 ++--- .../TSLintLogReaderTests.cs | 18 +++---- .../TextFormats/CsvReaderTests.cs | 20 +++---- .../TextFormats/TsvReaderTests.cs | 16 +++--- .../ToolFileConverterBaseTests.cs | 2 +- .../Sdk/CommonOptionsBaseTests.cs | 2 +- .../ExportConfigurationCommandBaseTests.cs | 2 +- .../BaselineOptionTests.cs | 4 +- .../ConvertCommandTests.cs | 3 +- .../ExtensionsTests.cs | 2 +- .../GenericCommandTests.cs | 4 +- .../OptionsInterpretterTests.cs | 17 ++---- .../PageCommandTests.cs | 12 ++--- .../RebaseUriCommandTests.cs | 7 +-- .../RewriteCommandTests.cs | 4 +- .../QueryCommandTests.cs | 2 +- .../RewriteCommandTests.cs | 1 - .../SarifWorkItemExtensionsTests.cs | 16 +++--- .../SarifWorkItemFilerTests.cs | 11 ++-- .../SarifWorkItemModelTests.cs | 1 - .../FullFingerprintMatcherTests.cs | 8 +-- .../IdenticalResultMatcherTests.cs | 44 ++++++++-------- .../ContextRegionResultMatcherTests.cs | 12 ++--- .../PartialFingerprintResultMatcherTests.cs | 12 ++--- .../ResultMatchingBaselinerTests.cs | 2 +- .../ResultMatchingTestHelpers.cs | 4 +- .../SarifLogResultMatcherTests.cs | 4 +- .../Baseline2/ExtractedResultTests.cs | 2 +- .../Baseline2/MatchedResultsTests.cs | 2 +- .../Baseline2/OverallBaseliningTests.cs | 2 - .../Baseline2/TrustMapTests.cs | 4 +- .../Baseline2/V2ResultMatcherTests.cs | 6 +-- .../Baseline2/WhatComparerTests.cs | 12 ++--- .../Baseline2/WhereComparerTests.cs | 22 ++++---- src/Test.UnitTests.Sarif/CacheTests.cs | 2 +- .../Comparers/ComparersTests.cs | 1 - .../Core/ArtifactLocationTests.cs | 2 +- .../Core/ArtifactTests.cs | 32 ++++++------ .../Core/LocationTests.cs | 1 - .../Core/PropertyBagHolderTests.cs | 4 +- .../Core/ReportingDescriptorTests.cs | 4 +- src/Test.UnitTests.Sarif/Core/RunTests.cs | 6 +-- .../Core/SerializedPropertyInfoTests.cs | 2 +- src/Test.UnitTests.Sarif/Core/StackTests.cs | 2 +- src/Test.UnitTests.Sarif/Core/ToolTests.cs | 2 +- .../Core/WebRequestTests.cs | 8 +-- .../Core/WebResponseTests.cs | 4 +- .../FileRegionsCacheTests.cs | 30 +++++------ src/Test.UnitTests.Sarif/JsonTests.cs | 2 +- .../Map/LongArrayDeltaConverterTests.cs | 4 +- .../OrderSensitiveValueComparisonListTests.cs | 2 +- .../GenericTests/GenericProcessorTests.cs | 10 ++-- .../GenericTests/TestFoldProcessor.cs | 2 +- .../Log/LogPipelineSerializationTests.cs | 2 +- .../Processors/Log/MergeStageTests.cs | 4 +- .../Processors/Log/RebaseUriStageTests.cs | 2 +- .../Processors/Log/SarifLogExtensionTests.cs | 8 +-- .../PropertiesDictionaryTests.cs | 2 +- .../Query/EvaluatorTests.cs | 6 +-- .../Query/StringSliceTests.cs | 4 +- .../Readers/DeferredCollectionsTests.cs | 12 ++--- .../Readers/LineMappingStreamReaderTests.cs | 18 +++---- .../NonDisposingDelegatingStreamTests.cs | 2 - .../Readers/PropertyBagConverterTests.cs | 4 +- .../Readers/SampleModel/LogModel.cs | 52 +++++++++++++------ .../RuntimeConditionsTests.cs | 2 - .../SarifUtilitiesTests.cs | 2 - src/Test.UnitTests.Sarif/UriConverterTests.cs | 8 +-- .../Visitors/MakeUriAbsoluteVisitorTest.cs | 26 +++++----- .../PerRunPerRuleSplittingVisitorTests.cs | 2 +- .../Visitors/RebaseUriVisitorTests.cs | 42 +++++++-------- .../RemoveOptionalDataVisitorTests.cs | 2 +- .../Visitors/RunMergingVisitorTests.cs | 3 +- .../Visitors/SortingVisitorTests.cs | 1 - .../Writers/BaseLoggerTestConcrete.cs | 5 -- .../Writers/CachingLoggerTests.cs | 8 +-- .../Writers/SarifConsolidatorTests.cs | 46 ++++++++-------- .../Writers/SarifLoggerTests.cs | 11 ++-- .../FilingClientFactoryTests.cs | 10 ++-- ...cationInsightsTelemetryInitializerTests.cs | 21 ++++---- .../Logging/MetricsLogValuesTests.cs | 22 ++++---- .../RandomSarifLogGenerator.cs | 14 ++--- .../TestAssetResourceExtractor.cs | 4 +- src/WorkItems/Logging/AssemblyExtensions.cs | 4 +- src/WorkItems/WorkItems.csproj | 1 + src/build.props | 2 +- 358 files changed, 1146 insertions(+), 1163 deletions(-) diff --git a/scripts/BuildAndTest.ps1 b/scripts/BuildAndTest.ps1 index 39efbd42d..48c74d3e5 100644 --- a/scripts/BuildAndTest.ps1 +++ b/scripts/BuildAndTest.ps1 @@ -94,7 +94,7 @@ function Invoke-DotNetBuild($solutionFileRelativePath) { Write-Information "Building $solutionFileRelativePath..." $solutionFilePath = Join-Path $SourceRoot $solutionFileRelativePath - & dotnet build $solutionFilePath --configuration $Configuration --verbosity $BuildVerbosity --no-incremental -bl -p:WarningsAsErrors="MSB3277" + & dotnet build $solutionFilePath --configuration $Configuration --verbosity $BuildVerbosity --no-incremental -bl -p:WarningsAsErrors="MSB3277" /p:EnforceCodeStyleInBuild=true if ($LASTEXITCODE -ne 0) { Exit-WithFailureMessage $ScriptName "Build of $solutionFilePath failed." @@ -199,13 +199,16 @@ if (-not $NoRestore) { } } -if (-not $NoObjectModel) { - # Generate the SARIF object model classes from the SARIF JSON schema. - dotnet msbuild /verbosity:minimal /target:BuildAndInjectObjectModel $SourceRoot\Sarif\Sarif.csproj /fileloggerparameters:Verbosity=detailed`;LogFile=CodeGen.log - if ($LASTEXITCODE -ne 0) { - Exit-WithFailureMessage $ScriptName "SARIF object model generation failed." - } -} +# The SARIF object model is stable. We disable autogenerating it to allow +# for strict control enforcing style guidelines from command-line builds. +#if (-not $NoObjectModel) { +# # Generate the SARIF object model classes from the SARIF JSON schema. +# dotnet msbuild /verbosity:minimal /target:BuildAndInjectObjectModel $SourceRoot\Sarif\Sarif.csproj /fileloggerparameters:Verbosity=detailed`;LogFile=CodeGen.log +# if ($LASTEXITCODE -ne 0) { +# Exit-WithFailureMessage $ScriptName "SARIF object model generation failed." +# } +#} + if (-not $?) { Exit-WithFailureMessage $ScriptName "BeforeBuild failed." diff --git a/src/.editorconfig b/src/.editorconfig index ad920b226..54ce51e04 100644 --- a/src/.editorconfig +++ b/src/.editorconfig @@ -297,6 +297,7 @@ csharp_style_prefer_local_over_anonymous_function = true:suggestion dotnet_diagnostic.SA1602.severity = suggestion dotnet_diagnostic.SA1307.severity = silent csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion +csharp_style_prefer_primary_constructors = true:suggestion [*Tests.cs] @@ -323,4 +324,5 @@ dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion dotnet_style_prefer_compound_assignment = true:suggestion dotnet_style_prefer_simplified_interpolation = true:suggestion dotnet_style_namespace_match_folder = true:suggestion -dotnet_code_quality_unused_parameters = all:error \ No newline at end of file +dotnet_code_quality_unused_parameters = all:error +dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion \ No newline at end of file diff --git a/src/Sarif.Converters/AndroidStudioConverter.cs b/src/Sarif.Converters/AndroidStudioConverter.cs index 40940859f..8075d46ad 100644 --- a/src/Sarif.Converters/AndroidStudioConverter.cs +++ b/src/Sarif.Converters/AndroidStudioConverter.cs @@ -50,7 +50,7 @@ public override void Convert(Stream input, IResultLogWriter output, OptionallyEm LogicalLocations.Clear(); - XmlReaderSettings settings = new XmlReaderSettings + var settings = new XmlReaderSettings { IgnoreWhitespace = true, IgnoreComments = true, @@ -61,7 +61,7 @@ public override void Convert(Stream input, IResultLogWriter output, OptionallyEm }; IList results; - using (XmlReader xmlReader = XmlReader.Create(input, settings)) + using (var xmlReader = XmlReader.Create(input, settings)) { results = ProcessAndroidStudioLog(xmlReader); } @@ -244,7 +244,7 @@ private static void SetSarifResultPropertiesForProblem(Result result, AndroidStu private static string GenerateFullMessage(string description, ImmutableArray hints) { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); sb.Append(description); foreach (string hint in hints) { diff --git a/src/Sarif.Converters/AndroidStudioProblem.cs b/src/Sarif.Converters/AndroidStudioProblem.cs index 8a16608b1..e4fd85d94 100644 --- a/src/Sarif.Converters/AndroidStudioProblem.cs +++ b/src/Sarif.Converters/AndroidStudioProblem.cs @@ -143,7 +143,7 @@ public static AndroidStudioProblem Parse(XmlReader reader, AndroidStudioStrings throw reader.CreateException(ConverterResources.AndroidStudioNotProblemElement); } - Builder b = new Builder(); + var b = new Builder(); if (!reader.IsEmptyElement) { int problemDepth = reader.Depth; diff --git a/src/Sarif.Converters/ClangAnalyzerConverter.cs b/src/Sarif.Converters/ClangAnalyzerConverter.cs index e28ef8e53..8c1f1e67a 100644 --- a/src/Sarif.Converters/ClangAnalyzerConverter.cs +++ b/src/Sarif.Converters/ClangAnalyzerConverter.cs @@ -37,7 +37,7 @@ public override void Convert(Stream input, IResultLogWriter output, OptionallyEm try { - XmlReaderSettings settings = new XmlReaderSettings + var settings = new XmlReaderSettings { IgnoreWhitespace = true, DtdProcessing = DtdProcessing.Ignore, @@ -46,7 +46,7 @@ public override void Convert(Stream input, IResultLogWriter output, OptionallyEm var results = new List(); - using (XmlReader xmlReader = XmlReader.Create(input, settings)) + using (var xmlReader = XmlReader.Create(input, settings)) { xmlReader.MoveToContent(); xmlReader.ReadStartElement(ClangSchemaStrings.PlistName); @@ -179,7 +179,7 @@ private Result CreateResult(IDictionary issueData) private static IList ReadArray(XmlReader xmlReader) { - List list = new List(); + var list = new List(); bool readerMoved = false; // ReadElementContentAsString moves the reader so prevent double moves. xmlReader.Read(); // Read past the "array" element start. diff --git a/src/Sarif.Converters/ClangTidyConverter.cs b/src/Sarif.Converters/ClangTidyConverter.cs index 9e7334f15..7986d0557 100644 --- a/src/Sarif.Converters/ClangTidyConverter.cs +++ b/src/Sarif.Converters/ClangTidyConverter.cs @@ -29,7 +29,7 @@ public override void Convert(Stream input, IResultLogWriter output, OptionallyEm using var textReader = new StreamReader(input); ClangTidyReport report = deserializer.Deserialize(textReader); - List logs = new List(); + var logs = new List(); if (report != null) { string reportPath = (input as FileStream)?.Name; @@ -78,7 +78,7 @@ private void AddLineNumberAndColumnNumber(ClangTidyReport report, List LoadLogFile(string logFilePath) { - List returnValue = new List(); + var returnValue = new List(); var logLines = File.ReadAllLines(logFilePath).ToList(); foreach (string line in logLines) @@ -91,7 +91,7 @@ private List LoadLogFile(string logFilePath) int columnNumber; if (int.TryParse(match.Groups[2].Value, out lineNumber) && int.TryParse(match.Groups[3].Value, out columnNumber)) { - ClangTidyConsoleDiagnostic consoleDiagnostic = new ClangTidyConsoleDiagnostic() + var consoleDiagnostic = new ClangTidyConsoleDiagnostic() { LineNumber = lineNumber, ColumnNumber = columnNumber @@ -108,7 +108,7 @@ internal static Result CreateResult(ClangTidyDiagnostic entry) { entry = entry ?? throw new ArgumentNullException(nameof(entry)); - Result result = new Result() + var result = new Result() { RuleId = entry.DiagnosticName, Message = new Message { Text = entry.DiagnosticMessage.Message }, @@ -118,14 +118,14 @@ internal static Result CreateResult(ClangTidyDiagnostic entry) // no level infomation in Clang-Tidy report result.Level = FailureLevel.Warning; - Region region = new Region() + var region = new Region() { CharOffset = entry.DiagnosticMessage.FileOffset, StartLine = entry.DiagnosticMessage.LineNumber, StartColumn = entry.DiagnosticMessage.ColumnNumber, }; - Uri analysisTargetUri = new Uri(entry.DiagnosticMessage.FilePath, UriKind.RelativeOrAbsolute); + var analysisTargetUri = new Uri(entry.DiagnosticMessage.FilePath, UriKind.RelativeOrAbsolute); var physicalLocation = new PhysicalLocation { @@ -136,7 +136,7 @@ internal static Result CreateResult(ClangTidyDiagnostic entry) Region = region }; - Location location = new Location() + var location = new Location() { PhysicalLocation = physicalLocation }; @@ -152,7 +152,7 @@ internal static Result CreateResult(ClangTidyDiagnostic entry) foreach (ClangTidyReplacement fix in entry.DiagnosticMessage.Replacements) { - Replacement replacement = new Replacement(); + var replacement = new Replacement(); replacement.DeletedRegion = new Region { @@ -180,7 +180,7 @@ internal static Result CreateResult(ClangTidyDiagnostic entry) Replacements = replacements }; - Fix sarifFix = new Fix(description: null, artifactChanges: new List() { sarifFileChange }, properties: null); + var sarifFix = new Fix(description: null, artifactChanges: new List() { sarifFileChange }, properties: null); result.Fixes = new List { sarifFix }; } diff --git a/src/Sarif.Converters/ContrastSecurityConverter.cs b/src/Sarif.Converters/ContrastSecurityConverter.cs index f68a69ad5..628bf7545 100644 --- a/src/Sarif.Converters/ContrastSecurityConverter.cs +++ b/src/Sarif.Converters/ContrastSecurityConverter.cs @@ -594,7 +594,7 @@ private Result ConstructFormsWithoutAutocompletePreventionResult(ContrastLogRead if (KeyIsReservedPropertyName(key)) { continue; } string jsonValue = properties[key]; - JObject root = JObject.Parse(jsonValue); + var root = JObject.Parse(jsonValue); string snippet = root["html"].Value(); int snippetLength = snippet.Length; @@ -1429,7 +1429,7 @@ private static void ReadFindings(SparseReader reader, object parent) private void ReadFinding(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; string ruleId = reader.ReadAttributeString(SchemaStrings.AttributeRuleId); @@ -1443,7 +1443,7 @@ private void ReadFinding(SparseReader reader, object parent) private static void ReadRequest(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; context.ClearRequest(); string protocol = reader.ReadAttributeString(SchemaStrings.AttributeProtocol); @@ -1458,13 +1458,13 @@ private static void ReadRequest(SparseReader reader, object parent) private static void ReadBody(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; context.RequestBody = reader.ReadElementContentAsString(); } private static void ReadHeaders(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; context.ClearHeaders(); reader.ReadChildren(SchemaStrings.ElementHeaders, parent); @@ -1475,7 +1475,7 @@ private static void ReadH(SparseReader reader, object parent) string name = reader.ReadAttributeString(SchemaStrings.AttributeName); string value = reader.ReadAttributeString(SchemaStrings.AttributeValue); - Context context = (Context)parent; + var context = (Context)parent; context.AddHeader(name, value); reader.ReadChildren(SchemaStrings.ElementH, parent); @@ -1483,7 +1483,7 @@ private static void ReadH(SparseReader reader, object parent) private static void ReadParameters(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; context.ClearParameters(); reader.ReadChildren(SchemaStrings.ElementParameters, parent); @@ -1491,7 +1491,7 @@ private static void ReadParameters(SparseReader reader, object parent) private static void ReadEvents(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; context.Signature = null; context.MethodEvent = null; context.PropagationEvents = null; @@ -1505,7 +1505,7 @@ private static void ReadPropagationEvent(SparseReader reader, object parent) { reader.ReadChildren(SchemaStrings.ElementPropagationEvent, parent); - Context context = (Context)parent; + var context = (Context)parent; context.PropagationEvents = context.PropagationEvents ?? new List(); context.PropagationEvents.Add(context.CurrentThreadFlowLocation); context.CurrentThreadFlowLocation = null; @@ -1514,7 +1514,7 @@ private static void ReadPropagationEvent(SparseReader reader, object parent) private static void ReadSignature(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; string signature = reader.ReadElementContentAsString(); context.Signature = CreateStackFrameFromSignature(signature); } @@ -1566,7 +1566,7 @@ private static void ReadArgs(SparseReader reader, object parent) private void ReadProperties(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; if (!_readingProps) { @@ -1608,7 +1608,7 @@ private static void ReadP(SparseReader reader, object parent) { string value = reader.ReadAttributeString(SchemaStrings.AttributeValue); - Context context = (Context)parent; + var context = (Context)parent; context.AddParameter(name, value); } @@ -1622,7 +1622,7 @@ private static void ReadReturn(SparseReader reader, object parent) private static void ReadStack(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; Debug.Assert(context.CurrentThreadFlowLocation == null); context.CurrentThreadFlowLocation = new ThreadFlowLocation { @@ -1644,14 +1644,14 @@ private static void ReadSources(SparseReader reader, object parent) private static void ReadEvidence(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; string evidence = reader.ReadElementContentAsString(); context.RefineEvidence(evidence); } private static void ReadSource(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; string type = reader.ReadAttributeString(SchemaStrings.AttributeType); string name = reader.ReadAttributeString(SchemaStrings.AttributeName); context.Sources = context.Sources ?? new HashSet>(); @@ -1661,7 +1661,7 @@ private static void ReadSource(SparseReader reader, object parent) private static void ReadFrame(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; string frame = reader.ReadElementContentAsString(); context.CurrentThreadFlowLocation.Stack.Frames.Add(CreateStackFrameFromSignature(frame)); } @@ -1670,7 +1670,7 @@ private static void ReadMethodEvent(SparseReader reader, object parent) { reader.ReadChildren(SchemaStrings.ElementMethodEvent, parent); - Context context = (Context)parent; + var context = (Context)parent; context.MethodEvent = context.CurrentThreadFlowLocation; context.CurrentThreadFlowLocation = null; context.Signature = null; diff --git a/src/Sarif.Converters/CppCheckConverter.cs b/src/Sarif.Converters/CppCheckConverter.cs index 3ddf8ae36..791bcdd53 100644 --- a/src/Sarif.Converters/CppCheckConverter.cs +++ b/src/Sarif.Converters/CppCheckConverter.cs @@ -41,7 +41,7 @@ public override void Convert(Stream input, IResultLogWriter output, OptionallyEm throw new ArgumentNullException(nameof(output)); } - XmlReaderSettings settings = new XmlReaderSettings + var settings = new XmlReaderSettings { IgnoreWhitespace = true, DtdProcessing = DtdProcessing.Ignore, @@ -49,7 +49,7 @@ public override void Convert(Stream input, IResultLogWriter output, OptionallyEm XmlResolver = null }; - using (XmlReader xmlReader = XmlReader.Create(input, settings)) + using (var xmlReader = XmlReader.Create(input, settings)) { ProcessCppCheckLog(xmlReader, output, dataToInsert); } diff --git a/src/Sarif.Converters/FortifyConverter.cs b/src/Sarif.Converters/FortifyConverter.cs index 510948c65..b30909d11 100644 --- a/src/Sarif.Converters/FortifyConverter.cs +++ b/src/Sarif.Converters/FortifyConverter.cs @@ -55,7 +55,7 @@ public override void Convert(Stream input, IResultLogWriter output, OptionallyEm string runDescription = null; var results = new List(); - using (XmlReader reader = XmlReader.Create(input, settings)) + using (var reader = XmlReader.Create(input, settings)) { while (reader.Read()) { @@ -79,7 +79,7 @@ public override void Convert(Stream input, IResultLogWriter output, OptionallyEm { while (StringReference.AreEqual(reader.LocalName, _strings.Issue)) { - FortifyIssue fortify = FortifyIssue.Parse(reader, _strings); + var fortify = FortifyIssue.Parse(reader, _strings); results.Add(ConvertFortifyIssueToSarifIssue(fortify)); } } @@ -122,7 +122,7 @@ public static Result ConvertFortifyIssueToSarifIssue(FortifyIssue fortify) SarifUtilities.AddOrUpdateDictionaryEntry(result.PartialFingerprints, "InstanceId", fortify.InstanceId); } - List messageComponents = new List(); + var messageComponents = new List(); if (fortify.Abstract != null) { messageComponents.Add(fortify.Abstract); diff --git a/src/Sarif.Converters/FortifyFprConverter.cs b/src/Sarif.Converters/FortifyFprConverter.cs index 08388998e..c914e093f 100644 --- a/src/Sarif.Converters/FortifyFprConverter.cs +++ b/src/Sarif.Converters/FortifyFprConverter.cs @@ -277,7 +277,7 @@ internal static Dictionary GetOriginalUriBaseIdsDictio private XmlReader OpenAuditFvdlReader(Stream fprFileStream) { - ZipArchive fprArchive = new ZipArchive(fprFileStream); + var fprArchive = new ZipArchive(fprFileStream); ZipArchiveEntry auditEntry = fprArchive.Entries.Single(e => e.FullName.Equals("audit.fvdl")); var settings = new XmlReaderSettings @@ -459,7 +459,7 @@ private void ParseFile() if (!string.IsNullOrEmpty(fileName)) { - Uri uri = new Uri(fileName, UriKind.RelativeOrAbsolute); + var uri = new Uri(fileName, UriKind.RelativeOrAbsolute); var fileData = new Artifact { Encoding = encoding, @@ -851,7 +851,7 @@ private PhysicalLocation ParsePhysicalLocationFromSourceInfo() { string path = _reader.GetAttribute(_strings.PathAttribute); - PhysicalLocation location = new PhysicalLocation + var location = new PhysicalLocation { Region = ParseRegion() }; @@ -1057,7 +1057,7 @@ private void ParseNode() string nodeLabel = _reader.ReadElementContentAsString(); // Convert to SARIF types. - Node node = new Node( + var node = new Node( new ThreadFlowLocation { Kinds = ConvertActionTypeToLocationKinds(actionType), @@ -1156,7 +1156,7 @@ private void ParseSnippet() }; } - using (StringReader reader = new StringReader(text)) + using (var reader = new StringReader(text)) { // Read down to the first line we want to include. for (int i = 0; i < regionStartLine - snippetStartLine; i++) @@ -1270,7 +1270,7 @@ private ReportingDescriptor FindOrCreateRule(string ruleGuid, out int ruleIndex) { bool isGuid = Guid.TryParse(NormalizeGuid(ruleGuid), out Guid parsedGuid); - ReportingDescriptor rule = new ReportingDescriptor + var rule = new ReportingDescriptor { Id = ruleGuid, Guid = isGuid ? parsedGuid : (Guid?)null @@ -1317,7 +1317,7 @@ private bool AtEndOf(string elementName) private void AddMessagesToResult(Result result) { ReportingDescriptor rule = _rules[result.RuleIndex]; - Message message = new Message(); + var message = new Message(); string messageText = (rule.ShortDescription ?? rule.FullDescription)?.Text; diff --git a/src/Sarif.Converters/FortifyIssue.cs b/src/Sarif.Converters/FortifyIssue.cs index 3068f8520..9ee5df138 100644 --- a/src/Sarif.Converters/FortifyIssue.cs +++ b/src/Sarif.Converters/FortifyIssue.cs @@ -181,7 +181,7 @@ public static FortifyIssue Parse(XmlReader xmlReader, FortifyStrings strings) string friority = xmlReader.ReadOptionalElementContentAsString(strings.Friority); xmlReader.IgnoreElement(strings.Tag, IgnoreOptions.Optional | IgnoreOptions.Multiple); xmlReader.IgnoreElement(strings.Comment, IgnoreOptions.Optional | IgnoreOptions.Multiple); - FortifyPathElement primary = FortifyPathElement.Parse(xmlReader, strings); + var primary = FortifyPathElement.Parse(xmlReader, strings); FortifyPathElement source; if (xmlReader.NodeType == XmlNodeType.Element && StringReference.AreEqual(xmlReader.LocalName, strings.Source)) { diff --git a/src/Sarif.Converters/FxCopConverter.cs b/src/Sarif.Converters/FxCopConverter.cs index 1a5235fcc..b16c95569 100644 --- a/src/Sarif.Converters/FxCopConverter.cs +++ b/src/Sarif.Converters/FxCopConverter.cs @@ -88,7 +88,7 @@ internal ReportingDescriptor CreateRule(FxCopLogReader.Context context) internal Result CreateResult(FxCopLogReader.Context context) { - Result result = new Result(); + var result = new Result(); string uniqueId = context.GetUniqueId(); @@ -726,7 +726,7 @@ public FxCopLogReader() public void Read(Context context, Stream input) { - XmlSchemaSet schemaSet = new XmlSchemaSet(); + var schemaSet = new XmlSchemaSet(); Assembly assembly = typeof(FxCopLogReader).Assembly; var settings = new XmlReaderSettings { @@ -737,7 +737,7 @@ public void Read(Context context, Stream input) using (Stream stream = assembly.GetManifestResourceStream(FxCopLogReader.FxCopReportSchema)) using (var reader = XmlReader.Create(stream, settings)) { - XmlSchema schema = XmlSchema.Read(reader, new ValidationEventHandler(ReportError)); + var schema = XmlSchema.Read(reader, new ValidationEventHandler(ReportError)); schemaSet.Add(schema); } @@ -779,7 +779,7 @@ private static void ReportError(object sender, EventArgs e) private static void ReadFxCopReport(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; context.RefineReport(reader.ReadAttributeString(SchemaStrings.AttributeVersion)); reader.ReadChildren(SchemaStrings.ElementFxCopReport, parent); @@ -793,7 +793,7 @@ private static void ReadExceptions(SparseReader reader, object parent) private void ReadException(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; string ruleId = reader.ReadAttributeString(SchemaStrings.AttributeKeyword); string kind = reader.ReadAttributeString(SchemaStrings.AttributeKind); @@ -818,7 +818,7 @@ private void ReadException(SparseReader reader, object parent) private static void ReadExceptionType(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; if (context.Exception) { @@ -828,35 +828,35 @@ private static void ReadExceptionType(SparseReader reader, object parent) private static void ReadExceptionMessage(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; context.RefineExceptionMessage(reader.ReadElementContentAsString()); } private static void ReadStackTrace(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; context.RefineStackTrace(reader.ReadElementContentAsString()); } private void ReadInnerExceptionType(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; context.RefineInnerExceptionType(reader.ReadElementContentAsString()); } private static void ReadInnerExceptionMessage(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; context.RefineInnerExceptionMessage(reader.ReadElementContentAsString()); } private static void ReadInnerStackTrace(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; context.RefineInnerStackTrace(reader.ReadElementContentAsString()); } @@ -868,7 +868,7 @@ private static void ReadResources(SparseReader reader, object parent) private static void ReadResource(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; context.RefineResource(reader.ReadAttributeString(SchemaStrings.AttributeName)); reader.ReadChildren(SchemaStrings.ElementResource, parent); @@ -882,7 +882,7 @@ private static void ReadRules(SparseReader reader, object parent) private void ReadRule(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; context.RefineRule( typeName: reader.ReadAttributeString(SchemaStrings.AttributeTypeName), @@ -901,7 +901,7 @@ private void ReadRule(SparseReader reader, object parent) private static void ReadResolution(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; context.RefineResolution( name: reader.ReadAttributeString(SchemaStrings.AttributeName), @@ -915,7 +915,7 @@ private static void ReadTargets(SparseReader reader, object parent) private static void ReadTarget(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; context.RefineTarget(reader.ReadAttributeString(SchemaStrings.AttributeName)); reader.ReadChildren(SchemaStrings.ElementTarget, parent); @@ -929,7 +929,7 @@ private void ReadModules(SparseReader reader, object parent) private void ReadModule(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; context.RefineModule(reader.ReadAttributeString(SchemaStrings.AttributeName)); reader.ReadChildren(SchemaStrings.ElementModule, parent); @@ -943,7 +943,7 @@ private static void ReadNamespaces(SparseReader reader, object parent) private void ReadNamespace(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; context.RefineNamespace(reader.ReadAttributeString(SchemaStrings.AttributeName)); reader.ReadChildren(SchemaStrings.ElementNamespace, parent); @@ -957,7 +957,7 @@ private static void ReadTypes(SparseReader reader, object parent) private static void ReadType(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; if (context.Exception) { @@ -978,7 +978,7 @@ private static void ReadMembers(SparseReader reader, object parent) private static void ReadMember(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; context.RefineMember(reader.ReadAttributeString(SchemaStrings.AttributeName)); reader.ReadChildren(SchemaStrings.ElementMember, parent); @@ -992,7 +992,7 @@ private static void ReadMessages(SparseReader reader, object parent) private void ReadMessage(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; string messageId = reader.ReadAttributeString(SchemaStrings.AttributeId); string typename = reader.ReadAttributeString(SchemaStrings.AttributeTypeName); @@ -1022,7 +1022,7 @@ private void ReadMessage(SparseReader reader, object parent) private void ReadIssue(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; string resolutionName = reader.ReadAttributeString(SchemaStrings.AttributeName); string certainty = reader.ReadAttributeString(SchemaStrings.AttributeCertainty); @@ -1059,7 +1059,7 @@ private void ReadIssue(SparseReader reader, object parent) private void ReadItem(SparseReader reader, object parent) { - Context context = (Context)parent; + var context = (Context)parent; context.Items = context.Items ?? new List(); context.Items.Add(reader.ReadElementContentAsString()); } diff --git a/src/Sarif.Converters/PREFastConverter.cs b/src/Sarif.Converters/PREFastConverter.cs index 317b45c39..3c1056aca 100644 --- a/src/Sarif.Converters/PREFastConverter.cs +++ b/src/Sarif.Converters/PREFastConverter.cs @@ -28,7 +28,7 @@ public override void Convert(Stream input, IResultLogWriter output, OptionallyEm LogicalLocations.Clear(); - XmlReaderSettings settings = new XmlReaderSettings + var settings = new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore, XmlResolver = null diff --git a/src/Sarif.Converters/PylintConverter.cs b/src/Sarif.Converters/PylintConverter.cs index fcca17e42..90d0021fb 100644 --- a/src/Sarif.Converters/PylintConverter.cs +++ b/src/Sarif.Converters/PylintConverter.cs @@ -41,7 +41,7 @@ internal Result CreateResult(PylintLogEntry defect) { defect = defect ?? throw new ArgumentNullException(nameof(defect)); - Result result = new Result + var result = new Result { RuleId = $"{defect.MessageId}({defect.Symbol})", Message = new Message { Text = defect.Message }, diff --git a/src/Sarif.Converters/SemmleQlConverter.cs b/src/Sarif.Converters/SemmleQlConverter.cs index 2dc0b8713..583fc17a5 100644 --- a/src/Sarif.Converters/SemmleQlConverter.cs +++ b/src/Sarif.Converters/SemmleQlConverter.cs @@ -257,7 +257,7 @@ private IList NormalizeRawMessage(string rawMessage, out string normal /// private Region MakeRegion(List fields) { - Region region = new Region + var region = new Region { StartLine = GetInteger(fields, FieldIndex.StartLine), StartColumn = GetInteger(fields, FieldIndex.StartColumn), diff --git a/src/Sarif.Converters/SparseReader.cs b/src/Sarif.Converters/SparseReader.cs index a9515d5d7..d89531a6d 100644 --- a/src/Sarif.Converters/SparseReader.cs +++ b/src/Sarif.Converters/SparseReader.cs @@ -110,7 +110,9 @@ public void ReadChildren(string tagName, object parent, out string innerText) ReadStartElement(); if (isEmpty) + { return; // DONE with this element + } while (!IsEndState(tagName)) { diff --git a/src/Sarif.Converters/TSLintConverter.cs b/src/Sarif.Converters/TSLintConverter.cs index 9d7edfebb..325e3ceb7 100644 --- a/src/Sarif.Converters/TSLintConverter.cs +++ b/src/Sarif.Converters/TSLintConverter.cs @@ -41,7 +41,7 @@ internal Result CreateResult(TSLintLogEntry entry) { entry = entry ?? throw new ArgumentNullException(nameof(entry)); - Result result = new Result() + var result = new Result() { RuleId = entry.RuleName, Message = new Message { Text = entry.Failure }, @@ -63,7 +63,7 @@ internal Result CreateResult(TSLintLogEntry entry) break; } - Region region = new Region() + var region = new Region() { // The TSLint logs have line and column start at 0, Sarif has them starting at 1, so add 1 to each StartLine = entry.StartPosition.Line + 1, @@ -77,7 +77,7 @@ internal Result CreateResult(TSLintLogEntry entry) int length = entry.EndPosition.Position - entry.StartPosition.Position; region.CharLength = length > 0 ? length : 0; - Uri analysisTargetUri = new Uri(entry.Name, UriKind.Relative); + var analysisTargetUri = new Uri(entry.Name, UriKind.Relative); var physicalLocation = new PhysicalLocation { @@ -88,7 +88,7 @@ internal Result CreateResult(TSLintLogEntry entry) Region = region }; - Location location = new Location() + var location = new Location() { PhysicalLocation = physicalLocation }; @@ -104,7 +104,7 @@ internal Result CreateResult(TSLintLogEntry entry) foreach (TSLintLogFix fix in entry.Fixes) { - Replacement replacement = new Replacement(); + var replacement = new Replacement(); replacement.DeletedRegion = new Region { @@ -132,7 +132,7 @@ internal Result CreateResult(TSLintLogEntry entry) Replacements = replacements }; - Fix sarifFix = new Fix(description: null, artifactChanges: new List() { sarifFileChange }, properties: null); + var sarifFix = new Fix(description: null, artifactChanges: new List() { sarifFileChange }, properties: null); result.Fixes = new List { sarifFix }; } diff --git a/src/Sarif.Converters/TSLintLogReader.cs b/src/Sarif.Converters/TSLintLogReader.cs index 8a5d4cd51..e40a98a0e 100644 --- a/src/Sarif.Converters/TSLintLogReader.cs +++ b/src/Sarif.Converters/TSLintLogReader.cs @@ -32,7 +32,7 @@ public override TSLintLog ReadLog(Stream input) using (TextReader streamReader = new StreamReader(input)) using (JsonReader reader = new JsonTextReader(streamReader)) { - JToken rootToken = JToken.ReadFrom(reader); + var rootToken = JToken.ReadFrom(reader); rootToken = NormalizeLog(rootToken); string normalizedLogContents = rootToken.ToString(); using (Stream normalizedLogStream = new MemoryStream(Encoding.UTF8.GetBytes(normalizedLogContents))) diff --git a/src/Sarif.Driver/EnumerableExtensions.cs b/src/Sarif.Driver/EnumerableExtensions.cs index 66f7fc8ec..530191ab3 100644 --- a/src/Sarif.Driver/EnumerableExtensions.cs +++ b/src/Sarif.Driver/EnumerableExtensions.cs @@ -158,7 +158,7 @@ public static IList Shuffle(this IEnumerable sequence, Random randomNum // A naïve Knuth Fischer Yates shuffle. T swapTemp; - List values = sequence.ToList(); + var values = sequence.ToList(); int currentlySelecting = values.Count; while (currentlySelecting > 1) { diff --git a/src/Sarif.Driver/Sdk/CommandBase.cs b/src/Sarif.Driver/Sdk/CommandBase.cs index d397ffc4c..e7726532f 100644 --- a/src/Sarif.Driver/Sdk/CommandBase.cs +++ b/src/Sarif.Driver/Sdk/CommandBase.cs @@ -53,7 +53,7 @@ public static T ReadSarifFile(IFileSystem fileSystem, string filePath, IContr { var serializer = new JsonSerializer() { ContractResolver = contractResolver }; - using (JsonTextReader reader = new JsonTextReader(new StreamReader(fileSystem.FileOpenRead(filePath)))) + using (var reader = new JsonTextReader(new StreamReader(fileSystem.FileOpenRead(filePath)))) { return serializer.Deserialize(reader); } @@ -88,7 +88,7 @@ public static void WriteSarifFile(IFileSystem fileSystem, public static HashSet CreateTargetsSet(IEnumerable targetSpecifiers, bool recurse, IFileSystem fileSystem) { - HashSet targets = new HashSet(StringComparer.OrdinalIgnoreCase); + var targets = new HashSet(StringComparer.OrdinalIgnoreCase); foreach (string specifier in targetSpecifiers) { string normalizedSpecifier = specifier; diff --git a/src/Sarif.Driver/Sdk/EntryPointUtilities.cs b/src/Sarif.Driver/Sdk/EntryPointUtilities.cs index 4c052d467..fe528515f 100644 --- a/src/Sarif.Driver/Sdk/EntryPointUtilities.cs +++ b/src/Sarif.Driver/Sdk/EntryPointUtilities.cs @@ -14,7 +14,7 @@ public static string[] GenerateArguments( IFileSystem fileSystem, IEnvironmentVariables environmentVariables) { - List expandedArguments = new List(); + var expandedArguments = new List(); foreach (string argument in args) { diff --git a/src/Sarif.Driver/Sdk/ExportRulesMetadataCommandBase.cs b/src/Sarif.Driver/Sdk/ExportRulesMetadataCommandBase.cs index 33e8354a1..a2dd2d022 100644 --- a/src/Sarif.Driver/Sdk/ExportRulesMetadataCommandBase.cs +++ b/src/Sarif.Driver/Sdk/ExportRulesMetadataCommandBase.cs @@ -75,7 +75,7 @@ private void OutputSonarQubeRulesMetadata(string outputFilePath, ImmutableArray< const string TAB = " "; var sb = new StringBuilder(); - SortedDictionary sortedRuleContexts = new SortedDictionary(); + var sortedRuleContexts = new SortedDictionary(); foreach (ReportingDescriptor rule in skimmers) { @@ -128,7 +128,7 @@ private void OutputSarifRulesMetadata(string outputFilePath, ImmutableArray sortedRules = new SortedDictionary(); + var sortedRules = new SortedDictionary(); foreach (ReportingDescriptor rule in skimmers) { diff --git a/src/Sarif.Driver/SemanticVersion.cs b/src/Sarif.Driver/SemanticVersion.cs index f765b29d1..a2d4e2c06 100644 --- a/src/Sarif.Driver/SemanticVersion.cs +++ b/src/Sarif.Driver/SemanticVersion.cs @@ -293,9 +293,9 @@ public static explicit operator SemanticVersion(string version) internal static SemanticVersion MakeLegalVersion(string version) { // split off first NonNumeric or dot character - Regex regex = new Regex(@"[^0-9\\.]"); + var regex = new Regex(@"[^0-9\\.]"); Match match = regex.Match(version); - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); string tempVersion = string.Empty; string versionPart2 = string.Empty; diff --git a/src/Sarif.Driver/StringExtensions.cs b/src/Sarif.Driver/StringExtensions.cs index 23050139c..2fcb7db50 100644 --- a/src/Sarif.Driver/StringExtensions.cs +++ b/src/Sarif.Driver/StringExtensions.cs @@ -3,7 +3,7 @@ namespace Microsoft.CodeAnalysis.Sarif.Driver { - /// Extensions on the class. + /// Extensions on the class. public static class StringExtensions { /// Gets a null value for null or whitespace strings. Otherwise passes though the source string unchanged. diff --git a/src/Sarif.Multitool.Library/ApplyPolicyCommand.cs b/src/Sarif.Multitool.Library/ApplyPolicyCommand.cs index 57421ac28..32d1e193d 100644 --- a/src/Sarif.Multitool.Library/ApplyPolicyCommand.cs +++ b/src/Sarif.Multitool.Library/ApplyPolicyCommand.cs @@ -22,7 +22,7 @@ public int Run(ApplyPolicyOptions options) try { Console.WriteLine($"Applying policy '{options.InputFilePath}' => '{options.OutputFilePath}'..."); - Stopwatch w = Stopwatch.StartNew(); + var w = Stopwatch.StartNew(); bool valid = ValidateOptions(options); if (!valid) { return FAILURE; } diff --git a/src/Sarif.Multitool.Library/ConvertCommand.cs b/src/Sarif.Multitool.Library/ConvertCommand.cs index 366181266..5758fbd28 100644 --- a/src/Sarif.Multitool.Library/ConvertCommand.cs +++ b/src/Sarif.Multitool.Library/ConvertCommand.cs @@ -57,12 +57,12 @@ public int Run(ConvertOptions convertOptions, IFileSystem fileSystem = null) { SarifLog sarifLog; - JsonSerializer serializer = new JsonSerializer() + var serializer = new JsonSerializer() { Formatting = convertOptions.PrettyPrint ? Formatting.Indented : 0, }; - using (JsonTextReader reader = new JsonTextReader(new StreamReader(convertOptions.OutputFilePath))) + using (var reader = new JsonTextReader(new StreamReader(convertOptions.OutputFilePath))) { sarifLog = serializer.Deserialize(reader); } @@ -71,8 +71,8 @@ public int Run(ConvertOptions convertOptions, IFileSystem fileSystem = null) visitor.VisitSarifLog(sarifLog); using (FileStream stream = File.Create(convertOptions.OutputFilePath)) - using (StreamWriter streamWriter = new StreamWriter(stream)) - using (JsonTextWriter writer = new JsonTextWriter(streamWriter)) + using (var streamWriter = new StreamWriter(stream)) + using (var writer = new JsonTextWriter(streamWriter)) { serializer.Serialize(writer, sarifLog); } diff --git a/src/Sarif.Multitool.Library/MergeCommand.cs b/src/Sarif.Multitool.Library/MergeCommand.cs index 39c0b8fb7..9d5f70609 100644 --- a/src/Sarif.Multitool.Library/MergeCommand.cs +++ b/src/Sarif.Multitool.Library/MergeCommand.cs @@ -40,7 +40,7 @@ public MergeCommand(IFileSystem fileSystem = null) : base(fileSystem) public int Run(MergeOptions mergeOptions) { - Stopwatch w = Stopwatch.StartNew(); + var w = Stopwatch.StartNew(); try { _options = mergeOptions; diff --git a/src/Sarif.Multitool.Library/PageCommand.cs b/src/Sarif.Multitool.Library/PageCommand.cs index 5535aec03..36ddc985e 100644 --- a/src/Sarif.Multitool.Library/PageCommand.cs +++ b/src/Sarif.Multitool.Library/PageCommand.cs @@ -107,7 +107,7 @@ internal SarifLog PageViaOm(PageOptions options) private JsonMapNode LoadOrRebuildMap(PageOptions options) { JsonMapNode root; - Stopwatch w = Stopwatch.StartNew(); + var w = Stopwatch.StartNew(); string mapPath = Path.ChangeExtension(options.InputFilePath, ".map.json"); @@ -139,7 +139,7 @@ private JsonMapNode LoadOrRebuildMap(PageOptions options) private void ExtractPage(PageOptions options, JsonMapNode root) { - Stopwatch w = Stopwatch.StartNew(); + var w = Stopwatch.StartNew(); Console.WriteLine($"Extracting {options.Count:n0} results from index {options.Index:n0}\r\n from \"{options.InputFilePath}\"\r\n into \"{options.OutputFilePath}\"..."); JsonMapNode runs, run, results; diff --git a/src/Sarif.Multitool.Library/QueryCommand.cs b/src/Sarif.Multitool.Library/QueryCommand.cs index 78959394e..4ba76fba3 100644 --- a/src/Sarif.Multitool.Library/QueryCommand.cs +++ b/src/Sarif.Multitool.Library/QueryCommand.cs @@ -41,7 +41,7 @@ public int RunWithoutCatch(QueryOptions options) bool valid = DriverUtilities.ReportWhetherOutputFileCanBeCreated(options.OutputFilePath, options.Force, _fileSystem); if (!valid) { return FAILURE; } - Stopwatch w = Stopwatch.StartNew(); + var w = Stopwatch.StartNew(); int originalTotal = 0; int matchCount = 0; @@ -60,7 +60,7 @@ public int RunWithoutCatch(QueryOptions options) originalTotal += run.Results.Count; // Find matches for Results in the Run - BitArray matches = new BitArray(run.Results.Count); + var matches = new BitArray(run.Results.Count); evaluator.Evaluate(run.Results, matches); // Count the new matches diff --git a/src/Sarif.Multitool.Library/RewriteCommand.cs b/src/Sarif.Multitool.Library/RewriteCommand.cs index a46fe7004..40db2cade 100644 --- a/src/Sarif.Multitool.Library/RewriteCommand.cs +++ b/src/Sarif.Multitool.Library/RewriteCommand.cs @@ -30,7 +30,7 @@ public int Run(RewriteOptions options) try { Console.WriteLine($"Rewriting '{options.InputFilePath}' => '{options.OutputFilePath}'..."); - Stopwatch w = Stopwatch.StartNew(); + var w = Stopwatch.StartNew(); bool valid = ValidateOptions(options); if (!valid) @@ -126,7 +126,7 @@ private bool ValidateOptions(RewriteOptions rewriteOptions) // #2271 https://github.com/microsoft/sarif-sdk/issues/2271 private string SniffVersion(string sarifPath) { - using (JsonTextReader reader = new JsonTextReader(new StreamReader(_fileSystem.FileOpenRead(sarifPath)))) + using (var reader = new JsonTextReader(new StreamReader(_fileSystem.FileOpenRead(sarifPath)))) { while (reader.Read()) { diff --git a/src/Sarif.Multitool.Library/Rules/SARIF1005.UriMustBeAbsolute.cs b/src/Sarif.Multitool.Library/Rules/SARIF1005.UriMustBeAbsolute.cs index f46630865..89b50e292 100644 --- a/src/Sarif.Multitool.Library/Rules/SARIF1005.UriMustBeAbsolute.cs +++ b/src/Sarif.Multitool.Library/Rules/SARIF1005.UriMustBeAbsolute.cs @@ -81,7 +81,7 @@ private void AnalyzeUri(string uriString, string pointer) { // Ok, it's a well-formed URI of some kind. If it's not absolute, _now_ we // can report it. - Uri uri = new Uri(uriString, UriKind.RelativeOrAbsolute); + var uri = new Uri(uriString, UriKind.RelativeOrAbsolute); if (!uri.IsAbsoluteUri) { // {0}: The value of this property is required to be an absolute URI, but '{1}' is a relative URI reference. diff --git a/src/Sarif.Multitool.Library/Rules/SARIF2004.OptimizeFileSize.cs b/src/Sarif.Multitool.Library/Rules/SARIF2004.OptimizeFileSize.cs index b25649f1a..e3c229a28 100644 --- a/src/Sarif.Multitool.Library/Rules/SARIF2004.OptimizeFileSize.cs +++ b/src/Sarif.Multitool.Library/Rules/SARIF2004.OptimizeFileSize.cs @@ -7,8 +7,6 @@ using Microsoft.Json.Pointer; -using Newtonsoft.Json.Linq; - namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules { public class OptimizeFileSize : SarifValidationSkimmerBase @@ -186,7 +184,7 @@ private void AnalyzeLocationOnlyArtifacts(Run run, string runPointer) private bool HasResultLocationsWithUriAndIndex(string resultPointer) { - JToken resultToken = resultPointer.ToJToken(Context.InputLogToken); + var resultToken = resultPointer.ToJToken(Context.InputLogToken); return resultToken.HasProperty(SarifPropertyName.Uri) && resultToken.HasProperty(SarifPropertyName.Index); @@ -194,7 +192,7 @@ private bool HasResultLocationsWithUriAndIndex(string resultPointer) private bool HasLocationOnlyArtifacts(string artifactPointer) { - JToken artifactToken = artifactPointer.ToJToken(Context.InputLogToken); + var artifactToken = artifactPointer.ToJToken(Context.InputLogToken); return artifactToken.HasProperty(SarifPropertyName.Location) && artifactToken.Children().Count() == 1; @@ -236,7 +234,7 @@ private void AnalyzeIdOnlyRules(Run run, string runPointer) private bool HasIdOnlyRules(string rulePointer) { - JToken ruleToken = rulePointer.ToJToken(Context.InputLogToken); + var ruleToken = rulePointer.ToJToken(Context.InputLogToken); return ruleToken.HasProperty(SarifPropertyName.Id) && ruleToken.Children().Count() == 1; diff --git a/src/Sarif.Multitool.Library/Rules/SARIF2006.UrisShouldBeReachable.cs b/src/Sarif.Multitool.Library/Rules/SARIF2006.UrisShouldBeReachable.cs index aa234ced3..dc4e9ce3f 100644 --- a/src/Sarif.Multitool.Library/Rules/SARIF2006.UrisShouldBeReachable.cs +++ b/src/Sarif.Multitool.Library/Rules/SARIF2006.UrisShouldBeReachable.cs @@ -90,7 +90,7 @@ private void AnalyzeUri(string uriString, string pointer) if (uriString != null && IsWellFormedUriString(uriString, UriKind.Absolute)) { // Ok, it's a well-formed absolute URI. If it's not reachable, _now_ we can report it. - Uri uri = new Uri(uriString, UriKind.Absolute); + var uri = new Uri(uriString, UriKind.Absolute); if (uri.AbsoluteUri != "https://schemastore.azurewebsites.net/schemas/json/sarif-2.1.0-rtm.6.json" && // TODO: Shaopeng to remove after finalized and published. !IsUriReachable(uri.AbsoluteUri)) diff --git a/src/Sarif.Multitool/AnalyzeTestCommand.cs b/src/Sarif.Multitool/AnalyzeTestCommand.cs index 7de2acc74..1f3acb5dc 100644 --- a/src/Sarif.Multitool/AnalyzeTestCommand.cs +++ b/src/Sarif.Multitool/AnalyzeTestCommand.cs @@ -2,7 +2,6 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.Collections.Generic; using System.Reflection; diff --git a/src/Sarif.Multitool/AnalyzeTestContext.cs b/src/Sarif.Multitool/AnalyzeTestContext.cs index bb33ce970..66139ec9c 100644 --- a/src/Sarif.Multitool/AnalyzeTestContext.cs +++ b/src/Sarif.Multitool/AnalyzeTestContext.cs @@ -2,8 +2,6 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; - namespace Microsoft.CodeAnalysis.Sarif.Multitool { #pragma warning disable CS0618 diff --git a/src/Sarif.Multitool/Program.cs b/src/Sarif.Multitool/Program.cs index 0cf31ce01..f533c8d22 100644 --- a/src/Sarif.Multitool/Program.cs +++ b/src/Sarif.Multitool/Program.cs @@ -17,7 +17,7 @@ internal static class Program /// 0 on success; nonzero on failure. public static int Main(string[] args) { - OptionsInterpretter optionsInterpretter = new OptionsInterpretter(); + var optionsInterpretter = new OptionsInterpretter(); return Parser.Default.ParseArguments< // Keep this in alphabetical order diff --git a/src/Sarif/ArtifactProvider.cs b/src/Sarif/ArtifactProvider.cs index ad9e06cc8..ccc9489ba 100644 --- a/src/Sarif/ArtifactProvider.cs +++ b/src/Sarif/ArtifactProvider.cs @@ -1,10 +1,7 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.Collections.Generic; -using System.IO; -using System.IO.Compression; namespace Microsoft.CodeAnalysis.Sarif { diff --git a/src/Sarif/Autogenerated/Address.cs b/src/Sarif/Autogenerated/Address.cs index 176243c2c..162cc3da1 100644 --- a/src/Sarif/Autogenerated/Address.cs +++ b/src/Sarif/Autogenerated/Address.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; diff --git a/src/Sarif/Autogenerated/AddressComparer.cs b/src/Sarif/Autogenerated/AddressComparer.cs index e339fb03f..ff1e2e990 100644 --- a/src/Sarif/Autogenerated/AddressComparer.cs +++ b/src/Sarif/Autogenerated/AddressComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -89,4 +88,4 @@ public int Compare(Address left, Address right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/AddressEqualityComparer.cs b/src/Sarif/Autogenerated/AddressEqualityComparer.cs index 5ee42023d..18660f6cc 100644 --- a/src/Sarif/Autogenerated/AddressEqualityComparer.cs +++ b/src/Sarif/Autogenerated/AddressEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -148,4 +147,4 @@ public int GetHashCode(Address obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/Artifact.cs b/src/Sarif/Autogenerated/Artifact.cs index 1c2e62794..84928ca09 100644 --- a/src/Sarif/Autogenerated/Artifact.cs +++ b/src/Sarif/Autogenerated/Artifact.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Runtime.Serialization; + using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif @@ -249,4 +250,4 @@ protected virtual void Init(Message description, ArtifactLocation location, int } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ArtifactChange.cs b/src/Sarif/Autogenerated/ArtifactChange.cs index c9af80d79..5ec76bd27 100644 --- a/src/Sarif/Autogenerated/ArtifactChange.cs +++ b/src/Sarif/Autogenerated/ArtifactChange.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -143,4 +143,4 @@ protected virtual void Init(ArtifactLocation artifactLocation, IEnumerable threadFlows if (threadFlows != null) { var destination_0 = new List(); - foreach (var value_0 in threadFlows) + foreach (ThreadFlow value_0 in threadFlows) { if (value_0 == null) { @@ -143,4 +143,4 @@ protected virtual void Init(Message message, IEnumerable threadFlows } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/CodeFlowComparer.cs b/src/Sarif/Autogenerated/CodeFlowComparer.cs index f54422ade..6302fd5b2 100644 --- a/src/Sarif/Autogenerated/CodeFlowComparer.cs +++ b/src/Sarif/Autogenerated/CodeFlowComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -47,4 +46,4 @@ public int Compare(CodeFlow left, CodeFlow right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/CodeFlowEqualityComparer.cs b/src/Sarif/Autogenerated/CodeFlowEqualityComparer.cs index 8fdd1a04d..6e784007d 100644 --- a/src/Sarif/Autogenerated/CodeFlowEqualityComparer.cs +++ b/src/Sarif/Autogenerated/CodeFlowEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -125,4 +124,4 @@ public int GetHashCode(CodeFlow obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ColumnKind.cs b/src/Sarif/Autogenerated/ColumnKind.cs index 9bc1648e7..b8e522e18 100644 --- a/src/Sarif/Autogenerated/ColumnKind.cs +++ b/src/Sarif/Autogenerated/ColumnKind.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.CodeDom.Compiler; @@ -15,4 +15,4 @@ public enum ColumnKind Utf16CodeUnits, UnicodeCodePoints } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ComparerExtensions.cs b/src/Sarif/Autogenerated/ComparerExtensions.cs index 9f54fb42f..7d2409ea7 100644 --- a/src/Sarif/Autogenerated/ComparerExtensions.cs +++ b/src/Sarif/Autogenerated/ComparerExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -188,4 +188,4 @@ public static int ObjectCompares(this object left, object right) return Comparer.Default.Compare(left, right); } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ConfigurationOverride.cs b/src/Sarif/Autogenerated/ConfigurationOverride.cs index 279139812..005b8220c 100644 --- a/src/Sarif/Autogenerated/ConfigurationOverride.cs +++ b/src/Sarif/Autogenerated/ConfigurationOverride.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -130,4 +130,4 @@ protected virtual void Init(ReportingConfiguration configuration, ReportingDescr } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ConfigurationOverrideComparer.cs b/src/Sarif/Autogenerated/ConfigurationOverrideComparer.cs index cb40f8165..180457623 100644 --- a/src/Sarif/Autogenerated/ConfigurationOverrideComparer.cs +++ b/src/Sarif/Autogenerated/ConfigurationOverrideComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -47,4 +46,4 @@ public int Compare(ConfigurationOverride left, ConfigurationOverride right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ConfigurationOverrideEqualityComparer.cs b/src/Sarif/Autogenerated/ConfigurationOverrideEqualityComparer.cs index 6ba8f5a2c..15cd63a62 100644 --- a/src/Sarif/Autogenerated/ConfigurationOverrideEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ConfigurationOverrideEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -102,4 +101,4 @@ public int GetHashCode(ConfigurationOverride obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/Conversion.cs b/src/Sarif/Autogenerated/Conversion.cs index 69871c8f5..578ba9e35 100644 --- a/src/Sarif/Autogenerated/Conversion.cs +++ b/src/Sarif/Autogenerated/Conversion.cs @@ -1,10 +1,11 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Runtime.Serialization; + using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif @@ -159,4 +160,4 @@ protected virtual void Init(Tool tool, Invocation invocation, IEnumerable(); - foreach (var value_0 in innerExceptions) + foreach (ExceptionData value_0 in innerExceptions) { if (value_0 == null) { @@ -165,4 +166,4 @@ protected virtual void Init(string kind, string message, Stack stack, IEnumerabl } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ExceptionDataComparer.cs b/src/Sarif/Autogenerated/ExceptionDataComparer.cs index 71fcfd5ae..d48bddfee 100644 --- a/src/Sarif/Autogenerated/ExceptionDataComparer.cs +++ b/src/Sarif/Autogenerated/ExceptionDataComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -59,4 +58,4 @@ public int Compare(ExceptionData left, ExceptionData right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ExceptionDataEqualityComparer.cs b/src/Sarif/Autogenerated/ExceptionDataEqualityComparer.cs index 96d4817b5..9b052343c 100644 --- a/src/Sarif/Autogenerated/ExceptionDataEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ExceptionDataEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -145,4 +144,4 @@ public int GetHashCode(ExceptionData obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ExternalProperties.cs b/src/Sarif/Autogenerated/ExternalProperties.cs index b335f3e15..270741adb 100644 --- a/src/Sarif/Autogenerated/ExternalProperties.cs +++ b/src/Sarif/Autogenerated/ExternalProperties.cs @@ -1,10 +1,11 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Runtime.Serialization; + using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif @@ -553,4 +554,4 @@ protected virtual void Init(Uri schema, SarifVersion version, Guid? guid, Guid? } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ExternalPropertiesComparer.cs b/src/Sarif/Autogenerated/ExternalPropertiesComparer.cs index 207077036..2b1b7ee65 100644 --- a/src/Sarif/Autogenerated/ExternalPropertiesComparer.cs +++ b/src/Sarif/Autogenerated/ExternalPropertiesComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -155,4 +154,4 @@ public int Compare(ExternalProperties left, ExternalProperties right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ExternalPropertiesEqualityComparer.cs b/src/Sarif/Autogenerated/ExternalPropertiesEqualityComparer.cs index d18f66e16..53bf6ffe2 100644 --- a/src/Sarif/Autogenerated/ExternalPropertiesEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ExternalPropertiesEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -577,4 +576,4 @@ public int GetHashCode(ExternalProperties obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ExternalPropertyFileReference.cs b/src/Sarif/Autogenerated/ExternalPropertyFileReference.cs index 78585e40d..7b0169212 100644 --- a/src/Sarif/Autogenerated/ExternalPropertyFileReference.cs +++ b/src/Sarif/Autogenerated/ExternalPropertyFileReference.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Runtime.Serialization; + using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif @@ -141,4 +142,4 @@ protected virtual void Init(ArtifactLocation location, Guid? guid, int itemCount } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ExternalPropertyFileReferenceComparer.cs b/src/Sarif/Autogenerated/ExternalPropertyFileReferenceComparer.cs index ab2fc0dbf..e537c9468 100644 --- a/src/Sarif/Autogenerated/ExternalPropertyFileReferenceComparer.cs +++ b/src/Sarif/Autogenerated/ExternalPropertyFileReferenceComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -53,4 +52,4 @@ public int Compare(ExternalPropertyFileReference left, ExternalPropertyFileRefer return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ExternalPropertyFileReferenceEqualityComparer.cs b/src/Sarif/Autogenerated/ExternalPropertyFileReferenceEqualityComparer.cs index c70006cd2..b5307a0c9 100644 --- a/src/Sarif/Autogenerated/ExternalPropertyFileReferenceEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ExternalPropertyFileReferenceEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -108,4 +107,4 @@ public int GetHashCode(ExternalPropertyFileReference obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ExternalPropertyFileReferences.cs b/src/Sarif/Autogenerated/ExternalPropertyFileReferences.cs index 3387f59e6..ee25bc0cb 100644 --- a/src/Sarif/Autogenerated/ExternalPropertyFileReferences.cs +++ b/src/Sarif/Autogenerated/ExternalPropertyFileReferences.cs @@ -1,10 +1,11 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Runtime.Serialization; + using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif @@ -509,4 +510,4 @@ protected virtual void Init(ExternalPropertyFileReference conversion, IEnumerabl } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ExternalPropertyFileReferencesComparer.cs b/src/Sarif/Autogenerated/ExternalPropertyFileReferencesComparer.cs index bb1fa1c38..5d9b0c733 100644 --- a/src/Sarif/Autogenerated/ExternalPropertyFileReferencesComparer.cs +++ b/src/Sarif/Autogenerated/ExternalPropertyFileReferencesComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -131,4 +130,4 @@ public int Compare(ExternalPropertyFileReferences left, ExternalPropertyFileRefe return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ExternalPropertyFileReferencesEqualityComparer.cs b/src/Sarif/Autogenerated/ExternalPropertyFileReferencesEqualityComparer.cs index 7af288312..8e4ce159e 100644 --- a/src/Sarif/Autogenerated/ExternalPropertyFileReferencesEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ExternalPropertyFileReferencesEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -541,4 +540,4 @@ public int GetHashCode(ExternalPropertyFileReferences obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/FailureLevel.cs b/src/Sarif/Autogenerated/FailureLevel.cs index bbd402b73..e62e6ab4a 100644 --- a/src/Sarif/Autogenerated/FailureLevel.cs +++ b/src/Sarif/Autogenerated/FailureLevel.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.CodeDom.Compiler; @@ -16,4 +16,4 @@ public enum FailureLevel Warning, Error } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/Fix.cs b/src/Sarif/Autogenerated/Fix.cs index 2d5ba7395..4f76ee0f0 100644 --- a/src/Sarif/Autogenerated/Fix.cs +++ b/src/Sarif/Autogenerated/Fix.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -143,4 +143,4 @@ protected virtual void Init(Message description, IEnumerable art } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/FixComparer.cs b/src/Sarif/Autogenerated/FixComparer.cs index edf863f8c..e7448b336 100644 --- a/src/Sarif/Autogenerated/FixComparer.cs +++ b/src/Sarif/Autogenerated/FixComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -47,4 +46,4 @@ public int Compare(Fix left, Fix right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/FixEqualityComparer.cs b/src/Sarif/Autogenerated/FixEqualityComparer.cs index 9e117ce2c..0a2c74a95 100644 --- a/src/Sarif/Autogenerated/FixEqualityComparer.cs +++ b/src/Sarif/Autogenerated/FixEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -125,4 +124,4 @@ public int GetHashCode(Fix obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/Graph.cs b/src/Sarif/Autogenerated/Graph.cs index 65a8d5f31..a99c1abc4 100644 --- a/src/Sarif/Autogenerated/Graph.cs +++ b/src/Sarif/Autogenerated/Graph.cs @@ -1,10 +1,11 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Runtime.Serialization; + using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif @@ -173,4 +174,4 @@ protected virtual void Init(Message description, IEnumerable nodes, IEnume } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/GraphComparer.cs b/src/Sarif/Autogenerated/GraphComparer.cs index 075c92eea..9c9ddb1a7 100644 --- a/src/Sarif/Autogenerated/GraphComparer.cs +++ b/src/Sarif/Autogenerated/GraphComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -53,4 +52,4 @@ public int Compare(Graph left, Graph right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/GraphEqualityComparer.cs b/src/Sarif/Autogenerated/GraphEqualityComparer.cs index 255da37f6..c19c076d4 100644 --- a/src/Sarif/Autogenerated/GraphEqualityComparer.cs +++ b/src/Sarif/Autogenerated/GraphEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -158,4 +157,4 @@ public int GetHashCode(Graph obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/GraphTraversal.cs b/src/Sarif/Autogenerated/GraphTraversal.cs index b89295c6e..3fb9f6b7a 100644 --- a/src/Sarif/Autogenerated/GraphTraversal.cs +++ b/src/Sarif/Autogenerated/GraphTraversal.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Runtime.Serialization; + using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif @@ -200,4 +201,4 @@ protected virtual void Init(int runGraphIndex, int resultGraphIndex, Message des } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/GraphTraversalComparer.cs b/src/Sarif/Autogenerated/GraphTraversalComparer.cs index 04e431411..00b631cf1 100644 --- a/src/Sarif/Autogenerated/GraphTraversalComparer.cs +++ b/src/Sarif/Autogenerated/GraphTraversalComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -71,4 +70,4 @@ public int Compare(GraphTraversal left, GraphTraversal right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/GraphTraversalEqualityComparer.cs b/src/Sarif/Autogenerated/GraphTraversalEqualityComparer.cs index 0d006500f..5f8a3e246 100644 --- a/src/Sarif/Autogenerated/GraphTraversalEqualityComparer.cs +++ b/src/Sarif/Autogenerated/GraphTraversalEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -185,4 +184,4 @@ public int GetHashCode(GraphTraversal obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ISarifNode.cs b/src/Sarif/Autogenerated/ISarifNode.cs index 02aa3ef1b..b398fcfe2 100644 --- a/src/Sarif/Autogenerated/ISarifNode.cs +++ b/src/Sarif/Autogenerated/ISarifNode.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.CodeDom.Compiler; @@ -21,4 +21,4 @@ public interface ISarifNode /// ISarifNode DeepClone(); } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/Invocation.cs b/src/Sarif/Autogenerated/Invocation.cs index 432f81129..79c139059 100644 --- a/src/Sarif/Autogenerated/Invocation.cs +++ b/src/Sarif/Autogenerated/Invocation.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -339,7 +339,7 @@ protected virtual void Init(string commandLine, IEnumerable arguments, I if (arguments != null) { var destination_0 = new List(); - foreach (var value_0 in arguments) + foreach (string value_0 in arguments) { destination_0.Add(value_0); } @@ -350,7 +350,7 @@ protected virtual void Init(string commandLine, IEnumerable arguments, I if (responseFiles != null) { var destination_1 = new List(); - foreach (var value_1 in responseFiles) + foreach (ArtifactLocation value_1 in responseFiles) { if (value_1 == null) { @@ -371,7 +371,7 @@ protected virtual void Init(string commandLine, IEnumerable arguments, I if (ruleConfigurationOverrides != null) { var destination_2 = new List(); - foreach (var value_2 in ruleConfigurationOverrides) + foreach (ConfigurationOverride value_2 in ruleConfigurationOverrides) { if (value_2 == null) { @@ -389,7 +389,7 @@ protected virtual void Init(string commandLine, IEnumerable arguments, I if (notificationConfigurationOverrides != null) { var destination_3 = new List(); - foreach (var value_3 in notificationConfigurationOverrides) + foreach (ConfigurationOverride value_3 in notificationConfigurationOverrides) { if (value_3 == null) { @@ -407,7 +407,7 @@ protected virtual void Init(string commandLine, IEnumerable arguments, I if (toolExecutionNotifications != null) { var destination_4 = new List(); - foreach (var value_4 in toolExecutionNotifications) + foreach (Notification value_4 in toolExecutionNotifications) { if (value_4 == null) { @@ -425,7 +425,7 @@ protected virtual void Init(string commandLine, IEnumerable arguments, I if (toolConfigurationNotifications != null) { var destination_5 = new List(); - foreach (var value_5 in toolConfigurationNotifications) + foreach (Notification value_5 in toolConfigurationNotifications) { if (value_5 == null) { diff --git a/src/Sarif/Autogenerated/InvocationComparer.cs b/src/Sarif/Autogenerated/InvocationComparer.cs index 84519509c..ee81f49e3 100644 --- a/src/Sarif/Autogenerated/InvocationComparer.cs +++ b/src/Sarif/Autogenerated/InvocationComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -185,4 +184,4 @@ public int Compare(Invocation left, Invocation right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/InvocationEqualityComparer.cs b/src/Sarif/Autogenerated/InvocationEqualityComparer.cs index e51fb8624..8559d7ce0 100644 --- a/src/Sarif/Autogenerated/InvocationEqualityComparer.cs +++ b/src/Sarif/Autogenerated/InvocationEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -474,4 +473,4 @@ public int GetHashCode(Invocation obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/Location.cs b/src/Sarif/Autogenerated/Location.cs index 2aa8d21a2..85793a0dc 100644 --- a/src/Sarif/Autogenerated/Location.cs +++ b/src/Sarif/Autogenerated/Location.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -169,7 +169,7 @@ protected virtual void Init(BigInteger id, PhysicalLocation physicalLocation, IE if (logicalLocations != null) { var destination_0 = new List(); - foreach (var value_0 in logicalLocations) + foreach (LogicalLocation value_0 in logicalLocations) { if (value_0 == null) { @@ -192,7 +192,7 @@ protected virtual void Init(BigInteger id, PhysicalLocation physicalLocation, IE if (annotations != null) { var destination_1 = new List(); - foreach (var value_1 in annotations) + foreach (Region value_1 in annotations) { if (value_1 == null) { @@ -210,7 +210,7 @@ protected virtual void Init(BigInteger id, PhysicalLocation physicalLocation, IE if (relationships != null) { var destination_2 = new List(); - foreach (var value_2 in relationships) + foreach (LocationRelationship value_2 in relationships) { if (value_2 == null) { diff --git a/src/Sarif/Autogenerated/LocationComparer.cs b/src/Sarif/Autogenerated/LocationComparer.cs index 7e0748148..38efcba36 100644 --- a/src/Sarif/Autogenerated/LocationComparer.cs +++ b/src/Sarif/Autogenerated/LocationComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -71,4 +70,4 @@ public int Compare(Location left, Location right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/LocationEqualityComparer.cs b/src/Sarif/Autogenerated/LocationEqualityComparer.cs index 280751d4d..9fa7e66d0 100644 --- a/src/Sarif/Autogenerated/LocationEqualityComparer.cs +++ b/src/Sarif/Autogenerated/LocationEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -207,4 +206,4 @@ public int GetHashCode(Location obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/LocationRelationship.cs b/src/Sarif/Autogenerated/LocationRelationship.cs index 91725c50a..098896a5f 100644 --- a/src/Sarif/Autogenerated/LocationRelationship.cs +++ b/src/Sarif/Autogenerated/LocationRelationship.cs @@ -1,10 +1,11 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Runtime.Serialization; + using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif @@ -148,4 +149,4 @@ protected virtual void Init(int target, IEnumerable kinds, Message descr } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/LocationRelationshipComparer.cs b/src/Sarif/Autogenerated/LocationRelationshipComparer.cs index b6c3f97a9..7c9a5eb8e 100644 --- a/src/Sarif/Autogenerated/LocationRelationshipComparer.cs +++ b/src/Sarif/Autogenerated/LocationRelationshipComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -53,4 +52,4 @@ public int Compare(LocationRelationship left, LocationRelationship right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/LocationRelationshipEqualityComparer.cs b/src/Sarif/Autogenerated/LocationRelationshipEqualityComparer.cs index 1f81a2e82..cfa3ac3e1 100644 --- a/src/Sarif/Autogenerated/LocationRelationshipEqualityComparer.cs +++ b/src/Sarif/Autogenerated/LocationRelationshipEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -131,4 +130,4 @@ public int GetHashCode(LocationRelationship obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/LogicalLocation.cs b/src/Sarif/Autogenerated/LogicalLocation.cs index 486dc14c1..108f3bf3e 100644 --- a/src/Sarif/Autogenerated/LogicalLocation.cs +++ b/src/Sarif/Autogenerated/LogicalLocation.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Runtime.Serialization; + using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif @@ -170,4 +171,4 @@ protected virtual void Init(string name, int index, string fullyQualifiedName, s } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/LogicalLocationComparer.cs b/src/Sarif/Autogenerated/LogicalLocationComparer.cs index be27e7647..fb9f54797 100644 --- a/src/Sarif/Autogenerated/LogicalLocationComparer.cs +++ b/src/Sarif/Autogenerated/LogicalLocationComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -71,4 +70,4 @@ public int Compare(LogicalLocation left, LogicalLocation right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/LogicalLocationEqualityComparer.cs b/src/Sarif/Autogenerated/LogicalLocationEqualityComparer.cs index fc7e2d051..99935de85 100644 --- a/src/Sarif/Autogenerated/LogicalLocationEqualityComparer.cs +++ b/src/Sarif/Autogenerated/LogicalLocationEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -134,4 +133,4 @@ public int GetHashCode(LogicalLocation obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/Message.cs b/src/Sarif/Autogenerated/Message.cs index 29b98476f..12d923e68 100644 --- a/src/Sarif/Autogenerated/Message.cs +++ b/src/Sarif/Autogenerated/Message.cs @@ -1,10 +1,11 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Runtime.Serialization; + using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif @@ -140,7 +141,7 @@ protected virtual void Init(string text, string markdown, string id, IEnumerable if (arguments != null) { var destination_0 = new List(); - foreach (var value_0 in arguments) + foreach (string value_0 in arguments) { destination_0.Add(value_0); } @@ -154,4 +155,4 @@ protected virtual void Init(string text, string markdown, string id, IEnumerable } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/MessageComparer.cs b/src/Sarif/Autogenerated/MessageComparer.cs index 2102913ee..63fb48f1f 100644 --- a/src/Sarif/Autogenerated/MessageComparer.cs +++ b/src/Sarif/Autogenerated/MessageComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -59,4 +58,4 @@ public int Compare(Message left, Message right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/MessageEqualityComparer.cs b/src/Sarif/Autogenerated/MessageEqualityComparer.cs index 82763a1e6..11c49f6bc 100644 --- a/src/Sarif/Autogenerated/MessageEqualityComparer.cs +++ b/src/Sarif/Autogenerated/MessageEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -145,4 +144,4 @@ public int GetHashCode(Message obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/MultiformatMessageString.cs b/src/Sarif/Autogenerated/MultiformatMessageString.cs index 06d701007..65a84ff2a 100644 --- a/src/Sarif/Autogenerated/MultiformatMessageString.cs +++ b/src/Sarif/Autogenerated/MultiformatMessageString.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -122,4 +122,4 @@ protected virtual void Init(string text, string markdown, IDictionary locations, Message message, Fa if (locations != null) { var destination_0 = new List(); - foreach (var value_0 in locations) + foreach (Location value_0 in locations) { if (value_0 == null) { @@ -223,4 +224,4 @@ protected virtual void Init(IEnumerable locations, Message message, Fa } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/NotificationComparer.cs b/src/Sarif/Autogenerated/NotificationComparer.cs index ff8434c4a..01e3e2694 100644 --- a/src/Sarif/Autogenerated/NotificationComparer.cs +++ b/src/Sarif/Autogenerated/NotificationComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -83,4 +82,4 @@ public int Compare(Notification left, Notification right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/NotificationEqualityComparer.cs b/src/Sarif/Autogenerated/NotificationEqualityComparer.cs index a9ff82f06..fa3c8ab1c 100644 --- a/src/Sarif/Autogenerated/NotificationEqualityComparer.cs +++ b/src/Sarif/Autogenerated/NotificationEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -173,4 +172,4 @@ public int GetHashCode(Notification obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/PhysicalLocation.cs b/src/Sarif/Autogenerated/PhysicalLocation.cs index 50a430b9e..c25ad7db5 100644 --- a/src/Sarif/Autogenerated/PhysicalLocation.cs +++ b/src/Sarif/Autogenerated/PhysicalLocation.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -158,4 +158,4 @@ protected virtual void Init(Address address, ArtifactLocation artifactLocation, } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/PhysicalLocationComparer.cs b/src/Sarif/Autogenerated/PhysicalLocationComparer.cs index c8394c73d..be47f830c 100644 --- a/src/Sarif/Autogenerated/PhysicalLocationComparer.cs +++ b/src/Sarif/Autogenerated/PhysicalLocationComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -59,4 +58,4 @@ public int Compare(PhysicalLocation left, PhysicalLocation right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/PhysicalLocationEqualityComparer.cs b/src/Sarif/Autogenerated/PhysicalLocationEqualityComparer.cs index 9354a2f6e..5c769e4eb 100644 --- a/src/Sarif/Autogenerated/PhysicalLocationEqualityComparer.cs +++ b/src/Sarif/Autogenerated/PhysicalLocationEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -122,4 +121,4 @@ public int GetHashCode(PhysicalLocation obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/PropertyBag.cs b/src/Sarif/Autogenerated/PropertyBag.cs index d5d053f4b..f5b6247de 100644 --- a/src/Sarif/Autogenerated/PropertyBag.cs +++ b/src/Sarif/Autogenerated/PropertyBag.cs @@ -1,10 +1,11 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Runtime.Serialization; + using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif @@ -110,4 +111,4 @@ protected virtual void Init(IEnumerable tags) } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/PropertyBagComparer.cs b/src/Sarif/Autogenerated/PropertyBagComparer.cs index 3c18daa8d..d00657de5 100644 --- a/src/Sarif/Autogenerated/PropertyBagComparer.cs +++ b/src/Sarif/Autogenerated/PropertyBagComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -35,4 +34,4 @@ public int Compare(PropertyBag left, PropertyBag right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/PropertyBagEqualityComparer.cs b/src/Sarif/Autogenerated/PropertyBagEqualityComparer.cs index 718ac2de9..748c280eb 100644 --- a/src/Sarif/Autogenerated/PropertyBagEqualityComparer.cs +++ b/src/Sarif/Autogenerated/PropertyBagEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -77,4 +76,4 @@ public int GetHashCode(PropertyBag obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/Rectangle.cs b/src/Sarif/Autogenerated/Rectangle.cs index a52887102..6fc1ec10f 100644 --- a/src/Sarif/Autogenerated/Rectangle.cs +++ b/src/Sarif/Autogenerated/Rectangle.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -156,4 +156,4 @@ protected virtual void Init(double top, double left, double bottom, double right } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/RectangleComparer.cs b/src/Sarif/Autogenerated/RectangleComparer.cs index ae667f74a..de47a9b7e 100644 --- a/src/Sarif/Autogenerated/RectangleComparer.cs +++ b/src/Sarif/Autogenerated/RectangleComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -65,4 +64,4 @@ public int Compare(Rectangle left, Rectangle right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/RectangleEqualityComparer.cs b/src/Sarif/Autogenerated/RectangleEqualityComparer.cs index 780953e97..d123901e1 100644 --- a/src/Sarif/Autogenerated/RectangleEqualityComparer.cs +++ b/src/Sarif/Autogenerated/RectangleEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -116,4 +115,4 @@ public int GetHashCode(Rectangle obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/Region.cs b/src/Sarif/Autogenerated/Region.cs index c30668cad..a31141ed1 100644 --- a/src/Sarif/Autogenerated/Region.cs +++ b/src/Sarif/Autogenerated/Region.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Runtime.Serialization; + using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif @@ -228,4 +229,4 @@ protected virtual void Init(int startLine, int startColumn, int endLine, int end } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/RegionComparer.cs b/src/Sarif/Autogenerated/RegionComparer.cs index 97712cf0d..d7ded9a8c 100644 --- a/src/Sarif/Autogenerated/RegionComparer.cs +++ b/src/Sarif/Autogenerated/RegionComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -101,4 +100,4 @@ public int Compare(Region left, Region right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/RegionEqualityComparer.cs b/src/Sarif/Autogenerated/RegionEqualityComparer.cs index d8d4b7d21..7f0498926 100644 --- a/src/Sarif/Autogenerated/RegionEqualityComparer.cs +++ b/src/Sarif/Autogenerated/RegionEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -160,4 +159,4 @@ public int GetHashCode(Region obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/Replacement.cs b/src/Sarif/Autogenerated/Replacement.cs index f6111f3e5..9a6f214ab 100644 --- a/src/Sarif/Autogenerated/Replacement.cs +++ b/src/Sarif/Autogenerated/Replacement.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -130,4 +130,4 @@ protected virtual void Init(Region deletedRegion, ArtifactContent insertedConten } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ReplacementComparer.cs b/src/Sarif/Autogenerated/ReplacementComparer.cs index 51fd9f549..1435c403b 100644 --- a/src/Sarif/Autogenerated/ReplacementComparer.cs +++ b/src/Sarif/Autogenerated/ReplacementComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -47,4 +46,4 @@ public int Compare(Replacement left, Replacement right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ReplacementEqualityComparer.cs b/src/Sarif/Autogenerated/ReplacementEqualityComparer.cs index ece6427ed..4dfb088a7 100644 --- a/src/Sarif/Autogenerated/ReplacementEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ReplacementEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -102,4 +101,4 @@ public int GetHashCode(Replacement obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ReportingConfiguration.cs b/src/Sarif/Autogenerated/ReportingConfiguration.cs index d83441ba9..a266436d3 100644 --- a/src/Sarif/Autogenerated/ReportingConfiguration.cs +++ b/src/Sarif/Autogenerated/ReportingConfiguration.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -7,8 +7,6 @@ using System.ComponentModel; using System.Runtime.Serialization; -using Microsoft.CodeAnalysis.Sarif.Readers; - using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif diff --git a/src/Sarif/Autogenerated/ReportingConfigurationComparer.cs b/src/Sarif/Autogenerated/ReportingConfigurationComparer.cs index bc6998168..d45c94f82 100644 --- a/src/Sarif/Autogenerated/ReportingConfigurationComparer.cs +++ b/src/Sarif/Autogenerated/ReportingConfigurationComparer.cs @@ -1,10 +1,17 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. + +/* Unmerged change from project 'Sarif(net462)' +Before: using System; using System.CodeDom.Compiler; +After: +using System.CodeDom.Compiler; +*/ +using System.CodeDom.Compiler; + using System.Collections.Generic; -using Microsoft.CodeAnalysis.Sarif.Readers; namespace Microsoft.CodeAnalysis.Sarif { @@ -60,4 +67,4 @@ public int Compare(ReportingConfiguration left, ReportingConfiguration right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ReportingConfigurationEqualityComparer.cs b/src/Sarif/Autogenerated/ReportingConfigurationEqualityComparer.cs index 7e7ebbd34..de328ec44 100644 --- a/src/Sarif/Autogenerated/ReportingConfigurationEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ReportingConfigurationEqualityComparer.cs @@ -1,10 +1,17 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. + +/* Unmerged change from project 'Sarif(net462)' +Before: using System; using System.CodeDom.Compiler; +After: +using System.CodeDom.Compiler; +*/ +using System.CodeDom.Compiler; + using System.Collections.Generic; -using Microsoft.CodeAnalysis.Sarif.Readers; namespace Microsoft.CodeAnalysis.Sarif { @@ -139,4 +146,4 @@ public int GetHashCode(ReportingConfiguration obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ReportingDescriptor.cs b/src/Sarif/Autogenerated/ReportingDescriptor.cs index 9fd32376b..c29c90ce3 100644 --- a/src/Sarif/Autogenerated/ReportingDescriptor.cs +++ b/src/Sarif/Autogenerated/ReportingDescriptor.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -227,7 +227,7 @@ protected virtual void Init(string id, IEnumerable deprecatedIds, Guid? if (deprecatedIds != null) { var destination_0 = new List(); - foreach (var value_0 in deprecatedIds) + foreach (string value_0 in deprecatedIds) { destination_0.Add(value_0); } @@ -239,7 +239,7 @@ protected virtual void Init(string id, IEnumerable deprecatedIds, Guid? if (deprecatedGuids != null) { var destination_1 = new List(); - foreach (var value_1 in deprecatedGuids) + foreach (Guid value_1 in deprecatedGuids) { destination_1.Add(value_1); } @@ -251,7 +251,7 @@ protected virtual void Init(string id, IEnumerable deprecatedIds, Guid? if (deprecatedNames != null) { var destination_2 = new List(); - foreach (var value_2 in deprecatedNames) + foreach (string value_2 in deprecatedNames) { destination_2.Add(value_2); } @@ -272,7 +272,7 @@ protected virtual void Init(string id, IEnumerable deprecatedIds, Guid? if (messageStrings != null) { MessageStrings = new Dictionary(); - foreach (var value_3 in messageStrings) + foreach (KeyValuePair value_3 in messageStrings) { MessageStrings.Add(value_3.Key, new MultiformatMessageString(value_3.Value)); } @@ -296,7 +296,7 @@ protected virtual void Init(string id, IEnumerable deprecatedIds, Guid? if (relationships != null) { var destination_3 = new List(); - foreach (var value_4 in relationships) + foreach (ReportingDescriptorRelationship value_4 in relationships) { if (value_4 == null) { diff --git a/src/Sarif/Autogenerated/ReportingDescriptorComparer.cs b/src/Sarif/Autogenerated/ReportingDescriptorComparer.cs index a5f127b3e..22c348176 100644 --- a/src/Sarif/Autogenerated/ReportingDescriptorComparer.cs +++ b/src/Sarif/Autogenerated/ReportingDescriptorComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -113,4 +112,4 @@ public int Compare(ReportingDescriptor left, ReportingDescriptor right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ReportingDescriptorEqualityComparer.cs b/src/Sarif/Autogenerated/ReportingDescriptorEqualityComparer.cs index 80865c2cf..ab98caf0a 100644 --- a/src/Sarif/Autogenerated/ReportingDescriptorEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ReportingDescriptorEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -329,4 +328,4 @@ public int GetHashCode(ReportingDescriptor obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ReportingDescriptorReference.cs b/src/Sarif/Autogenerated/ReportingDescriptorReference.cs index 81fe63944..a14ac60ec 100644 --- a/src/Sarif/Autogenerated/ReportingDescriptorReference.cs +++ b/src/Sarif/Autogenerated/ReportingDescriptorReference.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Runtime.Serialization; + using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif @@ -151,4 +152,4 @@ protected virtual void Init(string id, int index, Guid? guid, ToolComponentRefer } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ReportingDescriptorReferenceComparer.cs b/src/Sarif/Autogenerated/ReportingDescriptorReferenceComparer.cs index dd4ae8425..51947388b 100644 --- a/src/Sarif/Autogenerated/ReportingDescriptorReferenceComparer.cs +++ b/src/Sarif/Autogenerated/ReportingDescriptorReferenceComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -59,4 +58,4 @@ public int Compare(ReportingDescriptorReference left, ReportingDescriptorReferen return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ReportingDescriptorReferenceEqualityComparer.cs b/src/Sarif/Autogenerated/ReportingDescriptorReferenceEqualityComparer.cs index 13b250040..75f9fa16c 100644 --- a/src/Sarif/Autogenerated/ReportingDescriptorReferenceEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ReportingDescriptorReferenceEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -118,4 +117,4 @@ public int GetHashCode(ReportingDescriptorReference obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ReportingDescriptorRelationship.cs b/src/Sarif/Autogenerated/ReportingDescriptorRelationship.cs index 145bd032a..c30fa3a6f 100644 --- a/src/Sarif/Autogenerated/ReportingDescriptorRelationship.cs +++ b/src/Sarif/Autogenerated/ReportingDescriptorRelationship.cs @@ -1,10 +1,11 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Runtime.Serialization; + using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif @@ -152,4 +153,4 @@ protected virtual void Init(ReportingDescriptorReference target, IEnumerable(); - foreach (var value_0 in locations) + foreach (Location value_0 in locations) { if (value_0 == null) { @@ -470,7 +470,7 @@ protected virtual void Init(string ruleId, int ruleIndex, ReportingDescriptorRef if (stacks != null) { var destination_1 = new List(); - foreach (var value_1 in stacks) + foreach (Stack value_1 in stacks) { if (value_1 == null) { @@ -488,7 +488,7 @@ protected virtual void Init(string ruleId, int ruleIndex, ReportingDescriptorRef if (codeFlows != null) { var destination_2 = new List(); - foreach (var value_2 in codeFlows) + foreach (CodeFlow value_2 in codeFlows) { if (value_2 == null) { @@ -506,7 +506,7 @@ protected virtual void Init(string ruleId, int ruleIndex, ReportingDescriptorRef if (graphs != null) { var destination_3 = new List(); - foreach (var value_3 in graphs) + foreach (Graph value_3 in graphs) { if (value_3 == null) { @@ -524,7 +524,7 @@ protected virtual void Init(string ruleId, int ruleIndex, ReportingDescriptorRef if (graphTraversals != null) { var destination_4 = new List(); - foreach (var value_4 in graphTraversals) + foreach (GraphTraversal value_4 in graphTraversals) { if (value_4 == null) { @@ -542,7 +542,7 @@ protected virtual void Init(string ruleId, int ruleIndex, ReportingDescriptorRef if (relatedLocations != null) { var destination_5 = new List(); - foreach (var value_5 in relatedLocations) + foreach (Location value_5 in relatedLocations) { if (value_5 == null) { @@ -560,7 +560,7 @@ protected virtual void Init(string ruleId, int ruleIndex, ReportingDescriptorRef if (suppressions != null) { var destination_6 = new List(); - foreach (var value_6 in suppressions) + foreach (Suppression value_6 in suppressions) { if (value_6 == null) { @@ -580,7 +580,7 @@ protected virtual void Init(string ruleId, int ruleIndex, ReportingDescriptorRef if (attachments != null) { var destination_7 = new List(); - foreach (var value_7 in attachments) + foreach (Attachment value_7 in attachments) { if (value_7 == null) { @@ -603,7 +603,7 @@ protected virtual void Init(string ruleId, int ruleIndex, ReportingDescriptorRef if (workItemUris != null) { var destination_8 = new List(); - foreach (var value_8 in workItemUris) + foreach (Uri value_8 in workItemUris) { destination_8.Add(value_8); } @@ -619,7 +619,7 @@ protected virtual void Init(string ruleId, int ruleIndex, ReportingDescriptorRef if (fixes != null) { var destination_9 = new List(); - foreach (var value_9 in fixes) + foreach (Fix value_9 in fixes) { if (value_9 == null) { @@ -637,7 +637,7 @@ protected virtual void Init(string ruleId, int ruleIndex, ReportingDescriptorRef if (taxa != null) { var destination_10 = new List(); - foreach (var value_10 in taxa) + foreach (ReportingDescriptorReference value_10 in taxa) { if (value_10 == null) { diff --git a/src/Sarif/Autogenerated/ResultComparer.cs b/src/Sarif/Autogenerated/ResultComparer.cs index e7b9e3bad..be7e5076a 100644 --- a/src/Sarif/Autogenerated/ResultComparer.cs +++ b/src/Sarif/Autogenerated/ResultComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -209,4 +208,4 @@ public int Compare(Result left, Result right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ResultEqualityComparer.cs b/src/Sarif/Autogenerated/ResultEqualityComparer.cs index 208462b03..7bca7d4cf 100644 --- a/src/Sarif/Autogenerated/ResultEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ResultEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -657,4 +656,4 @@ public int GetHashCode(Result obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ResultKind.cs b/src/Sarif/Autogenerated/ResultKind.cs index 003abb57d..ccdb8ba03 100644 --- a/src/Sarif/Autogenerated/ResultKind.cs +++ b/src/Sarif/Autogenerated/ResultKind.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.CodeDom.Compiler; @@ -19,4 +19,4 @@ public enum ResultKind Open, Informational } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ResultProvenance.cs b/src/Sarif/Autogenerated/ResultProvenance.cs index 853e1b0bf..6ea1fe624 100644 --- a/src/Sarif/Autogenerated/ResultProvenance.cs +++ b/src/Sarif/Autogenerated/ResultProvenance.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Runtime.Serialization; + using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif @@ -187,4 +188,4 @@ protected virtual void Init(DateTime firstDetectionTimeUtc, DateTime lastDetecti } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ResultProvenanceComparer.cs b/src/Sarif/Autogenerated/ResultProvenanceComparer.cs index 626af506c..2b6cdc4a8 100644 --- a/src/Sarif/Autogenerated/ResultProvenanceComparer.cs +++ b/src/Sarif/Autogenerated/ResultProvenanceComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -71,4 +70,4 @@ public int Compare(ResultProvenance left, ResultProvenance right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ResultProvenanceEqualityComparer.cs b/src/Sarif/Autogenerated/ResultProvenanceEqualityComparer.cs index 2207a7cb4..78d95c524 100644 --- a/src/Sarif/Autogenerated/ResultProvenanceEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ResultProvenanceEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -153,4 +152,4 @@ public int GetHashCode(ResultProvenance obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/Run.cs b/src/Sarif/Autogenerated/Run.cs index 522a1b916..d7b990a23 100644 --- a/src/Sarif/Autogenerated/Run.cs +++ b/src/Sarif/Autogenerated/Run.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -373,7 +373,7 @@ protected virtual void Init(Tool tool, IEnumerable invocations, Conv if (invocations != null) { var destination_0 = new List(); - foreach (var value_0 in invocations) + foreach (Invocation value_0 in invocations) { if (value_0 == null) { @@ -397,7 +397,7 @@ protected virtual void Init(Tool tool, IEnumerable invocations, Conv if (versionControlProvenance != null) { var destination_1 = new List(); - foreach (var value_1 in versionControlProvenance) + foreach (VersionControlDetails value_1 in versionControlProvenance) { if (value_1 == null) { @@ -415,7 +415,7 @@ protected virtual void Init(Tool tool, IEnumerable invocations, Conv if (originalUriBaseIds != null) { OriginalUriBaseIds = new Dictionary(); - foreach (var value_2 in originalUriBaseIds) + foreach (KeyValuePair value_2 in originalUriBaseIds) { OriginalUriBaseIds.Add(value_2.Key, new ArtifactLocation(value_2.Value)); } @@ -424,7 +424,7 @@ protected virtual void Init(Tool tool, IEnumerable invocations, Conv if (artifacts != null) { var destination_2 = new List(); - foreach (var value_3 in artifacts) + foreach (Artifact value_3 in artifacts) { if (value_3 == null) { @@ -442,7 +442,7 @@ protected virtual void Init(Tool tool, IEnumerable invocations, Conv if (logicalLocations != null) { var destination_3 = new List(); - foreach (var value_4 in logicalLocations) + foreach (LogicalLocation value_4 in logicalLocations) { if (value_4 == null) { @@ -460,7 +460,7 @@ protected virtual void Init(Tool tool, IEnumerable invocations, Conv if (graphs != null) { var destination_4 = new List(); - foreach (var value_5 in graphs) + foreach (Graph value_5 in graphs) { if (value_5 == null) { @@ -478,7 +478,7 @@ protected virtual void Init(Tool tool, IEnumerable invocations, Conv if (results != null) { var destination_5 = new List(); - foreach (var value_6 in results) + foreach (Result value_6 in results) { if (value_6 == null) { @@ -501,7 +501,7 @@ protected virtual void Init(Tool tool, IEnumerable invocations, Conv if (runAggregates != null) { var destination_6 = new List(); - foreach (var value_7 in runAggregates) + foreach (RunAutomationDetails value_7 in runAggregates) { if (value_7 == null) { @@ -520,7 +520,7 @@ protected virtual void Init(Tool tool, IEnumerable invocations, Conv if (redactionTokens != null) { var destination_7 = new List(); - foreach (var value_8 in redactionTokens) + foreach (string value_8 in redactionTokens) { destination_7.Add(value_8); } @@ -533,7 +533,7 @@ protected virtual void Init(Tool tool, IEnumerable invocations, Conv if (newlineSequences != null) { var destination_8 = new List(); - foreach (var value_9 in newlineSequences) + foreach (string value_9 in newlineSequences) { destination_8.Add(value_9); } @@ -550,7 +550,7 @@ protected virtual void Init(Tool tool, IEnumerable invocations, Conv if (threadFlowLocations != null) { var destination_9 = new List(); - foreach (var value_10 in threadFlowLocations) + foreach (ThreadFlowLocation value_10 in threadFlowLocations) { if (value_10 == null) { @@ -568,7 +568,7 @@ protected virtual void Init(Tool tool, IEnumerable invocations, Conv if (taxonomies != null) { var destination_10 = new List(); - foreach (var value_11 in taxonomies) + foreach (ToolComponent value_11 in taxonomies) { if (value_11 == null) { @@ -586,7 +586,7 @@ protected virtual void Init(Tool tool, IEnumerable invocations, Conv if (addresses != null) { var destination_11 = new List
(); - foreach (var value_12 in addresses) + foreach (Address value_12 in addresses) { if (value_12 == null) { @@ -604,7 +604,7 @@ protected virtual void Init(Tool tool, IEnumerable invocations, Conv if (translations != null) { var destination_12 = new List(); - foreach (var value_13 in translations) + foreach (ToolComponent value_13 in translations) { if (value_13 == null) { @@ -622,7 +622,7 @@ protected virtual void Init(Tool tool, IEnumerable invocations, Conv if (policies != null) { var destination_13 = new List(); - foreach (var value_14 in policies) + foreach (ToolComponent value_14 in policies) { if (value_14 == null) { @@ -640,7 +640,7 @@ protected virtual void Init(Tool tool, IEnumerable invocations, Conv if (webRequests != null) { var destination_14 = new List(); - foreach (var value_15 in webRequests) + foreach (WebRequest value_15 in webRequests) { if (value_15 == null) { @@ -658,7 +658,7 @@ protected virtual void Init(Tool tool, IEnumerable invocations, Conv if (webResponses != null) { var destination_15 = new List(); - foreach (var value_16 in webResponses) + foreach (WebResponse value_16 in webResponses) { if (value_16 == null) { diff --git a/src/Sarif/Autogenerated/RunAutomationDetails.cs b/src/Sarif/Autogenerated/RunAutomationDetails.cs index 189e6f2c2..2ddebcff2 100644 --- a/src/Sarif/Autogenerated/RunAutomationDetails.cs +++ b/src/Sarif/Autogenerated/RunAutomationDetails.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -146,4 +146,4 @@ protected virtual void Init(Message description, string id, Guid? guid, Guid? co } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/RunAutomationDetailsComparer.cs b/src/Sarif/Autogenerated/RunAutomationDetailsComparer.cs index b0ff8b341..7cfb2b807 100644 --- a/src/Sarif/Autogenerated/RunAutomationDetailsComparer.cs +++ b/src/Sarif/Autogenerated/RunAutomationDetailsComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -59,4 +58,4 @@ public int Compare(RunAutomationDetails left, RunAutomationDetails right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/RunAutomationDetailsEqualityComparer.cs b/src/Sarif/Autogenerated/RunAutomationDetailsEqualityComparer.cs index 382f5fc12..0c3eba55a 100644 --- a/src/Sarif/Autogenerated/RunAutomationDetailsEqualityComparer.cs +++ b/src/Sarif/Autogenerated/RunAutomationDetailsEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -122,4 +121,4 @@ public int GetHashCode(RunAutomationDetails obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/RunComparer.cs b/src/Sarif/Autogenerated/RunComparer.cs index 7fab369c0..fb99b6844 100644 --- a/src/Sarif/Autogenerated/RunComparer.cs +++ b/src/Sarif/Autogenerated/RunComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -197,4 +196,4 @@ public int Compare(Run left, Run right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/RunEqualityComparer.cs b/src/Sarif/Autogenerated/RunEqualityComparer.cs index a6aaf5c9a..2485fd725 100644 --- a/src/Sarif/Autogenerated/RunEqualityComparer.cs +++ b/src/Sarif/Autogenerated/RunEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -744,4 +743,4 @@ public int GetHashCode(Run obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/SarifLog.cs b/src/Sarif/Autogenerated/SarifLog.cs index faa389199..6d672e0d9 100644 --- a/src/Sarif/Autogenerated/SarifLog.cs +++ b/src/Sarif/Autogenerated/SarifLog.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -149,7 +149,7 @@ protected virtual void Init(Uri schemaUri, SarifVersion version, IEnumerable(); - foreach (var value_0 in runs) + foreach (Run value_0 in runs) { if (value_0 == null) { @@ -167,7 +167,7 @@ protected virtual void Init(Uri schemaUri, SarifVersion version, IEnumerable(); - foreach (var value_1 in inlineExternalProperties) + foreach (ExternalProperties value_1 in inlineExternalProperties) { if (value_1 == null) { diff --git a/src/Sarif/Autogenerated/SarifLogComparer.cs b/src/Sarif/Autogenerated/SarifLogComparer.cs index 45947c147..4f2150b76 100644 --- a/src/Sarif/Autogenerated/SarifLogComparer.cs +++ b/src/Sarif/Autogenerated/SarifLogComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -59,4 +58,4 @@ public int Compare(SarifLog left, SarifLog right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/SarifLogEqualityComparer.cs b/src/Sarif/Autogenerated/SarifLogEqualityComparer.cs index 32dd562e5..6e5112c7e 100644 --- a/src/Sarif/Autogenerated/SarifLogEqualityComparer.cs +++ b/src/Sarif/Autogenerated/SarifLogEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -164,4 +163,4 @@ public int GetHashCode(SarifLog obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/SarifNodeKind.cs b/src/Sarif/Autogenerated/SarifNodeKind.cs index b10c34fef..b250a00ca 100644 --- a/src/Sarif/Autogenerated/SarifNodeKind.cs +++ b/src/Sarif/Autogenerated/SarifNodeKind.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.CodeDom.Compiler; @@ -228,4 +228,4 @@ public enum SarifNodeKind /// WebResponse } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/SarifRewritingVisitor.cs b/src/Sarif/Autogenerated/SarifRewritingVisitor.cs index a92b828e5..fb11a3852 100644 --- a/src/Sarif/Autogenerated/SarifRewritingVisitor.cs +++ b/src/Sarif/Autogenerated/SarifRewritingVisitor.cs @@ -1,9 +1,8 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; using System.CodeDom.Compiler; -using System.Collections.Generic; using System.Linq; namespace Microsoft.CodeAnalysis.Sarif @@ -1454,4 +1453,4 @@ public virtual WebResponse VisitWebResponse(WebResponse node) return node; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/SarifVersion.cs b/src/Sarif/Autogenerated/SarifVersion.cs index ee4e23e58..dd6bae438 100644 --- a/src/Sarif/Autogenerated/SarifVersion.cs +++ b/src/Sarif/Autogenerated/SarifVersion.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.CodeDom.Compiler; @@ -15,4 +15,4 @@ public enum SarifVersion OneZeroZero, Current } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/SpecialLocations.cs b/src/Sarif/Autogenerated/SpecialLocations.cs index 334957bfb..455363bc4 100644 --- a/src/Sarif/Autogenerated/SpecialLocations.cs +++ b/src/Sarif/Autogenerated/SpecialLocations.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -116,4 +116,4 @@ protected virtual void Init(ArtifactLocation displayBase, IDictionary frames, IDi if (frames != null) { var destination_0 = new List(); - foreach (var value_0 in frames) + foreach (StackFrame value_0 in frames) { if (value_0 == null) { @@ -143,4 +143,4 @@ protected virtual void Init(Message message, IEnumerable frames, IDi } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/StackComparer.cs b/src/Sarif/Autogenerated/StackComparer.cs index 576f16ef8..46192234f 100644 --- a/src/Sarif/Autogenerated/StackComparer.cs +++ b/src/Sarif/Autogenerated/StackComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -47,4 +46,4 @@ public int Compare(Stack left, Stack right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/StackEqualityComparer.cs b/src/Sarif/Autogenerated/StackEqualityComparer.cs index 15fb7df7e..8c92c4cd5 100644 --- a/src/Sarif/Autogenerated/StackEqualityComparer.cs +++ b/src/Sarif/Autogenerated/StackEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -125,4 +124,4 @@ public int GetHashCode(Stack obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/StackFrame.cs b/src/Sarif/Autogenerated/StackFrame.cs index bdf05d5f9..31381a91d 100644 --- a/src/Sarif/Autogenerated/StackFrame.cs +++ b/src/Sarif/Autogenerated/StackFrame.cs @@ -1,10 +1,11 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Runtime.Serialization; + using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif @@ -144,7 +145,7 @@ protected virtual void Init(Location location, string module, int threadId, IEnu if (parameters != null) { var destination_0 = new List(); - foreach (var value_0 in parameters) + foreach (string value_0 in parameters) { destination_0.Add(value_0); } @@ -158,4 +159,4 @@ protected virtual void Init(Location location, string module, int threadId, IEnu } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/StackFrameComparer.cs b/src/Sarif/Autogenerated/StackFrameComparer.cs index bf6c3f956..a293a9af4 100644 --- a/src/Sarif/Autogenerated/StackFrameComparer.cs +++ b/src/Sarif/Autogenerated/StackFrameComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -59,4 +58,4 @@ public int Compare(StackFrame left, StackFrame right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/StackFrameEqualityComparer.cs b/src/Sarif/Autogenerated/StackFrameEqualityComparer.cs index 232f02572..bd4618344 100644 --- a/src/Sarif/Autogenerated/StackFrameEqualityComparer.cs +++ b/src/Sarif/Autogenerated/StackFrameEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -141,4 +140,4 @@ public int GetHashCode(StackFrame obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/Suppression.cs b/src/Sarif/Autogenerated/Suppression.cs index 23051ca84..c598597db 100644 --- a/src/Sarif/Autogenerated/Suppression.cs +++ b/src/Sarif/Autogenerated/Suppression.cs @@ -1,10 +1,11 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Runtime.Serialization; + using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif @@ -159,4 +160,4 @@ protected virtual void Init(Guid? guid, SuppressionKind kind, SuppressionStatus } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/SuppressionComparer.cs b/src/Sarif/Autogenerated/SuppressionComparer.cs index af991b886..c6ce16763 100644 --- a/src/Sarif/Autogenerated/SuppressionComparer.cs +++ b/src/Sarif/Autogenerated/SuppressionComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -65,4 +64,4 @@ public int Compare(Suppression left, Suppression right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/SuppressionEqualityComparer.cs b/src/Sarif/Autogenerated/SuppressionEqualityComparer.cs index e89a7be96..d9b39593d 100644 --- a/src/Sarif/Autogenerated/SuppressionEqualityComparer.cs +++ b/src/Sarif/Autogenerated/SuppressionEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -124,4 +123,4 @@ public int GetHashCode(Suppression obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/SuppressionKind.cs b/src/Sarif/Autogenerated/SuppressionKind.cs index 982fb0ef2..753034027 100644 --- a/src/Sarif/Autogenerated/SuppressionKind.cs +++ b/src/Sarif/Autogenerated/SuppressionKind.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.CodeDom.Compiler; @@ -15,4 +15,4 @@ public enum SuppressionKind InSource, External } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/SuppressionStatus.cs b/src/Sarif/Autogenerated/SuppressionStatus.cs index 57bfd30e6..ce6b59de8 100644 --- a/src/Sarif/Autogenerated/SuppressionStatus.cs +++ b/src/Sarif/Autogenerated/SuppressionStatus.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.CodeDom.Compiler; @@ -16,4 +16,4 @@ public enum SuppressionStatus UnderReview, Rejected } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ThreadFlow.cs b/src/Sarif/Autogenerated/ThreadFlow.cs index 7968b10e9..a631ece8d 100644 --- a/src/Sarif/Autogenerated/ThreadFlow.cs +++ b/src/Sarif/Autogenerated/ThreadFlow.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -152,7 +152,7 @@ protected virtual void Init(string id, Message message, object initialState, obj if (locations != null) { var destination_0 = new List(); - foreach (var value_0 in locations) + foreach (ThreadFlowLocation value_0 in locations) { if (value_0 == null) { @@ -173,4 +173,4 @@ protected virtual void Init(string id, Message message, object initialState, obj } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ThreadFlowComparer.cs b/src/Sarif/Autogenerated/ThreadFlowComparer.cs index e0e0da33b..0c9288312 100644 --- a/src/Sarif/Autogenerated/ThreadFlowComparer.cs +++ b/src/Sarif/Autogenerated/ThreadFlowComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -65,4 +64,4 @@ public int Compare(ThreadFlow left, ThreadFlow right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ThreadFlowEqualityComparer.cs b/src/Sarif/Autogenerated/ThreadFlowEqualityComparer.cs index 498f4576c..2dc727927 100644 --- a/src/Sarif/Autogenerated/ThreadFlowEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ThreadFlowEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -155,4 +154,4 @@ public int GetHashCode(ThreadFlow obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ThreadFlowLocation.cs b/src/Sarif/Autogenerated/ThreadFlowLocation.cs index 35525ebe4..f8e07ea52 100644 --- a/src/Sarif/Autogenerated/ThreadFlowLocation.cs +++ b/src/Sarif/Autogenerated/ThreadFlowLocation.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Runtime.Serialization; + using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif @@ -242,7 +243,7 @@ protected virtual void Init(int index, Location location, Stack stack, IEnumerab if (kinds != null) { var destination_0 = new List(); - foreach (var value_0 in kinds) + foreach (string value_0 in kinds) { destination_0.Add(value_0); } @@ -253,7 +254,7 @@ protected virtual void Init(int index, Location location, Stack stack, IEnumerab if (taxa != null) { var destination_1 = new List(); - foreach (var value_1 in taxa) + foreach (ReportingDescriptorReference value_1 in taxa) { if (value_1 == null) { @@ -272,7 +273,7 @@ protected virtual void Init(int index, Location location, Stack stack, IEnumerab if (state != null) { State = new Dictionary(); - foreach (var value_2 in state) + foreach (KeyValuePair value_2 in state) { State.Add(value_2.Key, new MultiformatMessageString(value_2.Value)); } @@ -298,4 +299,4 @@ protected virtual void Init(int index, Location location, Stack stack, IEnumerab } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ThreadFlowLocationComparer.cs b/src/Sarif/Autogenerated/ThreadFlowLocationComparer.cs index b3ecf65c7..bfa3a814b 100644 --- a/src/Sarif/Autogenerated/ThreadFlowLocationComparer.cs +++ b/src/Sarif/Autogenerated/ThreadFlowLocationComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -113,4 +112,4 @@ public int Compare(ThreadFlowLocation left, ThreadFlowLocation right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ThreadFlowLocationEqualityComparer.cs b/src/Sarif/Autogenerated/ThreadFlowLocationEqualityComparer.cs index a0fa5a959..cf466d112 100644 --- a/src/Sarif/Autogenerated/ThreadFlowLocationEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ThreadFlowLocationEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -266,4 +265,4 @@ public int GetHashCode(ThreadFlowLocation obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ThreadFlowLocationImportance.cs b/src/Sarif/Autogenerated/ThreadFlowLocationImportance.cs index 390e41fd8..39dc8cf46 100644 --- a/src/Sarif/Autogenerated/ThreadFlowLocationImportance.cs +++ b/src/Sarif/Autogenerated/ThreadFlowLocationImportance.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.CodeDom.Compiler; @@ -15,4 +15,4 @@ public enum ThreadFlowLocationImportance Essential, Unimportant } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/Tool.cs b/src/Sarif/Autogenerated/Tool.cs index 72e4059d8..b7839bdba 100644 --- a/src/Sarif/Autogenerated/Tool.cs +++ b/src/Sarif/Autogenerated/Tool.cs @@ -1,10 +1,11 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Runtime.Serialization; + using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif @@ -124,7 +125,7 @@ protected virtual void Init(ToolComponent driver, IEnumerable ext if (extensions != null) { var destination_0 = new List(); - foreach (var value_0 in extensions) + foreach (ToolComponent value_0 in extensions) { if (value_0 == null) { @@ -145,4 +146,4 @@ protected virtual void Init(ToolComponent driver, IEnumerable ext } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ToolComparer.cs b/src/Sarif/Autogenerated/ToolComparer.cs index b7ef4a6da..a21347fb0 100644 --- a/src/Sarif/Autogenerated/ToolComparer.cs +++ b/src/Sarif/Autogenerated/ToolComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -47,4 +46,4 @@ public int Compare(Tool left, Tool right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ToolComponent.cs b/src/Sarif/Autogenerated/ToolComponent.cs index 136dc685b..bff507087 100644 --- a/src/Sarif/Autogenerated/ToolComponent.cs +++ b/src/Sarif/Autogenerated/ToolComponent.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Runtime.Serialization; + using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif @@ -387,7 +388,7 @@ protected virtual void Init(Guid? guid, string name, string organization, string if (globalMessageStrings != null) { GlobalMessageStrings = new Dictionary(); - foreach (var value_0 in globalMessageStrings) + foreach (KeyValuePair value_0 in globalMessageStrings) { GlobalMessageStrings.Add(value_0.Key, new MultiformatMessageString(value_0.Value)); } @@ -396,7 +397,7 @@ protected virtual void Init(Guid? guid, string name, string organization, string if (notifications != null) { var destination_0 = new List(); - foreach (var value_1 in notifications) + foreach (ReportingDescriptor value_1 in notifications) { if (value_1 == null) { @@ -414,7 +415,7 @@ protected virtual void Init(Guid? guid, string name, string organization, string if (rules != null) { var destination_1 = new List(); - foreach (var value_2 in rules) + foreach (ReportingDescriptor value_2 in rules) { if (value_2 == null) { @@ -432,7 +433,7 @@ protected virtual void Init(Guid? guid, string name, string organization, string if (taxa != null) { var destination_2 = new List(); - foreach (var value_3 in taxa) + foreach (ReportingDescriptor value_3 in taxa) { if (value_3 == null) { @@ -450,7 +451,7 @@ protected virtual void Init(Guid? guid, string name, string organization, string if (locations != null) { var destination_3 = new List(); - foreach (var value_4 in locations) + foreach (ArtifactLocation value_4 in locations) { if (value_4 == null) { @@ -483,7 +484,7 @@ protected virtual void Init(Guid? guid, string name, string organization, string if (supportedTaxonomies != null) { var destination_4 = new List(); - foreach (var value_5 in supportedTaxonomies) + foreach (ToolComponentReference value_5 in supportedTaxonomies) { if (value_5 == null) { @@ -504,4 +505,4 @@ protected virtual void Init(Guid? guid, string name, string organization, string } } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ToolComponentComparer.cs b/src/Sarif/Autogenerated/ToolComponentComparer.cs index 908c838f6..7b2b1e0cc 100644 --- a/src/Sarif/Autogenerated/ToolComponentComparer.cs +++ b/src/Sarif/Autogenerated/ToolComponentComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -197,4 +196,4 @@ public int Compare(ToolComponent left, ToolComponent right) return compareResult; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ToolComponentContents.cs b/src/Sarif/Autogenerated/ToolComponentContents.cs index 8de37428c..847721f2e 100644 --- a/src/Sarif/Autogenerated/ToolComponentContents.cs +++ b/src/Sarif/Autogenerated/ToolComponentContents.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -17,4 +17,4 @@ public enum ToolComponentContents LocalizedData = 1, NonLocalizedData = 2 } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ToolComponentEqualityComparer.cs b/src/Sarif/Autogenerated/ToolComponentEqualityComparer.cs index 2c6c1e6f8..e09dd3a8f 100644 --- a/src/Sarif/Autogenerated/ToolComponentEqualityComparer.cs +++ b/src/Sarif/Autogenerated/ToolComponentEqualityComparer.cs @@ -1,7 +1,6 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.CodeDom.Compiler; using System.Collections.Generic; @@ -487,4 +486,4 @@ public int GetHashCode(ToolComponent obj) return result; } } -} \ No newline at end of file +} diff --git a/src/Sarif/Autogenerated/ToolComponentReference.cs b/src/Sarif/Autogenerated/ToolComponentReference.cs index 35e5301f4..95e13f8fe 100644 --- a/src/Sarif/Autogenerated/ToolComponentReference.cs +++ b/src/Sarif/Autogenerated/ToolComponentReference.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft. All Rights Reserved. +// Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Runtime.Serialization; + using Newtonsoft.Json; namespace Microsoft.CodeAnalysis.Sarif @@ -137,4 +138,4 @@ protected virtual void Init(string name, int index, Guid? guid, IDictionary resultMatchingProperties = new Dictionary(); + var resultMatchingProperties = new Dictionary(); Dictionary originalResultMatchingProperties = null; if (PreviousResult != null && CurrentResult != null) { diff --git a/src/Sarif/Baseline/ResultMatching/ExactMatchers/FullFingerprintResultMatcher.cs b/src/Sarif/Baseline/ResultMatching/ExactMatchers/FullFingerprintResultMatcher.cs index 5307aba15..0347a84f0 100644 --- a/src/Sarif/Baseline/ResultMatching/ExactMatchers/FullFingerprintResultMatcher.cs +++ b/src/Sarif/Baseline/ResultMatching/ExactMatchers/FullFingerprintResultMatcher.cs @@ -11,14 +11,14 @@ internal class FullFingerprintResultMatcher : IResultMatcher { public IList Match(IList baseline, IList current) { - List matchedResults = new List(); - Dictionary, List> baselineResults = new Dictionary, List>(FingerprintEqualityCalculator.Instance); + var matchedResults = new List(); + var baselineResults = new Dictionary, List>(FingerprintEqualityCalculator.Instance); foreach (ExtractedResult result in baseline) { foreach (string key in result.Result.Fingerprints.Keys) { - Tuple fingerprint = new Tuple(key, result.Result.Fingerprints[key]); + var fingerprint = new Tuple(key, result.Result.Fingerprints[key]); if (!baselineResults.ContainsKey(fingerprint) || baselineResults[fingerprint] == null) { baselineResults[fingerprint] = new List() { result }; @@ -34,7 +34,7 @@ public IList Match(IList baseline, IList fingerprint = new Tuple(key, result.Result.Fingerprints[key]); + var fingerprint = new Tuple(key, result.Result.Fingerprints[key]); if (baselineResults.ContainsKey(fingerprint) && baselineResults[fingerprint] != null && baselineResults[fingerprint].Count > 0) { ExtractedResult baselineResult = baselineResults[fingerprint].First(); diff --git a/src/Sarif/Baseline/ResultMatching/ExactMatchers/IdenticalResultMatcher.cs b/src/Sarif/Baseline/ResultMatching/ExactMatchers/IdenticalResultMatcher.cs index 704619aff..9ce35c719 100644 --- a/src/Sarif/Baseline/ResultMatching/ExactMatchers/IdenticalResultMatcher.cs +++ b/src/Sarif/Baseline/ResultMatching/ExactMatchers/IdenticalResultMatcher.cs @@ -22,13 +22,13 @@ public IdenticalResultMatcher(bool considerPropertyBagsWhenComparing) public IList Match(IList baseline, IList current) { - List matchedResults = new List(); + var matchedResults = new List(); IdenticalResultEqualityComparer comparer = _considerPropertyBagsWhenComparing ? IdenticalResultEqualityComparer.PropertyBagComparingInstance : IdenticalResultEqualityComparer.PropertyBagIgnoringInstance; - Dictionary> baselineResults = new Dictionary>(comparer); + var baselineResults = new Dictionary>(comparer); foreach (ExtractedResult result in baseline) { diff --git a/src/Sarif/Baseline/ResultMatching/HeuristicMatchers/ContextRegionHeuristicMatcher.cs b/src/Sarif/Baseline/ResultMatching/HeuristicMatchers/ContextRegionHeuristicMatcher.cs index e0d01690e..3015d79db 100644 --- a/src/Sarif/Baseline/ResultMatching/HeuristicMatchers/ContextRegionHeuristicMatcher.cs +++ b/src/Sarif/Baseline/ResultMatching/HeuristicMatchers/ContextRegionHeuristicMatcher.cs @@ -18,7 +18,7 @@ public bool Equals(ExtractedResult x, ExtractedResult y) { IEnumerable xContextRegions = x.Result.Locations.Select(loc => loc.PhysicalLocation.ContextRegion.Snippet); - HashSet yContextRegions = new HashSet(ArtifactContentEqualityComparer.Instance); + var yContextRegions = new HashSet(ArtifactContentEqualityComparer.Instance); foreach (ArtifactContent content in y.Result.Locations.Select(loc => loc.PhysicalLocation.ContextRegion.Snippet)) { yContextRegions.Add(content); diff --git a/src/Sarif/Baseline/ResultMatching/HeuristicMatchers/HeuristicMatcher.cs b/src/Sarif/Baseline/ResultMatching/HeuristicMatchers/HeuristicMatcher.cs index 59f916a69..6680824ce 100644 --- a/src/Sarif/Baseline/ResultMatching/HeuristicMatchers/HeuristicMatcher.cs +++ b/src/Sarif/Baseline/ResultMatching/HeuristicMatchers/HeuristicMatcher.cs @@ -76,7 +76,7 @@ public bool TryMatchResult(Dictionary> resultDictiona int unmodifiedKey = Comparer.GetHashCode(currentResult); if (resultDictionary.ContainsKey(unmodifiedKey)) { - List matchingBaselineResult = resultDictionary[unmodifiedKey].Where(b => Comparer.Equals(b, currentResult)).ToList(); + var matchingBaselineResult = resultDictionary[unmodifiedKey].Where(b => Comparer.Equals(b, currentResult)).ToList(); if (matchingBaselineResult.Count == 1) { result = new MatchedResults(matchingBaselineResult[0], currentResult); diff --git a/src/Sarif/Baseline/ResultMatching/SarifLogResultMatcher.cs b/src/Sarif/Baseline/ResultMatching/SarifLogResultMatcher.cs index 4caded8b5..bed4b6ceb 100644 --- a/src/Sarif/Baseline/ResultMatching/SarifLogResultMatcher.cs +++ b/src/Sarif/Baseline/ResultMatching/SarifLogResultMatcher.cs @@ -115,7 +115,7 @@ private SarifLog BaselineSarifLogs(IEnumerable previous, IEnumerable c List currentResults = current == null ? new List() : ExtractResultsFromRuns(current); - List matchedResults = new List(); + var matchedResults = new List(); // Calculate exact mappings using exactResultMatchers. CalculateMatches(ExactResultMatchers, baselineResults, currentResults, matchedResults); @@ -163,7 +163,7 @@ private void CalculateMatches(IEnumerable matchers, List ExtractResultsFromRuns(IEnumerable sarifRuns) { - List results = new List(); + var results = new List(); foreach (Run run in sarifRuns) { if (run.Results != null) diff --git a/src/Sarif/Baseline/V2/TrustMap.cs b/src/Sarif/Baseline/V2/TrustMap.cs index 5ee287d28..d17b653df 100644 --- a/src/Sarif/Baseline/V2/TrustMap.cs +++ b/src/Sarif/Baseline/V2/TrustMap.cs @@ -61,7 +61,7 @@ public float Trust(string propertySetName, string propertyName) /// WhatComponent for a Result attribute used in baselining public void Add(WhatComponent component) { - TrustKey key = new TrustKey(component); + var key = new TrustKey(component); TrustValue value = null; if (!_map.TryGetValue(key, out value)) diff --git a/src/Sarif/Baseline/V2/V2ResultMatcher.cs b/src/Sarif/Baseline/V2/V2ResultMatcher.cs index 5e7da706f..825be6acf 100644 --- a/src/Sarif/Baseline/V2/V2ResultMatcher.cs +++ b/src/Sarif/Baseline/V2/V2ResultMatcher.cs @@ -12,7 +12,7 @@ public class V2ResultMatcher : IResultMatcher { public IList Match(IList before, IList after) { - StatefulResultMatcher state = new StatefulResultMatcher(before, after); + var state = new StatefulResultMatcher(before, after); return state.Match(); } } @@ -94,10 +94,10 @@ public IList Match() private void BuildMaps() { // Identify all locations used in each log - HashSet beforeLocationIdentifiers = new HashSet(); + var beforeLocationIdentifiers = new HashSet(); _before.ForEach((result) => WhereComparer.AddLocationIdentifiers(result, beforeLocationIdentifiers)); - HashSet afterLocationIdentifiers = new HashSet(); + var afterLocationIdentifiers = new HashSet(); _after.ForEach((result) => WhereComparer.AddLocationIdentifiers(result, afterLocationIdentifiers)); // Populate WhatMap and TrustMap to guide subsequent matching @@ -247,7 +247,7 @@ private void LinkNearbySimilarResults() private IList BuildMatchList() { - List matches = new List(); + var matches = new List(); // 1. Add all Removed Results. for (int beforeIndex = 0; beforeIndex < _before.Count; ++beforeIndex) diff --git a/src/Sarif/Baseline/V2/WhereComparer.cs b/src/Sarif/Baseline/V2/WhereComparer.cs index a8b5aa969..e808673b0 100644 --- a/src/Sarif/Baseline/V2/WhereComparer.cs +++ b/src/Sarif/Baseline/V2/WhereComparer.cs @@ -202,7 +202,7 @@ public static string LocationSpecifier(ExtractedResult result, HashSet o // Otherwise, return empty, so that all Results without matching locations // are put in the same "bucket" for matching. (File Rename handling) - return String.Empty; + return string.Empty; } // Add all Uris and FullyQualifiedLocations in the Result to a set diff --git a/src/Sarif/Core/Notification.cs b/src/Sarif/Core/Notification.cs index 78ec61008..aebf72afe 100644 --- a/src/Sarif/Core/Notification.cs +++ b/src/Sarif/Core/Notification.cs @@ -1,7 +1,9 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +#if DEBUG using System; +#endif namespace Microsoft.CodeAnalysis.Sarif { @@ -18,10 +20,10 @@ public override string ToString() Uri uri = this.Locations?[0].PhysicalLocation?.ArtifactLocation?.Uri; if (uri != null) { sb.Append(uri); } - + if (this.Descriptor != null) { sb.Append(" : ").Append(this.Descriptor?.Id); } if (this.AssociatedRule != null) { sb.Append(" : ").Append(this.AssociatedRule?.Id); } - + sb.Append($" : {this.Level}"); if (!string.IsNullOrEmpty(this.Message?.Text)) @@ -38,7 +40,7 @@ public override string ToString() sb.Length = sb.Length - 1; sb.Append('}'); } - + if (this.Exception != null) { sb.Append($" : {this.Exception.ToString().Replace(Environment.NewLine, string.Empty)}"); diff --git a/src/Sarif/Core/PropertyBagHolder.cs b/src/Sarif/Core/PropertyBagHolder.cs index f2385273a..ff90e56b8 100644 --- a/src/Sarif/Core/PropertyBagHolder.cs +++ b/src/Sarif/Core/PropertyBagHolder.cs @@ -206,7 +206,7 @@ public void SetPropertiesFrom(IPropertyBagHolder other) // We need the concrete class because the IPropertyBagHolder interface // doesn't expose the raw Properties array. - PropertyBagHolder otherHolder = other as PropertyBagHolder; + var otherHolder = other as PropertyBagHolder; Debug.Assert(otherHolder != null); Properties = other.PropertyNames.Count > 0 ? new Dictionary() : null; diff --git a/src/Sarif/Core/Run.cs b/src/Sarif/Core/Run.cs index 03706e907..5ab3f06bb 100644 --- a/src/Sarif/Core/Run.cs +++ b/src/Sarif/Core/Run.cs @@ -158,7 +158,7 @@ public void SetRunOnResults() { if (this.Results != null) { - DeferredList deferredResults = this.Results as DeferredList; + var deferredResults = this.Results as DeferredList; if (deferredResults != null) { @@ -245,7 +245,7 @@ public bool ShouldSerializeNewlineSequences() internal static Dictionary ComputePolicies(IEnumerable policies) { - Dictionary localCache = new Dictionary(); + var localCache = new Dictionary(); // checking if we have have policies if (policies == null || !policies.Any()) diff --git a/src/Sarif/Core/Stack.cs b/src/Sarif/Core/Stack.cs index 900af4b55..1b14898ca 100644 --- a/src/Sarif/Core/Stack.cs +++ b/src/Sarif/Core/Stack.cs @@ -93,7 +93,7 @@ public Stack(StackTrace stackTrace) /// public static Stack Create(string stackTrace) { - Stack stack = new Stack(); + var stack = new Stack(); if (string.IsNullOrEmpty(stackTrace)) { @@ -154,7 +154,7 @@ public string ToString(StackFormat stackFormat) { if (this.Frames == null) { return "[No frames]"; } - StringBuilder sb = new StringBuilder(255); + var sb = new StringBuilder(255); for (int i = 0; i < this.Frames.Count; i++) { diff --git a/src/Sarif/Core/StackFrame.cs b/src/Sarif/Core/StackFrame.cs index bd728daea..b505456e3 100644 --- a/src/Sarif/Core/StackFrame.cs +++ b/src/Sarif/Core/StackFrame.cs @@ -32,7 +32,7 @@ public static StackFrame Create(System.Diagnostics.StackFrame dotNetStackFrame) Assembly assembly = methodBase?.DeclaringType.Assembly; string fullyQualifiedName = CreateFullyQualifiedName(methodBase); - StackFrame stackFrame = new StackFrame + var stackFrame = new StackFrame { Module = assembly?.GetName().Name, Location = new Location() diff --git a/src/Sarif/Core/Tool.cs b/src/Sarif/Core/Tool.cs index 4d7d2b22b..b040b9508 100644 --- a/src/Sarif/Core/Tool.cs +++ b/src/Sarif/Core/Tool.cs @@ -37,7 +37,7 @@ public static Tool CreateFromAssemblyData(Assembly assembly = null, dottedQuadFileVersion = ParseFileVersion(version.ToString()); } - Tool tool = new Tool + var tool = new Tool { Driver = new ToolComponent { diff --git a/src/Sarif/ExternalProcess.cs b/src/Sarif/ExternalProcess.cs index edd4871d1..1c5130678 100644 --- a/src/Sarif/ExternalProcess.cs +++ b/src/Sarif/ExternalProcess.cs @@ -24,7 +24,7 @@ public ExternalProcess( { acceptableReturnCodes = acceptableReturnCodes ?? new int[] { 0 }; - ProcessStartInfo psi = new ProcessStartInfo(); + var psi = new ProcessStartInfo(); psi.FileName = exePath; psi.Arguments = arguments; @@ -39,7 +39,7 @@ public ExternalProcess( psi.StandardOutputEncoding = System.Text.Encoding.UTF8; psi.WindowStyle = ProcessWindowStyle.Hidden; - using (Process process = Process.Start(psi)) + using (var process = Process.Start(psi)) { StdErr = new ConsoleStreamCapture(); StdOut = stdOut ?? new ConsoleStreamCapture(); diff --git a/src/Sarif/HashUtilities.cs b/src/Sarif/HashUtilities.cs index b40f79108..4ab259410 100644 --- a/src/Sarif/HashUtilities.cs +++ b/src/Sarif/HashUtilities.cs @@ -338,7 +338,7 @@ public static Dictionary RollingHash(string fileText) private static Long ComputeFirstMod() { - Long firstMod = new Long(1, 0, false); + var firstMod = new Long(1, 0, false); for (int i = 0; i < 100; i++) { diff --git a/src/Sarif/LineInfo.cs b/src/Sarif/LineInfo.cs index 500f47fde..bebca9c6b 100644 --- a/src/Sarif/LineInfo.cs +++ b/src/Sarif/LineInfo.cs @@ -51,7 +51,7 @@ public LineInfo(int startOffset, int lineNumber) /// true if the objects are considered equal, false if they are not. public override bool Equals(object obj) { - LineInfo? other = obj as LineInfo?; + var other = obj as LineInfo?; return other != null && this.Equals(other.Value); } diff --git a/src/Sarif/Map/JsonMapBuilder.cs b/src/Sarif/Map/JsonMapBuilder.cs index 568442bbe..659106302 100644 --- a/src/Sarif/Map/JsonMapBuilder.cs +++ b/src/Sarif/Map/JsonMapBuilder.cs @@ -52,7 +52,7 @@ public static JsonMapNode Build(Func streamProvider, JsonMapSettings set } // Parse file using JsonPositionedTextReader so map can get byte locations of elements - using (JsonPositionedTextReader reader = new JsonPositionedTextReader(streamProvider)) + using (var reader = new JsonPositionedTextReader(streamProvider)) { if (!reader.Read()) { return null; } return Build(reader, runSettings, startPosition: 0, out long _); @@ -91,7 +91,7 @@ private static JsonMapNode Build(JsonPositionedTextReader reader, JsonMapRunSett } // For objects and arrays, capture the exact position, then build a node and look inside... - JsonMapNode node = new JsonMapNode(); + var node = new JsonMapNode(); node.Start = reader.TokenPosition; node.Count = 0; @@ -206,7 +206,7 @@ private static void FilterArrayStarts(JsonMapNode node, JsonMapRunSettings setti if (every > 1) { int newCount = node.Count / every; - List newStarts = new List(newCount); + var newStarts = new List(newCount); for (int i = 0; i * every < node.Count; ++i) { diff --git a/src/Sarif/Map/JsonMapNode.cs b/src/Sarif/Map/JsonMapNode.cs index 701270ace..b401396a7 100644 --- a/src/Sarif/Map/JsonMapNode.cs +++ b/src/Sarif/Map/JsonMapNode.cs @@ -134,7 +134,7 @@ public long FindArrayStart(int index, Func inputStreamProvider) // Make it a valid array prefix (it must start with '[', which will look like the root of the Json document buffer[0] = (byte)'['; - using (JsonPositionedTextReader reader = new JsonPositionedTextReader(() => new MemoryStream(buffer))) + using (var reader = new JsonPositionedTextReader(() => new MemoryStream(buffer))) { // Find the desired array item index in the buffer long relativePosition = reader.ReadToArrayIndex(index - startIndex); diff --git a/src/Sarif/Map/LongArrayDeltaConverter.cs b/src/Sarif/Map/LongArrayDeltaConverter.cs index 0089cb0c7..e345eeed5 100644 --- a/src/Sarif/Map/LongArrayDeltaConverter.cs +++ b/src/Sarif/Map/LongArrayDeltaConverter.cs @@ -35,7 +35,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist reader.Read(); - List list = new List(); + var list = new List(); long current = 0; // Convert the array values from relative to absolute @@ -65,7 +65,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s return; } - List list = (List)value; + var list = (List)value; writer.WriteStartArray(); diff --git a/src/Sarif/OffsetInfo.cs b/src/Sarif/OffsetInfo.cs index b1306b357..ada3b247c 100644 --- a/src/Sarif/OffsetInfo.cs +++ b/src/Sarif/OffsetInfo.cs @@ -60,7 +60,7 @@ private OffsetInfo(SerializationInfo info, StreamingContext context) /// true if the objects are considered equal, false if they are not. public override bool Equals(object obj) { - OffsetInfo? other = obj as OffsetInfo?; + var other = obj as OffsetInfo?; return other != null && this.Equals(other.Value); } diff --git a/src/Sarif/Processors/Generic/GenericMappingAction.cs b/src/Sarif/Processors/Generic/GenericMappingAction.cs index 152f58693..d7381967a 100644 --- a/src/Sarif/Processors/Generic/GenericMappingAction.cs +++ b/src/Sarif/Processors/Generic/GenericMappingAction.cs @@ -17,7 +17,7 @@ public GenericMappingAction(Func action) public IEnumerable Map(IEnumerable collection) { - List output = new List(); + var output = new List(); foreach (T value in collection) { output.Add(Action.Invoke(value)); diff --git a/src/Sarif/PropertiesDictionary.cs b/src/Sarif/PropertiesDictionary.cs index 09314b9da..0b8bb23c9 100644 --- a/src/Sarif/PropertiesDictionary.cs +++ b/src/Sarif/PropertiesDictionary.cs @@ -183,7 +183,7 @@ public void SaveToXml(string filePath) public void SaveToXml(Stream stream) { var settings = new XmlWriterSettings { Indent = true }; - using (XmlWriter writer = XmlWriter.Create(stream, settings)) + using (var writer = XmlWriter.Create(stream, settings)) { this.SavePropertiesToXmlStream(writer, settings, null, SettingNameToDescriptionsMap); } @@ -212,7 +212,7 @@ public void LoadFromXml(Stream stream) XmlResolver = null }; - using (XmlReader reader = XmlReader.Create(stream, settings)) + using (var reader = XmlReader.Create(stream, settings)) { if (reader.IsStartElement(PropertiesDictionaryExtensionMethods.PROPERTIES_ID)) { diff --git a/src/Sarif/Query/BitArrayExtensions.cs b/src/Sarif/Query/BitArrayExtensions.cs index 435618f80..d7155ddc7 100644 --- a/src/Sarif/Query/BitArrayExtensions.cs +++ b/src/Sarif/Query/BitArrayExtensions.cs @@ -34,7 +34,7 @@ public static int TrueCount(this BitArray array) /// List of items from set which were included in BitArray public static List MatchingSubset(this BitArray matches, IList set) { - List subset = new List(); + var subset = new List(); for (int i = 0; i < set.Count; ++i) { diff --git a/src/Sarif/Query/Evaluators/ExpressionEvaluators.cs b/src/Sarif/Query/Evaluators/ExpressionEvaluators.cs index 4b468505b..c699cfa92 100644 --- a/src/Sarif/Query/Evaluators/ExpressionEvaluators.cs +++ b/src/Sarif/Query/Evaluators/ExpressionEvaluators.cs @@ -81,7 +81,7 @@ public AndEvaluator(IEnumerable> terms) public void Evaluate(ICollection list, BitArray matches) { - BitArray termMatches = new BitArray(list.Count); + var termMatches = new BitArray(list.Count); for (int i = 0; i < _terms.Count; ++i) { @@ -118,7 +118,7 @@ public OrEvaluator(IEnumerable> terms) public void Evaluate(ICollection list, BitArray matches) { - BitArray termMatches = new BitArray(list.Count); + var termMatches = new BitArray(list.Count); foreach (IExpressionEvaluator term in _terms) { diff --git a/src/Sarif/Query/Evaluators/PropertyBagPropertyEvaluator.cs b/src/Sarif/Query/Evaluators/PropertyBagPropertyEvaluator.cs index 6c27555e3..2797cf633 100644 --- a/src/Sarif/Query/Evaluators/PropertyBagPropertyEvaluator.cs +++ b/src/Sarif/Query/Evaluators/PropertyBagPropertyEvaluator.cs @@ -1,5 +1,5 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; using System.Collections; @@ -60,13 +60,21 @@ public PropertyBagPropertyEvaluator(TermExpression term) private IExpressionEvaluator CreateEvaluator(TermExpression term) { if (IsStringComparison(term)) + { return new StringEvaluator(GetProperty, term, StringComparison.OrdinalIgnoreCase); + } else if (IsDateTimeComparison(term)) + { return new DateTimeEvaluator(GetProperty, term); + } else if (IsDoubleComparison(term)) + { return new DoubleEvaluator(GetProperty, term); + } else + { return new StringEvaluator(GetProperty, term, StringComparison.OrdinalIgnoreCase); + } } private static readonly ReadOnlyCollection s_stringSpecificOperators = diff --git a/src/Sarif/Query/ExpressionParser.cs b/src/Sarif/Query/ExpressionParser.cs index de3754e91..aa44406f9 100644 --- a/src/Sarif/Query/ExpressionParser.cs +++ b/src/Sarif/Query/ExpressionParser.cs @@ -75,7 +75,7 @@ public static string Escape(string value) // Otherwise, build the string, doubling each character to escape int nextCopyFrom = 0; - StringBuilder result = new StringBuilder(); + var result = new StringBuilder(); result.Append('\''); for (int i = 0; i < value.Length; ++i) @@ -129,7 +129,7 @@ public static string ToString(CompareOperator op) public static IExpression ParseExpression(string expression) { - StringSlice text = new StringSlice(expression); + var text = new StringSlice(expression); // Parse the expression IExpression result = ParseExpression(ref text); @@ -146,7 +146,7 @@ private static IExpression ParseExpression(ref StringSlice text) ConsumeWhitespace(ref text); if (text.Length == 0) { return new AllExpression(); } - List terms = new List + var terms = new List { ParseAndExpression(ref text) }; @@ -170,7 +170,7 @@ private static IExpression ParseExpression(ref StringSlice text) private static IExpression ParseAndExpression(ref StringSlice text) { - List terms = new List + var terms = new List { ParseTerm(ref text) }; diff --git a/src/Sarif/Query/Expressions.cs b/src/Sarif/Query/Expressions.cs index 6db93d387..aafa92727 100644 --- a/src/Sarif/Query/Expressions.cs +++ b/src/Sarif/Query/Expressions.cs @@ -36,7 +36,7 @@ public AndExpression(IReadOnlyList terms) public override string ToString() { - StringBuilder result = new StringBuilder(); + var result = new StringBuilder(); foreach (IExpression part in Terms) { diff --git a/src/Sarif/Readers/DeferredDictionary.cs b/src/Sarif/Readers/DeferredDictionary.cs index c4b9c1be8..bc63a2e8b 100644 --- a/src/Sarif/Readers/DeferredDictionary.cs +++ b/src/Sarif/Readers/DeferredDictionary.cs @@ -64,7 +64,7 @@ private void EnsurePositionsBuilt() private void BuildPositions() { using (Stream stream = _streamProvider()) - using (JsonPositionedTextReader reader = new JsonPositionedTextReader(() => stream)) + using (var reader = new JsonPositionedTextReader(() => stream)) { stream.Seek(_start, SeekOrigin.Begin); reader.Read(); @@ -194,7 +194,7 @@ private bool TryGetValue(string key, bool readValue, out T value) { _stream.Seek(keyPosition, SeekOrigin.Begin); - using (JsonInnerTextReader reader = new JsonInnerTextReader(new JsonObjectMemberStreamReader(_stream))) + using (var reader = new JsonInnerTextReader(new JsonObjectMemberStreamReader(_stream))) { reader.CloseInput = false; diff --git a/src/Sarif/Readers/DeferredList.cs b/src/Sarif/Readers/DeferredList.cs index 45be1286a..5f5afca06 100644 --- a/src/Sarif/Readers/DeferredList.cs +++ b/src/Sarif/Readers/DeferredList.cs @@ -89,7 +89,7 @@ private void EnsurePositionsBuilt() private void BuildPositions() { using (Stream stream = _streamProvider()) - using (JsonPositionedTextReader reader = new JsonPositionedTextReader(() => stream)) + using (var reader = new JsonPositionedTextReader(() => stream)) { stream.Seek(_start, SeekOrigin.Begin); reader.Read(); @@ -100,7 +100,7 @@ private void BuildPositions() private void BuildPositions(JsonPositionedTextReader reader, long currentOffset) { - List positions = new List(); + var positions = new List(); while (true) { @@ -161,7 +161,7 @@ public T this[int index] _stream.Seek(position, SeekOrigin.Begin); // Build a JsonTextReader - using (JsonInnerTextReader reader = new JsonInnerTextReader(new StreamReader(_stream))) + using (var reader = new JsonInnerTextReader(new StreamReader(_stream))) { reader.CloseInput = false; reader.Read(); diff --git a/src/Sarif/Readers/SarifContractResolver.cs b/src/Sarif/Readers/SarifContractResolver.cs index a7163bec3..280185331 100644 --- a/src/Sarif/Readers/SarifContractResolver.cs +++ b/src/Sarif/Readers/SarifContractResolver.cs @@ -19,29 +19,53 @@ protected override JsonContract CreateContract(Type objectType) // this will only be called once and then cached if (objectType == typeof(Uri)) + { contract.Converter = UriConverter.Instance; + } else if (objectType == typeof(DateTime)) + { contract.Converter = DateTimeConverter.Instance; + } else if (objectType == typeof(Version)) + { contract.Converter = VersionConverter.Instance; + } else if (objectType == typeof(SarifVersion)) + { contract.Converter = SarifVersionConverter.Instance; + } else if (objectType == typeof(ThreadFlowLocationImportance)) + { contract.Converter = EnumConverter.Instance; + } else if (objectType == typeof(FailureLevel)) + { contract.Converter = EnumConverter.Instance; + } else if (objectType == typeof(ResultKind)) + { contract.Converter = EnumConverter.Instance; + } else if (objectType == typeof(BaselineState)) + { contract.Converter = EnumConverter.Instance; + } else if (objectType == typeof(SuppressionKind)) + { contract.Converter = FlagsEnumConverter.Instance; + } else if (objectType == typeof(ArtifactRoles)) + { contract.Converter = FlagsEnumConverter.Instance; + } else if (objectType == typeof(IDictionary)) + { contract.Converter = PropertyBagConverter.Instance; + } else if (objectType == typeof(Dictionary)) + { contract.Converter = PropertyBagConverter.Instance; + } return contract; } diff --git a/src/Sarif/Readers/SerializedPropertyInfoConverter.cs b/src/Sarif/Readers/SerializedPropertyInfoConverter.cs index bdcc06a4f..c27c3700c 100644 --- a/src/Sarif/Readers/SerializedPropertyInfoConverter.cs +++ b/src/Sarif/Readers/SerializedPropertyInfoConverter.cs @@ -21,9 +21,9 @@ public static SerializedPropertyInfo Read(JsonReader reader) { bool wasString = reader.TokenType == JsonToken.String; - StringBuilder builder = new StringBuilder(); - using (StringWriter w = new StringWriter(builder)) - using (JsonTextWriter writer = new JsonTextWriter(w)) + var builder = new StringBuilder(); + using (var w = new StringWriter(builder)) + using (var writer = new JsonTextWriter(w)) { writer.WriteToken(reader); } diff --git a/src/Sarif/Readers/VersionConverter.cs b/src/Sarif/Readers/VersionConverter.cs index 0da4046b9..1bc05cf05 100644 --- a/src/Sarif/Readers/VersionConverter.cs +++ b/src/Sarif/Readers/VersionConverter.cs @@ -32,7 +32,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s throw new ArgumentNullException(nameof(writer)); } - Version version = (Version)value; + var version = (Version)value; string versionString = version.ToString(); diff --git a/src/Sarif/RuleUtilities.cs b/src/Sarif/RuleUtilities.cs index 54e782c5c..9567358b7 100644 --- a/src/Sarif/RuleUtilities.cs +++ b/src/Sarif/RuleUtilities.cs @@ -46,7 +46,7 @@ public static Result BuildResult(FailureLevel level, ResultKind kind, IAnalysisC ruleMessageId = NormalizeRuleMessageId(ruleMessageId, context.Rule.Id); - Result result = new Result + var result = new Result { RuleId = context.Rule.Id, diff --git a/src/Sarif/Sarif.csproj b/src/Sarif/Sarif.csproj index 39ab22e74..e6795dd4a 100644 --- a/src/Sarif/Sarif.csproj +++ b/src/Sarif/Sarif.csproj @@ -21,6 +21,7 @@ netstandard2.0 $(TargetFrameworks);net462 + true @@ -99,7 +100,13 @@ SdkResources.resx - - + + diff --git a/src/Sarif/TypedPropertiesDictionaryConverter.cs b/src/Sarif/TypedPropertiesDictionaryConverter.cs index 168780020..2f878c777 100644 --- a/src/Sarif/TypedPropertiesDictionaryConverter.cs +++ b/src/Sarif/TypedPropertiesDictionaryConverter.cs @@ -63,7 +63,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist return JsonConvert.DeserializeObject(reader.ReadAsString(), _versionConverter); } - JObject jo = JObject.Load(reader); + var jo = JObject.Load(reader); var result = new PropertiesDictionary(); foreach (JProperty property in jo.Properties()) diff --git a/src/Sarif/UriHelper.cs b/src/Sarif/UriHelper.cs index b6c335a00..666350f09 100644 --- a/src/Sarif/UriHelper.cs +++ b/src/Sarif/UriHelper.cs @@ -62,7 +62,7 @@ public static string MakeValidUri(string path) } else if (Uri.TryCreate(path, UriKind.Relative, out uri)) { - UriBuilder builder = new UriBuilder("http", "www.example.com", 80, path); + var builder = new UriBuilder("http", "www.example.com", 80, path); validUri = builder.Uri.AbsolutePath; // Since what we actually want is a relative path, strip the leading "/" diff --git a/src/Sarif/VersionOne/Core/PropertyBagHolderVersionOne.cs b/src/Sarif/VersionOne/Core/PropertyBagHolderVersionOne.cs index d73cf6dfe..842209a61 100644 --- a/src/Sarif/VersionOne/Core/PropertyBagHolderVersionOne.cs +++ b/src/Sarif/VersionOne/Core/PropertyBagHolderVersionOne.cs @@ -136,7 +136,7 @@ public void SetPropertiesFrom(IPropertyBagHolderVersionOne other) // We need the concrete class because the IPropertyBagHolderVersionOne interface // doesn't expose the raw Properties array. - PropertyBagHolderVersionOne otherHolder = other as PropertyBagHolderVersionOne; + var otherHolder = other as PropertyBagHolderVersionOne; Debug.Assert(otherHolder != null); Properties = other.PropertyNames.Count > 0 ? new Dictionary() : null; diff --git a/src/Sarif/VersionOne/Readers/SarifContractResolverVersionOne.cs b/src/Sarif/VersionOne/Readers/SarifContractResolverVersionOne.cs index b3651774e..c928c62fa 100644 --- a/src/Sarif/VersionOne/Readers/SarifContractResolverVersionOne.cs +++ b/src/Sarif/VersionOne/Readers/SarifContractResolverVersionOne.cs @@ -20,31 +20,57 @@ protected override JsonContract CreateContract(Type objectType) // this will only be called once and then cached if (objectType == typeof(Uri)) + { contract.Converter = UriConverter.Instance; + } else if (objectType == typeof(DateTime)) + { contract.Converter = DateTimeConverter.Instance; + } else if (objectType == typeof(Version)) + { contract.Converter = VersionConverter.Instance; + } else if (objectType == typeof(SarifVersionVersionOne)) + { contract.Converter = SarifVersionConverter.Instance; + } else if (objectType == typeof(AnnotatedCodeLocationKindVersionOne)) + { contract.Converter = EnumConverter.Instance; + } else if (objectType == typeof(AnnotatedCodeLocationImportanceVersionOne)) + { contract.Converter = EnumConverter.Instance; + } else if (objectType == typeof(ResultLevelVersionOne)) + { contract.Converter = EnumConverter.Instance; + } else if (objectType == typeof(RuleConfigurationVersionOne)) + { contract.Converter = EnumConverter.Instance; + } else if (objectType == typeof(NotificationLevelVersionOne)) + { contract.Converter = EnumConverter.Instance; + } else if (objectType == typeof(AlgorithmKindVersionOne)) + { contract.Converter = EnumConverter.Instance; + } else if (objectType == typeof(BaselineStateVersionOne)) + { contract.Converter = EnumConverter.Instance; + } else if (objectType == typeof(SuppressionStatesVersionOne)) + { contract.Converter = FlagsEnumConverter.Instance; + } else if (objectType == typeof(IDictionary)) + { contract.Converter = PropertyBagConverter.Instance; + } return contract; } diff --git a/src/Sarif/Visitors/PartitioningVisitor.cs b/src/Sarif/Visitors/PartitioningVisitor.cs index 55b5adbec..cdca94151 100644 --- a/src/Sarif/Visitors/PartitioningVisitor.cs +++ b/src/Sarif/Visitors/PartitioningVisitor.cs @@ -365,7 +365,7 @@ private SarifLog CreatePartitionLog(T partitionValue) var partitionArtifactIndexRemappingDictionary = new Dictionary(); artifactIndexRemappingDictionaries.Add(partitionArtifactIndexRemappingDictionary); - List allPartitionArtifactIndicesList = allPartitionArtifactIndices + var allPartitionArtifactIndicesList = allPartitionArtifactIndices .OrderBy(index => index) .ToList(); diff --git a/src/Sarif/Visitors/SarifCurrentToVersionOneVisitor.cs b/src/Sarif/Visitors/SarifCurrentToVersionOneVisitor.cs index 756c43e01..ca1bd40a7 100644 --- a/src/Sarif/Visitors/SarifCurrentToVersionOneVisitor.cs +++ b/src/Sarif/Visitors/SarifCurrentToVersionOneVisitor.cs @@ -303,7 +303,7 @@ internal InvocationVersionOne CreateInvocationVersionOne(Invocation v2Invocation _currentRun.ToolNotifications = new List(); } - List notifications = v2Invocation.ToolExecutionNotifications.Select(CreateNotificationVersionOne).ToList(); + var notifications = v2Invocation.ToolExecutionNotifications.Select(CreateNotificationVersionOne).ToList(); _currentRun.ToolNotifications = _currentRun.ToolNotifications.Union(notifications).ToList(); } } diff --git a/src/Sarif/Visitors/SarifVersionOneToCurrentVisitor.cs b/src/Sarif/Visitors/SarifVersionOneToCurrentVisitor.cs index 97eeeb6d8..f8cda2f1a 100644 --- a/src/Sarif/Visitors/SarifVersionOneToCurrentVisitor.cs +++ b/src/Sarif/Visitors/SarifVersionOneToCurrentVisitor.cs @@ -1011,7 +1011,7 @@ internal Run CreateRun(RunVersionOne v1Run) _v1LogicalLocationKeyToDecoratedNameMap = visitor.LogicalLocationKeyToDecoratedNameMap; run.LogicalLocations = new List(); - HashSet populatedKeys = new HashSet(); + var populatedKeys = new HashSet(); foreach (KeyValuePair pair in v1Run.LogicalLocations) { diff --git a/src/Sarif/Writers/MemoryStreamSarifLogger.cs b/src/Sarif/Writers/MemoryStreamSarifLogger.cs index bef641288..6ef386556 100644 --- a/src/Sarif/Writers/MemoryStreamSarifLogger.cs +++ b/src/Sarif/Writers/MemoryStreamSarifLogger.cs @@ -81,7 +81,7 @@ public SarifLog ToSarifLog() this.writer.BaseStream.Position = 0; - SarifLog log = SarifLog.Load(this.writer.BaseStream); + var log = SarifLog.Load(this.writer.BaseStream); return log; } diff --git a/src/Sarif/Writers/PrereleaseCompatibilityTransformer.cs b/src/Sarif/Writers/PrereleaseCompatibilityTransformer.cs index fe1de6da8..2833e0633 100644 --- a/src/Sarif/Writers/PrereleaseCompatibilityTransformer.cs +++ b/src/Sarif/Writers/PrereleaseCompatibilityTransformer.cs @@ -32,7 +32,7 @@ public static SarifLog UpdateToCurrentVersion( if (string.IsNullOrEmpty(prereleaseSarifLog)) { return null; } - JObject logObject = JObject.Parse(prereleaseSarifLog); + var logObject = JObject.Parse(prereleaseSarifLog); string version = (string)logObject["version"]; if (version == SarifUtilities.V1_0_0) @@ -487,7 +487,7 @@ private static bool ConvertRunRedactionTokenToArray(JObject run) { if (run["redactionToken"] is JToken redactionToken) { - JArray redactionTokens = new JArray + var redactionTokens = new JArray { redactionToken }; @@ -730,7 +730,7 @@ private static void RenameMessageIdToId(JObject run) private static void MoveToolLanguageToRun(JObject run) { - JObject tool = (JObject)run["tool"]; + var tool = (JObject)run["tool"]; if (tool["language"] is JToken language) { tool.Remove("language"); @@ -1502,11 +1502,11 @@ private static void MoveToolPropertiesIntoDriverToolComponent(JObject run) // 1. Retrieve run.tool object, which will serve as the basis of the // new run.tool.driver object and zap sarifLoggerVersion from it. - JObject driver = (JObject)run["tool"]; + var driver = (JObject)run["tool"]; driver.Remove("sarifLoggerVersion"); // 2. Create a new tool object, preserving only the language property - JObject tool = new JObject(new JProperty("language", driver["language"] ?? "en-US")); + var tool = new JObject(new JProperty("language", driver["language"] ?? "en-US")); driver.Remove("language"); // https://github.com/oasis-tcs/sarif-spec/issues/319 @@ -1591,7 +1591,7 @@ private static void MergeRichMessageStringsIntoMessageStrings(JArray descriptors private static JObject CreateMultiformatMessageStringFromPlaintext(string plaintext) { - JProperty textProperty = new JProperty("text", plaintext); + var textProperty = new JProperty("text", plaintext); return new JObject(textProperty); } @@ -1604,7 +1604,7 @@ private static void MoveRuleDescriptors(JObject run) return; } - JObject tool = (JObject)run["tool"]; + var tool = (JObject)run["tool"]; // 1. 'run.resources.messageStrings' moves to 'run.tool.globalMessageStrings' if (resources["messageStrings"] is JObject messageStrings) @@ -1799,7 +1799,7 @@ private static bool ApplyChangesFromTC25ThroughTC30( { // result.message SHALL be present constraint should be added to schema // https://github.com/oasis-tcs/sarif-spec/issues/262 - JObject message = (JObject)result["message"]; + var message = (JObject)result["message"]; if (message == null) { @@ -1823,7 +1823,7 @@ private static bool ApplyChangesFromTC25ThroughTC30( // // We will also explicitly apply the default tool.language value of "en-US". - JObject tool = (JObject)run["tool"]; + var tool = (JObject)run["tool"]; modifiedLog |= RenameProperty(tool, previousName: "fileVersion", newName: "dottedQuadFileVersion"); PopulatePropertyIfAbsent(tool, "language", "en-US", ref modifiedLog); @@ -1849,7 +1849,7 @@ private static JToken ConvertRulesDictionaryToArray(JObject rules, Dictionary jObjectToIndexMap = new Dictionary(); + var jObjectToIndexMap = new Dictionary(); foreach (JProperty ruleEntry in rules.Properties()) { @@ -1910,7 +1910,7 @@ private static JToken ConvertFilesDictionaryToArray(JObject files, Dictionary jObjectToIndexMap = new Dictionary(); + var jObjectToIndexMap = new Dictionary(); foreach (JProperty fileEntry in files.Properties()) { @@ -1975,7 +1975,7 @@ private static void AddEntryToFileLocationToIndexMap(JObject filesDictionary, st var fileLocationKey = ArtifactLocation.CreateFromFilesDictionaryKey(key, parentKey); - JObject fileLocationObject = new JObject(); + var fileLocationObject = new JObject(); file["fileLocation"] = fileLocationObject; fileLocationObject["uri"] = fileLocationKey.Uri; fileLocationObject["uriBaseId"] = fileLocationKey.UriBaseId; @@ -2002,7 +2002,7 @@ private static JArray ConvertLogicalLocationsDictionaryToArray( if (logicalLocations == null) { return null; } - Dictionary jObjectToIndexMap = new Dictionary(); + var jObjectToIndexMap = new Dictionary(); logicalLocationToIndexMap = new Dictionary(LogicalLocation.ValueComparer); fullyQualifiedLogicalNameToIndexMap = new Dictionary(); @@ -2297,7 +2297,7 @@ internal static bool UpdateRunResults(JObject run) { bool modifiedRun = false; - JArray results = (JArray)run["results"]; + var results = (JArray)run["results"]; if (results == null) { return modifiedRun; } foreach (JObject result in results) @@ -2332,12 +2332,12 @@ private static bool UpdateCodeFlows(JArray codeFlows) foreach (JObject codeFlow in codeFlows) { - JArray threadFlows = (JArray)codeFlow["threadFlows"]; + var threadFlows = (JArray)codeFlow["threadFlows"]; if (threadFlows == null) { continue; } foreach (JObject threadFlow in threadFlows) { - JArray threadFlowLocations = (JArray)threadFlow["locations"]; + var threadFlowLocations = (JArray)threadFlow["locations"]; if (threadFlowLocations == null) { continue; } foreach (JObject threadFlowLocation in threadFlowLocations) @@ -2517,7 +2517,7 @@ private static bool UpdateFileHashesProperty(JObject file) JToken hashes = file["hashes"]; if (hashes == null || hashes.Type != JTokenType.Array) { return modifiedRun; } - JObject rewrittenHashes = new JObject(); + var rewrittenHashes = new JObject(); foreach (JObject hash in hashes) { diff --git a/src/Sarif/Writers/SarifConsolidator.cs b/src/Sarif/Writers/SarifConsolidator.cs index e67ea29c4..c3e1b8fa8 100644 --- a/src/Sarif/Writers/SarifConsolidator.cs +++ b/src/Sarif/Writers/SarifConsolidator.cs @@ -157,8 +157,8 @@ public IList Trim(IList locations) { if (locations == null || locations.Count == 0) { return locations; } - HashSet uniqueLocations = new HashSet(Location.ValueComparer); - List newLocations = new List(); + var uniqueLocations = new HashSet(Location.ValueComparer); + var newLocations = new List(); foreach (Location location in locations) { @@ -190,8 +190,8 @@ public IList Trim(IList logicalLocations) { if (logicalLocations == null || logicalLocations.Count == 0) { return logicalLocations; } - HashSet uniqueLocations = new HashSet(LogicalLocation.ValueComparer); - List newLocations = new List(); + var uniqueLocations = new HashSet(LogicalLocation.ValueComparer); + var newLocations = new List(); foreach (LogicalLocation logicalLocation in logicalLocations) { diff --git a/src/Sarif/Writers/SarifOneZeroZeroLogger.cs b/src/Sarif/Writers/SarifOneZeroZeroLogger.cs index a41c1cd6a..cc2f9b50c 100644 --- a/src/Sarif/Writers/SarifOneZeroZeroLogger.cs +++ b/src/Sarif/Writers/SarifOneZeroZeroLogger.cs @@ -60,7 +60,7 @@ public override void Dispose() var transformer = new SarifCurrentToVersionOneVisitor(); transformer.VisitSarifLog(v2Log); - JsonSerializerSettings v1Settings = new JsonSerializerSettings() + var v1Settings = new JsonSerializerSettings() { ContractResolver = SarifContractResolverVersionOne.Instance, Formatting = PrettyPrint ? Formatting.Indented : Formatting.None diff --git a/src/Test.EndToEnd.Baselining/BaseliningDetailEnricher.cs b/src/Test.EndToEnd.Baselining/BaseliningDetailEnricher.cs index d94b2d762..699f7e36d 100644 --- a/src/Test.EndToEnd.Baselining/BaseliningDetailEnricher.cs +++ b/src/Test.EndToEnd.Baselining/BaseliningDetailEnricher.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.Collections.Generic; using System.IO; using System.Text.RegularExpressions; @@ -55,8 +54,8 @@ public void Convert(string sourcePath, string targetPath) public void Convert(Stream source, Stream target) { - using (StreamReader reader = new StreamReader(source)) - using (StreamWriter writer = new StreamWriter(target)) + using (var reader = new StreamReader(source)) + using (var writer = new StreamWriter(target)) { Convert(reader, writer); } diff --git a/src/Test.EndToEnd.Baselining/BaseliningDetailLogger.cs b/src/Test.EndToEnd.Baselining/BaseliningDetailLogger.cs index e89883d01..57c139b13 100644 --- a/src/Test.EndToEnd.Baselining/BaseliningDetailLogger.cs +++ b/src/Test.EndToEnd.Baselining/BaseliningDetailLogger.cs @@ -47,7 +47,7 @@ private static string RelativeSeriesPath(string seriesPath) public void Write(SarifLog newBaselineLog, SarifLog baselineLog, BaseliningSummary summary) { - Dictionary baselineResultsByGuid = new Dictionary(); + var baselineResultsByGuid = new Dictionary(); foreach (Result result in baselineLog.EnumerateResults()) { baselineResultsByGuid[result.CorrelationGuid ?? result.Guid] = result; diff --git a/src/Test.EndToEnd.Baselining/BaseliningSummary.cs b/src/Test.EndToEnd.Baselining/BaseliningSummary.cs index 647a27ba9..1df08145f 100644 --- a/src/Test.EndToEnd.Baselining/BaseliningSummary.cs +++ b/src/Test.EndToEnd.Baselining/BaseliningSummary.cs @@ -73,7 +73,7 @@ public void AddCounts(BaseliningSummary inner) public void Add(SarifLog newBaselineLog, SarifLog baselineLog, SarifLog currentLog) { - Dictionary newAndRemovedPerUri = new Dictionary(); + var newAndRemovedPerUri = new Dictionary(); foreach (Result result in newBaselineLog.EnumerateResults()) { diff --git a/src/Test.EndToEnd.Baselining/BaseliningTester.cs b/src/Test.EndToEnd.Baselining/BaseliningTester.cs index 195318e9c..18b936ef8 100644 --- a/src/Test.EndToEnd.Baselining/BaseliningTester.cs +++ b/src/Test.EndToEnd.Baselining/BaseliningTester.cs @@ -55,7 +55,7 @@ public BaseliningSummary RunAll(string rootPath) public BaseliningSummary RunUnder(string folderPath, string reportingName) { - BaseliningSummary folderSummary = new BaseliningSummary(Path.GetFileName(folderPath)); + var folderSummary = new BaseliningSummary(Path.GetFileName(folderPath)); // Recurse on subfolders, if found foreach (string subfolder in Directory.EnumerateDirectories(folderPath, "*", SearchOption.TopDirectoryOnly)) @@ -77,12 +77,12 @@ public BaseliningSummary RunUnder(string folderPath, string reportingName) public BaseliningSummary RunSeries(string seriesPath, string reportingName, int debugLogIndex = -1, int debugResultIndex = -1) { string outputLogPath = Path.ChangeExtension(seriesPath.Replace($"\\{InputFolderName}\\", $"\\{OutputFolderName}\\"), ".log"); - BaseliningSummary seriesSummary = new BaseliningSummary(Path.GetFileName(seriesPath)); + var seriesSummary = new BaseliningSummary(Path.GetFileName(seriesPath)); Directory.CreateDirectory(Path.GetDirectoryName(outputLogPath)); using (Stream outputStream = File.Create(outputLogPath)) - using (BaseliningDetailLogger logger = new BaseliningDetailLogger(seriesPath, outputStream)) + using (var logger = new BaseliningDetailLogger(seriesPath, outputStream)) { // Load the original baseline SarifLog baseline = LoadBaseline(seriesPath); @@ -100,11 +100,11 @@ public BaseliningSummary RunSeries(string seriesPath, string reportingName, int if (debugLogIndex == current.LogIndex) { - List absentResults = newBaseline.EnumerateResults().Where((r) => r.BaselineState == BaselineState.Absent).ToList(); - List newResults = newBaseline.EnumerateResults().Where((r) => r.BaselineState == BaselineState.New).ToList(); + var absentResults = newBaseline.EnumerateResults().Where((r) => r.BaselineState == BaselineState.Absent).ToList(); + var newResults = newBaseline.EnumerateResults().Where((r) => r.BaselineState == BaselineState.New).ToList(); } - BaseliningSummary fileSummary = new BaseliningSummary(Path.GetFileNameWithoutExtension(current.FilePath)); + var fileSummary = new BaseliningSummary(Path.GetFileNameWithoutExtension(current.FilePath)); fileSummary.Add(newBaseline, baseline, current.Log); seriesSummary.AddCounts(fileSummary); logger.Write(newBaseline, baseline, fileSummary); @@ -138,7 +138,7 @@ public void EnrichUnder(string folderPath) public void EnrichSeries(string seriesPath) { string outputLogPath = Path.ChangeExtension(seriesPath.Replace($"\\{InputFolderName}\\", $"\\{OutputFolderName}\\"), ".log"); - BaseliningDetailEnricher enricher = new BaseliningDetailEnricher(); + var enricher = new BaseliningDetailEnricher(); // Load Baseline details SarifLog baseline = LoadBaseline(seriesPath); @@ -196,7 +196,7 @@ public LogInSeries(SarifLog log, int logIndex, string filePath) private IEnumerable LoadSeriesLogs(string seriesPath) { // Baseline each log in order - List logs = new List(Directory.EnumerateFiles(seriesPath, "*.sarif", SearchOption.TopDirectoryOnly).Where(filePath => !filePath.EndsWith(FirstBaselineFileName)).OrderBy(path => path)); + var logs = new List(Directory.EnumerateFiles(seriesPath, "*.sarif", SearchOption.TopDirectoryOnly).Where(filePath => !filePath.EndsWith(FirstBaselineFileName)).OrderBy(path => path)); int logIndex = 1; foreach (string filePath in logs) @@ -232,8 +232,8 @@ public static bool AreSufficientlySimiliar(SarifLog baseline, string baselineRes return false; } - ExtractedResult bExtractedResult = new ExtractedResult(bResult, bResult.Run); - ExtractedResult cExtractedResult = new ExtractedResult(cResult, cResult.Run); + var bExtractedResult = new ExtractedResult(bResult, bResult.Run); + var cExtractedResult = new ExtractedResult(cResult, cResult.Run); bool outcome = bExtractedResult.IsSufficientlySimilarTo(cExtractedResult); return outcome; @@ -291,7 +291,7 @@ private static SarifLog Baseline(SarifLog baselineLog, SarifLog currentLog) // Mark all Results which are NOT in the new run as 'Unchanged' if (filteringMode == BaselineFilteringMode.ToIncludedArtifacts) { - HashSet includedArtifacts = new HashSet(currentLog.AllResultArtifactUris().Select(uri => uri.OriginalString)); + var includedArtifacts = new HashSet(currentLog.AllResultArtifactUris().Select(uri => uri.OriginalString)); foreach (Result result in outputLog.EnumerateResults()) { @@ -332,7 +332,7 @@ private static void SortForBaselining(SarifLog log) private static void SortForBaselining(Run run) { run.SetRunOnResults(); - List results = (List)run.Results; + var results = (List)run.Results; results.Sort(DirectResultMatchingComparer.Instance); } diff --git a/src/Test.EndToEnd.Baselining/Program.cs b/src/Test.EndToEnd.Baselining/Program.cs index faa6f27b4..b92046e36 100644 --- a/src/Test.EndToEnd.Baselining/Program.cs +++ b/src/Test.EndToEnd.Baselining/Program.cs @@ -85,7 +85,7 @@ private static int Main(string[] args) { try { - Program program = new Program(); + var program = new Program(); return Parser.Default.ParseArguments(args).MapResult( (RunOptions options) => Program.Run(options), @@ -102,7 +102,7 @@ private static int Main(string[] args) private static int Run(RunOptions options) { - BaseliningTester tester = new BaseliningTester(); + var tester = new BaseliningTester(); BaseliningSummary overallSummary = tester.RunAll(options.TestRootPath); return 0; @@ -110,7 +110,7 @@ private static int Run(RunOptions options) private static int Debug(DebugOptions options) { - BaseliningTester tester = new BaseliningTester(); + var tester = new BaseliningTester(); tester.RunSeries(Path.Combine(options.TestRootPath, BaseliningTester.InputFolderName, options.DebugSeriesPath), options.DebugSeriesPath, options.DebugLogIndex, options.DebugResultIndex); return 0; @@ -118,7 +118,7 @@ private static int Debug(DebugOptions options) private static int CreateDebugLogs(RebuildDebugLogsOptions options) { - BaseliningTester tester = new BaseliningTester(); + var tester = new BaseliningTester(); tester.EnrichUnder(Path.Combine(options.TestRootPath, BaseliningTester.InputFolderName)); return 0; diff --git a/src/Test.FunctionalTests.Sarif/MultitoolCommandLineTests.cs b/src/Test.FunctionalTests.Sarif/MultitoolCommandLineTests.cs index 0fd37f4ff..c8351f43e 100644 --- a/src/Test.FunctionalTests.Sarif/MultitoolCommandLineTests.cs +++ b/src/Test.FunctionalTests.Sarif/MultitoolCommandLineTests.cs @@ -5,9 +5,11 @@ using System.IO; using FluentAssertions; -using FluentAssertions.Execution; +#if DEBUG +using FluentAssertions.Execution; using Microsoft.CodeAnalysis.Sarif.Driver; +#endif using Xunit; @@ -25,13 +27,13 @@ public void Multitool_LaunchesAndRunsSuccessfully() Directory.GetCurrentDirectory(), @"..\..\Sarif.Multitool\netcoreapp3.1\Sarif.Multitool.exe")); - ProcessStartInfo startInfo = new ProcessStartInfo(multitoolPath, @"validate v2\ConverterTestData\ContrastSecurity\WebGoat.xml.sarif") + var startInfo = new ProcessStartInfo(multitoolPath, @"validate v2\ConverterTestData\ContrastSecurity\WebGoat.xml.sarif") { WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true }; - using (Process process = Process.Start(startInfo)) + using (var process = Process.Start(startInfo)) { process.WaitForExit(); diff --git a/src/Test.FunctionalTests.Sarif/PropertyBagConverterTests.cs b/src/Test.FunctionalTests.Sarif/PropertyBagConverterTests.cs index 8549ce47b..4ddc117b2 100644 --- a/src/Test.FunctionalTests.Sarif/PropertyBagConverterTests.cs +++ b/src/Test.FunctionalTests.Sarif/PropertyBagConverterTests.cs @@ -31,7 +31,7 @@ public void PropertyBagConverter_RoundTrip() long longPropertyValue = (long)10 * int.MaxValue; string dateTimePropertyName = nameof(dateTimePropertyName); - DateTime dateTimePropertyValue = new DateTime(2019, 9, 27, 13, 52, 0); + var dateTimePropertyValue = new DateTime(2019, 9, 27, 13, 52, 0); var run = new Run { diff --git a/src/Test.FunctionalTests.Sarif/SarifConverterTests.cs b/src/Test.FunctionalTests.Sarif/SarifConverterTests.cs index e0e099d7d..a3dd9b5b3 100644 --- a/src/Test.FunctionalTests.Sarif/SarifConverterTests.cs +++ b/src/Test.FunctionalTests.Sarif/SarifConverterTests.cs @@ -119,7 +119,7 @@ private void BatchRunConverter(string tool, string inputFilter = "*.xml", bool e private static void EnrichSarifLog(string actualFilePath) { - JsonSerializerSettings settings = new JsonSerializerSettings() + var settings = new JsonSerializerSettings() { Formatting = Formatting.Indented, }; diff --git a/src/Test.FunctionalTests.Sarif/SarifLogEqualityComparerTests.cs b/src/Test.FunctionalTests.Sarif/SarifLogEqualityComparerTests.cs index 111964f47..9fef81626 100644 --- a/src/Test.FunctionalTests.Sarif/SarifLogEqualityComparerTests.cs +++ b/src/Test.FunctionalTests.Sarif/SarifLogEqualityComparerTests.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.IO; using FluentAssertions; diff --git a/src/Test.UnitTests.Sarif.Converters/BuiltinConverterFactoryTests.cs b/src/Test.UnitTests.Sarif.Converters/BuiltinConverterFactoryTests.cs index dd008daba..ef2833a65 100644 --- a/src/Test.UnitTests.Sarif.Converters/BuiltinConverterFactoryTests.cs +++ b/src/Test.UnitTests.Sarif.Converters/BuiltinConverterFactoryTests.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; -using System.Collections.Generic; using System.Linq; using Microsoft.CodeAnalysis.Sarif.Converters; @@ -16,7 +15,7 @@ public class BuiltInConverterFactoryTests [Fact] public void BuiltInConverterFactory_HasConverterForEveryBuiltInToolFormat() { - List toolFormats = Utilities.GetToolFormats() + var toolFormats = Utilities.GetToolFormats() .ToList(); string factoryName = nameof(BuiltInConverterFactory); diff --git a/src/Test.UnitTests.Sarif.Converters/ClangAnalyzerConverterTests.cs b/src/Test.UnitTests.Sarif.Converters/ClangAnalyzerConverterTests.cs index f21285684..3a46ea566 100644 --- a/src/Test.UnitTests.Sarif.Converters/ClangAnalyzerConverterTests.cs +++ b/src/Test.UnitTests.Sarif.Converters/ClangAnalyzerConverterTests.cs @@ -15,21 +15,21 @@ public class ClangAnalyzerConverterTests : ConverterTestsBase(() => converter.Convert(null, null, OptionallyEmittedData.None)); } [Fact] public void ClangAnalyzerConverter_Convert_NullOutput() { - ClangAnalyzerConverter converter = new ClangAnalyzerConverter(); + var converter = new ClangAnalyzerConverter(); Assert.Throws(() => converter.Convert(new MemoryStream(), null, OptionallyEmittedData.None)); } [Fact] public void ClangAnalyzerConverter_Convert_NullLogTest() { - ClangAnalyzerConverter converter = new ClangAnalyzerConverter(); + var converter = new ClangAnalyzerConverter(); Assert.Throws(() => converter.Convert(null, new ResultLogObjectWriter(), OptionallyEmittedData.None)); } @@ -59,7 +59,7 @@ public void ClangAnalyzerConverter_BadIntValue() { string clangAnalyzerLog = "\r\n\r\n\r\n\r\nclang_version\r\nUbuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)\r\nfiles\r\n\r\njcparam.c\r\n\r\ndiagnostics\r\n\r\n\r\npath\r\n\r\n\r\nkind\r\nevent\r\nlocation\r\n\r\nline\r\nBogus\r\ncol\r\n5\r\nfile\r\n0\r\n\r\nranges\r\n\r\n\r\n\r\nline\r\n595\r\ncol\r\n15\r\nfile\r\n0\r\n\r\n\r\nline\r\n595\r\ncol\r\n50\r\nfile\r\n0\r\n\r\n\r\n\r\ndepth\r\n0\r\nextended_message\r\nValue stored to 'scanptr' is never read\r\nmessage\r\nValue stored to 'scanptr' is never read\r\n\r\n\r\ndescription\r\nValue stored to 'scanptr' is never read\r\ncategory\r\nDead store\r\ntype\r\nDead assignment\r\nissue_context_kind\r\nfunction\r\nissue_context\r\njpeg_simple_progression\r\nissue_hash\r\n57\r\nlocation\r\n\r\nline\r\nBogus\r\ncol\r\n5\r\nfile\r\n0\r\n\r\nHTMLDiagnostics_files\r\n\r\nreport-ab0d45.html\r\n\r\n\r\n\r\n\r\n\r\n"; - ClangAnalyzerConverter converter = new ClangAnalyzerConverter(); + var converter = new ClangAnalyzerConverter(); Assert.Throws(() => Utilities.GetConverterJson(converter, clangAnalyzerLog)); } @@ -68,7 +68,7 @@ public void ClangAnalyzerConverter_MissingStringDictionaryKey() { string clangAnalyzerLog = "\r\n\r\n\r\n\r\nNo Key Throw\r\nfiles\r\n\r\njcparam.c\r\n\r\n\r\n\r\n"; - ClangAnalyzerConverter converter = new ClangAnalyzerConverter(); + var converter = new ClangAnalyzerConverter(); Assert.Throws(() => Utilities.GetConverterJson(converter, clangAnalyzerLog)); } @@ -77,7 +77,7 @@ public void ClangAnalyzerConverter_MissingArrayDictionaryKey() { string clangAnalyzerLog = "\r\n\r\n\r\n\r\n\r\nfiles\r\n\r\njcparam.c\r\n\r\n\r\n\r\n"; - ClangAnalyzerConverter converter = new ClangAnalyzerConverter(); + var converter = new ClangAnalyzerConverter(); Assert.Throws(() => Utilities.GetConverterJson(converter, clangAnalyzerLog)); } @@ -85,7 +85,7 @@ public void ClangAnalyzerConverter_MissingArrayDictionaryKey() public void ClangAnalyzerConverter_MissingNestedStringDictionaryKey() { string clangAnalyzerLog = "\r\n\r\n\r\n\r\nclang_version\r\nUbuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)\r\nfiles\r\n\r\njcparam.c\r\n\r\ndiagnostics\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"; - ClangAnalyzerConverter converter = new ClangAnalyzerConverter(); + var converter = new ClangAnalyzerConverter(); Assert.Throws(() => Utilities.GetConverterJson(converter, clangAnalyzerLog)); } @@ -93,7 +93,7 @@ public void ClangAnalyzerConverter_MissingNestedStringDictionaryKey() public void ClangAnalyzerConverter_MissingNestedArrayDictionaryKey() { string clangAnalyzerLog = "\r\n\r\n\r\n\r\nclang_version\r\nUbuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)\r\nfiles\r\n\r\njcparam.c\r\n\r\ndiagnostics\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"; - ClangAnalyzerConverter converter = new ClangAnalyzerConverter(); + var converter = new ClangAnalyzerConverter(); Assert.Throws(() => Utilities.GetConverterJson(converter, clangAnalyzerLog)); } @@ -101,7 +101,7 @@ public void ClangAnalyzerConverter_MissingNestedArrayDictionaryKey() public void ClangAnalyzerConverter_MissingNestedDictionaryKey() { string clangAnalyzerLog = "\r\n\r\n\r\n\r\nclang_version\r\nUbuntu clang version 3.4-1ubuntu3 (tags/RELEASE_34/final) (based on LLVM 3.4)\r\nfiles\r\n\r\njcparam.c\r\n\r\ndiagnostics\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"; - ClangAnalyzerConverter converter = new ClangAnalyzerConverter(); + var converter = new ClangAnalyzerConverter(); Assert.Throws(() => Utilities.GetConverterJson(converter, clangAnalyzerLog)); } } diff --git a/src/Test.UnitTests.Sarif.Converters/CppCheckConverterTests.cs b/src/Test.UnitTests.Sarif.Converters/CppCheckConverterTests.cs index 81b186ac1..4cdf25a7f 100644 --- a/src/Test.UnitTests.Sarif.Converters/CppCheckConverterTests.cs +++ b/src/Test.UnitTests.Sarif.Converters/CppCheckConverterTests.cs @@ -18,21 +18,21 @@ public class CppCheckConverterTests : ConverterTestsBase [Fact] public void CppCheckConverter_Convert_NullInput() { - CppCheckConverter converter = new CppCheckConverter(); + var converter = new CppCheckConverter(); Assert.Throws(() => converter.Convert(null, null, OptionallyEmittedData.None)); } [Fact] public void CppCheckConverter_Convert_NullOutput() { - CppCheckConverter converter = new CppCheckConverter(); + var converter = new CppCheckConverter(); Assert.Throws(() => converter.Convert(new MemoryStream(), null, OptionallyEmittedData.None)); } [Fact] public void CppCheckConverter_Convert_NullLogTest() { - CppCheckConverter converter = new CppCheckConverter(); + var converter = new CppCheckConverter(); Assert.Throws(() => converter.Convert(null, new ResultLogObjectWriter(), OptionallyEmittedData.None)); } diff --git a/src/Test.UnitTests.Sarif.Converters/FortifyFprConverterTests.cs b/src/Test.UnitTests.Sarif.Converters/FortifyFprConverterTests.cs index f69c7982d..ffb15145c 100644 --- a/src/Test.UnitTests.Sarif.Converters/FortifyFprConverterTests.cs +++ b/src/Test.UnitTests.Sarif.Converters/FortifyFprConverterTests.cs @@ -16,7 +16,7 @@ public class FortifyFprConverterTests [Fact] public void FortifyFprConverter_GetFailureLevelFromRuleMetadata_MissingImpactProperty_ReturnsWarning() { - ReportingDescriptor rule = new ReportingDescriptor(); + var rule = new ReportingDescriptor(); FailureLevel level = FortifyFprConverter.GetFailureLevelFromRuleMetadata(rule); @@ -51,7 +51,7 @@ public void FortifyFprConverter_GetFailureLevelFromRuleMetadata_ReturnsAppropria foreach (KeyValuePair keyValuePair in expectedInputOutputs) { - ReportingDescriptor rule = new ReportingDescriptor(); + var rule = new ReportingDescriptor(); rule.SetProperty("Impact", keyValuePair.Key); FailureLevel level = FortifyFprConverter.GetFailureLevelFromRuleMetadata(rule); diff --git a/src/Test.UnitTests.Sarif.Converters/FortifyIssueTests.cs b/src/Test.UnitTests.Sarif.Converters/FortifyIssueTests.cs index bf1432ffa..304f6ad06 100644 --- a/src/Test.UnitTests.Sarif.Converters/FortifyIssueTests.cs +++ b/src/Test.UnitTests.Sarif.Converters/FortifyIssueTests.cs @@ -247,7 +247,7 @@ public void FortifyIssue_Parse_CanParseMinimalIssue() [Fact] public void FortifyIssue_Parse_IgnoresNonCweTypeExternalCategories() { - XElement xml = XElement.Parse(s_fullIssueXml); + var xml = XElement.Parse(s_fullIssueXml); xml.Element("ExternalCategory").Attribute("type").Value = "a_differnt_type"; FortifyIssue result = Parse(xml); result.CweIds.Should().BeEmpty(); @@ -256,7 +256,7 @@ public void FortifyIssue_Parse_IgnoresNonCweTypeExternalCategories() [Fact] public void FortifyIssue_Parse_RequiresElementsInOrder() { - XElement xml = XElement.Parse(s_fullIssueXml); + var xml = XElement.Parse(s_fullIssueXml); // Move the primary node to the end XElement primary = xml.Element("Primary"); primary.Remove(); @@ -267,7 +267,7 @@ public void FortifyIssue_Parse_RequiresElementsInOrder() [Fact] public void FortifyIssue_Parse_RequiresCategory() { - XElement xml = XElement.Parse(s_minimalIssueXml); + var xml = XElement.Parse(s_minimalIssueXml); xml.Element("Category").Remove(); Assert.Throws(() => Parse(xml)); } @@ -275,7 +275,7 @@ public void FortifyIssue_Parse_RequiresCategory() [Fact] public void FortifyIssue_Parse_RequiresFolder() { - XElement xml = XElement.Parse(s_minimalIssueXml); + var xml = XElement.Parse(s_minimalIssueXml); xml.Element("Folder").Remove(); Assert.Throws(() => Parse(xml)); } @@ -283,7 +283,7 @@ public void FortifyIssue_Parse_RequiresFolder() [Fact] public void FortifyIssue_Parse_RequiresKingdom() { - XElement xml = XElement.Parse(s_minimalIssueXml); + var xml = XElement.Parse(s_minimalIssueXml); xml.Element("Kingdom").Remove(); Assert.Throws(() => Parse(xml)); } @@ -291,7 +291,7 @@ public void FortifyIssue_Parse_RequiresKingdom() [Fact] public void FortifyIssue_Parse_RequiresPrimary() { - XElement xml = XElement.Parse(s_minimalIssueXml); + var xml = XElement.Parse(s_minimalIssueXml); xml.Element("Primary").Remove(); Assert.Throws(() => Parse(xml)); } diff --git a/src/Test.UnitTests.Sarif.Converters/PylintConverterTests.cs b/src/Test.UnitTests.Sarif.Converters/PylintConverterTests.cs index f870e15d3..e2d7cb925 100644 --- a/src/Test.UnitTests.Sarif.Converters/PylintConverterTests.cs +++ b/src/Test.UnitTests.Sarif.Converters/PylintConverterTests.cs @@ -96,7 +96,7 @@ public void PylintConverter_Convert_WhenInputIsNull_ThrowsArgumentNullException( public void PylintConverter_Convert_WhenInputIsValid_Passes() { byte[] data = Encoding.UTF8.GetBytes(InputJson); - MemoryStream stream = new MemoryStream(data); + var stream = new MemoryStream(data); var mockWriter = new Mock(); mockWriter.Setup(writer => writer.Initialize(It.IsAny())); diff --git a/src/Test.UnitTests.Sarif.Converters/TSLintConverterTests.cs b/src/Test.UnitTests.Sarif.Converters/TSLintConverterTests.cs index 1eceb27ac..2b2107d91 100644 --- a/src/Test.UnitTests.Sarif.Converters/TSLintConverterTests.cs +++ b/src/Test.UnitTests.Sarif.Converters/TSLintConverterTests.cs @@ -82,7 +82,7 @@ private TSLintLogEntry CreateTestLogEntry() private Result CreateTestResult() { - Result testResult = new Result() + var testResult = new Result() { RuleId = "ruleName.test.value", Message = new Message { Text = "failure.test.value" }, @@ -90,7 +90,7 @@ private Result CreateTestResult() Kind = ResultKind.Fail }; - Region region = new Region() + var region = new Region() { StartLine = 3, StartColumn = 2, @@ -100,7 +100,7 @@ private Result CreateTestResult() CharOffset = 3, CharLength = 10 }; - PhysicalLocation physLoc = new PhysicalLocation() + var physLoc = new PhysicalLocation() { ArtifactLocation = new ArtifactLocation { @@ -108,7 +108,7 @@ private Result CreateTestResult() }, Region = region }; - Location location = new Location() + var location = new Location() { PhysicalLocation = physLoc }; @@ -118,7 +118,7 @@ private Result CreateTestResult() location }; - Replacement replacement = new Replacement() + var replacement = new Replacement() { DeletedRegion = new Region { @@ -173,7 +173,7 @@ public void TSLintConverter_Convert_WhenInputIsNull_ThrowsArgumentNullException( public void TSLintConverter_Convert_WhenInputIsValid_Passes() { byte[] data = Encoding.UTF8.GetBytes(InputJson); - MemoryStream stream = new MemoryStream(data); + var stream = new MemoryStream(data); var mockWriter = new Mock(); mockWriter.Setup(writer => writer.Initialize(It.IsAny())); diff --git a/src/Test.UnitTests.Sarif.Converters/TSLintLogReaderTests.cs b/src/Test.UnitTests.Sarif.Converters/TSLintLogReaderTests.cs index 56b2f593c..9483d9ca1 100644 --- a/src/Test.UnitTests.Sarif.Converters/TSLintLogReaderTests.cs +++ b/src/Test.UnitTests.Sarif.Converters/TSLintLogReaderTests.cs @@ -20,7 +20,7 @@ public class TSLintLogReaderTests [Fact] public void TSLintLogReader_ReadLog_WhenInputIsNull_ThrowsArgumentNullException() { - TSLintLogReader logReader = new TSLintLogReader(); + var logReader = new TSLintLogReader(); Action action = () => logReader.ReadLog(default(Stream)); action.Should().Throw(); @@ -57,7 +57,7 @@ public void TSLintLogReader_ReadLog_ProducesExpectedLog() } ]"; - TSLintLog expectedLog = new TSLintLog + var expectedLog = new TSLintLog { new TSLintLogEntry { @@ -89,7 +89,7 @@ public void TSLintLogReader_ReadLog_ProducesExpectedLog() } }; - TSLintLogReader logReader = new TSLintLogReader(); + var logReader = new TSLintLogReader(); TSLintLog actualLog = logReader.ReadLog(Input); @@ -155,10 +155,10 @@ public void TSLintLogReader_NormalizeLog_WrapsSingleFixInArray() } ]"; - JToken expectedToken = JToken.Parse(ExpectedOutput); + var expectedToken = JToken.Parse(ExpectedOutput); - JToken inputToken = JToken.Parse(Input); - TSLintLogReader logReader = new TSLintLogReader(); + var inputToken = JToken.Parse(Input); + var logReader = new TSLintLogReader(); JToken actualToken = logReader.NormalizeLog(inputToken); JToken.DeepEquals(expectedToken, actualToken).Should().BeTrue(); @@ -222,10 +222,10 @@ public void TSLintLogReader_NormalizeLog_HandlesInnerReplacements() }, ]"; - JToken expectedToken = JToken.Parse(ExpectedOutput); + var expectedToken = JToken.Parse(ExpectedOutput); - JToken inputToken = JToken.Parse(Input); - TSLintLogReader logReader = new TSLintLogReader(); + var inputToken = JToken.Parse(Input); + var logReader = new TSLintLogReader(); JToken actualToken = logReader.NormalizeLog(inputToken); JToken.DeepEquals(expectedToken, actualToken).Should().BeTrue(); diff --git a/src/Test.UnitTests.Sarif.Converters/TextFormats/CsvReaderTests.cs b/src/Test.UnitTests.Sarif.Converters/TextFormats/CsvReaderTests.cs index eca5f3f0c..17337cee7 100644 --- a/src/Test.UnitTests.Sarif.Converters/TextFormats/CsvReaderTests.cs +++ b/src/Test.UnitTests.Sarif.Converters/TextFormats/CsvReaderTests.cs @@ -19,7 +19,7 @@ public void CsvReader_Basics() int bufferSize = 64; // Empty file - verify no rows - using (CsvReader reader = new CsvReader(StreamFromString(""), bufferSize)) + using (var reader = new CsvReader(StreamFromString(""), bufferSize)) { Assert.False(reader.NextRow()); @@ -28,7 +28,7 @@ public void CsvReader_Basics() } // Single row file, no trailing newline - using (CsvReader reader = new CsvReader(StreamFromString("One,Two,Three"), bufferSize)) + using (var reader = new CsvReader(StreamFromString("One,Two,Three"), bufferSize)) { Assert.Equal(0, reader.RowCountRead); Assert.True(reader.NextRow()); @@ -39,7 +39,7 @@ public void CsvReader_Basics() } // Empty values - using (CsvReader reader = new CsvReader(StreamFromString(",Value,,"), bufferSize)) + using (var reader = new CsvReader(StreamFromString(",Value,,"), bufferSize)) { Assert.True(reader.NextRow()); Assert.Equal("|Value||", string.Join("|", reader.Current())); @@ -47,7 +47,7 @@ public void CsvReader_Basics() } // Newline variation and trailing newline - using (CsvReader reader = new CsvReader(StreamFromString("One\nTwo\r\nThree\r\n"), bufferSize)) + using (var reader = new CsvReader(StreamFromString("One\nTwo\r\nThree\r\n"), bufferSize)) { Assert.True(reader.NextRow()); Assert.Equal("One", string.Join("|", reader.Current())); @@ -60,7 +60,7 @@ public void CsvReader_Basics() // Row requiring a buffer resize and verify nothing is missed string oneHundredColumns = string.Join(",", Enumerable.Range(100, 100).Select(i => i.ToString())); - using (CsvReader reader = new CsvReader(StreamFromString(oneHundredColumns), bufferSize)) + using (var reader = new CsvReader(StreamFromString(oneHundredColumns), bufferSize)) { Assert.True(reader.NextRow()); Assert.Equal(100, reader.Current().Count); @@ -69,7 +69,7 @@ public void CsvReader_Basics() // Value exactly 2x buffer, requiring two buffer resizes to be read string valueRequiringBufferExpand = new string('0', 128); - using (CsvReader reader = new CsvReader(StreamFromString($"One,Two,Three\r\nSecond,Row\r\n{valueRequiringBufferExpand}"), bufferSize)) + using (var reader = new CsvReader(StreamFromString($"One,Two,Three\r\nSecond,Row\r\n{valueRequiringBufferExpand}"), bufferSize)) { Assert.True(reader.NextRow()); Assert.Equal("One|Two|Three", string.Join("|", reader.Current())); @@ -81,7 +81,7 @@ public void CsvReader_Basics() } // '\r' exactly at buffer boundary, requiring refill to track the unread '\n' to ignore - using (CsvReader reader = new CsvReader(StreamFromString($"{new string('0', 63)}\r\nNextRow\r\n"), bufferSize)) + using (var reader = new CsvReader(StreamFromString($"{new string('0', 63)}\r\nNextRow\r\n"), bufferSize)) { Assert.True(reader.NextRow()); Assert.Equal(new string('0', 63), string.Join("|", reader.Current())); @@ -91,7 +91,7 @@ public void CsvReader_Basics() } // Quoted value variations - quoted empty, quotes at start/end, quote in middle, unquoted after quoted, adjacent escaped quotes - using (CsvReader reader = new CsvReader(StreamFromString("\"\",\"\"\"Around\"\"\",\"With\"\"in\",None,\"Many\"\"\"\"\"\nNextRow"), bufferSize)) + using (var reader = new CsvReader(StreamFromString("\"\",\"\"\"Around\"\"\",\"With\"\"in\",None,\"Many\"\"\"\"\"\nNextRow"), bufferSize)) { Assert.True(reader.NextRow()); Assert.Equal("|\"Around\"|With\"in|None|Many\"\"", string.Join("|", reader.Current())); @@ -101,7 +101,7 @@ public void CsvReader_Basics() } // Exception for unescaped quote not at cell end - using (CsvReader reader = new CsvReader(StreamFromString("\"Unescaped\"Quote,"), bufferSize)) + using (var reader = new CsvReader(StreamFromString("\"Unescaped\"Quote,"), bufferSize)) { Assert.Throws(() => reader.NextRow()); } @@ -135,7 +135,7 @@ public void CsvReader_File() private int ParseFile(string filePath) { - using (CsvReader reader = new CsvReader(filePath)) + using (var reader = new CsvReader(filePath)) { while (reader.NextRow()) { } diff --git a/src/Test.UnitTests.Sarif.Converters/TextFormats/TsvReaderTests.cs b/src/Test.UnitTests.Sarif.Converters/TextFormats/TsvReaderTests.cs index 2011b047b..055966b39 100644 --- a/src/Test.UnitTests.Sarif.Converters/TextFormats/TsvReaderTests.cs +++ b/src/Test.UnitTests.Sarif.Converters/TextFormats/TsvReaderTests.cs @@ -19,7 +19,7 @@ public void TsvReader_Basics() int bufferSize = 64; // Empty file - verify no rows - using (TsvReader reader = new TsvReader(StreamFromString(""), bufferSize)) + using (var reader = new TsvReader(StreamFromString(""), bufferSize)) { Assert.False(reader.NextRow()); @@ -28,7 +28,7 @@ public void TsvReader_Basics() } // Single row file, no trailing newline - using (TsvReader reader = new TsvReader(StreamFromString("One\tTwo\tThree"), bufferSize)) + using (var reader = new TsvReader(StreamFromString("One\tTwo\tThree"), bufferSize)) { Assert.Equal(0, reader.RowCountRead); Assert.True(reader.NextRow()); @@ -39,7 +39,7 @@ public void TsvReader_Basics() } // Empty values - using (TsvReader reader = new TsvReader(StreamFromString("\tValue\t\t"), bufferSize)) + using (var reader = new TsvReader(StreamFromString("\tValue\t\t"), bufferSize)) { Assert.True(reader.NextRow()); Assert.Equal("|Value||", string.Join("|", reader.Current())); @@ -47,7 +47,7 @@ public void TsvReader_Basics() } // Newline variation and trailing newline - using (TsvReader reader = new TsvReader(StreamFromString("One\nTwo\r\nThree\r\n"), bufferSize)) + using (var reader = new TsvReader(StreamFromString("One\nTwo\r\nThree\r\n"), bufferSize)) { Assert.True(reader.NextRow()); Assert.Equal("One", string.Join("|", reader.Current())); @@ -60,7 +60,7 @@ public void TsvReader_Basics() // Row requiring a buffer resize and verify nothing is missed string oneHundredColumns = string.Join("\t", Enumerable.Range(100, 100).Select(i => i.ToString())); - using (TsvReader reader = new TsvReader(StreamFromString(oneHundredColumns), bufferSize)) + using (var reader = new TsvReader(StreamFromString(oneHundredColumns), bufferSize)) { Assert.True(reader.NextRow()); Assert.Equal(100, reader.Current().Count); @@ -69,7 +69,7 @@ public void TsvReader_Basics() // Value exactly 2x buffer, requiring two buffer resizes to be read string valueRequiringBufferExpand = new string('0', 128); - using (TsvReader reader = new TsvReader(StreamFromString($"One\tTwo\tThree\r\nSecond\tRow\r\n{valueRequiringBufferExpand}"), bufferSize)) + using (var reader = new TsvReader(StreamFromString($"One\tTwo\tThree\r\nSecond\tRow\r\n{valueRequiringBufferExpand}"), bufferSize)) { Assert.True(reader.NextRow()); Assert.Equal("One|Two|Three", string.Join("|", reader.Current())); @@ -81,7 +81,7 @@ public void TsvReader_Basics() } // '\r' exactly at buffer boundary, requiring refill to track the unread '\n' to ignore - using (TsvReader reader = new TsvReader(StreamFromString($"{new string('0', 63)}\r\nNextRow\r\n"), bufferSize)) + using (var reader = new TsvReader(StreamFromString($"{new string('0', 63)}\r\nNextRow\r\n"), bufferSize)) { Assert.True(reader.NextRow()); Assert.Equal(new string('0', 63), string.Join("|", reader.Current())); @@ -119,7 +119,7 @@ public void TsvReader_File() private int ParseFile(string filePath) { - using (TsvReader reader = new TsvReader(filePath)) + using (var reader = new TsvReader(filePath)) { while (reader.NextRow()) { } diff --git a/src/Test.UnitTests.Sarif.Converters/ToolFileConverterBaseTests.cs b/src/Test.UnitTests.Sarif.Converters/ToolFileConverterBaseTests.cs index 5ae43c054..b38212682 100644 --- a/src/Test.UnitTests.Sarif.Converters/ToolFileConverterBaseTests.cs +++ b/src/Test.UnitTests.Sarif.Converters/ToolFileConverterBaseTests.cs @@ -95,7 +95,7 @@ public void ConverterBase_MultipleDistinctIdenticallyNamedLogicalLocations() Kind = LogicalLocationKind.Package }; - Location location3 = new Location + var location3 = new Location { LogicalLocation = new LogicalLocation { diff --git a/src/Test.UnitTests.Sarif.Driver/Sdk/CommonOptionsBaseTests.cs b/src/Test.UnitTests.Sarif.Driver/Sdk/CommonOptionsBaseTests.cs index 20b811e52..b9248943b 100644 --- a/src/Test.UnitTests.Sarif.Driver/Sdk/CommonOptionsBaseTests.cs +++ b/src/Test.UnitTests.Sarif.Driver/Sdk/CommonOptionsBaseTests.cs @@ -18,7 +18,7 @@ public void CommonOptionsBase_ProducesExpectedOutputFileOptions() FilePersistenceOptions loggingOptions; // Any case in which PrettyPrint is not specified should default to PrettyPrint. - TestAnalyzeOptions analyzeOptions = new TestAnalyzeOptions() + var analyzeOptions = new TestAnalyzeOptions() { Quiet = true, }; diff --git a/src/Test.UnitTests.Sarif.Driver/Sdk/ExportConfigurationCommandBaseTests.cs b/src/Test.UnitTests.Sarif.Driver/Sdk/ExportConfigurationCommandBaseTests.cs index 2885a4cce..d1a04cf01 100644 --- a/src/Test.UnitTests.Sarif.Driver/Sdk/ExportConfigurationCommandBaseTests.cs +++ b/src/Test.UnitTests.Sarif.Driver/Sdk/ExportConfigurationCommandBaseTests.cs @@ -30,7 +30,7 @@ private static PropertiesDictionary CreateAllRulesDisabledConfiguration() public static PropertiesDictionary CreateDefaultConfiguration() { - PropertiesDictionary configuration = new PropertiesDictionary(); + var configuration = new PropertiesDictionary(); string path = Path.GetTempFileName() + ".xml"; try diff --git a/src/Test.UnitTests.Sarif.Multitool.Library/BaselineOptionTests.cs b/src/Test.UnitTests.Sarif.Multitool.Library/BaselineOptionTests.cs index 1dd8e57fd..f022c03bc 100644 --- a/src/Test.UnitTests.Sarif.Multitool.Library/BaselineOptionTests.cs +++ b/src/Test.UnitTests.Sarif.Multitool.Library/BaselineOptionTests.cs @@ -95,7 +95,7 @@ public void ValidateCommandWithBaseline_ResultShouldHaveBaselineStatus() int returnCode = new ValidateCommand().Run(options); returnCode.Should().Be(0); - SarifLog sarifLog = SarifLog.Load(outputPath); + var sarifLog = SarifLog.Load(outputPath); sarifLog.Runs.Count.Should().Be(1); sarifLog.Runs[0].Results.Count.Should().Be(1); @@ -129,7 +129,7 @@ public void ValidateCommandWithBaseline_InlineUpdate() int returnCode = new ValidateCommand().Run(options); returnCode.Should().Be(0); - SarifLog sarifLog = SarifLog.Load(baselineFilePath); + var sarifLog = SarifLog.Load(baselineFilePath); sarifLog.Runs.Count.Should().Be(1); sarifLog.Runs[0].Results.Count.Should().Be(1); diff --git a/src/Test.UnitTests.Sarif.Multitool.Library/ConvertCommandTests.cs b/src/Test.UnitTests.Sarif.Multitool.Library/ConvertCommandTests.cs index 309bb3814..eca7b3a17 100644 --- a/src/Test.UnitTests.Sarif.Multitool.Library/ConvertCommandTests.cs +++ b/src/Test.UnitTests.Sarif.Multitool.Library/ConvertCommandTests.cs @@ -6,7 +6,6 @@ using FluentAssertions; using Microsoft.CodeAnalysis.Sarif.Converters; -using Microsoft.CodeAnalysis.Sarif.Writers; using Moq; @@ -42,7 +41,7 @@ public void ConvertCommand_SemmleQlExample() File.Exists(outputFilePath).Should().BeTrue(); // Verify log loads, has correct Result count, and spot check a Result - SarifLog log = SarifLog.Load(outputFilePath); + var log = SarifLog.Load(outputFilePath); log.Runs[0].Results.Count.Should().Be(8); log.Runs[0].Results[7].Locations[0].PhysicalLocation.Region.StartLine.Should().Be(40); log.Runs[0].Results[7].Locations[0].PhysicalLocation.Region.StartColumn.Should().Be(43); diff --git a/src/Test.UnitTests.Sarif.Multitool.Library/ExtensionsTests.cs b/src/Test.UnitTests.Sarif.Multitool.Library/ExtensionsTests.cs index 123a842fa..a0f5fba4f 100644 --- a/src/Test.UnitTests.Sarif.Multitool.Library/ExtensionsTests.cs +++ b/src/Test.UnitTests.Sarif.Multitool.Library/ExtensionsTests.cs @@ -16,7 +16,7 @@ public class ExtensionsTests [Fact] public void Extensions_Validate_RefersToDriver() { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); foreach (ToolComponentReferenceTestCase item in s_toolComponentReferenceTestCases) { diff --git a/src/Test.UnitTests.Sarif.Multitool.Library/GenericCommandTests.cs b/src/Test.UnitTests.Sarif.Multitool.Library/GenericCommandTests.cs index bc1c7f15a..dac85451b 100644 --- a/src/Test.UnitTests.Sarif.Multitool.Library/GenericCommandTests.cs +++ b/src/Test.UnitTests.Sarif.Multitool.Library/GenericCommandTests.cs @@ -29,7 +29,7 @@ public void CommandsDoNotHaveConflictingShortNames() private void CheckTypeForDuplicateArgumentNames(Type type) { - Dictionary parameters = new Dictionary(); + var parameters = new Dictionary(); foreach (PropertyInfo property in type.GetProperties()) { @@ -57,7 +57,7 @@ private void CheckTypeForDuplicateArgumentNames(Type type) private Argument ParseOptionAttribute(CustomAttributeData attribute) { - Argument result = new Argument(); + var result = new Argument(); foreach (CustomAttributeTypedArgument argument in attribute.ConstructorArguments) { diff --git a/src/Test.UnitTests.Sarif.Multitool.Library/OptionsInterpretterTests.cs b/src/Test.UnitTests.Sarif.Multitool.Library/OptionsInterpretterTests.cs index 20b19939f..3668cea2b 100644 --- a/src/Test.UnitTests.Sarif.Multitool.Library/OptionsInterpretterTests.cs +++ b/src/Test.UnitTests.Sarif.Multitool.Library/OptionsInterpretterTests.cs @@ -2,21 +2,12 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; -using System.IO; using System.Linq; -using System.Text; using FluentAssertions; -using Microsoft.CodeAnalysis.Sarif.Driver; -using Microsoft.CodeAnalysis.Sarif.Readers; -using Microsoft.CodeAnalysis.Sarif.VersionOne; - using Moq; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - using Xunit; namespace Microsoft.CodeAnalysis.Sarif.Multitool @@ -29,9 +20,9 @@ public void OptionsInterpretter_ChangesNothingWhenEnvVarsEmpty() var mockEnvironmentVariableGetter = new Mock(); // Don't setup any responses so they always return null - OptionsInterpretter optionsInterpretter = new OptionsInterpretter(mockEnvironmentVariableGetter.Object); + var optionsInterpretter = new OptionsInterpretter(mockEnvironmentVariableGetter.Object); - List beforeAndAfter = new List(2); + var beforeAndAfter = new List(2); for (int i = 0; i < beforeAndAfter.Capacity; i++) { @@ -63,9 +54,9 @@ public void OptionsInterpretter_CorrectlyAddsAdditiveEnvVars() // Deliberately more delimeters than needed mockEnvironmentVariableGetter.Setup(x => x.GetEnvironmentVariable("SARIF_LEVEL_ADDITION")).Returns("Note"); - OptionsInterpretter optionsInterpretter = new OptionsInterpretter(mockEnvironmentVariableGetter.Object); + var optionsInterpretter = new OptionsInterpretter(mockEnvironmentVariableGetter.Object); - ValidateOptions analyzeOptionsBase = new ValidateOptions + var analyzeOptionsBase = new ValidateOptions { DataToInsert = new List { OptionallyEmittedData.Hashes, OptionallyEmittedData.EnvironmentVariables }, DataToRemove = new List { OptionallyEmittedData.VersionControlDetails }, diff --git a/src/Test.UnitTests.Sarif.Multitool.Library/PageCommandTests.cs b/src/Test.UnitTests.Sarif.Multitool.Library/PageCommandTests.cs index 51a84942c..1b05f0fd2 100644 --- a/src/Test.UnitTests.Sarif.Multitool.Library/PageCommandTests.cs +++ b/src/Test.UnitTests.Sarif.Multitool.Library/PageCommandTests.cs @@ -202,7 +202,7 @@ private static void RunAndCompare(PageOptions options) } // Run the normal Page command - PageCommand command = new PageCommand(fileSystem); + var command = new PageCommand(fileSystem); command.RunWithoutCatch(options); // Rewrite indented @@ -235,7 +235,7 @@ private static void HugeFileCompare(string sourceFilePath, int index, int count) string actualUnindentedPath = Path.ChangeExtension(sourceFilePath, ".Paged.Actual.Unformatted.sarif"); // Page with the Command - PageCommand command = new PageCommand(); + var command = new PageCommand(); command.RunWithoutCatch(new PageOptions() { InputFilePath = sourceFilePath, OutputFilePath = actualUnindentedPath, Index = index, Count = count }); // Indent the Paged output @@ -255,8 +255,8 @@ private static void HugeFileCompare(string sourceFilePath, int index, int count) private static void Indent(string sourceFilePath, string outputPath) { - using (JsonTextReader reader = new JsonTextReader(new StreamReader(sourceFilePath))) - using (JsonTextWriter writer = new JsonTextWriter(File.CreateText(outputPath))) + using (var reader = new JsonTextReader(new StreamReader(sourceFilePath))) + using (var writer = new JsonTextWriter(File.CreateText(outputPath))) { writer.Formatting = Newtonsoft.Json.Formatting.Indented; reader.Read(); @@ -266,8 +266,8 @@ private static void Indent(string sourceFilePath, string outputPath) private static void PageManual(string sourceFilePath, string outputPath, int index, int count) { - using (JsonTextReader reader = new JsonTextReader(new StreamReader(sourceFilePath))) - using (JsonTextWriter writer = new JsonTextWriter(File.CreateText(outputPath))) + using (var reader = new JsonTextReader(new StreamReader(sourceFilePath))) + using (var writer = new JsonTextWriter(File.CreateText(outputPath))) { writer.Formatting = Newtonsoft.Json.Formatting.Indented; diff --git a/src/Test.UnitTests.Sarif.Multitool.Library/RebaseUriCommandTests.cs b/src/Test.UnitTests.Sarif.Multitool.Library/RebaseUriCommandTests.cs index 98decec4b..99d8dab2b 100644 --- a/src/Test.UnitTests.Sarif.Multitool.Library/RebaseUriCommandTests.cs +++ b/src/Test.UnitTests.Sarif.Multitool.Library/RebaseUriCommandTests.cs @@ -7,9 +7,6 @@ using FluentAssertions; -using Microsoft.CodeAnalysis.Test.Utilities.Sarif; -using Microsoft.Extensions.Options; - using Moq; using Newtonsoft.Json; @@ -55,7 +52,7 @@ public void RebaseUriCommand_InjectsRegions() string inputSarifLog = JsonConvert.SerializeObject(sarifLog); string logFilePath = Path.Combine(Directory.GetCurrentDirectory(), "mylog.sarif"); - StringBuilder transformedContents = new StringBuilder(); + var transformedContents = new StringBuilder(); RebaseUriOptions options = CreateDefaultOptions(); @@ -127,7 +124,7 @@ private string RunRebaseUriCommand(string testFilePath, RebaseUriOptions options string inputSarifLog = GetInputSarifTextFromResource(testFilePath); string logFilePath = Path.Combine(Directory.GetCurrentDirectory(), "mylog.sarif"); - StringBuilder transformedContents = new StringBuilder(); + var transformedContents = new StringBuilder(); options.TargetFileSpecifiers = new string[] { logFilePath }; diff --git a/src/Test.UnitTests.Sarif.Multitool.Library/RewriteCommandTests.cs b/src/Test.UnitTests.Sarif.Multitool.Library/RewriteCommandTests.cs index de341e381..09d989d16 100644 --- a/src/Test.UnitTests.Sarif.Multitool.Library/RewriteCommandTests.cs +++ b/src/Test.UnitTests.Sarif.Multitool.Library/RewriteCommandTests.cs @@ -59,7 +59,7 @@ private string RunRewriteCommand(string testFilePath) string inputSarifLog = GetInputSarifTextFromResource(testFilePath); string logFilePath = Path.Combine(Directory.GetCurrentDirectory(), "mylog.sarif"); - StringBuilder transformedContents = new StringBuilder(); + var transformedContents = new StringBuilder(); this.options.InputFilePath = logFilePath; this.options.OutputFilePath = null; @@ -229,7 +229,7 @@ private static void RunTransformationToV2Test(string logFileContents) private void PrereleaseSarifLogVersionDiffersFromCurrent(string prereleaseV2Text) { - JObject sarifLog = JObject.Parse(prereleaseV2Text); + var sarifLog = JObject.Parse(prereleaseV2Text); ((string)sarifLog["$schema"]).Should().NotBe(SarifUtilities.SarifSchemaUri); ((string)sarifLog["version"]).Should().NotBe(SarifUtilities.StableSarifVersion); diff --git a/src/Test.UnitTests.Sarif.Multitool/QueryCommandTests.cs b/src/Test.UnitTests.Sarif.Multitool/QueryCommandTests.cs index 7b6cef7e0..ba47cc97d 100644 --- a/src/Test.UnitTests.Sarif.Multitool/QueryCommandTests.cs +++ b/src/Test.UnitTests.Sarif.Multitool/QueryCommandTests.cs @@ -23,7 +23,7 @@ public class TestFixture { public TestFixture() { - TestAssetResourceExtractor extractor = new TestAssetResourceExtractor(typeof(QueryCommandTests)); + var extractor = new TestAssetResourceExtractor(typeof(QueryCommandTests)); File.WriteAllText(fileWithPropertyBag, extractor.GetResourceText(fileWithPropertyBag)); } } diff --git a/src/Test.UnitTests.Sarif.Multitool/RewriteCommandTests.cs b/src/Test.UnitTests.Sarif.Multitool/RewriteCommandTests.cs index 2a967a9b5..b941c437d 100644 --- a/src/Test.UnitTests.Sarif.Multitool/RewriteCommandTests.cs +++ b/src/Test.UnitTests.Sarif.Multitool/RewriteCommandTests.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Generic; -using System.Linq; using CommandLine; diff --git a/src/Test.UnitTests.Sarif.WorkItems/SarifWorkItemExtensionsTests.cs b/src/Test.UnitTests.Sarif.WorkItems/SarifWorkItemExtensionsTests.cs index 5b31e4e95..161e8d9b2 100644 --- a/src/Test.UnitTests.Sarif.WorkItems/SarifWorkItemExtensionsTests.cs +++ b/src/Test.UnitTests.Sarif.WorkItems/SarifWorkItemExtensionsTests.cs @@ -69,10 +69,10 @@ public void SarifWorkItemExtensions_CreateWorkItemTitle_LongTitleFromUrl() string expectedTemplate = "[aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:Warning]: TestRuleId: Test Rule (in al...)"; string expected = $":Warning]: TestRuleId: Test Rule (in al" + new string('a', maxLength - expectedTemplate.Length) + "...)"; - Result result = new Result(); - ArtifactLocation artifactLocation = new ArtifactLocation(new Uri("al" + new string('a', 1024), UriKind.Relative), string.Empty, 0, new Message(), new Dictionary()); - PhysicalLocation physicalLocation = new PhysicalLocation(new Address(), artifactLocation, new Region(), new Region(), new Dictionary()); - Location location = new Location(0, physicalLocation, null, null, null, null, null); + var result = new Result(); + var artifactLocation = new ArtifactLocation(new Uri("al" + new string('a', 1024), UriKind.Relative), string.Empty, 0, new Message(), new Dictionary()); + var physicalLocation = new PhysicalLocation(new Address(), artifactLocation, new Region(), new Region(), new Dictionary()); + var location = new Location(0, physicalLocation, null, null, null, null, null); result.Locations = new List(); result.Locations.Add(location); result.RuleId = ruleId; @@ -89,9 +89,9 @@ public void SarifWorkItemExtensions_CreateWorkItemTitle_LongTitleFromUrl() [Fact] public void SarifWorkItemExtensions_CreateWorkItemTitle_LongTitleFromLogicalLocation() { - Result result = new Result(); - LogicalLocation logicaLocation = new LogicalLocation(null, 0, string.Empty, null, 0, null, null); - Location location = new Location(0, null, new[] { logicaLocation }, null, null, null, null); + var result = new Result(); + var logicaLocation = new LogicalLocation(null, 0, string.Empty, null, 0, null, null); + var location = new Location(0, null, new[] { logicaLocation }, null, null, null, null); result.Locations = new List(); result.Locations.Add(location); result.RuleId = "TestRuleId"; @@ -173,7 +173,7 @@ public PhraseToolNamesTestCase(List input, string expectedOutput) [Fact] public void SarifWorkItemExtensions_PhraseToolNames_ConstructPhraseCorrectly() { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); foreach (PhraseToolNamesTestCase testCase in s_phraseToolNamesTestCases) { diff --git a/src/Test.UnitTests.Sarif.WorkItems/SarifWorkItemFilerTests.cs b/src/Test.UnitTests.Sarif.WorkItems/SarifWorkItemFilerTests.cs index dd14a049c..3b40db430 100644 --- a/src/Test.UnitTests.Sarif.WorkItems/SarifWorkItemFilerTests.cs +++ b/src/Test.UnitTests.Sarif.WorkItems/SarifWorkItemFilerTests.cs @@ -10,7 +10,6 @@ using FluentAssertions; -using Microsoft.CodeAnalysis.Sarif.VersionOne; using Microsoft.CodeAnalysis.Test.Utilities.Sarif; using Microsoft.CodeAnalysis.WorkItems; using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models; @@ -325,10 +324,10 @@ public void WorkItemFiler_SarifLogResultsAreEmpty() [Fact] public void WorkItemFiler_FileWorkItems_RelativeSarifLogPath() { - Uri uri = new Uri("path/to/sarif/log.sarif", UriKind.Relative); + var uri = new Uri("path/to/sarif/log.sarif", UriKind.Relative); SarifWorkItemContext context = CreateAzureDevOpsTestContext(); - SarifWorkItemFiler filer = new SarifWorkItemFiler(context.HostUri, context); + var filer = new SarifWorkItemFiler(context.HostUri, context); Assert.Throws(() => filer.FileWorkItems(uri)); } @@ -352,8 +351,8 @@ private void TestWorkItemFiler(SarifLog sarifLog, SarifWorkItemContext context, string bugUriText = "https://example.com/" + Guid.NewGuid().ToString(); string bugHtmlUriText = "https://example.com/" + Guid.NewGuid().ToString(); - Uri bugUri = new Uri(bugUriText, UriKind.RelativeOrAbsolute); - Uri bugHtmlUri = new Uri(bugHtmlUriText, UriKind.RelativeOrAbsolute); + var bugUri = new Uri(bugUriText, UriKind.RelativeOrAbsolute); + var bugHtmlUri = new Uri(bugHtmlUriText, UriKind.RelativeOrAbsolute); workItem.Url = bugUriText; workItem.Links.AddLink("html", bugHtmlUriText); @@ -513,7 +512,7 @@ private static FilingClient CreateAdoMocksAndFilingClient(AttachmentReference at private static FilingClient CreateGitHubMocksAndFilingClient(string bugUriText, string bugHtmlUriText, SarifWorkItemFiler filer) { FilingClient filingClient; - Issue testGithubIssue = new Issue(bugUriText, bugHtmlUriText, bugUriText + "comments", bugUriText + "events", + var testGithubIssue = new Issue(bugUriText, bugHtmlUriText, bugUriText + "comments", bugUriText + "events", 111111, ItemState.Open, "TestTitle", "TestBody", new User(), new User(), null, new User(), null, new Milestone(1), 0, new PullRequest(), null, new DateTimeOffset(DateTime.Now), null, 111111, null, false, null, null); diff --git a/src/Test.UnitTests.Sarif.WorkItems/SarifWorkItemModelTests.cs b/src/Test.UnitTests.Sarif.WorkItems/SarifWorkItemModelTests.cs index 621a61d92..78d566211 100644 --- a/src/Test.UnitTests.Sarif.WorkItems/SarifWorkItemModelTests.cs +++ b/src/Test.UnitTests.Sarif.WorkItems/SarifWorkItemModelTests.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; -using System.Collections.Generic; using FluentAssertions; diff --git a/src/Test.UnitTests.Sarif/Baseline/ResultMatching/ExactMatchers/FullFingerprintMatcherTests.cs b/src/Test.UnitTests.Sarif/Baseline/ResultMatching/ExactMatchers/FullFingerprintMatcherTests.cs index 698ddba29..bd0045134 100644 --- a/src/Test.UnitTests.Sarif/Baseline/ResultMatching/ExactMatchers/FullFingerprintMatcherTests.cs +++ b/src/Test.UnitTests.Sarif/Baseline/ResultMatching/ExactMatchers/FullFingerprintMatcherTests.cs @@ -23,8 +23,8 @@ public void FullFingerprintMatcher_MatchesIdenticalFingerprints() resultA.Fingerprints = new Dictionary() { { "FingerprintAlgorithm1", "FingerprintValue1" }, { "FingerprintAlgorithm2", "FingerprintValue2" } }; resultB.Fingerprints = new Dictionary() { { "FingerprintAlgorithm1", "FingerprintValue1" } }; - ExtractedResult matchingResultA = new ExtractedResult(resultA, null); - ExtractedResult matchingResultB = new ExtractedResult(resultB, null); + var matchingResultA = new ExtractedResult(resultA, null); + var matchingResultB = new ExtractedResult(resultB, null); IEnumerable matchedResults = matcher.Match(new ExtractedResult[] { matchingResultA }, new ExtractedResult[] { matchingResultB }); @@ -42,8 +42,8 @@ public void FullFingerprintMatcher_DoesNotMatchOnChangedFingerprints() resultA.Fingerprints = new Dictionary() { { "FingerprintAlgorithm1", "FingerprintValue1" }, { "FingerprintAlgorithm2", "FingerprintValue2" } }; resultB.Fingerprints = new Dictionary() { { "FingerprintAlgorithm1", "FingerprintValue3" }, { "FingerprintAlgorithm2", "FingerprintValue4" } }; - ExtractedResult matchingResultA = new ExtractedResult(resultA, null); - ExtractedResult matchingResultB = new ExtractedResult(resultB, null); + var matchingResultA = new ExtractedResult(resultA, null); + var matchingResultB = new ExtractedResult(resultB, null); IEnumerable matchedResults = matcher.Match(new ExtractedResult[] { matchingResultA }, new ExtractedResult[] { matchingResultB }); diff --git a/src/Test.UnitTests.Sarif/Baseline/ResultMatching/ExactMatchers/IdenticalResultMatcherTests.cs b/src/Test.UnitTests.Sarif/Baseline/ResultMatching/ExactMatchers/IdenticalResultMatcherTests.cs index 061f91fb8..2a1171a52 100644 --- a/src/Test.UnitTests.Sarif/Baseline/ResultMatching/ExactMatchers/IdenticalResultMatcherTests.cs +++ b/src/Test.UnitTests.Sarif/Baseline/ResultMatching/ExactMatchers/IdenticalResultMatcherTests.cs @@ -18,8 +18,8 @@ public class IdenticalResultMatcherTests [Fact] public void IdenticalResultMatcher_MatchesIdenticalResults_Single() { - ExtractedResult resultA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context"), null); - ExtractedResult resultB = new ExtractedResult(resultA.Result.DeepClone(), null); + var resultA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context"), null); + var resultB = new ExtractedResult(resultA.Result.DeepClone(), null); IEnumerable matchedResults = matcher.Match(new ExtractedResult[] { resultA }, new ExtractedResult[] { resultB }); @@ -31,10 +31,10 @@ public void IdenticalResultMatcher_MatchesIdenticalResults_Single() [Fact] public void IdenticalResultMatcher_MatchesIdenticalResults_Multiple() { - ExtractedResult resultAA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context"), null); - ExtractedResult resultBA = new ExtractedResult(resultAA.Result.DeepClone(), null); - ExtractedResult resultAB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context2"), null); - ExtractedResult resultBB = new ExtractedResult(resultAB.Result.DeepClone(), null); + var resultAA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context"), null); + var resultBA = new ExtractedResult(resultAA.Result.DeepClone(), null); + var resultAB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context2"), null); + var resultBB = new ExtractedResult(resultAB.Result.DeepClone(), null); IEnumerable matchedResults = matcher.Match(new ExtractedResult[] { resultAA, resultAB }, new ExtractedResult[] { resultBA, resultBB }); @@ -46,8 +46,8 @@ public void IdenticalResultMatcher_MatchesIdenticalResults_Multiple() [Fact] public void IdenticalResultMatcher_DoesNotMatchDifferentResults_Single() { - ExtractedResult resultA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context"), null); - ExtractedResult resultB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context2"), null); + var resultA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context"), null); + var resultB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context2"), null); IEnumerable matchedResults = matcher.Match(new ExtractedResult[] { resultA }, new ExtractedResult[] { resultB }); @@ -57,10 +57,10 @@ public void IdenticalResultMatcher_DoesNotMatchDifferentResults_Single() [Fact] public void IdenticalResultMatcher_DoesNotMatchDifferentResults_Multiple() { - ExtractedResult resultAA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context1"), null); - ExtractedResult resultBA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context2"), null); - ExtractedResult resultAB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context3"), null); - ExtractedResult resultBB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context4"), null); + var resultAA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context1"), null); + var resultBA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context2"), null); + var resultAB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context3"), null); + var resultBB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context4"), null); IEnumerable matchedResults = matcher.Match(new ExtractedResult[] { resultAA, resultAB }, new ExtractedResult[] { resultBA, resultBB }); @@ -70,13 +70,13 @@ public void IdenticalResultMatcher_DoesNotMatchDifferentResults_Multiple() [Fact] public void IdenticalResultMatcher_MatchesResults_DifferingOnIdOrStatus_Single() { - ExtractedResult resultA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context"), null); + var resultA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context"), null); Result changedResultA = resultA.Result.DeepClone(); changedResultA.CorrelationGuid = Guid.NewGuid(); changedResultA.BaselineState = BaselineState.Unchanged; - ExtractedResult resultB = new ExtractedResult(changedResultA, null); + var resultB = new ExtractedResult(changedResultA, null); IEnumerable matchedResults = matcher.Match(new ExtractedResult[] { resultA }, new ExtractedResult[] { resultB }); @@ -88,20 +88,20 @@ public void IdenticalResultMatcher_MatchesResults_DifferingOnIdOrStatus_Single() [Fact] public void IdenticalResultMatcher_MatchesResults_DifferingOnIdOrStatus_Multiple() { - ExtractedResult resultAA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context"), null); + var resultAA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context"), null); Result changedResultA = resultAA.Result.DeepClone(); changedResultA.CorrelationGuid = Guid.NewGuid(); changedResultA.BaselineState = BaselineState.Unchanged; - ExtractedResult resultBA = new ExtractedResult(changedResultA, null); - ExtractedResult resultAB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context2"), null); + var resultBA = new ExtractedResult(changedResultA, null); + var resultAB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context2"), null); Result changedResultB = resultAB.Result.DeepClone(); changedResultA.CorrelationGuid = Guid.NewGuid(); changedResultA.BaselineState = BaselineState.New; - ExtractedResult resultBB = new ExtractedResult(changedResultB, null); + var resultBB = new ExtractedResult(changedResultB, null); IEnumerable matchedResults = matcher.Match(new ExtractedResult[] { resultAA, resultAB }, new ExtractedResult[] { resultBA, resultBB }); @@ -113,22 +113,22 @@ public void IdenticalResultMatcher_MatchesResults_DifferingOnIdOrStatus_Multiple [Fact] public void IdenticalResultMatcher_MatchesResults_DifferingOnResultMatchingProperties_Multiple() { - ExtractedResult resultAA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context"), null); + var resultAA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context"), null); Result changedResultA = resultAA.Result.DeepClone(); changedResultA.CorrelationGuid = Guid.NewGuid(); changedResultA.BaselineState = BaselineState.Unchanged; changedResultA.SetProperty(SarifLogResultMatcher.ResultMatchingResultPropertyName, new Dictionary { { "property", "value" } }); - ExtractedResult resultBA = new ExtractedResult(changedResultA, null); - ExtractedResult resultAB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context2"), null); + var resultBA = new ExtractedResult(changedResultA, null); + var resultAB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test", "file://test2", "test context2"), null); Result changedResultB = resultAB.Result.DeepClone(); changedResultA.CorrelationGuid = Guid.NewGuid(); changedResultA.BaselineState = BaselineState.New; changedResultB.SetProperty(SarifLogResultMatcher.ResultMatchingResultPropertyName, new Dictionary { { "property1", "value1" } }); - ExtractedResult resultBB = new ExtractedResult(changedResultB, null); + var resultBB = new ExtractedResult(changedResultB, null); IEnumerable matchedResults = matcher.Match(new ExtractedResult[] { resultAA, resultAB }, new ExtractedResult[] { resultBA, resultBB }); diff --git a/src/Test.UnitTests.Sarif/Baseline/ResultMatching/HeuristicMatchers/ContextRegionResultMatcherTests.cs b/src/Test.UnitTests.Sarif/Baseline/ResultMatching/HeuristicMatchers/ContextRegionResultMatcherTests.cs index 77058ebef..423ec913f 100644 --- a/src/Test.UnitTests.Sarif/Baseline/ResultMatching/HeuristicMatchers/ContextRegionResultMatcherTests.cs +++ b/src/Test.UnitTests.Sarif/Baseline/ResultMatching/HeuristicMatchers/ContextRegionResultMatcherTests.cs @@ -16,8 +16,8 @@ public class ContextRegionResultMatcherTests [Fact] public void ContextRegionHeuristicMatcher_NoRegion_DoesNotMatchResults() { - ExtractedResult resultA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test1", "file://test2", null, null), null); - ExtractedResult resultB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test3", "file://test4", null, null), null); + var resultA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test1", "file://test2", null, null), null); + var resultB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test3", "file://test4", null, null), null); IEnumerable matchedResults = matcher.Match(new List() { resultA }, new List() { resultB }); @@ -27,8 +27,8 @@ public void ContextRegionHeuristicMatcher_NoRegion_DoesNotMatchResults() [Fact] public void ContextRegionHeuristicMatcher_DifferentRegion_DoesNotMatchResults() { - ExtractedResult resultA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test1", "file://test2", null, "test one"), null); - ExtractedResult resultB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test3", "file://test4", null, "test two"), null); + var resultA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test1", "file://test2", null, "test one"), null); + var resultB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test3", "file://test4", null, "test two"), null); IEnumerable matchedResults = matcher.Match(new List() { resultA }, new List() { resultB }); @@ -38,8 +38,8 @@ public void ContextRegionHeuristicMatcher_DifferentRegion_DoesNotMatchResults() [Fact] public void ContextRegionHeuristicMatcher_SameRegion_MatchesResults() { - ExtractedResult resultA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test1", "file://test2", null, "region contents"), null); - ExtractedResult resultB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test3", "file://test4", null, "region contents"), null); + var resultA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test1", "file://test2", null, "region contents"), null); + var resultB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test3", "file://test4", null, "region contents"), null); IEnumerable matchedResults = matcher.Match(new List() { resultA }, new List() { resultB }); diff --git a/src/Test.UnitTests.Sarif/Baseline/ResultMatching/HeuristicMatchers/PartialFingerprintResultMatcherTests.cs b/src/Test.UnitTests.Sarif/Baseline/ResultMatching/HeuristicMatchers/PartialFingerprintResultMatcherTests.cs index d587ea2fb..392543696 100644 --- a/src/Test.UnitTests.Sarif/Baseline/ResultMatching/HeuristicMatchers/PartialFingerprintResultMatcherTests.cs +++ b/src/Test.UnitTests.Sarif/Baseline/ResultMatching/HeuristicMatchers/PartialFingerprintResultMatcherTests.cs @@ -16,8 +16,8 @@ public class PartialFingerprintResultMatcherTests [Fact] public void PartialFingerprintResultMatcher_WithoutPartialFingerprints_DoesNotMatch() { - ExtractedResult resultA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test1", "file://test2", null), null); - ExtractedResult resultB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test3", "file://test4", null), null); + var resultA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test1", "file://test2", null), null); + var resultB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test3", "file://test4", null), null); IEnumerable matchedResults = matcher.Match(new List() { resultA }, new List() { resultB }); @@ -27,11 +27,11 @@ public void PartialFingerprintResultMatcher_WithoutPartialFingerprints_DoesNotMa [Fact] public void PartialFingerprintResultMatcher_DifferentPartialFingerprints_DoesNotMatch() { - ExtractedResult resultA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test1", "file://test2", null), null); + var resultA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test1", "file://test2", null), null); resultA.Result.PartialFingerprints = new Dictionary() { { "Fingerprint1", "Value1" } }; - ExtractedResult resultB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test3", "file://test4", null), null); + var resultB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test3", "file://test4", null), null); resultA.Result.PartialFingerprints = new Dictionary() { { "Fingerprint1", "Value2" } }; @@ -43,11 +43,11 @@ public void PartialFingerprintResultMatcher_DifferentPartialFingerprints_DoesNot [Fact] public void PartialFingerprintResultMatcher_SamePartialFingerprints_Matches() { - ExtractedResult resultA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test1", "file://test2", null), null); + var resultA = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test1", "file://test2", null), null); resultA.Result.PartialFingerprints = new Dictionary() { { "Fingerprint1", "Value1" } }; - ExtractedResult resultB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test3", "file://test4", null), null); + var resultB = new ExtractedResult(ResultMatchingTestHelpers.CreateMatchingResult("file://test3", "file://test4", null), null); resultA.Result.PartialFingerprints = new Dictionary() { { "Fingerprint1", "Value1" } }; diff --git a/src/Test.UnitTests.Sarif/Baseline/ResultMatching/ResultMatchingBaselinerTests.cs b/src/Test.UnitTests.Sarif/Baseline/ResultMatching/ResultMatchingBaselinerTests.cs index 2efdad86c..4fa1e026a 100644 --- a/src/Test.UnitTests.Sarif/Baseline/ResultMatching/ResultMatchingBaselinerTests.cs +++ b/src/Test.UnitTests.Sarif/Baseline/ResultMatching/ResultMatchingBaselinerTests.cs @@ -92,7 +92,7 @@ public void ResultMatchingBaseliner_ShouldNotThrowExceptionWhenNoSimilarToolsAre baselineLog.Runs[0].Tool.Driver.Name = "Test1"; currentLog.Runs[0].Tool.Driver.Name = "Test2"; - var exception = Record.Exception(() => baseliner.Match(new SarifLog[] { baselineLog }, new SarifLog[] { currentLog }).First()); + Exception exception = Record.Exception(() => baseliner.Match(new SarifLog[] { baselineLog }, new SarifLog[] { currentLog }).First()); Assert.Null(exception); } diff --git a/src/Test.UnitTests.Sarif/Baseline/ResultMatching/ResultMatchingTestHelpers.cs b/src/Test.UnitTests.Sarif/Baseline/ResultMatching/ResultMatchingTestHelpers.cs index 4005bdbd6..52d70cd84 100644 --- a/src/Test.UnitTests.Sarif/Baseline/ResultMatching/ResultMatchingTestHelpers.cs +++ b/src/Test.UnitTests.Sarif/Baseline/ResultMatching/ResultMatchingTestHelpers.cs @@ -5,11 +5,11 @@ namespace Microsoft.CodeAnalysis.Sarif.Baseline.ResultMatching { - static class ResultMatchingTestHelpers + internal static class ResultMatchingTestHelpers { public static Result CreateMatchingResult(string target, string location, string regionContent, string contextRegionContent = null) { - Result result = new Result() + var result = new Result() { RuleId = "TEST001", Level = FailureLevel.Error, diff --git a/src/Test.UnitTests.Sarif/Baseline/ResultMatching/SarifLogResultMatcherTests.cs b/src/Test.UnitTests.Sarif/Baseline/ResultMatching/SarifLogResultMatcherTests.cs index 7745397c1..fcd84aeb9 100644 --- a/src/Test.UnitTests.Sarif/Baseline/ResultMatching/SarifLogResultMatcherTests.cs +++ b/src/Test.UnitTests.Sarif/Baseline/ResultMatching/SarifLogResultMatcherTests.cs @@ -199,7 +199,7 @@ public void SarifLogResultMatcher_CurrentLogEmpty_AllAbsent() { Random random = RandomSarifLogGenerator.GenerateRandomAndLog(this.output); SarifLog baselineLog = RandomSarifLogGenerator.GenerateSarifLogWithRuns(random, 1); - SarifLog currentLog = new SarifLog(); + var currentLog = new SarifLog(); currentLog.Runs = new Run[] { new Run() }; baselineLog.Runs[0].AutomationDetails = new RunAutomationDetails { Guid = Guid.NewGuid() }; @@ -302,7 +302,7 @@ public void SarifLogResultMatcher_PreviousLogEmpty_WorksAsExpected() [Fact] public void SarifLogResultMatcher_MultipleLogsDuplicateData_WorksAsExpected() { - SarifLog current1 = new SarifLog() + var current1 = new SarifLog() { Runs = new Run[] { diff --git a/src/Test.UnitTests.Sarif/Baseline2/ExtractedResultTests.cs b/src/Test.UnitTests.Sarif/Baseline2/ExtractedResultTests.cs index 5533f1379..b598e3db5 100644 --- a/src/Test.UnitTests.Sarif/Baseline2/ExtractedResultTests.cs +++ b/src/Test.UnitTests.Sarif/Baseline2/ExtractedResultTests.cs @@ -17,7 +17,7 @@ public class ExtractedResultTests [Fact] public void WhatComparer_MatchesCategory() { - Run run = new Run() + var run = new Run() { Tool = new Tool() { diff --git a/src/Test.UnitTests.Sarif/Baseline2/MatchedResultsTests.cs b/src/Test.UnitTests.Sarif/Baseline2/MatchedResultsTests.cs index 791145d69..a2f54589f 100644 --- a/src/Test.UnitTests.Sarif/Baseline2/MatchedResultsTests.cs +++ b/src/Test.UnitTests.Sarif/Baseline2/MatchedResultsTests.cs @@ -314,7 +314,7 @@ public void MatchedResults_SetsFirstDetectionTime() ExtractedResult currentExtracted = testCase.CurrentResult != null ? new ExtractedResult(testCase.CurrentResult, testCase.CurrentRun) : null; - MatchedResults matchedResults = new MatchedResults(previousExtracted, currentExtracted); + var matchedResults = new MatchedResults(previousExtracted, currentExtracted); Result result = matchedResults.CalculateBasedlinedResult(DictionaryMergeBehavior.InitializeFromMostRecent /* arbitrary */); diff --git a/src/Test.UnitTests.Sarif/Baseline2/OverallBaseliningTests.cs b/src/Test.UnitTests.Sarif/Baseline2/OverallBaseliningTests.cs index e4e834dda..70f7908b8 100644 --- a/src/Test.UnitTests.Sarif/Baseline2/OverallBaseliningTests.cs +++ b/src/Test.UnitTests.Sarif/Baseline2/OverallBaseliningTests.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; using System.Linq; using FluentAssertions; diff --git a/src/Test.UnitTests.Sarif/Baseline2/TrustMapTests.cs b/src/Test.UnitTests.Sarif/Baseline2/TrustMapTests.cs index f7b54ffa2..3d14e7d11 100644 --- a/src/Test.UnitTests.Sarif/Baseline2/TrustMapTests.cs +++ b/src/Test.UnitTests.Sarif/Baseline2/TrustMapTests.cs @@ -24,8 +24,8 @@ public class TrustMapTests public void TrustMap_Basics() { // Create a TrustMap for both of the Runs being compared - TrustMap beforeMap = new TrustMap(); - TrustMap afterMap = new TrustMap(); + var beforeMap = new TrustMap(); + var afterMap = new TrustMap(); // All properties are unknown to start beforeMap.Trust(Set, NameGreat).Should().Be(TrustMap.DefaultTrust); diff --git a/src/Test.UnitTests.Sarif/Baseline2/V2ResultMatcherTests.cs b/src/Test.UnitTests.Sarif/Baseline2/V2ResultMatcherTests.cs index 81bf84caa..b976da8fe 100644 --- a/src/Test.UnitTests.Sarif/Baseline2/V2ResultMatcherTests.cs +++ b/src/Test.UnitTests.Sarif/Baseline2/V2ResultMatcherTests.cs @@ -393,7 +393,7 @@ private void VerifyResultRules(Run run) private void SetResultRuleIndexOnly(Run run) { - Dictionary ruleIndexByRuleId = new Dictionary(); + var ruleIndexByRuleId = new Dictionary(); for (int i = 0; i < run.Tool.Driver.Rules.Count; ++i) { @@ -415,9 +415,9 @@ private void SetResultRuleIndexOnly(Run run) [Fact] public void ResultMatchingBaseliner_WhenThereIsOnlyOneCurrentRun_CopiesSelectedRunData() { - DateTime firstDetectionTime = new DateTime(2019, 10, 7, 12, 13, 14); + var firstDetectionTime = new DateTime(2019, 10, 7, 12, 13, 14); - Run originalRun = new Run + var originalRun = new Run { Tool = new Tool { diff --git a/src/Test.UnitTests.Sarif/Baseline2/WhatComparerTests.cs b/src/Test.UnitTests.Sarif/Baseline2/WhatComparerTests.cs index 779c2f27d..558184877 100644 --- a/src/Test.UnitTests.Sarif/Baseline2/WhatComparerTests.cs +++ b/src/Test.UnitTests.Sarif/Baseline2/WhatComparerTests.cs @@ -19,11 +19,11 @@ public class WhatComparerTests [Fact] public void WhatComparer_Basics() { - Run run = new Run(); - Result left = new Result { RuleId = "Rule1", Message = new Message() { Text = "One" }, Run = run }; - Result right = new Result { RuleId = "Rule1", Message = new Message() { Text = "Two" }, Run = run }; - ExtractedResult eLeft = new ExtractedResult(left, run); - ExtractedResult eRight = new ExtractedResult(right, run); + var run = new Run(); + var left = new Result { RuleId = "Rule1", Message = new Message() { Text = "One" }, Run = run }; + var right = new Result { RuleId = "Rule1", Message = new Message() { Text = "Two" }, Run = run }; + var eLeft = new ExtractedResult(left, run); + var eRight = new ExtractedResult(right, run); // GUIDs // ===== @@ -122,7 +122,7 @@ public void WhatComparer_Basics() WhatComparer.MatchesWhat(eLeft, eRight).Should().BeTrue(); // Verify snippets must also match. - Location location = new Location + var location = new Location { PhysicalLocation = new PhysicalLocation { diff --git a/src/Test.UnitTests.Sarif/Baseline2/WhereComparerTests.cs b/src/Test.UnitTests.Sarif/Baseline2/WhereComparerTests.cs index 31672da13..6a5e18647 100644 --- a/src/Test.UnitTests.Sarif/Baseline2/WhereComparerTests.cs +++ b/src/Test.UnitTests.Sarif/Baseline2/WhereComparerTests.cs @@ -32,7 +32,7 @@ public void WhereComparer_Region() // Reminder: CompareTo less than zero means left sorts before right. 5.CompareTo(10).Should().BeLessThan(0); - Region left = new Region(SampleRegion); + var left = new Region(SampleRegion); Region right; // Equal @@ -109,15 +109,15 @@ public void WhereComparer_Region() [Fact] public void WhereComparer_ArtifactLocation() { - Run run = new Run(); + var run = new Run(); run.Artifacts = new List(); run.Artifacts.Add(new Artifact() { Location = new ArtifactLocation() }); run.Artifacts.Add(new Artifact() { Location = ArtifactLocationUri1 }); run.Artifacts.Add(new Artifact() { Location = ArtifactLocationUri2 }); - ArtifactLocation left = new ArtifactLocation(ArtifactLocationUri1); - ArtifactLocation right = new ArtifactLocation(ArtifactLocationUri2); + var left = new ArtifactLocation(ArtifactLocationUri1); + var right = new ArtifactLocation(ArtifactLocationUri2); // Equal; run not needed if no index provided. WhereComparer.CompareTo(left, null, left, null).Should().Be(0); @@ -147,12 +147,12 @@ public void WhereComparer_ArtifactLocation() [Fact] public void WhereComparer_PhysicalLocation() { - PhysicalLocation left = new PhysicalLocation + var left = new PhysicalLocation { ArtifactLocation = new ArtifactLocation() { Uri = Uri1 } }; - PhysicalLocation right = new PhysicalLocation + var right = new PhysicalLocation { ArtifactLocation = new ArtifactLocation { Uri = Uri2 } }; @@ -162,7 +162,7 @@ public void WhereComparer_PhysicalLocation() WhereComparer.CompareTo(left, null, right, null).Should().BeLessThan(0); left.Region = SampleRegion; - PhysicalLocation leftLater = new PhysicalLocation(left) { Region = new Region(SampleRegion) { StartLine = SampleRegion.StartLine + 1 } }; + var leftLater = new PhysicalLocation(left) { Region = new Region(SampleRegion) { StartLine = SampleRegion.StartLine + 1 } }; // Sort by Region if Uris match WhereComparer.CompareTo(left, null, leftLater, null).Should().BeLessThan(0); @@ -188,14 +188,14 @@ public void WhereComparer_LogicalLocation() [Fact] public void WhereComparer_ListOfLogicalLocation() { - List empty = new List(); + var empty = new List(); - List left = new List + var left = new List { LogicalLocation1 }; - List right = new List + var right = new List { LogicalLocation1, LogicalLocation2 @@ -214,7 +214,7 @@ public void WhereComparer_ListOfLogicalLocation() WhereComparer.CompareTo(left, null, right, null).Should().BeLessThan(0); // Later location wins over longer list - List three = new List { LogicalLocation2 }; + var three = new List { LogicalLocation2 }; WhereComparer.CompareTo(right, null, three, null).Should().BeLessThan(0); } } diff --git a/src/Test.UnitTests.Sarif/CacheTests.cs b/src/Test.UnitTests.Sarif/CacheTests.cs index 8ad80d83b..dd06532d3 100644 --- a/src/Test.UnitTests.Sarif/CacheTests.cs +++ b/src/Test.UnitTests.Sarif/CacheTests.cs @@ -13,7 +13,7 @@ public class CacheTests public void CacheBasics() { int buildCount = 0; - Cache cache = new Cache( + var cache = new Cache( (key) => { buildCount++; return 10 * key; }, capacity: 2); diff --git a/src/Test.UnitTests.Sarif/Comparers/ComparersTests.cs b/src/Test.UnitTests.Sarif/Comparers/ComparersTests.cs index 088394d56..66b1a89c0 100644 --- a/src/Test.UnitTests.Sarif/Comparers/ComparersTests.cs +++ b/src/Test.UnitTests.Sarif/Comparers/ComparersTests.cs @@ -8,7 +8,6 @@ using FluentAssertions; using Microsoft.CodeAnalysis.Sarif; -using Microsoft.CodeAnalysis.Test.Utilities.Sarif; using Xunit; using Xunit.Abstractions; diff --git a/src/Test.UnitTests.Sarif/Core/ArtifactLocationTests.cs b/src/Test.UnitTests.Sarif/Core/ArtifactLocationTests.cs index 1c2d58ea0..20b16fd61 100644 --- a/src/Test.UnitTests.Sarif/Core/ArtifactLocationTests.cs +++ b/src/Test.UnitTests.Sarif/Core/ArtifactLocationTests.cs @@ -185,7 +185,7 @@ public void ToLocation_ProducesExpectedLocationObject() Uri = new Uri(SourceFile, UriKind.Relative) }; - Location location = artifactLocation.ToLocation(lineNumber: 12, column: 9, length: 14, offset: 140); + var location = artifactLocation.ToLocation(lineNumber: 12, column: 9, length: 14, offset: 140); PhysicalLocation physicalLocation = location.PhysicalLocation; physicalLocation.ArtifactLocation.Uri.OriginalString.Should().Be(SourceFile); diff --git a/src/Test.UnitTests.Sarif/Core/ArtifactTests.cs b/src/Test.UnitTests.Sarif/Core/ArtifactTests.cs index bafff0784..978a38218 100644 --- a/src/Test.UnitTests.Sarif/Core/ArtifactTests.cs +++ b/src/Test.UnitTests.Sarif/Core/ArtifactTests.cs @@ -33,12 +33,12 @@ public void Artifact_ComputeHashes() { string filePath = Path.GetTempFileName(); string fileContents = Guid.NewGuid().ToString(); - Uri uri = new Uri(filePath); + var uri = new Uri(filePath); try { File.WriteAllText(filePath, fileContents); - Artifact fileData = Artifact.Create(uri, OptionallyEmittedData.Hashes); + var fileData = Artifact.Create(uri, OptionallyEmittedData.Hashes); fileData.Location.Should().Be(null); HashData hashes = HashUtilities.ComputeHashes(filePath); fileData.Contents.Should().BeNull(); @@ -82,12 +82,12 @@ public void Artifact_PersistBinaryAndTextFileContents( { string filePath = Path.GetTempFileName() + fileExtension; string fileContents = Guid.NewGuid().ToString(); - Uri uri = new Uri(filePath); + var uri = new Uri(filePath); try { File.WriteAllText(filePath, fileContents); - Artifact fileData = Artifact.Create(uri, dataToInsert); + var fileData = Artifact.Create(uri, dataToInsert); fileData.Location.Should().BeNull(); if (dataToInsert.HasFlag(OptionallyEmittedData.Hashes)) @@ -134,12 +134,12 @@ public void Artifact_PersistTextFileContentsBigEndianUnicode() string textValue = "अचम्भा"; byte[] fileContents = encoding.GetBytes(textValue); - Uri uri = new Uri(filePath); + var uri = new Uri(filePath); try { File.WriteAllBytes(filePath, fileContents); - Artifact fileData = Artifact.Create(uri, OptionallyEmittedData.TextFiles, encoding: encoding); + var fileData = Artifact.Create(uri, OptionallyEmittedData.TextFiles, encoding: encoding); fileData.Location.Should().Be(null); fileData.Hashes.Should().BeNull(); @@ -158,8 +158,8 @@ public void Artifact_FileDoesNotExist() // If a file does not exist, and we request file contents // persistence, the logger will not raise an exception string filePath = Path.GetTempFileName(); - Uri uri = new Uri(filePath); - Artifact fileData = Artifact.Create(uri, OptionallyEmittedData.TextFiles); + var uri = new Uri(filePath); + var fileData = Artifact.Create(uri, OptionallyEmittedData.TextFiles); fileData.Location.Should().Be(null); fileData.Hashes.Should().BeNull(); fileData.Contents.Should().BeNull(); @@ -169,7 +169,7 @@ public void Artifact_FileDoesNotExist() public void Artifact_FileIsLocked() { string filePath = Path.GetTempFileName(); - Uri uri = new Uri(filePath); + var uri = new Uri(filePath); try { @@ -177,7 +177,7 @@ public void Artifact_FileIsLocked() // This raises an IOException, which is swallowed by FileData.Create using (FileStream exclusiveAccessReader = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.None)) { - Artifact fileData = Artifact.Create(uri, OptionallyEmittedData.TextFiles); + var fileData = Artifact.Create(uri, OptionallyEmittedData.TextFiles); fileData.Location.Should().Be(null); fileData.Hashes.Should().BeNull(); fileData.Contents.Should().BeNull(); @@ -204,7 +204,7 @@ public void Artifact_BinaryFileIsNotAccessibleDueToSecurity() [Fact] public void Artifact_SerializeSingleFileRole() { - Artifact fileData = Artifact.Create(new Uri("file:///example.cs"), OptionallyEmittedData.None); + var fileData = Artifact.Create(new Uri("file:///example.cs"), OptionallyEmittedData.None); fileData.Roles = ArtifactRoles.AnalysisTarget; string result = JsonConvert.SerializeObject(fileData); @@ -215,7 +215,7 @@ public void Artifact_SerializeSingleFileRole() [Fact] public void Artifact_SerializeMultipleFileRoles() { - Artifact fileData = Artifact.Create(new Uri("file:///example.cs"), OptionallyEmittedData.None); + var fileData = Artifact.Create(new Uri("file:///example.cs"), OptionallyEmittedData.None); fileData.Roles = ArtifactRoles.ResponseFile | ArtifactRoles.ResultFile; string actual = JsonConvert.SerializeObject(fileData); @@ -226,14 +226,14 @@ public void Artifact_SerializeMultipleFileRoles() [Fact] public void Artifact_DeserializeSingleFileRole() { - Artifact actual = JsonConvert.DeserializeObject("{\"roles\":[\"analysisTarget\"]}", typeof(Artifact)) as Artifact; + var actual = JsonConvert.DeserializeObject("{\"roles\":[\"analysisTarget\"]}", typeof(Artifact)) as Artifact; actual.Roles.Should().Be(ArtifactRoles.AnalysisTarget); } [Fact] public void Artifact_DeserializeMultipleFileRoles() { - Artifact actual = JsonConvert.DeserializeObject("{\"roles\":[\"responseFile\",\"resultFile\"]}", typeof(Artifact)) as Artifact; + var actual = JsonConvert.DeserializeObject("{\"roles\":[\"responseFile\",\"resultFile\"]}", typeof(Artifact)) as Artifact; actual.Roles.Should().Be(ArtifactRoles.ResponseFile | ArtifactRoles.ResultFile); } @@ -241,11 +241,11 @@ private static void RunUnauthorizedAccessTextForFile(bool isTextFile) { string extension = isTextFile ? ".cs" : ".dll"; string filePath = Path.GetFullPath(Guid.NewGuid().ToString()) + extension; - Uri uri = new Uri(filePath); + var uri = new Uri(filePath); IFileSystem fileSystem = SetUnauthorizedAccessExceptionMock(); - Artifact fileData = Artifact.Create( + var fileData = Artifact.Create( uri, OptionallyEmittedData.TextFiles, encoding: null, diff --git a/src/Test.UnitTests.Sarif/Core/LocationTests.cs b/src/Test.UnitTests.Sarif/Core/LocationTests.cs index a124e6a07..048eb2863 100644 --- a/src/Test.UnitTests.Sarif/Core/LocationTests.cs +++ b/src/Test.UnitTests.Sarif/Core/LocationTests.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; using System.Numerics; using FluentAssertions; diff --git a/src/Test.UnitTests.Sarif/Core/PropertyBagHolderTests.cs b/src/Test.UnitTests.Sarif/Core/PropertyBagHolderTests.cs index 278008d85..235ecc163 100644 --- a/src/Test.UnitTests.Sarif/Core/PropertyBagHolderTests.cs +++ b/src/Test.UnitTests.Sarif/Core/PropertyBagHolderTests.cs @@ -297,8 +297,8 @@ public void PropertyBagHolder_SetProperty_SetsDateTimeProperty() internal static class ExtensionsForPropertyBagHolderTests { - const string PropertyName = "prop"; - const string Input = "{\"properties\":{\"" + PropertyName + "\":12}}"; + private const string PropertyName = "prop"; + private const string Input = "{\"properties\":{\"" + PropertyName + "\":12}}"; internal static void ShouldSerializeAs(this T value, string serializedValue) { diff --git a/src/Test.UnitTests.Sarif/Core/ReportingDescriptorTests.cs b/src/Test.UnitTests.Sarif/Core/ReportingDescriptorTests.cs index e1dd781d2..e2df3f01e 100644 --- a/src/Test.UnitTests.Sarif/Core/ReportingDescriptorTests.cs +++ b/src/Test.UnitTests.Sarif/Core/ReportingDescriptorTests.cs @@ -18,7 +18,7 @@ public class ReportingDescriptorTests [Fact] public void ShouldSerializeShortDescription_CorrectlyHandlesNullAndEmptyValues() { - ReportingDescriptor reportingDescriptor = new ReportingDescriptor() + var reportingDescriptor = new ReportingDescriptor() { ShortDescription = null, FullDescription = null @@ -61,7 +61,7 @@ public void ShouldSerializeShortDescription_CorrectlyHandlesNullAndEmptyValues() [Fact] public void ShouldSerializeShortDescription_FalseForIdenticalStrings() { - ReportingDescriptor reportingDescriptor = new ReportingDescriptor() + var reportingDescriptor = new ReportingDescriptor() { ShortDescription = new MultiformatMessageString() { Text = "EasyFalse1" }, FullDescription = new MultiformatMessageString() { Text = "EasyFalse1" } diff --git a/src/Test.UnitTests.Sarif/Core/RunTests.cs b/src/Test.UnitTests.Sarif/Core/RunTests.cs index 9fc24095e..66a9d7c98 100644 --- a/src/Test.UnitTests.Sarif/Core/RunTests.cs +++ b/src/Test.UnitTests.Sarif/Core/RunTests.cs @@ -496,8 +496,8 @@ public void HasSuppressedResults_ReturnsExpectedValue() public void Run_ShouldSerializeAutomationDetails_WhenAnyPropertyIsValid() { const string id = "automation-id"; - Guid guid = Guid.Parse("8b02f0b8-6df5-40b2-9e93-5404e56676e2"); - Guid correlationGuid = Guid.Parse("3d468dd8-3c62-45ed-b86a-a4fe9da93dd9"); + var guid = Guid.Parse("8b02f0b8-6df5-40b2-9e93-5404e56676e2"); + var correlationGuid = Guid.Parse("3d468dd8-3c62-45ed-b86a-a4fe9da93dd9"); var sarifLog = new SarifLog { @@ -693,7 +693,7 @@ private Run BuildDefaultRunObject() private ToolComponent CreateToolComponent(string name, int rulesCount, FailureLevel failureLevel) { - ToolComponent toolComponent = new ToolComponent(); + var toolComponent = new ToolComponent(); toolComponent.Name = name; toolComponent.Rules = new ReportingDescriptor[rulesCount]; for (int i = 0; i < rulesCount; i++) diff --git a/src/Test.UnitTests.Sarif/Core/SerializedPropertyInfoTests.cs b/src/Test.UnitTests.Sarif/Core/SerializedPropertyInfoTests.cs index d1e8bb7c0..a050c7427 100644 --- a/src/Test.UnitTests.Sarif/Core/SerializedPropertyInfoTests.cs +++ b/src/Test.UnitTests.Sarif/Core/SerializedPropertyInfoTests.cs @@ -18,7 +18,7 @@ public class SerializedPropertyInfoTests [Fact] public void SerializedPropertyInfo_ComparerTests() { - Guid testGuid = Guid.NewGuid(); + var testGuid = Guid.NewGuid(); DateTime now = DateTime.UtcNow; var testCases = new[] diff --git a/src/Test.UnitTests.Sarif/Core/StackTests.cs b/src/Test.UnitTests.Sarif/Core/StackTests.cs index 4be57fbd4..1ae43ac50 100644 --- a/src/Test.UnitTests.Sarif/Core/StackTests.cs +++ b/src/Test.UnitTests.Sarif/Core/StackTests.cs @@ -22,7 +22,7 @@ public class StackTests public void Stack_CreateFromStackTrace() { var dotNetStack = new StackTrace(); - Stack stack = new Stack(dotNetStack); + var stack = new Stack(dotNetStack); // The .NET StackTrace.ToString() override must preserve a trailing NewLine // for compatibility reasons. We do not retain this behavior in ToString() diff --git a/src/Test.UnitTests.Sarif/Core/ToolTests.cs b/src/Test.UnitTests.Sarif/Core/ToolTests.cs index f6675d102..496898550 100644 --- a/src/Test.UnitTests.Sarif/Core/ToolTests.cs +++ b/src/Test.UnitTests.Sarif/Core/ToolTests.cs @@ -60,7 +60,7 @@ public DottedQuadFileVersionTestCase(string input, string expectedOutput) [Fact] public void Tool_ParseFileVersion_ExtractsDottedQuadFileVersion() { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); foreach (DottedQuadFileVersionTestCase testCase in s_dottedQuadFileVersionTestCases) { diff --git a/src/Test.UnitTests.Sarif/Core/WebRequestTests.cs b/src/Test.UnitTests.Sarif/Core/WebRequestTests.cs index 687fb6563..780f5b654 100644 --- a/src/Test.UnitTests.Sarif/Core/WebRequestTests.cs +++ b/src/Test.UnitTests.Sarif/Core/WebRequestTests.cs @@ -26,7 +26,7 @@ public void WebRequest_Parse_CreatesExpectedWebRequestObject() "; - WebRequest webRequest = WebRequest.Parse(RequestString); + var webRequest = WebRequest.Parse(RequestString); webRequest.Method.Should().Be("GET"); webRequest.Target.Should().Be("/hello.txt"); @@ -54,7 +54,7 @@ This is the body. Line 2. "; - WebRequest webRequest = WebRequest.Parse(RequestString); + var webRequest = WebRequest.Parse(RequestString); webRequest.Method.Should().Be("GET"); webRequest.Target.Should().Be("/hello.txt"); @@ -78,7 +78,7 @@ public void WebRequest_Parse_ExtractsParameters() "; - WebRequest webRequest = WebRequest.Parse(RequestString); + var webRequest = WebRequest.Parse(RequestString); webRequest.Method.Should().Be("GET"); webRequest.Target.Should().Be("/hello.txt?verbose=true&debug=false"); @@ -104,7 +104,7 @@ public void WebRequest_Parse_HandlesQueriesWithParametersWithoutValue() "; - WebRequest webRequest = WebRequest.Parse(RequestString); + var webRequest = WebRequest.Parse(RequestString); webRequest.Method.Should().Be("GET"); webRequest.Target.Should().Be("/hello.txt?this-query-is-a-parameter-without-value"); diff --git a/src/Test.UnitTests.Sarif/Core/WebResponseTests.cs b/src/Test.UnitTests.Sarif/Core/WebResponseTests.cs index aaacc596a..5511d38cf 100644 --- a/src/Test.UnitTests.Sarif/Core/WebResponseTests.cs +++ b/src/Test.UnitTests.Sarif/Core/WebResponseTests.cs @@ -31,7 +31,7 @@ public void WebResponse_Parse_CreatesExpectedWebResponseObject() Hello World!My payload includes a trailing NewLine. "; - WebResponse webResponse = WebResponse.Parse(ResponseString); + var webResponse = WebResponse.Parse(ResponseString); webResponse.Protocol.Should().Be("HTTP"); webResponse.Version.Should().Be("1.1"); @@ -60,7 +60,7 @@ public void WebResponse_Parse_CreatesExpectedWebResponseObjectWithoutBody() "; - WebResponse webResponse = WebResponse.Parse(ResponseString); + var webResponse = WebResponse.Parse(ResponseString); webResponse.Protocol.Should().Be("HTTP"); webResponse.Version.Should().Be("1.1"); diff --git a/src/Test.UnitTests.Sarif/FileRegionsCacheTests.cs b/src/Test.UnitTests.Sarif/FileRegionsCacheTests.cs index 3e3f54ec4..73bf47606 100644 --- a/src/Test.UnitTests.Sarif/FileRegionsCacheTests.cs +++ b/src/Test.UnitTests.Sarif/FileRegionsCacheTests.cs @@ -399,9 +399,9 @@ public void FileRegionsCache_PopulatesFromMissingFile() var run = new Run(); var fileRegionsCache = new FileRegionsCache(); - Uri uri = new Uri(@"c:\temp\DoesNotExist\" + Guid.NewGuid().ToString() + ".cpp"); + var uri = new Uri(@"c:\temp\DoesNotExist\" + Guid.NewGuid().ToString() + ".cpp"); - Region region = new Region() { CharOffset = 17 }; + var region = new Region() { CharOffset = 17 }; // Region should not be touched in any way if the file it references is missing fileRegionsCache.PopulateTextRegionProperties(region, uri, populateSnippet: false).ValueEquals(region).Should().BeTrue(); @@ -412,15 +412,15 @@ public void FileRegionsCache_PopulatesFromMissingFile() public void FileRegionsCache_PopulatesUsingProvidedText() { var fileRegionsCache = new FileRegionsCache(); - Uri uri = new Uri(@"c:\temp\DoesNotExist\" + Guid.NewGuid().ToString() + ".cpp"); + var uri = new Uri(@"c:\temp\DoesNotExist\" + Guid.NewGuid().ToString() + ".cpp"); string fileText = "12345\n56790\n"; int charOffset = 6; int charLength = 1; // Region should grab the second line of text in 'fileText'. - Region region = new Region() { CharOffset = charOffset, CharLength = charLength }; + var region = new Region() { CharOffset = charOffset, CharLength = charLength }; - Region expected = new Region() + var expected = new Region() { CharOffset = charOffset, CharLength = charLength, @@ -591,7 +591,7 @@ public void FileRegionsCache_ValidateConcurrencyData() Exception exception = Record.Exception(() => { var fileRegionsCache = new FileRegionsCache(); - List taskList = new List(); + var taskList = new List(); for (int i = 0; i < 1_000; i++) { @@ -606,7 +606,7 @@ public void FileRegionsCache_ValidateConcurrencyData() private static void ExecuteTests(string fileText, ReadOnlyCollection testCases) { - Uri uri = new Uri(@"c:\temp\myFile.cpp"); + var uri = new Uri(@"c:\temp\myFile.cpp"); var run = new Run(); IFileSystem mockFileSystem = MockFactory.MakeMockFileSystem(uri.LocalPath, fileText); @@ -653,19 +653,19 @@ private static void ExecuteTests(ReadOnlyCollection testCases, Fil [Fact(Skip = "Flaky test. Results vary depending on environment.")] public void FileRegionsCache_ProperlyCaches() { - Uri uri = new Uri(@"C:\Code\Program.cs"); + var uri = new Uri(@"C:\Code\Program.cs"); - StringBuilder fileContents = new StringBuilder(); + var fileContents = new StringBuilder(); for (int i = 0; i < 1000; ++i) { fileContents.AppendLine("0123456789"); } - Run run = new Run(); + var run = new Run(); IFileSystem mockFileSystem = MockFactory.MakeMockFileSystem(uri.LocalPath, fileContents.ToString()); - FileRegionsCache fileRegionsCache = new FileRegionsCache(fileSystem: mockFileSystem); + var fileRegionsCache = new FileRegionsCache(fileSystem: mockFileSystem); - Region region = new Region() + var region = new Region() { StartLine = 2, StartColumn = 1, @@ -673,7 +673,7 @@ public void FileRegionsCache_ProperlyCaches() EndColumn = 10, }; - Stopwatch w = Stopwatch.StartNew(); + var w = Stopwatch.StartNew(); for (int i = 0; i < 1000; ++i) { @@ -691,7 +691,7 @@ public void FileRegionsCache_ProperlyCaches() [Fact] public void FileRegionsCache_PopulatesNullRegion() { - Uri uri = new Uri(@"c:\temp\myFile.cpp"); + var uri = new Uri(@"c:\temp\myFile.cpp"); var run = new Run(); IFileSystem mockFileSystem = MockFactory.MakeMockFileSystem(uri.LocalPath, SPEC_EXAMPLE); @@ -707,7 +707,7 @@ public void FileRegionsCache_PopulatesNullRegion() [Fact] public void FileRegionsCache_IncreasingToLeftAndRight() { - Uri uri = new Uri(@"c:\temp\myFile.cpp"); + var uri = new Uri(@"c:\temp\myFile.cpp"); string fileContent = $"{new string('a', 200)}{new string('b', 800)}"; var region = new Region diff --git a/src/Test.UnitTests.Sarif/JsonTests.cs b/src/Test.UnitTests.Sarif/JsonTests.cs index 40457d780..373d74c0d 100644 --- a/src/Test.UnitTests.Sarif/JsonTests.cs +++ b/src/Test.UnitTests.Sarif/JsonTests.cs @@ -20,7 +20,7 @@ public abstract class JsonTests protected static string GetJson(Action testContent) { - StringBuilder result = new StringBuilder(); + var result = new StringBuilder(); using (var str = new StringWriter(result)) using (var json = new JsonTextWriter(str) { Formatting = Formatting.Indented, DateTimeZoneHandling = DateTimeZoneHandling.Utc }) using (var uut = new ResultLogJsonWriter(json)) diff --git a/src/Test.UnitTests.Sarif/Map/LongArrayDeltaConverterTests.cs b/src/Test.UnitTests.Sarif/Map/LongArrayDeltaConverterTests.cs index b39270532..bb908e1cd 100644 --- a/src/Test.UnitTests.Sarif/Map/LongArrayDeltaConverterTests.cs +++ b/src/Test.UnitTests.Sarif/Map/LongArrayDeltaConverterTests.cs @@ -37,7 +37,7 @@ public void LongArrayDeltaConverter_Basics() private static void RoundTrip(long[] values) { - Container before = new Container(); + var before = new Container(); if (values != null) { before.Values = new List(values); @@ -45,7 +45,7 @@ private static void RoundTrip(long[] values) string serialized = JsonConvert.SerializeObject(before); - Container after = (Container)JsonConvert.DeserializeObject(serialized, typeof(Container)); + var after = (Container)JsonConvert.DeserializeObject(serialized, typeof(Container)); Assert.Equal(values, after.Values); } } diff --git a/src/Test.UnitTests.Sarif/OrderSensitiveValueComparisonListTests.cs b/src/Test.UnitTests.Sarif/OrderSensitiveValueComparisonListTests.cs index 6a57dc845..4b9bd4ba5 100644 --- a/src/Test.UnitTests.Sarif/OrderSensitiveValueComparisonListTests.cs +++ b/src/Test.UnitTests.Sarif/OrderSensitiveValueComparisonListTests.cs @@ -103,7 +103,7 @@ private OrderSensitiveValueComparisonList CreateTestList(IEquali var fileChangeTwo = new ArtifactChange(); var fileChangeThree = new ArtifactChange(); - Guid differentiatingProperty = Guid.NewGuid(); + var differentiatingProperty = Guid.NewGuid(); fileChangeThree.SetProperty(DIFFERENTIATING_PROPERTY_NAME, differentiatingProperty); var list = new OrderSensitiveValueComparisonList(equalityComparer); diff --git a/src/Test.UnitTests.Sarif/Processors/GenericTests/GenericProcessorTests.cs b/src/Test.UnitTests.Sarif/Processors/GenericTests/GenericProcessorTests.cs index bad208176..50ac9de41 100644 --- a/src/Test.UnitTests.Sarif/Processors/GenericTests/GenericProcessorTests.cs +++ b/src/Test.UnitTests.Sarif/Processors/GenericTests/GenericProcessorTests.cs @@ -15,9 +15,9 @@ public class GenericProcessorTests { private List GenerateRandomIntList() { - Random r = new Random(); + var r = new Random(); int size = r.Next(1, 100); - List list = new List(size); + var list = new List(size); for (int i = 0; i < size; i++) { list.Add(r.Next()); @@ -30,7 +30,7 @@ public void GenericMapStage_WorksAsExpected() { List list = GenerateRandomIntList(); - TestMappingProcessor testMapper = new TestMappingProcessor(); + var testMapper = new TestMappingProcessor(); IEnumerable mappedList = testMapper.Map(list.AsEnumerable()); @@ -42,7 +42,7 @@ public void GenericReduceStage_WorksAsExpected() { List list = GenerateRandomIntList(); - TestFoldProcessor testFold = new TestFoldProcessor(); + var testFold = new TestFoldProcessor(); int result = testFold.Fold(list.AsEnumerable()); @@ -54,7 +54,7 @@ public void GenericActionPipeline_WorksAsExpected() { List list = GenerateRandomIntList(); - GenericActionPipeline actionPipeline = new GenericActionPipeline(new List> { new TestMappingProcessor(), new TestFoldProcessor(), new TestMappingProcessor() }); + var actionPipeline = new GenericActionPipeline(new List> { new TestMappingProcessor(), new TestFoldProcessor(), new TestMappingProcessor() }); IEnumerable result = actionPipeline.Act(list); diff --git a/src/Test.UnitTests.Sarif/Processors/GenericTests/TestFoldProcessor.cs b/src/Test.UnitTests.Sarif/Processors/GenericTests/TestFoldProcessor.cs index a71a89155..f25405124 100644 --- a/src/Test.UnitTests.Sarif/Processors/GenericTests/TestFoldProcessor.cs +++ b/src/Test.UnitTests.Sarif/Processors/GenericTests/TestFoldProcessor.cs @@ -5,7 +5,7 @@ namespace Microsoft.CodeAnalysis.Sarif.Processors { - class TestFoldProcessor : GenericFoldAction + internal class TestFoldProcessor : GenericFoldAction { public static Func internalFunction = (acc, value) => { return acc + value; }; diff --git a/src/Test.UnitTests.Sarif/Processors/Log/LogPipelineSerializationTests.cs b/src/Test.UnitTests.Sarif/Processors/Log/LogPipelineSerializationTests.cs index c6602b542..03bf19191 100644 --- a/src/Test.UnitTests.Sarif/Processors/Log/LogPipelineSerializationTests.cs +++ b/src/Test.UnitTests.Sarif/Processors/Log/LogPipelineSerializationTests.cs @@ -16,7 +16,7 @@ public class LogPipelineSerializationTests [Fact] public void SerializeDeserializePipeline_WorksAsExpected() { - SarifLogPipeline preserialized = new SarifLogPipeline( + var preserialized = new SarifLogPipeline( new List() { new SarifLogActionTuple(){Action=SarifLogAction.RebaseUri, Parameters=new string[] {"SrcRoot", @"C:\src\"} }, new SarifLogActionTuple(){Action=SarifLogAction.Merge, Parameters=new string[0]} diff --git a/src/Test.UnitTests.Sarif/Processors/Log/MergeStageTests.cs b/src/Test.UnitTests.Sarif/Processors/Log/MergeStageTests.cs index 39601eada..5ac6f1eff 100644 --- a/src/Test.UnitTests.Sarif/Processors/Log/MergeStageTests.cs +++ b/src/Test.UnitTests.Sarif/Processors/Log/MergeStageTests.cs @@ -20,7 +20,7 @@ public MergeStageTests(ITestOutputHelper outputHelper) output = outputHelper; } - readonly GenericFoldAction Merge = (GenericFoldAction)SarifLogProcessorFactory.GetActionStage(SarifLogAction.Merge); + private readonly GenericFoldAction Merge = (GenericFoldAction)SarifLogProcessorFactory.GetActionStage(SarifLogAction.Merge); [Theory] [InlineData(0)] @@ -46,7 +46,7 @@ public void MergeStage_MultipleFiles_MergeCorrectly(int fileCount) { Random random = RandomSarifLogGenerator.GenerateRandomAndLog(this.output); - List logs = new List(); + var logs = new List(); for (int i = 0; i < fileCount; i++) { logs.Add(RandomSarifLogGenerator.GenerateSarifLogWithRuns(random, random.Next(5))); diff --git a/src/Test.UnitTests.Sarif/Processors/Log/RebaseUriStageTests.cs b/src/Test.UnitTests.Sarif/Processors/Log/RebaseUriStageTests.cs index 373736a69..e59a9166f 100644 --- a/src/Test.UnitTests.Sarif/Processors/Log/RebaseUriStageTests.cs +++ b/src/Test.UnitTests.Sarif/Processors/Log/RebaseUriStageTests.cs @@ -29,7 +29,7 @@ public RebaseUriStageTests(ITestOutputHelper outputHelper) public void RewriteUri_RewritesAllFiles(int fileCount) { Random random = RandomSarifLogGenerator.GenerateRandomAndLog(this.output); - List logs = new List(); + var logs = new List(); for (int i = 0; i < fileCount; i++) { logs.Add(RandomSarifLogGenerator.GenerateSarifLogWithRuns(random, random.Next(10))); diff --git a/src/Test.UnitTests.Sarif/Processors/Log/SarifLogExtensionTests.cs b/src/Test.UnitTests.Sarif/Processors/Log/SarifLogExtensionTests.cs index 61c3d8886..243b130d2 100644 --- a/src/Test.UnitTests.Sarif/Processors/Log/SarifLogExtensionTests.cs +++ b/src/Test.UnitTests.Sarif/Processors/Log/SarifLogExtensionTests.cs @@ -27,8 +27,8 @@ public SarifLogExtensionTests(ITestOutputHelper testOutput) public void TestMerge_WorksAsExpected() { Random random = RandomSarifLogGenerator.GenerateRandomAndLog(this.output); - List logs = new List(); - List secondLogSet = new List(); + var logs = new List(); + var secondLogSet = new List(); int count = random.Next(10) + 1; for (int i = 0; i < count; i++) { @@ -46,7 +46,7 @@ public void TestMerge_WorksAsExpected() public void RebaseUri_WorksAsExpected() { Random random = RandomSarifLogGenerator.GenerateRandomAndLog(this.output); - List logs = new List(); + var logs = new List(); int count = random.Next(10) + 1; for (int i = 0; i < count; i++) @@ -107,7 +107,7 @@ public void AbsoluteUri_ReversesRebasedURIs() public void RebaseUri_WorksAsExpectedWithRebaseRelativeUris() { Random random = RandomSarifLogGenerator.GenerateRandomAndLog(this.output); - List logs = new List(); + var logs = new List(); int count = random.Next(10) + 1; for (int i = 0; i < count; i++) diff --git a/src/Test.UnitTests.Sarif/PropertiesDictionaryTests.cs b/src/Test.UnitTests.Sarif/PropertiesDictionaryTests.cs index 6d58afc04..848f118f0 100644 --- a/src/Test.UnitTests.Sarif/PropertiesDictionaryTests.cs +++ b/src/Test.UnitTests.Sarif/PropertiesDictionaryTests.cs @@ -137,7 +137,7 @@ public void PropertiesDictionary_ConcurrentReadAndWrite() Exception exception = Record.Exception(() => { - List taskList = new List(); + var taskList = new List(); for (int i = 0; i < 1000; i++) { diff --git a/src/Test.UnitTests.Sarif/Query/EvaluatorTests.cs b/src/Test.UnitTests.Sarif/Query/EvaluatorTests.cs index 9595c8c2e..aaf3288e4 100644 --- a/src/Test.UnitTests.Sarif/Query/EvaluatorTests.cs +++ b/src/Test.UnitTests.Sarif/Query/EvaluatorTests.cs @@ -50,10 +50,10 @@ public class EvaluatorTests [Fact] public void ComplexEvaluator_Basics() { - List set = new List(); + var set = new List(); for (int i = 0; i < 100; ++i) { - SampleItem item = new SampleItem(); + var item = new SampleItem(); item.ID = i; item.State = (State)(i % 4); item.Uri = i.ToString(); @@ -145,7 +145,7 @@ private static void Run(int expectedCount, string query, IList values, Fun IExpressionEvaluator evaluator = expression.ToEvaluator(converter); // Ask for matches from the array - BitArray matches = new BitArray(values.Count); + var matches = new BitArray(values.Count); evaluator.Evaluate(values, matches); // Verify the match count is correct diff --git a/src/Test.UnitTests.Sarif/Query/StringSliceTests.cs b/src/Test.UnitTests.Sarif/Query/StringSliceTests.cs index 09530292f..5f9b4ac59 100644 --- a/src/Test.UnitTests.Sarif/Query/StringSliceTests.cs +++ b/src/Test.UnitTests.Sarif/Query/StringSliceTests.cs @@ -34,7 +34,7 @@ private void EmptyChecks(StringSlice empty) Assert.Equal(-1, empty.CompareTo(":")); // AppendTo shouldn't do anything - StringBuilder result = new StringBuilder(); + var result = new StringBuilder(); empty.AppendTo(result); Assert.Equal(0, result.Length); @@ -62,7 +62,7 @@ public void StringSlice_Basics() Assert.Equal(3, slice.Length); Assert.Equal(0, slice.CompareTo("the")); - StringBuilder result = new StringBuilder(); + var result = new StringBuilder(); slice.AppendTo(result); Assert.Equal(3, result.Length); Assert.Equal("the", result.ToString()); diff --git a/src/Test.UnitTests.Sarif/Readers/DeferredCollectionsTests.cs b/src/Test.UnitTests.Sarif/Readers/DeferredCollectionsTests.cs index e2f884170..605069a29 100644 --- a/src/Test.UnitTests.Sarif/Readers/DeferredCollectionsTests.cs +++ b/src/Test.UnitTests.Sarif/Readers/DeferredCollectionsTests.cs @@ -66,12 +66,12 @@ public void EndToEnd_SingleLineJson_WithStream() private static void CompareReadNormalToReadDeferredWithStreams(string filePath) { LogModelSampleBuilder.EnsureSamplesBuilt(); - JsonSerializer serializer = new JsonSerializer(); + var serializer = new JsonSerializer(); Log expected; Log actual; // Read normally (JsonSerializer -> JsonTextReader -> StreamReader) - using (JsonTextReader reader = new JsonTextReader(new StreamReader(filePath))) + using (var reader = new JsonTextReader(new StreamReader(filePath))) { expected = serializer.Deserialize(reader); Assert.IsType>(expected.CodeContexts); @@ -82,7 +82,7 @@ private static void CompareReadNormalToReadDeferredWithStreams(string filePath) serializer.ContractResolver = new LogModelDeferredContractResolver(); Stream contents = File.OpenRead(filePath); - using (JsonPositionedTextReader reader = JsonPositionedTextReader.FromStream(contents)) + using (var reader = JsonPositionedTextReader.FromStream(contents)) { actual = serializer.Deserialize(reader); Assert.IsType>(actual.CodeContexts); @@ -98,7 +98,7 @@ private static void CompareReadNormalToReadDeferredLogs(Log expected, Log actual AssertEqual(expected, actual); // DeferredList Code Coverage - CopyTo() - LogMessage[] messages = new LogMessage[actual.Messages.Count + 1]; + var messages = new LogMessage[actual.Messages.Count + 1]; actual.Messages.CopyTo(messages, 1); if (actual.Messages.Count > 0) { Assert.Equal(actual.Messages[0], messages[1]); } @@ -125,12 +125,12 @@ private static void CompareReadNormalToReadDeferredLogs(Log expected, Log actual } // CopyTo - KeyValuePair[] contexts = new KeyValuePair[actual.CodeContexts.Count + 1]; + var contexts = new KeyValuePair[actual.CodeContexts.Count + 1]; actual.CodeContexts.CopyTo(contexts, 1); if (actual.CodeContexts.Count > 0) { Assert.Equal(actual.CodeContexts.First(), contexts[1]); } // Enumeration - Dictionary contextsCopy = new Dictionary(); + var contextsCopy = new Dictionary(); foreach (KeyValuePair pair in actual.CodeContexts) { contextsCopy[pair.Key] = pair.Value; diff --git a/src/Test.UnitTests.Sarif/Readers/LineMappingStreamReaderTests.cs b/src/Test.UnitTests.Sarif/Readers/LineMappingStreamReaderTests.cs index 920caf666..1d523b9f4 100644 --- a/src/Test.UnitTests.Sarif/Readers/LineMappingStreamReaderTests.cs +++ b/src/Test.UnitTests.Sarif/Readers/LineMappingStreamReaderTests.cs @@ -25,7 +25,7 @@ public void LineMappingStreamReader_Basics() // Read it all and find all newline indices byte[] content = File.ReadAllBytes(path); - List newlines = new List(); + var newlines = new List(); newlines.Add(-1); newlines.Add(-1); @@ -40,7 +40,7 @@ public void LineMappingStreamReader_Basics() char[] buffer = new char[1024]; int nextLine = 1; long bytesRead = 0; - using (LineMappingStreamReader reader = new LineMappingStreamReader(File.OpenRead(path))) + using (var reader = new LineMappingStreamReader(File.OpenRead(path))) { while (true) { @@ -71,14 +71,14 @@ public void LineMappingStreamReader_WithJsonReader() { LogModelSampleBuilder.EnsureSamplesBuilt(); string filePath = LogModelSampleBuilder.SampleLogPath; - JsonSerializer serializer = new JsonSerializer(); + var serializer = new JsonSerializer(); // Open a stream to read objects individually using (Stream seekingStream = File.OpenRead(filePath)) { // Read the Json with a LineMappingStreamReader - using (LineMappingStreamReader streamReader = new LineMappingStreamReader(File.OpenRead(filePath))) - using (JsonTextReader jsonReader = new JsonTextReader(streamReader)) + using (var streamReader = new LineMappingStreamReader(File.OpenRead(filePath))) + using (var jsonReader = new JsonTextReader(streamReader)) { // Get into the top object jsonReader.Read(); @@ -91,7 +91,7 @@ public void LineMappingStreamReader_WithJsonReader() long position = streamReader.LineAndCharToOffset(jsonReader.LineNumber, jsonReader.LinePosition); // Create an object from the original stream - JObject expected = (JObject)serializer.Deserialize(jsonReader); + var expected = (JObject)serializer.Deserialize(jsonReader); // Compare to one we get by seeking to the calculated byte offset JObject actual = ReadAtPosition(serializer, seekingStream, position); @@ -107,7 +107,7 @@ public void LineMappingStreamReader_WithJsonReader() private static JObject ReadAtPosition(JsonSerializer serializer, Stream stream, long position) { stream.Seek(position, SeekOrigin.Begin); - using (JsonTextReader jsonReader = new JsonTextReader(new StreamReader(stream))) + using (var jsonReader = new JsonTextReader(new StreamReader(stream))) { jsonReader.CloseInput = false; return (JObject)serializer.Deserialize(jsonReader); @@ -121,8 +121,8 @@ public void LineMappingStreamReader_BomHandling() File.WriteAllBytes(sampleFilePath, s_extractor.GetResourceBytes("elfie-arriba-utf8-bom.sarif")); // Read the Json with a LineMappingStreamReader - using (LineMappingStreamReader streamReader = new LineMappingStreamReader(File.OpenRead(sampleFilePath))) - using (JsonTextReader jsonReader = new JsonTextReader(streamReader)) + using (var streamReader = new LineMappingStreamReader(File.OpenRead(sampleFilePath))) + using (var jsonReader = new JsonTextReader(streamReader)) { // Get into the top object jsonReader.Read(); diff --git a/src/Test.UnitTests.Sarif/Readers/NonDisposingDelegatingStreamTests.cs b/src/Test.UnitTests.Sarif/Readers/NonDisposingDelegatingStreamTests.cs index 163982388..e1a016098 100644 --- a/src/Test.UnitTests.Sarif/Readers/NonDisposingDelegatingStreamTests.cs +++ b/src/Test.UnitTests.Sarif/Readers/NonDisposingDelegatingStreamTests.cs @@ -8,8 +8,6 @@ using FluentAssertions; -using Microsoft.CodeAnalysis.Test.UnitTests.Sarif.Readers; - using Xunit; namespace Microsoft.CodeAnalysis.Sarif.Readers diff --git a/src/Test.UnitTests.Sarif/Readers/PropertyBagConverterTests.cs b/src/Test.UnitTests.Sarif/Readers/PropertyBagConverterTests.cs index 27a85f190..85664fd5f 100644 --- a/src/Test.UnitTests.Sarif/Readers/PropertyBagConverterTests.cs +++ b/src/Test.UnitTests.Sarif/Readers/PropertyBagConverterTests.cs @@ -94,7 +94,7 @@ public void PropertyBagConverter_RoundTripsGuidProperty() PerformRoundTrip(); - Guid expectedGuid = new Guid("{12345678-90ab-cdef-1234-567890abcdef}"); + var expectedGuid = new Guid("{12345678-90ab-cdef-1234-567890abcdef}"); _inputObject.GetProperty("g").Should().Be(expectedGuid); _roundTrippedObject.GetProperty("g").Should().Be(expectedGuid); @@ -107,7 +107,7 @@ public void PropertyBagConverter_RoundTripsGuidPropertyWithoutBraces() PerformRoundTrip(); - Guid expectedGuid = new Guid("{12345678-90ab-cdef-1234-567890abcdef}"); + var expectedGuid = new Guid("{12345678-90ab-cdef-1234-567890abcdef}"); _inputObject.GetProperty("g").Should().Be(expectedGuid); _roundTrippedObject.GetProperty("g").Should().Be(expectedGuid); diff --git a/src/Test.UnitTests.Sarif/Readers/SampleModel/LogModel.cs b/src/Test.UnitTests.Sarif/Readers/SampleModel/LogModel.cs index 4c27af78f..26e459ba6 100644 --- a/src/Test.UnitTests.Sarif/Readers/SampleModel/LogModel.cs +++ b/src/Test.UnitTests.Sarif/Readers/SampleModel/LogModel.cs @@ -35,8 +35,11 @@ public override int GetHashCode() public override bool Equals(object obj) { - LogMessage other = obj as LogMessage; - if (other == null) return false; + var other = obj as LogMessage; + if (other == null) + { + return false; + } return this.Level == other.Level && this.WhenUtc == other.WhenUtc @@ -70,8 +73,11 @@ public override int GetHashCode() public override bool Equals(object obj) { - CodeContext other = obj as CodeContext; - if (other == null) return false; + var other = obj as CodeContext; + if (other == null) + { + return false; + } return this.ParentContextID == other.ParentContextID && this.Name == other.Name @@ -160,12 +166,12 @@ public static Log Build() public static Log Build(Random r, DateTime whenUtc, int messageCount) { - Log log = new Log(); + var log = new Log(); log.ID = Guid.NewGuid(); log.StartTimeUtc = whenUtc; log.ApplicationContext = "CodeCrawler.exe"; - Dictionary contexts = new Dictionary(); + var contexts = new Dictionary(); contexts["app"] = new CodeContext() { Name = "CodeCrawler.exe", Type = CodeContextType.Binary }; contexts["scan"] = new CodeContext() { Name = "CodeCrawler.Scanners", Type = CodeContextType.Namespace, ParentContextID = "app" }; contexts["file"] = new CodeContext() { Name = "FileScanner", Type = CodeContextType.Class, ParentContextID = "scan" }; @@ -173,14 +179,14 @@ public static Log Build(Random r, DateTime whenUtc, int messageCount) contexts["load"] = new CodeContext() { Name = "LoadRules()", Type = CodeContextType.Method, ParentContextID = "run" }; log.CodeContexts = contexts; - List codeContextKeys = new List(contexts.Keys); + var codeContextKeys = new List(contexts.Keys); log.Messages = new List(); for (int i = 0; i < messageCount; ++i) { whenUtc = whenUtc.AddMilliseconds(r.Next(10)); - LogMessage m = new LogMessage() + var m = new LogMessage() { Level = (Level)r.Next(5), WhenUtc = whenUtc, @@ -199,13 +205,16 @@ public static void EnsureSamplesBuilt() lock (_locker) { Log log = null; - JsonSerializer serializer = new JsonSerializer(); + var serializer = new JsonSerializer(); if (!File.Exists(SampleLogPath)) { - if (log == null) log = Build(); + if (log == null) + { + log = Build(); + } - using (JsonTextWriter writer = new JsonTextWriter(new StreamWriter(File.OpenWrite(SampleLogPath)))) + using (var writer = new JsonTextWriter(new StreamWriter(File.OpenWrite(SampleLogPath)))) { serializer.Formatting = Formatting.Indented; serializer.Serialize(writer, log); @@ -214,9 +223,12 @@ public static void EnsureSamplesBuilt() if (!File.Exists(SampleOneLinePath)) { - if (log == null) log = Build(); + if (log == null) + { + log = Build(); + } - using (JsonTextWriter writer = new JsonTextWriter(new StreamWriter(File.OpenWrite(SampleOneLinePath)))) + using (var writer = new JsonTextWriter(new StreamWriter(File.OpenWrite(SampleOneLinePath)))) { serializer.Formatting = Formatting.None; serializer.Serialize(writer, log); @@ -225,7 +237,10 @@ public static void EnsureSamplesBuilt() if (!File.Exists(SampleNoCodeContextsPath)) { - if (log == null) log = Build(); + if (log == null) + { + log = Build(); + } log.CodeContexts.Clear(); foreach (LogMessage m in log.Messages) @@ -233,7 +248,7 @@ public static void EnsureSamplesBuilt() m.CodeContextID = null; } - using (JsonTextWriter writer = new JsonTextWriter(new StreamWriter(File.OpenWrite(SampleNoCodeContextsPath)))) + using (var writer = new JsonTextWriter(new StreamWriter(File.OpenWrite(SampleNoCodeContextsPath)))) { serializer.Formatting = Formatting.None; serializer.Serialize(writer, log); @@ -242,12 +257,15 @@ public static void EnsureSamplesBuilt() if (!File.Exists(SampleEmptyPath)) { - if (log == null) log = Build(); + if (log == null) + { + log = Build(); + } log.CodeContexts.Clear(); log.Messages.Clear(); - using (JsonTextWriter writer = new JsonTextWriter(new StreamWriter(File.OpenWrite(SampleEmptyPath)))) + using (var writer = new JsonTextWriter(new StreamWriter(File.OpenWrite(SampleEmptyPath)))) { serializer.Formatting = Formatting.Indented; serializer.Serialize(writer, log); diff --git a/src/Test.UnitTests.Sarif/RuntimeConditionsTests.cs b/src/Test.UnitTests.Sarif/RuntimeConditionsTests.cs index 6dce42442..46c70e2a8 100644 --- a/src/Test.UnitTests.Sarif/RuntimeConditionsTests.cs +++ b/src/Test.UnitTests.Sarif/RuntimeConditionsTests.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; - using FluentAssertions; using FluentAssertions.Execution; diff --git a/src/Test.UnitTests.Sarif/SarifUtilitiesTests.cs b/src/Test.UnitTests.Sarif/SarifUtilitiesTests.cs index 24d7c5676..3918761c9 100644 --- a/src/Test.UnitTests.Sarif/SarifUtilitiesTests.cs +++ b/src/Test.UnitTests.Sarif/SarifUtilitiesTests.cs @@ -6,8 +6,6 @@ using System.Collections.ObjectModel; using System.Text; -using Castle.DynamicProxy.Generators; - using FluentAssertions; using Xunit; diff --git a/src/Test.UnitTests.Sarif/UriConverterTests.cs b/src/Test.UnitTests.Sarif/UriConverterTests.cs index 39af3d8a3..38fe475c8 100644 --- a/src/Test.UnitTests.Sarif/UriConverterTests.cs +++ b/src/Test.UnitTests.Sarif/UriConverterTests.cs @@ -100,7 +100,7 @@ public void Uri_RoundTripping_Direct() // Framework Bug: Uris with certain escaped unreserved characters are doubled by Uri.TryCreate // https://github.com/dotnet/runtime/issues/36288 - StringBuilder errors = new StringBuilder(); + var errors = new StringBuilder(); SarifUriRoundTrip("http://github.com/Microsoft/sarif-sdk", errors); SarifUriRoundTrip("src/Program.cs", errors); @@ -141,7 +141,7 @@ public void Uri_RoundTripping_Direct() private void SarifUriRoundTrip(string value, StringBuilder errors) { // Put in a class with a Uri using the Sarif 'UriConverter' - SingleUri sample = new SingleUri(); + var sample = new SingleUri(); sample.Uri = new Uri(value, UriKind.RelativeOrAbsolute); // Serialize and Deserialize @@ -155,9 +155,9 @@ private void DirectUriRoundTrip(string value, StringBuilder errors) { // .NET can return the string used to construct. // This seems like the safest way to roundtrip reliably - Uri original = new Uri(value, UriKind.RelativeOrAbsolute); + var original = new Uri(value, UriKind.RelativeOrAbsolute); string serialized = original.OriginalString; - Uri result = new Uri(serialized, UriKind.RelativeOrAbsolute); + var result = new Uri(serialized, UriKind.RelativeOrAbsolute); if (!result.Equals(original)) { errors.AppendLine(value); } } diff --git a/src/Test.UnitTests.Sarif/Visitors/MakeUriAbsoluteVisitorTest.cs b/src/Test.UnitTests.Sarif/Visitors/MakeUriAbsoluteVisitorTest.cs index a072e1753..08d66f5e7 100644 --- a/src/Test.UnitTests.Sarif/Visitors/MakeUriAbsoluteVisitorTest.cs +++ b/src/Test.UnitTests.Sarif/Visitors/MakeUriAbsoluteVisitorTest.cs @@ -43,10 +43,10 @@ public void MakeUriAbsoluteVisitor_VisitPhysicalLocation_SetsAbsoluteURI() }; // Initializes visitor with run in order to retrieve uri base id mappings - MakeUrisAbsoluteVisitor visitor = new MakeUrisAbsoluteVisitor(); + var visitor = new MakeUrisAbsoluteVisitor(); visitor.VisitRun(run); - PhysicalLocation location = new PhysicalLocation() { ArtifactLocation = new ArtifactLocation { UriBaseId = "%TEST%", Uri = new Uri("src/file.cs", UriKind.Relative) } }; + var location = new PhysicalLocation() { ArtifactLocation = new ArtifactLocation { UriBaseId = "%TEST%", Uri = new Uri("src/file.cs", UriKind.Relative) } }; PhysicalLocation newLocation = visitor.VisitPhysicalLocation(location); newLocation.ArtifactLocation.UriBaseId.Should().BeNull(); @@ -65,10 +65,10 @@ public void MakeUriAbsoluteVisitor_VisitPhysicalLocation_DoesNotSetUriIfNotInDic }; // Initializes visitor with run in order to retrieve uri base id mappings - MakeUrisAbsoluteVisitor visitor = new MakeUrisAbsoluteVisitor(); + var visitor = new MakeUrisAbsoluteVisitor(); visitor.VisitRun(run); - PhysicalLocation location = new PhysicalLocation() { ArtifactLocation = new ArtifactLocation { UriBaseId = "%TEST2%", Uri = new Uri("src/file.cs", UriKind.Relative) } }; + var location = new PhysicalLocation() { ArtifactLocation = new ArtifactLocation { UriBaseId = "%TEST2%", Uri = new Uri("src/file.cs", UriKind.Relative) } }; PhysicalLocation newLocation = visitor.VisitPhysicalLocation(location); newLocation.ArtifactLocation.UriBaseId.Should().NotBeNull(); @@ -87,10 +87,10 @@ public void MakeUriAbsoluteVisitor_VisitPhysicalLocation_DoesNotSetUriIfBaseIsNo }; // Initializes visitor with run in order to retrieve uri base id mappings - MakeUrisAbsoluteVisitor visitor = new MakeUrisAbsoluteVisitor(); + var visitor = new MakeUrisAbsoluteVisitor(); visitor.VisitRun(run); - PhysicalLocation location = new PhysicalLocation() { ArtifactLocation = new ArtifactLocation { UriBaseId = null, Uri = new Uri("src/file.cs", UriKind.Relative) } }; + var location = new PhysicalLocation() { ArtifactLocation = new ArtifactLocation { UriBaseId = null, Uri = new Uri("src/file.cs", UriKind.Relative) } }; PhysicalLocation newLocation = visitor.VisitPhysicalLocation(location); newLocation.ArtifactLocation.UriBaseId.Should().BeNull(); @@ -106,7 +106,7 @@ public void MakeUriAbsoluteVisitor_VisitRun_SetsAbsoluteUriForAllApplicableFiles ["%TEST2%"] = new ArtifactLocation { Uri = new Uri(@"D:\bld\out\") } }); - MakeUrisAbsoluteVisitor visitor = new MakeUrisAbsoluteVisitor(); + var visitor = new MakeUrisAbsoluteVisitor(); Run newRun = visitor.VisitRun(run); @@ -125,7 +125,7 @@ public void MakeUriAbsoluteVisitor_VisitRun_SetsAbsoluteUriForAllApplicableFiles [Fact] public void MakeUriAbsoluteVisitor_VisitRun_DoesNotSetAbsoluteUriIfNotApplicable() { - Dictionary uriMapping = new Dictionary() + var uriMapping = new Dictionary() { ["%TEST3%"] = new ArtifactLocation { Uri = new Uri(@"C:\srcroot\") }, ["%TEST4%"] = new ArtifactLocation { Uri = new Uri(@"D:\bld\out\") } @@ -134,7 +134,7 @@ public void MakeUriAbsoluteVisitor_VisitRun_DoesNotSetAbsoluteUriIfNotApplicable Run expectedRun = GenerateRunForTest(uriMapping); Run actualRun = expectedRun.DeepClone(); - MakeUrisAbsoluteVisitor visitor = new MakeUrisAbsoluteVisitor(); + var visitor = new MakeUrisAbsoluteVisitor(); Run newRun = visitor.VisitRun(actualRun); expectedRun.ValueEquals(actualRun).Should().BeTrue(); @@ -153,9 +153,9 @@ public void MakeUriAbsoluteVisitor_VisitSarifLog_MultipleRunsWithDifferentProper ["%TEST1%"] = new ArtifactLocation { Uri = new Uri(@"C:\src\abc\") }, ["%TEST2%"] = new ArtifactLocation { Uri = new Uri(@"D:\bld\123\") } }); - MakeUrisAbsoluteVisitor visitor = new MakeUrisAbsoluteVisitor(); + var visitor = new MakeUrisAbsoluteVisitor(); - SarifLog log = new SarifLog() { Runs = new Run[] { runA, runB } }; + var log = new SarifLog() { Runs = new Run[] { runA, runB } }; SarifLog newLog = visitor.VisitSarifLog(log); // Validate @@ -184,8 +184,8 @@ public void MakeUriAbsoluteVisitor_CombineUriFunctionsProperly() [Fact] public void MakeUriAbsoluteVisitor_CombineUriValidatesArgumentsProperly() { - Uri absoluteUri = new Uri("https://absolute.example.com", UriKind.Absolute); - Uri relativeUri = new Uri("relative/someResource", UriKind.Relative); + var absoluteUri = new Uri("https://absolute.example.com", UriKind.Absolute); + var relativeUri = new Uri("relative/someResource", UriKind.Relative); // First, ensure that our test data succeeds when used properly MakeUrisAbsoluteVisitor.CombineUris( diff --git a/src/Test.UnitTests.Sarif/Visitors/PerRunPerRuleSplittingVisitorTests.cs b/src/Test.UnitTests.Sarif/Visitors/PerRunPerRuleSplittingVisitorTests.cs index 28b166d29..665a9b696 100644 --- a/src/Test.UnitTests.Sarif/Visitors/PerRunPerRuleSplittingVisitorTests.cs +++ b/src/Test.UnitTests.Sarif/Visitors/PerRunPerRuleSplittingVisitorTests.cs @@ -70,7 +70,7 @@ public void PerRunPerRuleSplittingVisitor_RetainsRulesForUnbaselinedAndNewResult { SarifLog sarifLog = GetTestSarifLog(); - HashSet ruleIds = new HashSet(); + var ruleIds = new HashSet(); for (int i = 0; i < sarifLog.Runs[0].Results.Count; i++) { diff --git a/src/Test.UnitTests.Sarif/Visitors/RebaseUriVisitorTests.cs b/src/Test.UnitTests.Sarif/Visitors/RebaseUriVisitorTests.cs index c6f73f712..71d650b68 100644 --- a/src/Test.UnitTests.Sarif/Visitors/RebaseUriVisitorTests.cs +++ b/src/Test.UnitTests.Sarif/Visitors/RebaseUriVisitorTests.cs @@ -31,16 +31,16 @@ public RebaseUriVisitorTests(ITestOutputHelper testOutput) [InlineData("SRCROOT", @"C:\blddir\out\test.dll", @"C:\blddir\src\", null)] public void RebaseUriVisitor_VisitPhysicalLocation_RebasesUri_WhenAppropriate(string rootName, string locationUriStr, string baseUriStr, string expectedDifference) { - Uri locationUri = new Uri(locationUriStr); - Uri baseUri = new Uri(baseUriStr); - PhysicalLocation location = new PhysicalLocation + var locationUri = new Uri(locationUriStr); + var baseUri = new Uri(baseUriStr); + var location = new PhysicalLocation { ArtifactLocation = new ArtifactLocation { Uri = locationUri } }; - RebaseUriVisitor visitor = new RebaseUriVisitor(rootName, baseUri); + var visitor = new RebaseUriVisitor(rootName, baseUri); PhysicalLocation newLocation = visitor.VisitPhysicalLocation(location); if (!string.IsNullOrEmpty(expectedDifference)) @@ -58,7 +58,7 @@ public void RebaseUriVisitor_VisitPhysicalLocation_RebasesUri_WhenAppropriate(st [Fact] public void RebaseUriVisitor_VisitPhysicalLocation_DoesNotRebaseAlreadyRebasedUri() { - PhysicalLocation location = new PhysicalLocation + var location = new PhysicalLocation { ArtifactLocation = new ArtifactLocation { @@ -66,7 +66,7 @@ public void RebaseUriVisitor_VisitPhysicalLocation_DoesNotRebaseAlreadyRebasedUr UriBaseId = "BLDROOT" } }; - RebaseUriVisitor rebaseUriVisitor = new RebaseUriVisitor("SRCROOT", new Uri(@"C:\bld\src\")); + var rebaseUriVisitor = new RebaseUriVisitor("SRCROOT", new Uri(@"C:\bld\src\")); rebaseUriVisitor.VisitPhysicalLocation(location).Should().BeEquivalentTo(location, because: "we should not rebase a URI multiple times."); } @@ -74,14 +74,14 @@ public void RebaseUriVisitor_VisitPhysicalLocation_DoesNotRebaseAlreadyRebasedUr [Fact] public void RebaseUriVisitor_VisitPhysicalLocation_DoesNothingIfIndexReferenceToRunArtifacts() { - PhysicalLocation location = new PhysicalLocation + var location = new PhysicalLocation { ArtifactLocation = new ArtifactLocation { Index = 23 } }; - RebaseUriVisitor rebaseUriVisitor = new RebaseUriVisitor("SRCROOT", new Uri(@"C:\bld\src\")); + var rebaseUriVisitor = new RebaseUriVisitor("SRCROOT", new Uri(@"C:\bld\src\")); rebaseUriVisitor.VisitPhysicalLocation(location).Should().BeEquivalentTo(location, because: "artifact location does not need to be rebased."); } @@ -93,7 +93,7 @@ public void RebaseUriVisitor_VisitRun_AddsBaseUriDictionaryWhenNotPresent() Run oldRun = RandomSarifLogGenerator.GenerateRandomRun(random); - RebaseUriVisitor rebaseUriVisitor = new RebaseUriVisitor("SRCROOT", new Uri(@"C:\src\root")); + var rebaseUriVisitor = new RebaseUriVisitor("SRCROOT", new Uri(@"C:\src\root")); Run newRun = rebaseUriVisitor.VisitRun(oldRun); @@ -107,15 +107,15 @@ public void RebaseUriVisitor_VisitRun_AddsBaseUriDictionaryWhenNotPresent() public void RebaseUriVisitor_VisitRun_UpdatesBaseUriDictionaryWhenPresent() { const string srcRoot = "SRCROOT"; - Uri srcRootUri = new Uri(@"C:\src\root"); + var srcRootUri = new Uri(@"C:\src\root"); const string bldRoot = "BLDROOT"; - Uri bldRootUri = new Uri(@"C:\bld\root"); + var bldRootUri = new Uri(@"C:\bld\root"); Random random = RandomSarifLogGenerator.GenerateRandomAndLog(this.output); Run oldRun = RandomSarifLogGenerator.GenerateRandomRun(random); - RebaseUriVisitor rebaseUriVisitor = new RebaseUriVisitor(srcRoot, srcRootUri); + var rebaseUriVisitor = new RebaseUriVisitor(srcRoot, srcRootUri); var oldDictionary = new Dictionary() { { bldRoot, new ArtifactLocation { Uri = bldRootUri } } }; oldRun.OriginalUriBaseIds = oldDictionary; @@ -137,7 +137,7 @@ public void RebaseUriVisitor_VisitRun_CorrectlyPatchesFileDictionaryKeys() Run oldRun = RandomSarifLogGenerator.GenerateRandomRun(random); - RebaseUriVisitor rebaseUriVisitor = new RebaseUriVisitor("SRCROOT", new Uri(@"C:\src\")); + var rebaseUriVisitor = new RebaseUriVisitor("SRCROOT", new Uri(@"C:\src\")); Run newRun = rebaseUriVisitor.VisitRun(oldRun); @@ -153,7 +153,7 @@ public void RebaseUriVisitor_VisitRun_DoesNotPatchFileDictionaryKeysWhenNotABase Run oldRun = RandomSarifLogGenerator.GenerateRandomRun(random); - RebaseUriVisitor rebaseUriVisitor = new RebaseUriVisitor("SRCROOT", new Uri(@"C:\bld\")); + var rebaseUriVisitor = new RebaseUriVisitor("SRCROOT", new Uri(@"C:\bld\")); Run newRun = rebaseUriVisitor.VisitRun(oldRun); @@ -166,12 +166,12 @@ public void RebaseUriVisitor_VisitRun_DoesNotPatchFileDictionaryKeysWhenNotABase [Fact] public void RebaseUriVisitor_VisitFileData_PatchesParentUri() { - Uri rootfileUri = new Uri("file://C:/src/root/blah.zip"); - Uri childFileUri = new Uri("/stuff.doc", UriKind.RelativeOrAbsolute); + var rootfileUri = new Uri("file://C:/src/root/blah.zip"); + var childFileUri = new Uri("/stuff.doc", UriKind.RelativeOrAbsolute); - Artifact rootFileData = new Artifact() { Location = new ArtifactLocation { Uri = rootfileUri }, ParentIndex = -1 }; - Artifact childFileData = new Artifact() { Location = new ArtifactLocation { Uri = childFileUri }, ParentIndex = 0 }; - Run run = new Run + var rootFileData = new Artifact() { Location = new ArtifactLocation { Uri = rootfileUri }, ParentIndex = -1 }; + var childFileData = new Artifact() { Location = new ArtifactLocation { Uri = childFileUri }, ParentIndex = 0 }; + var run = new Run { Artifacts = new List { @@ -183,8 +183,8 @@ public void RebaseUriVisitor_VisitFileData_PatchesParentUri() }; string srcroot = "SRCROOT"; - Uri rootUriBaseId = new Uri(@"C:\src\root\"); - RebaseUriVisitor rebaseUriVisitor = new RebaseUriVisitor(srcroot, rootUriBaseId); + var rootUriBaseId = new Uri(@"C:\src\root\"); + var rebaseUriVisitor = new RebaseUriVisitor(srcroot, rootUriBaseId); run = rebaseUriVisitor.VisitRun(run); diff --git a/src/Test.UnitTests.Sarif/Visitors/RemoveOptionalDataVisitorTests.cs b/src/Test.UnitTests.Sarif/Visitors/RemoveOptionalDataVisitorTests.cs index e82241a4c..eee32fc9b 100644 --- a/src/Test.UnitTests.Sarif/Visitors/RemoveOptionalDataVisitorTests.cs +++ b/src/Test.UnitTests.Sarif/Visitors/RemoveOptionalDataVisitorTests.cs @@ -34,7 +34,7 @@ public void RemoveGuids() { SarifLog log = _sampleLog.DeepClone(); - RemoveOptionalDataVisitor v = new RemoveOptionalDataVisitor(OptionallyEmittedData.None); + var v = new RemoveOptionalDataVisitor(OptionallyEmittedData.None); v.Visit(log); log.Runs[0].Results[0].Guid.Should().NotBeNull(); diff --git a/src/Test.UnitTests.Sarif/Visitors/RunMergingVisitorTests.cs b/src/Test.UnitTests.Sarif/Visitors/RunMergingVisitorTests.cs index c696e0e27..9a0e28cba 100644 --- a/src/Test.UnitTests.Sarif/Visitors/RunMergingVisitorTests.cs +++ b/src/Test.UnitTests.Sarif/Visitors/RunMergingVisitorTests.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; using FluentAssertions; @@ -484,7 +483,7 @@ public void RunMergingVisitor_WhenCurrentRunIsNull_ShouldThrowException() } }; - RunMergingVisitor currentVisitor = new RunMergingVisitor(); + var currentVisitor = new RunMergingVisitor(); currentVisitor.Visit(baselineRun); currentVisitor.CurrentRun = currentRun; diff --git a/src/Test.UnitTests.Sarif/Visitors/SortingVisitorTests.cs b/src/Test.UnitTests.Sarif/Visitors/SortingVisitorTests.cs index 294005d12..a74ee31e6 100644 --- a/src/Test.UnitTests.Sarif/Visitors/SortingVisitorTests.cs +++ b/src/Test.UnitTests.Sarif/Visitors/SortingVisitorTests.cs @@ -11,7 +11,6 @@ using Microsoft.CodeAnalysis.Sarif; using Microsoft.CodeAnalysis.Sarif.Visitors; -using Microsoft.CodeAnalysis.Test.Utilities.Sarif; using Newtonsoft.Json; diff --git a/src/Test.UnitTests.Sarif/Writers/BaseLoggerTestConcrete.cs b/src/Test.UnitTests.Sarif/Writers/BaseLoggerTestConcrete.cs index f681f7b05..2fa013865 100644 --- a/src/Test.UnitTests.Sarif/Writers/BaseLoggerTestConcrete.cs +++ b/src/Test.UnitTests.Sarif/Writers/BaseLoggerTestConcrete.cs @@ -1,11 +1,6 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Text; - using Microsoft.CodeAnalysis.Sarif; using Microsoft.CodeAnalysis.Sarif.Writers; diff --git a/src/Test.UnitTests.Sarif/Writers/CachingLoggerTests.cs b/src/Test.UnitTests.Sarif/Writers/CachingLoggerTests.cs index 04c5086aa..bf4753f11 100644 --- a/src/Test.UnitTests.Sarif/Writers/CachingLoggerTests.cs +++ b/src/Test.UnitTests.Sarif/Writers/CachingLoggerTests.cs @@ -26,7 +26,7 @@ public void CachingLogger_EmitNotificationsCorrectly() } }; - TestAnalyzeOptions testAnalyzeOptions = new TestAnalyzeOptions(); + var testAnalyzeOptions = new TestAnalyzeOptions(); var logger = new CachingLogger(testAnalyzeOptions.FailureLevels, testAnalyzeOptions.ResultKinds); logger.LogConfigurationNotification(notification); @@ -42,7 +42,7 @@ public void CachingLogger_EmitResultsCorrectlyBasedOnRules() Result result01 = GenerateResult(); ReportingDescriptor rule01 = GenerateRule(); - TestAnalyzeOptions testAnalyzeOptions = new TestAnalyzeOptions(); + var testAnalyzeOptions = new TestAnalyzeOptions(); var logger = new CachingLogger(testAnalyzeOptions.FailureLevels, testAnalyzeOptions.ResultKinds); @@ -75,7 +75,7 @@ public void CachingLogger_ShouldEmitCorrectlyWhenResultContainsSubId() Result result01 = GenerateResult(); ReportingDescriptor rule01 = GenerateRule(); - TestAnalyzeOptions testAnalyzeOptions = new TestAnalyzeOptions(); + var testAnalyzeOptions = new TestAnalyzeOptions(); var logger = new CachingLogger(testAnalyzeOptions.FailureLevels, testAnalyzeOptions.ResultKinds); @@ -104,7 +104,7 @@ private static Result GenerateResult() string message = Guid.NewGuid().ToString(); string uriText = Guid.NewGuid().ToString(); - Uri uri = new Uri(uriText, UriKind.RelativeOrAbsolute); + var uri = new Uri(uriText, UriKind.RelativeOrAbsolute); return new Result { diff --git a/src/Test.UnitTests.Sarif/Writers/SarifConsolidatorTests.cs b/src/Test.UnitTests.Sarif/Writers/SarifConsolidatorTests.cs index b75a5f6a7..75af51b12 100644 --- a/src/Test.UnitTests.Sarif/Writers/SarifConsolidatorTests.cs +++ b/src/Test.UnitTests.Sarif/Writers/SarifConsolidatorTests.cs @@ -74,7 +74,7 @@ public class SarifConsolidatorTests [Fact] public void SarifConsolidator_Nulls() { - SarifConsolidator consolidator = new SarifConsolidator(new Run()); + var consolidator = new SarifConsolidator(new Run()); // Null objects handled gracefully (so callers can pass properties which may or may not be set) consolidator.Trim((Region)null); @@ -90,11 +90,11 @@ public void SarifConsolidator_Nulls() [Fact] public void SarifConsolidator_Region() { - SarifConsolidator consolidator = new SarifConsolidator(new Run()); + var consolidator = new SarifConsolidator(new Run()); // If line information, offsets removed. If EndLine == StartLine, EndLine removed - Region r = new Region(SampleRegion); - Region rExpected = new Region(SampleRegionTrimmed); + var r = new Region(SampleRegion); + var rExpected = new Region(SampleRegionTrimmed); consolidator.Trim(r); Assert.True(Region.ValueComparer.Equals(SampleRegionTrimmed, r)); @@ -118,7 +118,7 @@ public void SarifConsolidator_Region() Assert.Equal(1024, r.ByteOffset); Assert.True(Region.ValueComparer.Equals(rExpected, r)); - Region everythingRegion = new Region() { StartLine = 10, StartColumn = 12, EndLine = 13, EndColumn = 15, ByteOffset = 100, ByteLength = 10, CharOffset = 100, CharLength = 10 }; + var everythingRegion = new Region() { StartLine = 10, StartColumn = 12, EndLine = 13, EndColumn = 15, ByteOffset = 100, ByteLength = 10, CharOffset = 100, CharLength = 10 }; // Trim to ByteOffset only r = new Region(everythingRegion); @@ -146,11 +146,11 @@ public void SarifConsolidator_Region() [Fact] public void SarifConsolidator_ArtifactLocation() { - SarifConsolidator consolidator = new SarifConsolidator(new Run()); + var consolidator = new SarifConsolidator(new Run()); // If Index set, remove Uri and UriBaseId - ArtifactLocation a = new ArtifactLocation(SampleArtifactLocation); - ArtifactLocation aExpected = new ArtifactLocation(SampleArtifactLocationTrimmed); + var a = new ArtifactLocation(SampleArtifactLocation); + var aExpected = new ArtifactLocation(SampleArtifactLocationTrimmed); consolidator.Trim(a); Assert.Null(a.Uri); @@ -168,11 +168,11 @@ public void SarifConsolidator_ArtifactLocation() [Fact] public void SarifConsolidator_Location() { - SarifConsolidator consolidator = new SarifConsolidator(new Run()); + var consolidator = new SarifConsolidator(new Run()); // Id removed, inner components trimmed - Location loc = new Location(SampleLocation); - Location locExpected = new Location(SampleLocationTrimmed); + var loc = new Location(SampleLocation); + var locExpected = new Location(SampleLocationTrimmed); consolidator.Trim(loc); Assert.True(Location.ValueComparer.Equals(locExpected, loc)); @@ -181,10 +181,10 @@ public void SarifConsolidator_Location() [Fact] public void SarifConsolidator_Locations() { - SarifConsolidator consolidator = new SarifConsolidator(new Run()); + var consolidator = new SarifConsolidator(new Run()); // Duplicate locations removed, inner Locations trimmed - List locations = new List() + var locations = new List() { new Location(SampleLocation), new Location(SampleLocation) @@ -199,10 +199,10 @@ public void SarifConsolidator_Locations() [Fact] public void SarifConsolidator_LogicalLocations() { - SarifConsolidator consolidator = new SarifConsolidator(new Run()); + var consolidator = new SarifConsolidator(new Run()); // Duplicate locations removed, inner Locations trimmed - List locations = new List() + var locations = new List() { new LogicalLocation(SampleLogicalLocation), new LogicalLocation(SampleLogicalLocation) @@ -216,10 +216,10 @@ public void SarifConsolidator_LogicalLocations() [Fact] public void SarifConsolidator_ThreadFlow() { - ThreadFlowLocation tfl = new ThreadFlowLocation() { ExecutionOrder = 3, Module = "Loader" }; + var tfl = new ThreadFlowLocation() { ExecutionOrder = 3, Module = "Loader" }; // Pre-add a ThreadFlowLocation to the Run, to ensure it is considered for re-use - Run run = new Run() + var run = new Run() { ThreadFlowLocations = new List() { @@ -227,10 +227,10 @@ public void SarifConsolidator_ThreadFlow() } }; - SarifConsolidator consolidator = new SarifConsolidator(run); + var consolidator = new SarifConsolidator(run); // ThreadFlow: Unique Locations added to run; only indices on ThreadFlow - ThreadFlow flow = new ThreadFlow() + var flow = new ThreadFlow() { Locations = new List() { @@ -253,10 +253,10 @@ public void SarifConsolidator_ThreadFlow() [Fact] public void SarifConsolidator_Result() { - Run run = new Run(); - SarifConsolidator consolidator = new SarifConsolidator(run); + var run = new Run(); + var consolidator = new SarifConsolidator(run); - Result result = new Result() + var result = new Result() { Message = new Message() { Text = new string('Z', 500) }, Locations = new List() @@ -277,7 +277,7 @@ public void SarifConsolidator_Result() WebResponse = new WebResponse() }; - Result expected = new Result(result) + var expected = new Result(result) { Locations = new List() { diff --git a/src/Test.UnitTests.Sarif/Writers/SarifLoggerTests.cs b/src/Test.UnitTests.Sarif/Writers/SarifLoggerTests.cs index d2f861ed0..af7bf4a8a 100644 --- a/src/Test.UnitTests.Sarif/Writers/SarifLoggerTests.cs +++ b/src/Test.UnitTests.Sarif/Writers/SarifLoggerTests.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Collections.Immutable; using System.Diagnostics; using System.IO; using System.Linq; @@ -50,7 +49,7 @@ private static void StreamOwnershipHelper(bool closeWriterOnDispose) { string expectedText = s_extractor.GetResourceText("SimpleExample.sarif"); - MemoryStream memoryStream = new MemoryStream(); + var memoryStream = new MemoryStream(); var streamWriter = new StreamWriter(memoryStream); using (var logger = new SarifLogger(streamWriter, @@ -256,10 +255,10 @@ public void SarifLogger_WritesRunProperties() var versionControlUri = new Uri("https://www.github.com/contoso/contoso"); var versionControlDetails = new VersionControlDetails() { RepositoryUri = versionControlUri, AsOfTimeUtc = DateTime.UtcNow }; string originalUriBaseIdKey = "testBase"; - Uri originalUriBaseIdValue = new Uri("https://sourceserver.contoso.com"); + var originalUriBaseIdValue = new Uri("https://sourceserver.contoso.com"); var originalUriBaseIds = new Dictionary() { { originalUriBaseIdKey, new ArtifactLocation { Uri = originalUriBaseIdValue } } }; string defaultEncoding = "UTF7"; - List redactionTokens = new List { "[MY_REDACTION_TOKEN]" }; + var redactionTokens = new List { "[MY_REDACTION_TOKEN]" }; var sb = new StringBuilder(); @@ -877,7 +876,7 @@ public void SarifLogger_AcceptsOverrideOfDefaultEncoding() private void LogSimpleResult(SarifLogger sarifLogger) { - ReportingDescriptor rule = new ReportingDescriptor { Id = "RuleId" }; + var rule = new ReportingDescriptor { Id = "RuleId" }; sarifLogger.Log(rule, CreateSimpleResult(rule), null); } @@ -1158,7 +1157,7 @@ private static void VerifySarifLogHonoredKindAndLevel(FailureLevelSet desiredFai private static SarifLog CreateSarifLog(List allKindLevelCombinations, ReportingDescriptor rule, FailureLevelSet desiredFailureLevels, ResultKindSet desiredResultKinds) { - StringBuilder stringBuilder = new StringBuilder(); + var stringBuilder = new StringBuilder(); using (var stringWriter = new StringWriter(stringBuilder)) { diff --git a/src/Test.UnitTests.WorkItems/FilingClientFactoryTests.cs b/src/Test.UnitTests.WorkItems/FilingClientFactoryTests.cs index a1f3a9256..cb6a2fa97 100644 --- a/src/Test.UnitTests.WorkItems/FilingClientFactoryTests.cs +++ b/src/Test.UnitTests.WorkItems/FilingClientFactoryTests.cs @@ -23,7 +23,7 @@ public void CreateFilingTarget_ThrowsIfUriIsNull [Fact] public void CreateFilingTarget_ThrowsIfUriPatternIsNotRecognized() { - Uri hostUri = new Uri("https://www.example.com/myOrg/myProject"); + var hostUri = new Uri("https://www.example.com/myOrg/myProject"); Action action = () => FilingClientFactory.Create(hostUri); @@ -33,7 +33,7 @@ public void CreateFilingTarget_ThrowsIfUriPatternIsNotRecognized() [Fact] public void CreateFilingTarget_ThrowsIfUriIncludesAdditionalPathSegments() { - Uri hostUri = new Uri("https://github.com/myOrg/myProject/issues"); + var hostUri = new Uri("https://github.com/myOrg/myProject/issues"); Action action = () => FilingClientFactory.Create(hostUri); @@ -43,7 +43,7 @@ public void CreateFilingTarget_ThrowsIfUriIncludesAdditionalPathSegments() [Fact] public void CreateFilingTarget_CreatesGitHubFilingTarget() { - Uri hostUri = new Uri("https://github.com/myOrg/myProject"); + var hostUri = new Uri("https://github.com/myOrg/myProject"); FilingClient filingTarget = FilingClientFactory.Create(hostUri); @@ -55,7 +55,7 @@ public void CreateFilingTarget_CreatesGitHubFilingTarget() [Fact] public void CreateFilingTarget_CreatesAzureDevOpsFilingTarget() { - Uri hostUri = new Uri("https://dev.azure.com/myOrg/myProject"); + var hostUri = new Uri("https://dev.azure.com/myOrg/myProject"); FilingClient filingTarget = FilingClientFactory.Create(hostUri); @@ -67,7 +67,7 @@ public void CreateFilingTarget_CreatesAzureDevOpsFilingTarget() [Fact] public void CreateFilingTarget_CreatesLegacyAzureDevOpsFilingTarget() { - Uri hostUri = new Uri("https://myorg.visualstudio.com/myProject"); + var hostUri = new Uri("https://myorg.visualstudio.com/myProject"); FilingClient filingTarget = FilingClientFactory.Create(hostUri); diff --git a/src/Test.UnitTests.WorkItems/Logging/ApplicationInsightsTelemetryInitializerTests.cs b/src/Test.UnitTests.WorkItems/Logging/ApplicationInsightsTelemetryInitializerTests.cs index 61085f234..ede2df3bd 100644 --- a/src/Test.UnitTests.WorkItems/Logging/ApplicationInsightsTelemetryInitializerTests.cs +++ b/src/Test.UnitTests.WorkItems/Logging/ApplicationInsightsTelemetryInitializerTests.cs @@ -6,7 +6,6 @@ using FluentAssertions; using Microsoft.ApplicationInsights.DataContracts; -using Microsoft.TeamFoundation; using Xunit; @@ -17,7 +16,7 @@ public class ApplicationInsightsTelemetryInitializerTests [Fact] public void CreateFilingTarget_ThrowsIfTelemetryIsNull() { - ApplicationInsightsTelemetryInitializer initializer = new ApplicationInsightsTelemetryInitializer(); + var initializer = new ApplicationInsightsTelemetryInitializer(); Action action = () => initializer.Initialize(null); action.Should().Throw(); @@ -26,8 +25,8 @@ public void CreateFilingTarget_ThrowsIfTelemetryIsNull() [Fact] public void CreateFilingTarget_OperationIdIsSet() { - TraceTelemetry telemetry = new TraceTelemetry(); - ApplicationInsightsTelemetryInitializer initializer = new ApplicationInsightsTelemetryInitializer(); + var telemetry = new TraceTelemetry(); + var initializer = new ApplicationInsightsTelemetryInitializer(); telemetry.Context.Operation.Id.Should().BeNull(); @@ -37,7 +36,7 @@ public void CreateFilingTarget_OperationIdIsSet() Guid.TryParse(telemetry.Context.Operation.Id, out Guid temp).Should().BeTrue(); // A second telemetry item should be assigned the same operation_Id - TraceTelemetry telemetry2 = new TraceTelemetry(); + var telemetry2 = new TraceTelemetry(); initializer.Initialize(telemetry2); telemetry.Context.Operation.Id.Should().Be(telemetry2.Context.Operation.Id); } @@ -46,8 +45,8 @@ public void CreateFilingTarget_OperationIdIsSet() public void CreateFilingTarget_OperationIdIsDifferent() { // After initialization, the operation_Id should be set to a GUID. - TraceTelemetry telemetry = new TraceTelemetry(); - ApplicationInsightsTelemetryInitializer initializer = new ApplicationInsightsTelemetryInitializer(); + var telemetry = new TraceTelemetry(); + var initializer = new ApplicationInsightsTelemetryInitializer(); telemetry.Context.Operation.Id.Should().BeNull(); initializer.Initialize(telemetry); @@ -55,8 +54,8 @@ public void CreateFilingTarget_OperationIdIsDifferent() Guid.TryParse(telemetry.Context.Operation.Id, out Guid temp).Should().BeTrue(); // A second telemetry item using a different Initializer should be assigned a different operation_Id - TraceTelemetry telemetry2 = new TraceTelemetry(); - ApplicationInsightsTelemetryInitializer initializer2 = new ApplicationInsightsTelemetryInitializer(); + var telemetry2 = new TraceTelemetry(); + var initializer2 = new ApplicationInsightsTelemetryInitializer(); telemetry2.Context.Operation.Id.Should().BeNull(); initializer2.Initialize(telemetry2); @@ -69,8 +68,8 @@ public void CreateFilingTarget_OperationIdIsDifferent() [Fact] public void CreateFilingTarget_OperationIdShouldNotBeOverwritten() { - TraceTelemetry telemetry = new TraceTelemetry(); - ApplicationInsightsTelemetryInitializer initializer = new ApplicationInsightsTelemetryInitializer(); + var telemetry = new TraceTelemetry(); + var initializer = new ApplicationInsightsTelemetryInitializer(); const string operationId = "abcd"; telemetry.Context.Operation.Id = operationId; diff --git a/src/Test.UnitTests.WorkItems/Logging/MetricsLogValuesTests.cs b/src/Test.UnitTests.WorkItems/Logging/MetricsLogValuesTests.cs index 504af9b01..272349054 100644 --- a/src/Test.UnitTests.WorkItems/Logging/MetricsLogValuesTests.cs +++ b/src/Test.UnitTests.WorkItems/Logging/MetricsLogValuesTests.cs @@ -7,9 +7,7 @@ using FluentAssertions; -using Microsoft.ApplicationInsights.DataContracts; using Microsoft.Extensions.Logging; -using Microsoft.TeamFoundation; using Xunit; @@ -21,7 +19,7 @@ public class MetricsLogValuesTests public void MetricsLogValues_ThrowsIfNullOrEmptyDictionary() { string message = "message"; - EventId eventId = new EventId(1); + var eventId = new EventId(1); Action action = () => new MetricsLogValues(message, eventId, null); action.Should().Throw(); @@ -34,12 +32,12 @@ public void MetricsLogValues_ThrowsIfNullOrEmptyDictionary() public void MetricsLogValues_ToStringPreference() { string message = "Original"; - EventId eventId = new EventId(1); - Dictionary customDimensions = new Dictionary(); + var eventId = new EventId(1); + var customDimensions = new Dictionary(); customDimensions.Add("EventId", eventId.Id); // Prefer original message if it's provided - MetricsLogValues values = new MetricsLogValues(message, eventId, customDimensions); + var values = new MetricsLogValues(message, eventId, customDimensions); values.ToString().Should().Be(message); // Next prefer the eventId if it's provided @@ -52,13 +50,13 @@ public void MetricsLogValues_ToStringPreference() public void MetricsLogValues_ContainsAllCustomDimensions() { string message = "Original"; - EventId eventId = new EventId(1); - Dictionary customDimensions = new Dictionary(); + var eventId = new EventId(1); + var customDimensions = new Dictionary(); customDimensions.Add("One", 1); customDimensions.Add("Two", 2); customDimensions.Add("Three", 3); - MetricsLogValues values = new MetricsLogValues(message, eventId, customDimensions); + var values = new MetricsLogValues(message, eventId, customDimensions); values.Count.Should().Be(customDimensions.Count); @@ -72,14 +70,14 @@ public void MetricsLogValues_ContainsAllCustomDimensions() public void MetricsLogValues_NullOrEmptyAllCustomDimensions() { string message = "Original"; - EventId eventId = new EventId(1); - Dictionary customDimensions = new Dictionary(); + var eventId = new EventId(1); + var customDimensions = new Dictionary(); customDimensions.Add("Empty", ""); customDimensions.Add("Null1", null); customDimensions.Add("Null2", null); customDimensions.Add("HasValue", 3); - MetricsLogValues values = new MetricsLogValues(message, eventId, customDimensions); + var values = new MetricsLogValues(message, eventId, customDimensions); values.Count.Should().Be(customDimensions.Count); diff --git a/src/Test.Utilities.Sarif/RandomSarifLogGenerator.cs b/src/Test.Utilities.Sarif/RandomSarifLogGenerator.cs index ccaf9e695..83277170b 100644 --- a/src/Test.Utilities.Sarif/RandomSarifLogGenerator.cs +++ b/src/Test.Utilities.Sarif/RandomSarifLogGenerator.cs @@ -22,7 +22,7 @@ public static Random GenerateRandomAndLog(ITestOutputHelper output, [CallerMembe // Slightly roundabout. We want to randomly test this, but we also want to be able to repeat this if the test fails. int randomSeed = seed ?? (new Random()).Next(); - Random random = new Random(randomSeed); + var random = new Random(randomSeed); output.WriteLine($"TestName: {testName} has seed {randomSeed}"); @@ -31,7 +31,7 @@ public static Random GenerateRandomAndLog(ITestOutputHelper output, [CallerMembe public static SarifLog GenerateSarifLogWithRuns(Random randomGen, int runCount, int? resultCount = null, RandomDataFields dataFields = RandomDataFields.None) { - SarifLog log = new SarifLog(); + var log = new SarifLog(); if (runCount > 0) { @@ -48,8 +48,8 @@ public static SarifLog GenerateSarifLogWithRuns(Random randomGen, int runCount, public static Run GenerateRandomRun(Random random, int? resultCount = null, RandomDataFields dataFields = RandomDataFields.None) { - List ruleIds = new List() { "TEST001", "TEST002", "TEST003", "TEST004", "TEST005" }; - List filePaths = GenerateFakeFiles(GeneratorBaseUri, random.Next(20) + 1).Select(a => new Uri(a)).ToList(); + var ruleIds = new List() { "TEST001", "TEST002", "TEST003", "TEST004", "TEST005" }; + var filePaths = GenerateFakeFiles(GeneratorBaseUri, random.Next(20) + 1).Select(a => new Uri(a)).ToList(); int results = resultCount == null ? random.Next(100) : (int)resultCount; return new Run() @@ -72,7 +72,7 @@ public static Run GenerateRandomRunWithoutDuplicateIssues(Random random, IEquali { Run run = GenerateRandomRun(random, resultCount); IList resultList = run.Results; - List uniqueResults = new List(); + var uniqueResults = new List(); foreach (Result result in resultList) { if (!uniqueResults.Contains(result, comparer)) @@ -86,7 +86,7 @@ public static Run GenerateRandomRunWithoutDuplicateIssues(Random random, IEquali public static IEnumerable GenerateFakeFiles(string baseAddress, int count) { - List results = new List(); + var results = new List(); for (int i = 0; i < count; i++) { @@ -98,7 +98,7 @@ public static IEnumerable GenerateFakeFiles(string baseAddress, int coun public static IList GenerateFakeResults(Random random, List ruleIds, List filePaths, int resultCount, RandomDataFields dataFields = RandomDataFields.None) { - List results = new List(); + var results = new List(); for (int i = 0; i < resultCount; i++) { int fileIndex = random.Next(filePaths.Count); diff --git a/src/Test.Utilities.Sarif/TestAssetResourceExtractor.cs b/src/Test.Utilities.Sarif/TestAssetResourceExtractor.cs index cb8348c59..f94af869d 100644 --- a/src/Test.Utilities.Sarif/TestAssetResourceExtractor.cs +++ b/src/Test.Utilities.Sarif/TestAssetResourceExtractor.cs @@ -67,7 +67,7 @@ public string GetResourceText(string resourcePath) ValidateStream(resourcePath, fallbackResourcePath, stream); - using StreamReader reader = new StreamReader(stream); + using var reader = new StreamReader(stream); return reader.ReadToEnd(); } @@ -108,7 +108,7 @@ private Stream GetManifestResourceStream(string resourcePath, out string fallbac private byte[] GetBytesFromStream(Stream stream) { - using MemoryStream memoryStream = new MemoryStream(); + using var memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return memoryStream.ToArray(); } diff --git a/src/WorkItems/Logging/AssemblyExtensions.cs b/src/WorkItems/Logging/AssemblyExtensions.cs index 7ffeb8c75..b60bb0578 100644 --- a/src/WorkItems/Logging/AssemblyExtensions.cs +++ b/src/WorkItems/Logging/AssemblyExtensions.cs @@ -20,8 +20,8 @@ public static class AssemblyExtensions customDimensions ??= new Dictionary(); AssemblyName assemblyName = assembly.GetName(); - FileInfo assemblyFileInfo = new FileInfo(assembly.Location); - Dictionary assemblyMetrics = new Dictionary(customDimensions); + var assemblyFileInfo = new FileInfo(assembly.Location); + var assemblyMetrics = new Dictionary(customDimensions); assemblyMetrics.Add("Name", assemblyName.Name); assemblyMetrics.Add("Version", assemblyName.Version); assemblyMetrics.Add("CreationTime", assemblyFileInfo.CreationTime.ToUniversalTime().ToString()); diff --git a/src/WorkItems/WorkItems.csproj b/src/WorkItems/WorkItems.csproj index 33f7ce29c..59e1bc488 100644 --- a/src/WorkItems/WorkItems.csproj +++ b/src/WorkItems/WorkItems.csproj @@ -13,6 +13,7 @@ Classes for filing work items in either GitHub or AzureDevOps. WorkItems Microsoft.WorkItems + true diff --git a/src/build.props b/src/build.props index 3f03201f8..886602f6f 100644 --- a/src/build.props +++ b/src/build.props @@ -3,7 +3,7 @@ 8.0 - true + true From 29d527f5c43aff617d9ae72ad762c1c4b89252c7 Mon Sep 17 00:00:00 2001 From: Shaopeng <81775155+shaopeng-gh@users.noreply.github.com> Date: Wed, 21 Aug 2024 06:23:48 -0700 Subject: [PATCH 12/19] Fix FileNotFoundException when a file name or directory path contains URL-encoded characters (#2819) * Use OriginalString instead of LocalPath in EnumeratedArtifact * FIx OriginalString * Add tests * Add release Note --- ReleaseHistory.md | 1 + src/Sarif/EnumeratedArtifact.cs | 8 ++++---- .../Sdk/AnalyzeCommandBaseTests.cs | 17 ++++++++++++++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/ReleaseHistory.md b/ReleaseHistory.md index 621f326ba..3cdc33d7a 100644 --- a/ReleaseHistory.md +++ b/ReleaseHistory.md @@ -6,6 +6,7 @@ * DEP: Update `Azure.Identity` reference from 1.10.2 to 1.11.0 in `WorkItems` and `Sarif.Multitool.Library` to resolve [CVE-2024-29992](https://github.com/advisories/GHSA-wvxc-855f-jvrv). * BUG: Resolve process hangs when a file path is provided with a wildcard, but without a `-r` (recurse) flag during the multi-threaded analysis file enumeration phase. * BUG: Fix error `ERR997.NoValidAnalysisTargets` when scanning symbolic link files. +* BUG: Fix `ERR999.UnhandledEngineException: System.IO.FileNotFoundException: Could not find file` when a file name or directory path contains URL-encoded characters. ## **v4.5.4 [Sdk](https://www.nuget.org/packages/Sarif.Sdk/v4.5.4) | [Driver](https://www.nuget.org/packages/Sarif.Driver/v4.5.4) | [Converters](https://www.nuget.org/packages/Sarif.Converters/v4.5.4) | [Multitool](https://www.nuget.org/packages/Sarif.Multitool/v4.5.4) | [Multitool Library](https://www.nuget.org/packages/Sarif.Multitool.Library/v4.5.4) * BUG: Fix incorrect base class in rule ADO2012. diff --git a/src/Sarif/EnumeratedArtifact.cs b/src/Sarif/EnumeratedArtifact.cs index ca37ce503..3eb59283c 100644 --- a/src/Sarif/EnumeratedArtifact.cs +++ b/src/Sarif/EnumeratedArtifact.cs @@ -86,7 +86,7 @@ public byte[] Bytes } // This is our client-side, disk-based file retrieval case. - this.Stream = FileSystem.FileOpenRead(Uri.LocalPath); + this.Stream = FileSystem.FileOpenRead(Uri.OriginalString); } RetrieveDataFromStream(); @@ -164,9 +164,9 @@ public long? SizeInBytes } else if (Uri != null && Uri.IsAbsoluteUri && Uri.IsFile) { - this.sizeInBytes = FileSystem.IsSymbolicLink(Uri.LocalPath) - ? (long)FileSystem.FileStreamLength(Uri.LocalPath) - : (long)FileSystem.FileInfoLength(Uri.LocalPath); + this.sizeInBytes = FileSystem.IsSymbolicLink(Uri.OriginalString) + ? (long)FileSystem.FileStreamLength(Uri.OriginalString) + : (long)FileSystem.FileInfoLength(Uri.OriginalString); } else if (this.Contents != null) { diff --git a/src/Test.UnitTests.Sarif.Driver/Sdk/AnalyzeCommandBaseTests.cs b/src/Test.UnitTests.Sarif.Driver/Sdk/AnalyzeCommandBaseTests.cs index 1d37641ad..3f810208b 100644 --- a/src/Test.UnitTests.Sarif.Driver/Sdk/AnalyzeCommandBaseTests.cs +++ b/src/Test.UnitTests.Sarif.Driver/Sdk/AnalyzeCommandBaseTests.cs @@ -831,14 +831,25 @@ public Run AnalyzeFile(string fileName, } [Fact] - [Trait(TestTraits.WindowsOnly, "true")] public void AnalyzeCommand_EncodedPaths() { var logger = new MemoryStreamSarifLogger(dataToInsert: OptionallyEmittedData.Hashes); var command = new TestMultithreadedAnalyzeCommand(); - var uri = new Uri("/new folder/0%1%20%.txt", UriKind.Relative); + string path = @"C:\new folder\repro%2DCopy2.txt"; + var uri = new Uri(path, UriKind.Absolute); + + string content = "foo foo"; + var mockFileSystem = new Mock(); + mockFileSystem.Setup(x => x.IsSymbolicLink(path)).Returns(false); + mockFileSystem.Setup(x => x.FileStreamLength(path)).Returns(content.Length); + mockFileSystem.Setup(x => x.FileInfoLength(path)).Returns(content.Length); + mockFileSystem.Setup(x => x.FileReadAllText(path)).Returns(content); + mockFileSystem.Setup(x => x.FileOpenRead(path)).Returns(new MemoryStream(Encoding.UTF8.GetBytes(content))); - var target = new EnumeratedArtifact(FileSystem.Instance) { Uri = uri, Contents = "foo foo" }; + var target = new EnumeratedArtifact(mockFileSystem.Object) + { + Uri = uri + }; var options = new TestAnalyzeOptions { From 0b634af8ab33598ebd2e78eec565748ed0e89b16 Mon Sep 17 00:00:00 2001 From: "Michael C. Fanning" Date: Fri, 18 Oct 2024 10:30:59 -0700 Subject: [PATCH 13/19] Update Azure.Identity to 1.12.1 (#2823) DEP: Update Azure.Identity reference from 1.10.2 to 1.12.1 in WorkItems and Sarif.Multitool.Library to resolve CVE-2024-29992 and other CVEs. --- ReleaseHistory.md | 2 +- src/Sarif.Multitool.Library/Sarif.Multitool.Library.csproj | 2 +- src/WorkItems/WorkItems.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ReleaseHistory.md b/ReleaseHistory.md index 3cdc33d7a..24258db63 100644 --- a/ReleaseHistory.md +++ b/ReleaseHistory.md @@ -3,7 +3,7 @@ ## UNRELEASED * BRK: Remove defunct and unsupported `kusto` command in `Sarif.Multitool`. * DEP: Remove dependency on `Microsoft.Azure.Kusto.Data`. -* DEP: Update `Azure.Identity` reference from 1.10.2 to 1.11.0 in `WorkItems` and `Sarif.Multitool.Library` to resolve [CVE-2024-29992](https://github.com/advisories/GHSA-wvxc-855f-jvrv). +* DEP: Update `Azure.Identity` reference from 1.10.2 to 1.12.1 in `WorkItems` and `Sarif.Multitool.Library` to resolve [CVE-2024-29992](https://github.com/advisories/GHSA-wvxc-855f-jvrv) and other CVEs. * BUG: Resolve process hangs when a file path is provided with a wildcard, but without a `-r` (recurse) flag during the multi-threaded analysis file enumeration phase. * BUG: Fix error `ERR997.NoValidAnalysisTargets` when scanning symbolic link files. * BUG: Fix `ERR999.UnhandledEngineException: System.IO.FileNotFoundException: Could not find file` when a file name or directory path contains URL-encoded characters. diff --git a/src/Sarif.Multitool.Library/Sarif.Multitool.Library.csproj b/src/Sarif.Multitool.Library/Sarif.Multitool.Library.csproj index 1398d093c..789f4847a 100644 --- a/src/Sarif.Multitool.Library/Sarif.Multitool.Library.csproj +++ b/src/Sarif.Multitool.Library/Sarif.Multitool.Library.csproj @@ -15,7 +15,7 @@ - + diff --git a/src/WorkItems/WorkItems.csproj b/src/WorkItems/WorkItems.csproj index 59e1bc488..c050a1edf 100644 --- a/src/WorkItems/WorkItems.csproj +++ b/src/WorkItems/WorkItems.csproj @@ -25,7 +25,7 @@ - + From 81e93974283a75f61a930ee980c564ea78b2fc58 Mon Sep 17 00:00:00 2001 From: Nick Guerrera Date: Fri, 18 Oct 2024 14:03:17 -0500 Subject: [PATCH 14/19] Update `Azure.Core` from 1.35.0 to 1.41.0 (#2824) Upgrading to Azure.Identity 1.12.1 to addressed one vulnerability but pulled in Azure.Core 1.40.0 that has another. Make an explicit direct reference to Azure.Core 1.41.0 to resolve. --- ReleaseHistory.md | 1 + src/Sarif.Multitool.Library/Sarif.Multitool.Library.csproj | 1 + src/WorkItems/WorkItems.csproj | 1 + 3 files changed, 3 insertions(+) diff --git a/ReleaseHistory.md b/ReleaseHistory.md index 24258db63..86f816cf6 100644 --- a/ReleaseHistory.md +++ b/ReleaseHistory.md @@ -4,6 +4,7 @@ * BRK: Remove defunct and unsupported `kusto` command in `Sarif.Multitool`. * DEP: Remove dependency on `Microsoft.Azure.Kusto.Data`. * DEP: Update `Azure.Identity` reference from 1.10.2 to 1.12.1 in `WorkItems` and `Sarif.Multitool.Library` to resolve [CVE-2024-29992](https://github.com/advisories/GHSA-wvxc-855f-jvrv) and other CVEs. +* DEP: Update `Azure.Core` from 1.35.0 to 1.41.0 to satisfy minimum requirement of `Azure.Identity` 1.12.1 that also has no vulnerabilities. * BUG: Resolve process hangs when a file path is provided with a wildcard, but without a `-r` (recurse) flag during the multi-threaded analysis file enumeration phase. * BUG: Fix error `ERR997.NoValidAnalysisTargets` when scanning symbolic link files. * BUG: Fix `ERR999.UnhandledEngineException: System.IO.FileNotFoundException: Could not find file` when a file name or directory path contains URL-encoded characters. diff --git a/src/Sarif.Multitool.Library/Sarif.Multitool.Library.csproj b/src/Sarif.Multitool.Library/Sarif.Multitool.Library.csproj index 789f4847a..17b0d56b7 100644 --- a/src/Sarif.Multitool.Library/Sarif.Multitool.Library.csproj +++ b/src/Sarif.Multitool.Library/Sarif.Multitool.Library.csproj @@ -16,6 +16,7 @@ + diff --git a/src/WorkItems/WorkItems.csproj b/src/WorkItems/WorkItems.csproj index c050a1edf..c2e15da96 100644 --- a/src/WorkItems/WorkItems.csproj +++ b/src/WorkItems/WorkItems.csproj @@ -26,6 +26,7 @@ + From ffe21ed7f7d484a9502e28181f5e195bf30b5e05 Mon Sep 17 00:00:00 2001 From: Matt Kotsenas Date: Thu, 24 Oct 2024 06:36:56 -0700 Subject: [PATCH 15/19] Add NuGet shield to README (#2802) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1068e7c76..3ee2b0730 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # sarif-sdk [![Build Status](https://dev.azure.com/mseng/1ES/_apis/build/status/microsoft.sarif-sdk?branchName=master)](https://dev.azure.com/mseng/1ES/_build/latest?definitionId=9978&branchName=main) +[![Nuget](https://img.shields.io/nuget/v/Sarif.Sdk)](https://nuget.org/packages/Sarif.Sdk) The SARIF SDK contains .NET code and supporting files for working with the Static Analysis Results Interchange Format (SARIF). For more information about SARIF, see the [SARIF Home Page](http://sarifweb.azurewebsites.net). You can read the [SARIF specification](https://rawgit.com/sarif-standard/sarif-spec/master/Static%20Analysis%20Results%20Interchange%20Format%20(SARIF).html), or file [issues](https://github.com/sarif-standard/sarif-spec/issues) in the [SARIF GitHub repo](https://github.com/sarif-standard/sarif-spec). From e842b693638ab928b4d20fa49eef3f69469d8900 Mon Sep 17 00:00:00 2001 From: Nick Guerrera Date: Thu, 24 Oct 2024 10:57:28 -0500 Subject: [PATCH 16/19] Add PR validation (#2826) --- .github/workflows/build-and-test.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/build-and-test.yml diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 000000000..c9548d08d --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,24 @@ +name: Build and Test + +on: + pull_request: + branches: [ "main" ] + +jobs: + build: + name: Build and Test + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + with: + # GitHelper unit test requires full clone, not the shallow default of GitHub Actions + fetch-depth: 0 + - name: Setup dotnet + uses: actions/setup-dotnet@v4 + with: + dotnet-version: '3.1.x' + - name: Show dotnet info + run: dotnet --info + - name: Build and Test + # NoFormat because there is a separate format check action + run: ./BuildAndTest.cmd -NoFormat From b85eccb8fd1b038e2afcddbc4c690f666d99f5c2 Mon Sep 17 00:00:00 2001 From: Nick Guerrera Date: Thu, 24 Oct 2024 11:02:32 -0500 Subject: [PATCH 17/19] Add nguerrera to CODEOWNERS (#2827) --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index fb804976f..3332ac0e0 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -2,4 +2,4 @@ # This file controls who is tagged for review for any given pull request. # For anything not explicitly taken by someone else: -* @michaelcfanning @suvamM @shaopeng-gh @scottoneil-ms @rwoll @yongyan-gh @LingZhou-gh @EasyRhinoMSFT @cfaucon +* @michaelcfanning @suvamM @shaopeng-gh @scottoneil-ms @rwoll @yongyan-gh @LingZhou-gh @EasyRhinoMSFT @cfaucon @nguerrera From 76d8b0b296e0426b157cb3afb12794d0a1eac338 Mon Sep 17 00:00:00 2001 From: Nick Guerrera Date: Thu, 24 Oct 2024 12:59:49 -0500 Subject: [PATCH 18/19] Build multitool for npm in PR validation (#2828) --- .github/workflows/build-and-test.yml | 2 +- .github/workflows/build-multitool-for-npm.yml | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-multitool-for-npm.yml diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index c9548d08d..04dcb2774 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -6,7 +6,7 @@ on: jobs: build: - name: Build and Test + name: Run runs-on: windows-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/build-multitool-for-npm.yml b/.github/workflows/build-multitool-for-npm.yml new file mode 100644 index 000000000..8347c3832 --- /dev/null +++ b/.github/workflows/build-multitool-for-npm.yml @@ -0,0 +1,14 @@ +name: Build Multitool for npm + +on: + pull_request: + branches: [ "main" ] + +jobs: + build: + name: Run + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - name: Build Multitool for npm + run: ./scripts/BuildMultitoolForNpm.ps1 From 1af5bc3e6dd61184f427e58bbe75261e399678e4 Mon Sep 17 00:00:00 2001 From: Nick Guerrera Date: Thu, 24 Oct 2024 13:41:34 -0500 Subject: [PATCH 19/19] Set ado-build.yml to trigger CI on merge to main (#2829) --- ado-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ado-build.yml b/ado-build.yml index 33b9d2c6d..b4da1ca5a 100644 --- a/ado-build.yml +++ b/ado-build.yml @@ -1,4 +1,4 @@ -pr: +trigger: - "main" jobs: