Resolve formatting errors, fix tests
This commit is contained in:
Родитель
7bb2afae00
Коммит
bb9945e5ac
|
@ -52,7 +52,6 @@
|
|||
<PackageVersion Include="yamldotnet" Version="15.1.6" />
|
||||
<PackageVersion Include="Faker.net" Version="2.0.163" />
|
||||
<PackageVersion Include="Valleysoft.DockerfileModel" Version="1.1.1" />
|
||||
|
||||
<!-- Fix security alerts -->
|
||||
<PackageVersion Include="System.Formats.Asn1" Version="6.0.1" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common;
|
||||
namespace Microsoft.ComponentDetection.Common;
|
||||
|
||||
public class Column
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common;
|
||||
namespace Microsoft.ComponentDetection.Common;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.ComponentDetection.Contracts.TypedComponent;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common;
|
||||
namespace Microsoft.ComponentDetection.Common;
|
||||
|
||||
using System.IO;
|
||||
using Microsoft.ComponentDetection.Contracts;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common;
|
||||
namespace Microsoft.ComponentDetection.Common;
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common;
|
||||
namespace Microsoft.ComponentDetection.Common;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
|
@ -172,12 +172,12 @@ public class ComponentRecorder : IComponentRecorder
|
|||
#if DEBUG
|
||||
if (detectedComponent.DependencyRoots is null || detectedComponent.DependencyRoots.Count == 0)
|
||||
{
|
||||
this.logger.LogWarning("Detector should not populate DetectedComponent.DependencyRoots!");
|
||||
this.logger?.LogWarning("Detector should not populate DetectedComponent.DependencyRoots!");
|
||||
}
|
||||
|
||||
if (detectedComponent.DevelopmentDependency.HasValue)
|
||||
{
|
||||
this.logger.LogWarning("Detector should not populate DetectedComponent.DevelopmentDependency!");
|
||||
this.logger?.LogWarning("Detector should not populate DetectedComponent.DevelopmentDependency!");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common;
|
||||
namespace Microsoft.ComponentDetection.Common;
|
||||
|
||||
using Microsoft.ComponentDetection.Contracts.BcdeModels;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common;
|
||||
namespace Microsoft.ComponentDetection.Common;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common;
|
||||
namespace Microsoft.ComponentDetection.Common;
|
||||
|
||||
public interface IConsoleWritingService
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common;
|
||||
namespace Microsoft.ComponentDetection.Common;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common;
|
||||
namespace Microsoft.ComponentDetection.Common;
|
||||
|
||||
using System.IO;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common;
|
||||
namespace Microsoft.ComponentDetection.Common;
|
||||
|
||||
public enum ScanType
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common;
|
||||
namespace Microsoft.ComponentDetection.Common;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry.Attributes;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry.Attributes;
|
||||
|
||||
using System;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry;
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry;
|
||||
|
||||
using Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
|
||||
using System;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
|
||||
using System;
|
||||
using Microsoft.ComponentDetection.Contracts;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
|
||||
public class DetectorExecutionTelemetryRecord : BaseDetectionTelemetryRecord
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
|
||||
public class GoGraphTelemetryRecord : BaseDetectionTelemetryRecord
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
|
||||
using System;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
|
||||
public class LinuxContainerDetectorImageDetectionFailed : BaseDetectionTelemetryRecord
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
|
||||
public class LinuxContainerDetectorMissingRepoNameAndTagRecord : BaseDetectionTelemetryRecord
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
|
||||
public class LinuxContainerDetectorMissingVersion : BaseDetectionTelemetryRecord
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
|
||||
public class LinuxContainerDetectorTimeout : BaseDetectionTelemetryRecord
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
|
||||
public class LinuxContainerDetectorUnsupportedOs : BaseDetectionTelemetryRecord
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
|
||||
public class LinuxScannerTelemetryRecord : BaseDetectionTelemetryRecord
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
|
||||
public class LoadComponentDetectorsTelemetryRecord : BaseDetectionTelemetryRecord
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
|
||||
using System;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
|
||||
public class PypiCacheTelemetryRecord : BaseDetectionTelemetryRecord
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
|
||||
using System.Net;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
|
||||
public class PypiMaxRetriesReachedTelemetryRecord : BaseDetectionTelemetryRecord
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
|
||||
using System.Net;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
|
||||
public class RustCrateDetectorTelemetryRecord : BaseDetectionTelemetryRecord
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry.Records;
|
||||
|
||||
public class RustGraphTelemetryRecord : BaseDetectionTelemetryRecord
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("Microsoft.ComponentDetection.Orchestrator")]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common.Telemetry;
|
||||
namespace Microsoft.ComponentDetection.Common.Telemetry;
|
||||
|
||||
public enum TelemetryMode
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Common;
|
||||
namespace Microsoft.ComponentDetection.Common;
|
||||
|
||||
public enum WarnOnAlertSeverity
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
|
||||
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
|
||||
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
|
||||
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
|
||||
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
|
||||
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
|
||||
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
|
||||
|
||||
/// <summary>Used to communicate Dependency Scope of Component.
|
||||
/// Currently only populated for Maven component.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
|
||||
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.ComponentDetection.Contracts.TypedComponent;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
|
||||
namespace Microsoft.ComponentDetection.Contracts.BcdeModels;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts;
|
||||
namespace Microsoft.ComponentDetection.Contracts;
|
||||
|
||||
/// <summary>Class of detector, the names of which are converted into categories for all default detectors.</summary>
|
||||
public enum DetectorClass
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts;
|
||||
namespace Microsoft.ComponentDetection.Contracts;
|
||||
|
||||
using System.IO;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts;
|
||||
namespace Microsoft.ComponentDetection.Contracts;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts;
|
||||
namespace Microsoft.ComponentDetection.Contracts;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts.Internal;
|
||||
namespace Microsoft.ComponentDetection.Contracts.Internal;
|
||||
|
||||
using System;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts.Internal;
|
||||
namespace Microsoft.ComponentDetection.Contracts.Internal;
|
||||
|
||||
public class ProcessRequest
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts;
|
||||
namespace Microsoft.ComponentDetection.Contracts;
|
||||
|
||||
/// <summary>
|
||||
/// Represents the configuration for the kill switch.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts;
|
||||
namespace Microsoft.ComponentDetection.Contracts;
|
||||
|
||||
/// <summary>Code used to communicate the state of a scan after completion.</summary>
|
||||
public enum ProcessingResultCode
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
|
||||
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
|
||||
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
|
||||
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
|
||||
|
||||
public class CondaComponent : TypedComponent
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
|
||||
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
|
||||
|
||||
using System;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
|
||||
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
|
||||
|
||||
using System;
|
||||
using PackageUrl;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
|
||||
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
|
||||
|
||||
using PackageUrl;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
|
||||
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
|
||||
|
||||
using Microsoft.ComponentDetection.Contracts.Internal;
|
||||
using PackageUrl;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
|
||||
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
|
||||
|
||||
using PackageUrl;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
|
||||
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using PackageUrl;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
|
||||
namespace Microsoft.ComponentDetection.Contracts.TypedComponent;
|
||||
|
||||
using System;
|
||||
|
||||
|
|
|
@ -29,11 +29,11 @@ public class PodComponentDetector : FileComponentDetector
|
|||
|
||||
public override string Id { get; } = "CocoaPods";
|
||||
|
||||
public override IEnumerable<string> Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.CocoaPods) };
|
||||
public override IEnumerable<string> Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.CocoaPods)];
|
||||
|
||||
public override IList<string> SearchPatterns { get; } = new List<string> { "Podfile.lock" };
|
||||
public override IList<string> SearchPatterns { get; } = ["Podfile.lock"];
|
||||
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes { get; } = new[] { ComponentType.Pod, ComponentType.Git };
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes { get; } = [ComponentType.Pod, ComponentType.Git];
|
||||
|
||||
public override int Version { get; } = 2;
|
||||
|
||||
|
@ -225,7 +225,7 @@ public class PodComponentDetector : FileComponentDetector
|
|||
foreach (var pod in podDependencies)
|
||||
{
|
||||
// Add all the dependencies to the map, without duplicates
|
||||
dependenciesMap.TryAdd(pod.Key, new HashSet<string>());
|
||||
dependenciesMap.TryAdd(pod.Key, []);
|
||||
|
||||
foreach (var dependency in pod.Value)
|
||||
{
|
||||
|
|
|
@ -26,13 +26,13 @@ public class ConanLockComponentDetector : FileComponentDetector, IDefaultOffComp
|
|||
|
||||
public override string Id => "ConanLock";
|
||||
|
||||
public override IList<string> SearchPatterns => new List<string> { "conan.lock" };
|
||||
public override IList<string> SearchPatterns => ["conan.lock"];
|
||||
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes => new[] { ComponentType.Conan };
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes => [ComponentType.Conan];
|
||||
|
||||
public override int Version { get; } = 1;
|
||||
|
||||
public override IEnumerable<string> Categories => new List<string> { "Conan" };
|
||||
public override IEnumerable<string> Categories => ["Conan"];
|
||||
|
||||
protected override async Task OnFileFoundAsync(ProcessRequest processRequest, IDictionary<string, string> detectorArgs, CancellationToken cancellationToken = default)
|
||||
{
|
||||
|
@ -52,9 +52,8 @@ public class ConanLockComponentDetector : FileComponentDetector, IDefaultOffComp
|
|||
var packagesDictionary = conanLock.GraphLock.Nodes;
|
||||
var explicitReferencedDependencies = new HashSet<string>();
|
||||
var developmentDependencies = new HashSet<string>();
|
||||
if (packagesDictionary.ContainsKey("0"))
|
||||
if (packagesDictionary.Remove("0", out var rootNode))
|
||||
{
|
||||
packagesDictionary.Remove("0", out var rootNode);
|
||||
if (rootNode?.Requires != null)
|
||||
{
|
||||
explicitReferencedDependencies = new HashSet<string>(rootNode.Requires);
|
||||
|
|
|
@ -28,7 +28,7 @@ public static class CondaDependencyResolver
|
|||
public static void UpdateDirectlyReferencedPackages(ISingleFileComponentRecorder singleFileComponentRecorder)
|
||||
=> singleFileComponentRecorder.GetDetectedComponents().Keys.ForEach(componentId =>
|
||||
{
|
||||
if (!singleFileComponentRecorder.DependencyGraph.GetAncestors(componentId).Any())
|
||||
if (singleFileComponentRecorder.DependencyGraph.GetAncestors(componentId).Count == 0)
|
||||
{
|
||||
singleFileComponentRecorder.RegisterUsage(
|
||||
singleFileComponentRecorder.GetComponent(componentId),
|
||||
|
@ -100,7 +100,7 @@ public static class CondaDependencyResolver
|
|||
/// <returns>A list of packages without dependencies.</returns>
|
||||
private static List<CondaPackage> GetPackages(CondaLock condaLock)
|
||||
=> condaLock?.Package == null
|
||||
? new List<CondaPackage>()
|
||||
? []
|
||||
: condaLock.Package;
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -27,13 +27,13 @@ public class CondaLockComponentDetector : FileComponentDetector, IDefaultOffComp
|
|||
|
||||
public override string Id => "CondaLock";
|
||||
|
||||
public override IList<string> SearchPatterns { get; } = new List<string> { "conda-lock.yml", "*.conda-lock.yml" };
|
||||
public override IList<string> SearchPatterns { get; } = ["conda-lock.yml", "*.conda-lock.yml"];
|
||||
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes => new[] { ComponentType.Conda, ComponentType.Pip };
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes => [ComponentType.Conda, ComponentType.Pip];
|
||||
|
||||
public override int Version { get; } = 2;
|
||||
|
||||
public override IEnumerable<string> Categories => new List<string> { "Python" };
|
||||
public override IEnumerable<string> Categories => ["Python"];
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override Task OnFileFoundAsync(ProcessRequest processRequest, IDictionary<string, string> detectorArgs, CancellationToken cancellationToken = default)
|
||||
|
|
|
@ -35,11 +35,11 @@ public class DockerfileComponentDetector : FileComponentDetector, IDefaultOffCom
|
|||
|
||||
public override string Id { get; } = "DockerReference";
|
||||
|
||||
public override IEnumerable<string> Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.DockerReference) };
|
||||
public override IEnumerable<string> Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.DockerReference)];
|
||||
|
||||
public override IList<string> SearchPatterns { get; } = new List<string> { "dockerfile", "dockerfile.*", "*.dockerfile" };
|
||||
public override IList<string> SearchPatterns { get; } = ["dockerfile", "dockerfile.*", "*.dockerfile"];
|
||||
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes { get; } = new[] { ComponentType.DockerReference };
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes { get; } = [ComponentType.DockerReference];
|
||||
|
||||
public override int Version => 1;
|
||||
|
||||
|
@ -55,7 +55,7 @@ public class DockerfileComponentDetector : FileComponentDetector, IDefaultOffCom
|
|||
string contents;
|
||||
using (var reader = new StreamReader(file.Stream))
|
||||
{
|
||||
contents = await reader.ReadToEndAsync();
|
||||
contents = await reader.ReadToEndAsync(cancellationToken);
|
||||
}
|
||||
|
||||
var stageNameMap = new Dictionary<string, string>();
|
||||
|
@ -69,7 +69,7 @@ public class DockerfileComponentDetector : FileComponentDetector, IDefaultOffCom
|
|||
|
||||
private Task ParseDockerFileAsync(string fileContents, string fileLocation, ISingleFileComponentRecorder singleFileComponentRecorder, Dictionary<string, string> stageNameMap)
|
||||
{
|
||||
var dockerfileModel = Valleysoft.DockerfileModel.Dockerfile.Parse(fileContents);
|
||||
var dockerfileModel = Dockerfile.Parse(fileContents);
|
||||
var instructions = dockerfileModel.Items;
|
||||
foreach (var instruction in instructions)
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@ public class GoComponentDetector : FileComponentDetector
|
|||
@"(?<name>.*)\s+(?<version>.*?)(/go\.mod)?\s+(?<hash>.*)",
|
||||
RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);
|
||||
|
||||
private readonly HashSet<string> projectRoots = new();
|
||||
private readonly HashSet<string> projectRoots = [];
|
||||
|
||||
private readonly ICommandLineInvocationService commandLineInvocationService;
|
||||
private readonly IEnvironmentVariableService envVarService;
|
||||
|
@ -44,11 +44,11 @@ public class GoComponentDetector : FileComponentDetector
|
|||
|
||||
public override string Id => "Go";
|
||||
|
||||
public override IEnumerable<string> Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.GoMod) };
|
||||
public override IEnumerable<string> Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.GoMod)];
|
||||
|
||||
public override IList<string> SearchPatterns { get; } = new List<string> { "go.mod", "go.sum" };
|
||||
public override IList<string> SearchPatterns { get; } = ["go.mod", "go.sum"];
|
||||
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes { get; } = new[] { ComponentType.Go };
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes { get; } = [ComponentType.Go];
|
||||
|
||||
public override int Version => 7;
|
||||
|
||||
|
@ -90,7 +90,7 @@ public class GoComponentDetector : FileComponentDetector
|
|||
private IEnumerable<ComponentStream> FindAdjacentGoModComponentStreams(ProcessRequest processRequest) =>
|
||||
this.ComponentStreamEnumerableFactory.GetComponentStreams(
|
||||
new FileInfo(processRequest.ComponentStream.Location).Directory,
|
||||
new[] { "go.mod" },
|
||||
["go.mod"],
|
||||
(_, _) => false,
|
||||
false)
|
||||
.Select(x =>
|
||||
|
@ -224,7 +224,7 @@ public class GoComponentDetector : FileComponentDetector
|
|||
var projectRootDirectory = Directory.GetParent(location);
|
||||
record.ProjectRoot = projectRootDirectory.FullName;
|
||||
|
||||
var isGoAvailable = await this.commandLineInvocationService.CanCommandBeLocatedAsync("go", null, workingDirectory: projectRootDirectory, new[] { "version" });
|
||||
var isGoAvailable = await this.commandLineInvocationService.CanCommandBeLocatedAsync("go", null, workingDirectory: projectRootDirectory, ["version"]);
|
||||
record.IsGoAvailable = isGoAvailable;
|
||||
|
||||
if (!isGoAvailable)
|
||||
|
@ -236,7 +236,7 @@ public class GoComponentDetector : FileComponentDetector
|
|||
this.Logger.LogInformation("Go CLI was found in system and will be used to generate dependency graph. " +
|
||||
"Detection time may be improved by activating fallback strategy (https://github.com/microsoft/component-detection/blob/main/docs/detectors/go.md#fallback-detection-strategy). " +
|
||||
"But, it will introduce noise into the detected components.");
|
||||
var goDependenciesProcess = await this.commandLineInvocationService.ExecuteCommandAsync("go", null, workingDirectory: projectRootDirectory, new[] { "list", "-mod=readonly", "-m", "-json", "all" });
|
||||
var goDependenciesProcess = await this.commandLineInvocationService.ExecuteCommandAsync("go", null, workingDirectory: projectRootDirectory, ["list", "-mod=readonly", "-m", "-json", "all"]);
|
||||
if (goDependenciesProcess.ExitCode != 0)
|
||||
{
|
||||
this.Logger.LogError("Go CLI command \"go list -m -json all\" failed with error: {GoDependenciesProcessStdErr}", goDependenciesProcess.StdErr);
|
||||
|
@ -308,7 +308,7 @@ public class GoComponentDetector : FileComponentDetector
|
|||
}
|
||||
|
||||
// Stopping at the first ) restrict the detection to only the require section.
|
||||
while ((line = await reader.ReadLineAsync()) != null && !line.EndsWith(")"))
|
||||
while ((line = await reader.ReadLineAsync()) != null && !line.EndsWith(')'))
|
||||
{
|
||||
this.TryRegisterDependencyFromModLine(line, singleFileComponentRecorder);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class GoComponentWithReplaceDetector : FileComponentDetector, IExperiment
|
|||
@"(?<name>.*)\s+(?<version>.*?)(/go\.mod)?\s+(?<hash>.*)",
|
||||
RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase);
|
||||
|
||||
private readonly HashSet<string> projectRoots = new();
|
||||
private readonly HashSet<string> projectRoots = [];
|
||||
|
||||
private readonly ICommandLineInvocationService commandLineInvocationService;
|
||||
private readonly IEnvironmentVariableService envVarService;
|
||||
|
@ -44,11 +44,11 @@ public class GoComponentWithReplaceDetector : FileComponentDetector, IExperiment
|
|||
|
||||
public override string Id => "GoWithReplace";
|
||||
|
||||
public override IEnumerable<string> Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.GoMod) };
|
||||
public override IEnumerable<string> Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.GoMod)];
|
||||
|
||||
public override IList<string> SearchPatterns { get; } = new List<string> { "go.mod", "go.sum" };
|
||||
public override IList<string> SearchPatterns { get; } = ["go.mod", "go.sum"];
|
||||
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes { get; } = new[] { ComponentType.Go };
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes { get; } = [ComponentType.Go];
|
||||
|
||||
public override int Version => 1;
|
||||
|
||||
|
@ -90,7 +90,7 @@ public class GoComponentWithReplaceDetector : FileComponentDetector, IExperiment
|
|||
private IEnumerable<ComponentStream> FindAdjacentGoModComponentStreams(ProcessRequest processRequest) =>
|
||||
this.ComponentStreamEnumerableFactory.GetComponentStreams(
|
||||
new FileInfo(processRequest.ComponentStream.Location).Directory,
|
||||
new[] { "go.mod" },
|
||||
["go.mod"],
|
||||
(_, _) => false,
|
||||
false)
|
||||
.Select(x =>
|
||||
|
@ -224,7 +224,7 @@ public class GoComponentWithReplaceDetector : FileComponentDetector, IExperiment
|
|||
var projectRootDirectory = Directory.GetParent(location);
|
||||
record.ProjectRoot = projectRootDirectory.FullName;
|
||||
|
||||
var isGoAvailable = await this.commandLineInvocationService.CanCommandBeLocatedAsync("go", null, workingDirectory: projectRootDirectory, new[] { "version" });
|
||||
var isGoAvailable = await this.commandLineInvocationService.CanCommandBeLocatedAsync("go", null, workingDirectory: projectRootDirectory, ["version"]);
|
||||
record.IsGoAvailable = isGoAvailable;
|
||||
|
||||
if (!isGoAvailable)
|
||||
|
@ -236,7 +236,7 @@ public class GoComponentWithReplaceDetector : FileComponentDetector, IExperiment
|
|||
this.Logger.LogInformation("Go CLI was found in system and will be used to generate dependency graph. " +
|
||||
"Detection time may be improved by activating fallback strategy (https://github.com/microsoft/component-detection/blob/main/docs/detectors/go.md#fallback-detection-strategy). " +
|
||||
"But, it will introduce noise into the detected components.");
|
||||
var goDependenciesProcess = await this.commandLineInvocationService.ExecuteCommandAsync("go", null, workingDirectory: projectRootDirectory, new[] { "list", "-mod=readonly", "-m", "-json", "all" });
|
||||
var goDependenciesProcess = await this.commandLineInvocationService.ExecuteCommandAsync("go", null, workingDirectory: projectRootDirectory, ["list", "-mod=readonly", "-m", "-json", "all"]);
|
||||
if (goDependenciesProcess.ExitCode != 0)
|
||||
{
|
||||
this.Logger.LogError("Go CLI command \"go list -m -json all\" failed with error: {GoDependenciesProcessStdErr}", goDependenciesProcess.StdErr);
|
||||
|
@ -309,7 +309,7 @@ public class GoComponentWithReplaceDetector : FileComponentDetector, IExperiment
|
|||
}
|
||||
|
||||
// Stopping at the first ) restrict the detection to only the require section.
|
||||
while ((line = await reader.ReadLineAsync()) != null && !line.EndsWith(")"))
|
||||
while ((line = await reader.ReadLineAsync()) != null && !line.EndsWith(')'))
|
||||
{
|
||||
this.TryRegisterDependencyFromModLine(line, singleFileComponentRecorder);
|
||||
}
|
||||
|
|
|
@ -31,19 +31,19 @@ public class GradleComponentDetector : FileComponentDetector, IComponentDetector
|
|||
this.Scanner = walkerFactory;
|
||||
this.Logger = logger;
|
||||
|
||||
this.devLockfiles = envVarService.GetListEnvironmentVariable(DevLockfilesEnvVar) ?? new List<string>();
|
||||
this.devConfigurations = envVarService.GetListEnvironmentVariable(DevConfigurationsEnvVar) ?? new List<string>();
|
||||
this.devLockfiles = envVarService.GetListEnvironmentVariable(DevLockfilesEnvVar) ?? [];
|
||||
this.devConfigurations = envVarService.GetListEnvironmentVariable(DevConfigurationsEnvVar) ?? [];
|
||||
this.Logger.LogDebug("Gradle dev-only lockfiles {Lockfiles}", string.Join(", ", this.devLockfiles));
|
||||
this.Logger.LogDebug("Gradle dev-only configurations {Configurations}", string.Join(", ", this.devConfigurations));
|
||||
}
|
||||
|
||||
public override string Id { get; } = "Gradle";
|
||||
|
||||
public override IEnumerable<string> Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.Maven) };
|
||||
public override IEnumerable<string> Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.Maven)];
|
||||
|
||||
public override IList<string> SearchPatterns { get; } = new List<string> { "*.lockfile" };
|
||||
public override IList<string> SearchPatterns { get; } = ["*.lockfile"];
|
||||
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes { get; } = new[] { ComponentType.Maven };
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes { get; } = [ComponentType.Maven];
|
||||
|
||||
public override int Version { get; } = 3;
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public class IvyDetector : FileComponentDetector, IExperimentalDetector
|
|||
|
||||
internal const string AntVersionArgument = "-version";
|
||||
|
||||
internal static readonly string[] AdditionalValidCommands = { "ant" };
|
||||
internal static readonly string[] AdditionalValidCommands = ["ant"];
|
||||
|
||||
private readonly ICommandLineInvocationService commandLineInvocationService;
|
||||
|
||||
|
@ -61,13 +61,13 @@ public class IvyDetector : FileComponentDetector, IExperimentalDetector
|
|||
|
||||
public override string Id => "Ivy";
|
||||
|
||||
public override IList<string> SearchPatterns => new List<string> { "ivy.xml" };
|
||||
public override IList<string> SearchPatterns => ["ivy.xml"];
|
||||
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes => new[] { ComponentType.Maven };
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes => [ComponentType.Maven];
|
||||
|
||||
public override int Version => 2;
|
||||
|
||||
public override IEnumerable<string> Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.Maven) };
|
||||
public override IEnumerable<string> Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.Maven)];
|
||||
|
||||
protected override async Task<IObservable<ProcessRequest>> OnPrepareDetectionAsync(
|
||||
IObservable<ProcessRequest> processRequests,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Detectors.Linux.Exceptions;
|
||||
namespace Microsoft.ComponentDetection.Detectors.Linux.Exceptions;
|
||||
|
||||
using System;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Detectors.Linux;
|
||||
namespace Microsoft.ComponentDetection.Detectors.Linux;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
|
|
@ -31,9 +31,9 @@ public class LinuxContainerDetector : IComponentDetector
|
|||
|
||||
public string Id => "Linux";
|
||||
|
||||
public IEnumerable<string> Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.Linux) };
|
||||
public IEnumerable<string> Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.Linux)];
|
||||
|
||||
public IEnumerable<ComponentType> SupportedComponentTypes => new[] { ComponentType.Linux };
|
||||
public IEnumerable<ComponentType> SupportedComponentTypes => [ComponentType.Linux];
|
||||
|
||||
public int Version => 4;
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class LinuxContainerDetector : IComponentDetector
|
|||
.ToList();
|
||||
#pragma warning restore CA1308
|
||||
|
||||
if (imagesToProcess == null || !imagesToProcess.Any())
|
||||
if (imagesToProcess == null || imagesToProcess.Count == 0)
|
||||
{
|
||||
this.logger.LogInformation("No instructions received to scan docker images.");
|
||||
return EmptySuccessfulScan();
|
||||
|
@ -110,7 +110,7 @@ public class LinuxContainerDetector : IComponentDetector
|
|||
return new ImageScanningResult
|
||||
{
|
||||
ContainerDetails = null,
|
||||
Components = Enumerable.Empty<DetectedComponent>(),
|
||||
Components = [],
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -135,13 +135,7 @@ public class LinuxContainerDetector : IComponentDetector
|
|||
null);
|
||||
}
|
||||
|
||||
var imageDetails = await this.dockerService.InspectImageAsync(image, cancellationToken);
|
||||
|
||||
// Unable to fetch image details
|
||||
if (imageDetails == null)
|
||||
{
|
||||
throw new MissingContainerDetailException(image);
|
||||
}
|
||||
var imageDetails = await this.dockerService.InspectImageAsync(image, cancellationToken) ?? throw new MissingContainerDetailException(image);
|
||||
|
||||
processedImages.TryAdd(imageDetails.ImageId, imageDetails);
|
||||
}
|
||||
|
|
|
@ -17,12 +17,16 @@ public class LinuxScanner : ILinuxScanner
|
|||
{
|
||||
private const string ScannerImage = "governancecontainerregistry.azurecr.io/syft:v0.100.0@sha256:df7b07bfadff45e0135d74f22478f47b16ac6aff4e8dbd93133fcae3bbbb790d";
|
||||
|
||||
private static readonly IList<string> CmdParameters = new List<string>
|
||||
{
|
||||
"--quiet", "--scope", "all-layers", "--output", "json",
|
||||
};
|
||||
private static readonly IList<string> CmdParameters =
|
||||
[
|
||||
"--quiet",
|
||||
"--scope",
|
||||
"all-layers",
|
||||
"--output",
|
||||
"json",
|
||||
];
|
||||
|
||||
private static readonly IEnumerable<string> AllowedArtifactTypes = new[] { "apk", "deb", "rpm" };
|
||||
private static readonly IEnumerable<string> AllowedArtifactTypes = ["apk", "deb", "rpm"];
|
||||
|
||||
private static readonly SemaphoreSlim DockerSemaphore = new SemaphoreSlim(2);
|
||||
|
||||
|
@ -163,7 +167,7 @@ public class LinuxScanner : ILinuxScanner
|
|||
}
|
||||
|
||||
var licenses = artifact.Licenses;
|
||||
if (licenses != null && licenses.Any())
|
||||
if (licenses != null && licenses.Length != 0)
|
||||
{
|
||||
return string.Join(", ", licenses.Select(l => l.Value));
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Detectors.Maven;
|
||||
namespace Microsoft.ComponentDetection.Detectors.Maven;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
@ -12,7 +12,7 @@ public class GraphNode<T>
|
|||
|
||||
public T Value { get; set; }
|
||||
|
||||
public List<GraphNode<T>> Children { get; } = new List<GraphNode<T>>();
|
||||
public List<GraphNode<T>> Children { get; } = [];
|
||||
|
||||
public List<GraphNode<T>> Parents { get; } = new List<GraphNode<T>>();
|
||||
public List<GraphNode<T>> Parents { get; } = [];
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public class MavenCommandService : IMavenCommandService
|
|||
|
||||
internal const string MvnVersionArgument = "--version";
|
||||
|
||||
internal static readonly string[] AdditionalValidCommands = new[] { "mvn.cmd" };
|
||||
internal static readonly string[] AdditionalValidCommands = ["mvn.cmd"];
|
||||
|
||||
private readonly ICommandLineInvocationService commandLineInvocationService;
|
||||
private readonly IMavenStyleDependencyGraphParserService parserService;
|
||||
|
|
|
@ -47,7 +47,7 @@ public static class MavenParsingUtilities
|
|||
{
|
||||
// Six part versions have an entry in their 4th index. We remove it to normalize. E.g.:
|
||||
// var mysteriousSixPartVersionPart = results[3];
|
||||
results = new[] { results[0], results[1], results[2], results[4], results[5] };
|
||||
results = [results[0], results[1], results[2], results[4], results[5]];
|
||||
}
|
||||
|
||||
// 'MavenCompile' is a default scope for maven dependencies.
|
||||
|
|
|
@ -8,9 +8,9 @@ using Microsoft.Extensions.Logging;
|
|||
|
||||
public class MavenStyleDependencyGraphParser
|
||||
{
|
||||
private static readonly char[] TrimCharacters = new char[] { '|', ' ' };
|
||||
private static readonly char[] TrimCharacters = ['|', ' '];
|
||||
|
||||
private static readonly string[] ComponentSplitters = new[] { "+-", "\\-" };
|
||||
private static readonly string[] ComponentSplitters = ["+-", "\\-"];
|
||||
|
||||
private readonly Stack<GraphNodeAtLevel<string>> stack = new Stack<GraphNodeAtLevel<string>>();
|
||||
|
||||
|
|
|
@ -36,13 +36,13 @@ public class MvnCliComponentDetector : FileComponentDetector
|
|||
|
||||
public override string Id => "MvnCli";
|
||||
|
||||
public override IList<string> SearchPatterns => new List<string> { MavenManifest };
|
||||
public override IList<string> SearchPatterns => [MavenManifest];
|
||||
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes => new[] { ComponentType.Maven };
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes => [ComponentType.Maven];
|
||||
|
||||
public override int Version => 4;
|
||||
|
||||
public override IEnumerable<string> Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.Maven) };
|
||||
public override IEnumerable<string> Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.Maven)];
|
||||
|
||||
private void LogDebugWithId(string message)
|
||||
{
|
||||
|
@ -70,7 +70,7 @@ public class MvnCliComponentDetector : FileComponentDetector
|
|||
|
||||
this.LogDebugWithId($"Nested {MavenManifest} files processed successfully, retrieving generated dependency graphs.");
|
||||
|
||||
return this.ComponentStreamEnumerableFactory.GetComponentStreams(this.CurrentScanRequest.SourceDirectory, new[] { this.mavenCommandService.BcdeMvnDependencyFileName }, this.CurrentScanRequest.DirectoryExclusionPredicate)
|
||||
return this.ComponentStreamEnumerableFactory.GetComponentStreams(this.CurrentScanRequest.SourceDirectory, [this.mavenCommandService.BcdeMvnDependencyFileName], this.CurrentScanRequest.DirectoryExclusionPredicate)
|
||||
.Select(componentStream =>
|
||||
{
|
||||
// The file stream is going to be disposed after the iteration is finished
|
||||
|
@ -137,7 +137,7 @@ public class MvnCliComponentDetector : FileComponentDetector
|
|||
var current = directoryItemFacades.GetOrAdd(currentDir, _ => new DirectoryItemFacadeOptimized
|
||||
{
|
||||
Name = currentDir,
|
||||
FileNames = new HashSet<string>(),
|
||||
FileNames = [],
|
||||
});
|
||||
|
||||
// If we didn't come from a directory, it's because we're just getting started. Our current directory should include the file that led to it showing up in the graph.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#nullable enable
|
||||
#nullable enable
|
||||
namespace Microsoft.ComponentDetection.Detectors.Npm.Contracts;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#nullable enable
|
||||
#nullable enable
|
||||
namespace Microsoft.ComponentDetection.Detectors.Npm.Contracts;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#nullable enable
|
||||
#nullable enable
|
||||
namespace Microsoft.ComponentDetection.Detectors.Npm.Contracts;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#nullable enable
|
||||
#nullable enable
|
||||
namespace Microsoft.ComponentDetection.Detectors.Npm.Contracts;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#nullable enable
|
||||
#nullable enable
|
||||
namespace Microsoft.ComponentDetection.Detectors.Npm.Contracts;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#nullable enable
|
||||
#nullable enable
|
||||
namespace Microsoft.ComponentDetection.Detectors.Npm.Contracts;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#nullable enable
|
||||
#nullable enable
|
||||
namespace Microsoft.ComponentDetection.Detectors.Npm.Contracts;
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
|
|
@ -34,11 +34,11 @@ public class NpmComponentDetector : FileComponentDetector
|
|||
|
||||
public override string Id { get; } = "Npm";
|
||||
|
||||
public override IEnumerable<string> Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.Npm) };
|
||||
public override IEnumerable<string> Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.Npm)];
|
||||
|
||||
public override IList<string> SearchPatterns { get; } = new List<string> { "package.json" };
|
||||
public override IList<string> SearchPatterns { get; } = ["package.json"];
|
||||
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes { get; } = new[] { ComponentType.Npm };
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes { get; } = [ComponentType.Npm];
|
||||
|
||||
public override int Version { get; } = 2;
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class NpmComponentDetector : FileComponentDetector
|
|||
string contents;
|
||||
using (var reader = new StreamReader(file.Stream))
|
||||
{
|
||||
contents = await reader.ReadToEndAsync();
|
||||
contents = await reader.ReadToEndAsync(cancellationToken);
|
||||
}
|
||||
|
||||
await this.SafeProcessAllPackageJTokensAsync(filePath, contents, (token) =>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Detectors.Npm;
|
||||
namespace Microsoft.ComponentDetection.Detectors.Npm;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -95,7 +95,7 @@ public static class NpmComponentUtilities
|
|||
|
||||
public static IDictionary<string, IDictionary<string, bool>> TryGetAllPackageJsonDependencies(Stream stream, out IList<string> yarnWorkspaces)
|
||||
{
|
||||
yarnWorkspaces = new List<string>();
|
||||
yarnWorkspaces = [];
|
||||
|
||||
using var file = new StreamReader(stream);
|
||||
using var reader = new JsonTextReader(file);
|
||||
|
|
|
@ -47,16 +47,16 @@ public abstract class NpmLockfileDetectorBase : FileComponentDetector
|
|||
/// <returns>Used in scenarios where one file path creates multiple JTokens, a false value indicates processing additional JTokens should be halted, proceed otherwise.</returns>
|
||||
protected delegate bool JTokenProcessingDelegate(JToken token);
|
||||
|
||||
public override IEnumerable<string> Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.Npm) };
|
||||
public override IEnumerable<string> Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.Npm)];
|
||||
|
||||
public override IList<string> SearchPatterns { get; } = new List<string> { "package-lock.json", "npm-shrinkwrap.json", LernaSearchPattern };
|
||||
public override IList<string> SearchPatterns { get; } = ["package-lock.json", "npm-shrinkwrap.json", LernaSearchPattern];
|
||||
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes { get; } = new[] { ComponentType.Npm };
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes { get; } = [ComponentType.Npm];
|
||||
|
||||
private List<ProcessRequest> LernaFiles { get; } = new();
|
||||
private List<ProcessRequest> LernaFiles { get; } = [];
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override IList<string> SkippedFolders => new List<string> { "node_modules", "pnpm-store" };
|
||||
protected override IList<string> SkippedFolders => ["node_modules", "pnpm-store"];
|
||||
|
||||
protected abstract bool IsSupportedLockfileVersion(int lockfileVersion);
|
||||
|
||||
|
@ -98,7 +98,7 @@ public abstract class NpmLockfileDetectorBase : FileComponentDetector
|
|||
|
||||
protected override async Task OnFileFoundAsync(ProcessRequest processRequest, IDictionary<string, string> detectorArgs, CancellationToken cancellationToken = default)
|
||||
{
|
||||
IEnumerable<string> packageJsonPattern = new List<string> { "package.json" };
|
||||
IEnumerable<string> packageJsonPattern = ["package.json"];
|
||||
var singleFileComponentRecorder = processRequest.SingleFileComponentRecorder;
|
||||
var file = processRequest.ComponentStream;
|
||||
|
||||
|
@ -243,8 +243,8 @@ public abstract class NpmLockfileDetectorBase : FileComponentDetector
|
|||
directoryItemFacadesByPath[currentDir] = current = new DirectoryItemFacade
|
||||
{
|
||||
Name = currentDir,
|
||||
Files = new List<IComponentStream>(),
|
||||
Directories = new List<DirectoryItemFacade>(),
|
||||
Files = [],
|
||||
Directories = [],
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -18,11 +18,11 @@ using Microsoft.Extensions.Logging;
|
|||
|
||||
public class NuGetComponentDetector : FileComponentDetector
|
||||
{
|
||||
private static readonly IEnumerable<string> LowConfidencePackages = new[] { "Newtonsoft.Json" };
|
||||
private static readonly IEnumerable<string> LowConfidencePackages = ["Newtonsoft.Json"];
|
||||
|
||||
public const string NugetConfigFileName = "nuget.config";
|
||||
|
||||
private readonly IList<string> repositoryPathKeyNames = new List<string> { "repositorypath", "globalpackagesfolder" };
|
||||
private readonly IList<string> repositoryPathKeyNames = ["repositorypath", "globalpackagesfolder"];
|
||||
|
||||
public NuGetComponentDetector(
|
||||
IComponentStreamEnumerableFactory componentStreamEnumerableFactory,
|
||||
|
@ -36,11 +36,11 @@ public class NuGetComponentDetector : FileComponentDetector
|
|||
|
||||
public override string Id { get; } = "NuGet";
|
||||
|
||||
public override IEnumerable<string> Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.NuGet) };
|
||||
public override IEnumerable<string> Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.NuGet)];
|
||||
|
||||
public override IList<string> SearchPatterns { get; } = new List<string> { "*.nupkg", "*.nuspec", NugetConfigFileName, "paket.lock" };
|
||||
public override IList<string> SearchPatterns { get; } = ["*.nupkg", "*.nuspec", NugetConfigFileName, "paket.lock"];
|
||||
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes { get; } = new[] { ComponentType.NuGet };
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes { get; } = [ComponentType.NuGet];
|
||||
|
||||
public override int Version { get; } = 2;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Detectors.NuGet;
|
||||
namespace Microsoft.ComponentDetection.Detectors.NuGet;
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
@ -27,20 +27,15 @@ public static class NuGetNuspecUtilities
|
|||
var nuspecEntry =
|
||||
archive.Entries.FirstOrDefault(x =>
|
||||
x.Name.EndsWith(".nuspec", StringComparison.OrdinalIgnoreCase)
|
||||
&& !x.FullName.Contains('/'));
|
||||
|
||||
if (nuspecEntry == null)
|
||||
{
|
||||
throw new FileNotFoundException("No nuspec file was found");
|
||||
}
|
||||
&& !x.FullName.Contains('/')) ?? throw new FileNotFoundException("No nuspec file was found");
|
||||
|
||||
using var nuspecStream = nuspecEntry.Open();
|
||||
|
||||
return await GetNuspecBytesFromNuspecStreamAsync(nuspecStream, nuspecEntry.Length);
|
||||
}
|
||||
catch (InvalidDataException ex)
|
||||
catch (InvalidDataException)
|
||||
{
|
||||
throw ex;
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
@ -33,17 +33,17 @@ public sealed class NuGetPackagesConfigDetector : FileComponentDetector
|
|||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IList<string> SearchPatterns => new[] { "packages.config" };
|
||||
public override IList<string> SearchPatterns => ["packages.config"];
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string Id => "NuGetPackagesConfig";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEnumerable<string> Categories =>
|
||||
new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.NuGet) };
|
||||
[Enum.GetName(typeof(DetectorClass), DetectorClass.NuGet)];
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes => new[] { ComponentType.NuGet };
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes => [ComponentType.NuGet];
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int Version => 1;
|
||||
|
|
|
@ -24,13 +24,13 @@ public class NuGetProjectModelProjectCentricComponentDetector : FileComponentDet
|
|||
|
||||
private readonly ConcurrentDictionary<string, int> frameworkComponentsThatWereOmmittedWithCount = new ConcurrentDictionary<string, int>();
|
||||
|
||||
private readonly List<string> netCoreFrameworkNames = new List<string> { "Microsoft.AspNetCore.App", "Microsoft.AspNetCore.Razor.Design", "Microsoft.NETCore.App" };
|
||||
private readonly List<string> netCoreFrameworkNames = ["Microsoft.AspNetCore.App", "Microsoft.AspNetCore.Razor.Design", "Microsoft.NETCore.App"];
|
||||
|
||||
// This list is meant to encompass all net standard dependencies, but likely contains some net core app 1.x ones, too.
|
||||
// The specific guidance we got around populating this list is to do so based on creating a dotnet core 1.x app to make sure we had the complete
|
||||
// set of netstandard.library files that could show up in later sdk versions.
|
||||
private readonly string[] netStandardDependencies = new[]
|
||||
{
|
||||
private readonly string[] netStandardDependencies =
|
||||
[
|
||||
"Libuv",
|
||||
"Microsoft.CodeAnalysis.Analyzers",
|
||||
"Microsoft.CodeAnalysis.Common",
|
||||
|
@ -183,7 +183,7 @@ public class NuGetProjectModelProjectCentricComponentDetector : FileComponentDet
|
|||
"System.Xml.XmlSerializer",
|
||||
"System.Xml.XPath",
|
||||
"System.Xml.XPath.XDocument",
|
||||
};
|
||||
];
|
||||
|
||||
private readonly IFileUtilityService fileUtilityService;
|
||||
|
||||
|
@ -201,11 +201,11 @@ public class NuGetProjectModelProjectCentricComponentDetector : FileComponentDet
|
|||
|
||||
public override string Id { get; } = "NuGetProjectCentric";
|
||||
|
||||
public override IEnumerable<string> Categories => new[] { Enum.GetName(typeof(DetectorClass), DetectorClass.NuGet) };
|
||||
public override IEnumerable<string> Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.NuGet)];
|
||||
|
||||
public override IList<string> SearchPatterns { get; } = new List<string> { "project.assets.json" };
|
||||
public override IList<string> SearchPatterns { get; } = ["project.assets.json"];
|
||||
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes { get; } = new[] { ComponentType.NuGet };
|
||||
public override IEnumerable<ComponentType> SupportedComponentTypes { get; } = [ComponentType.NuGet];
|
||||
|
||||
public override int Version { get; } = 1;
|
||||
|
||||
|
@ -273,7 +273,7 @@ public class NuGetProjectModelProjectCentricComponentDetector : FileComponentDet
|
|||
return;
|
||||
}
|
||||
|
||||
visited ??= new HashSet<string>();
|
||||
visited ??= [];
|
||||
|
||||
var libraryComponent = new DetectedComponent(new NuGetComponent(library.Name, library.Version.ToNormalizedString()));
|
||||
singleFileComponentRecorder.RegisterUsage(libraryComponent, explicitlyReferencedComponentIds.Contains(libraryComponent.Component.Id), parentComponentId);
|
||||
|
@ -427,7 +427,7 @@ public class NuGetProjectModelProjectCentricComponentDetector : FileComponentDet
|
|||
|
||||
private HashSet<string> GetDependencyComponentIds(LockFile lockFile, LockFileTarget target, IList<PackageDependency> dependencies, HashSet<string> visited = null)
|
||||
{
|
||||
visited ??= new HashSet<string>();
|
||||
visited ??= [];
|
||||
var currentComponents = new HashSet<string>();
|
||||
foreach (var dependency in dependencies)
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace Microsoft.ComponentDetection.Detectors.Pip;
|
||||
namespace Microsoft.ComponentDetection.Detectors.Pip;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
|
|
@ -26,8 +26,8 @@ public class PipDependencySpecification
|
|||
/// <summary>
|
||||
/// These are packages that we don't want to evaluate in our graph as they are generally python builtins.
|
||||
/// </summary>
|
||||
public static readonly HashSet<string> PackagesToIgnore = new HashSet<string>
|
||||
{
|
||||
public static readonly HashSet<string> PackagesToIgnore =
|
||||
[
|
||||
"-markerlib",
|
||||
"pip",
|
||||
"pip-tools",
|
||||
|
@ -35,7 +35,7 @@ public class PipDependencySpecification
|
|||
"pkg-resources",
|
||||
"setuptools",
|
||||
"wheel",
|
||||
};
|
||||
];
|
||||
|
||||
// Extracts abcd from a string like abcd==1.*,!=1.3
|
||||
private static readonly Regex PipNameExtractionRegex = new Regex(
|
||||
|
@ -82,9 +82,9 @@ public class PipDependencySpecification
|
|||
/// <summary>
|
||||
/// Gets or sets the set of dependency specifications that constrain the overall dependency request (ex: ==1.0, >=2.0).
|
||||
/// </summary>
|
||||
public IList<string> DependencySpecifiers { get; set; } = new List<string>();
|
||||
public IList<string> DependencySpecifiers { get; set; } = [];
|
||||
|
||||
public IList<string> ConditionalDependencySpecifiers { get; set; } = new List<string>();
|
||||
public IList<string> ConditionalDependencySpecifiers { get; set; } = [];
|
||||
|
||||
private string DebuggerDisplay => $"{this.Name} ({string.Join(';', this.DependencySpecifiers)})";
|
||||
|
||||
|
@ -186,15 +186,12 @@ public class PipDependencySpecification
|
|||
var conditionalSpec = $"{conditionalOperator}{conditionalValue}";
|
||||
try
|
||||
{
|
||||
conditionMet = PythonVersionUtilities.VersionValidForSpec(pythonEnvironmentVariables[conditionalVar], new List<string> { conditionalSpec });
|
||||
conditionMet = PythonVersionUtilities.VersionValidForSpec(pythonEnvironmentVariables[conditionalVar], [conditionalSpec]);
|
||||
}
|
||||
catch (ArgumentException ae)
|
||||
{
|
||||
conditionMet = false;
|
||||
if (this.Logger != null)
|
||||
{
|
||||
this.Logger.LogDebug("Could not create pip dependency: {ErrorMessage}", ae.Message);
|
||||
}
|
||||
this.Logger?.LogDebug("Could not create pip dependency: {ErrorMessage}", ae.Message);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -256,10 +253,7 @@ public class PipDependencySpecification
|
|||
}
|
||||
catch (ArgumentException ae)
|
||||
{
|
||||
if (this.Logger != null)
|
||||
{
|
||||
this.Logger.LogDebug("Could not create pip dependency: {ErrorMessage}", ae.Message);
|
||||
}
|
||||
this.Logger?.LogDebug("Could not create pip dependency: {ErrorMessage}", ae.Message);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче