Skip to content
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
1a3f651
Add Docker Compose, Helm, and Kubernetes component detectors
jpinz Apr 2, 2026
077d1d0
Add tests for Docker Compose, Dockerfile, Helm, and Kubernetes compon…
jpinz Apr 2, 2026
fd74cb5
Add `#nullable disable` to the new files
jpinz Apr 2, 2026
d5c91ed
Fix helm file patterns, and update tests
jpinz Apr 2, 2026
a111856
Add tests for Docker, Helm, and Kubernetes images with tag and digest
jpinz Apr 3, 2026
70776f8
Add support for additional Docker Compose file patterns and new tests…
jpinz Apr 3, 2026
a099d56
Refactor DockerCompose and Kubernetes component detectors to address …
jpinz Apr 3, 2026
0bbc3db
Refine HelmComponentDetector to process only relevant values files an…
jpinz Apr 3, 2026
5c4e487
Add default to switch cases
jpinz Apr 3, 2026
b5d3fbf
Enhance KubernetesComponentDetector to skip non-manifest files and im…
jpinz Apr 3, 2026
5158b75
Move DockerCompose ordering in DetectorClass enum
jpinz Apr 3, 2026
a26f434
Merge branch 'main' into jupinzer/add_container_detectors
jpinz Apr 3, 2026
0873316
Fix build issues
jpinz Apr 3, 2026
ea3b0a4
Skip image references with unresolved variables in DockerCompose, Hel…
Copilot Apr 3, 2026
5984b1c
Remove accidentally committed .nuget/nuget.exe and add to .gitignore
Copilot Apr 3, 2026
9d56f38
Fix failing tests
jpinz Apr 3, 2026
8bce22b
Merge branch 'main' into jupinzer/add_container_detectors
jpinz Apr 3, 2026
ad592b2
Add docs for the new detectors
jpinz Apr 3, 2026
9ae1dd4
Add a new Containers DetectorCategory that enabled Dockerfile, Docker…
jpinz Apr 3, 2026
70762f1
Use shared HasUnresolvedVariables in Dockerfile detector, add Helm co…
Copilot Apr 3, 2026
d220257
Fix AllowedDetectorIds+Categories intersection bug in DetectorRestric…
Copilot Apr 3, 2026
dff7d5f
Rename test variables for clarity in DetectorRestrictionServiceTests
Copilot Apr 3, 2026
569babe
Refactor DockerfileComponentDetector to use DockerReferenceUtility fo…
jpinz Apr 3, 2026
f651b13
Revert Containers DetectorCategory support
jpinz Apr 3, 2026
7f08f43
Fix Helm detector file ordering via two-pass OnPrepareDetectionAsync
Copilot Apr 3, 2026
b77c789
Refactor image reference handling in component detectors to use TryPa…
jpinz Apr 6, 2026
70ada53
Remove duplicate search patterns for Helm charts in HelmComponentDete…
jpinz Apr 6, 2026
e5ffbb5
Add "PodTemplate" to KubernetesKinds in KubernetesComponentDetector
jpinz Apr 6, 2026
c0f586c
Remove `#nullable enable` from files added in this PR
jpinz Apr 6, 2026
5d270f5
Add test for skipping values.yaml in different directory from Chart.yaml
jpinz Apr 6, 2026
df6c196
enable nullable on the new files and fix issues with it
jpinz Apr 6, 2026
ce8e98b
Clarify that values files won't be processed in the helm detector if …
jpinz Apr 6, 2026
5b148b7
Refactor Categories property to use nameof for DetectorClass in multi…
jpinz Apr 6, 2026
84b4383
Add `PodTemplate` to the docs for kubernetes
jpinz Apr 6, 2026
6478e2e
Optimize the KubernetesComponentDetector.OnFileFoundAsync method
jpinz Apr 6, 2026
a3fa9b8
Add verification tests for DockerCompose, Helm, and Kubernetes.
jpinz Apr 7, 2026
146759c
Merge branch 'main' into jupinzer/add_container_detectors
jpinz Apr 7, 2026
7fc72c1
Add test for Kubernetes Pod with image tag and digest
jpinz Apr 7, 2026
9b8e1b7
Merge branch 'main' into jupinzer/add_container_detectors
jpinz Apr 8, 2026
bac8dc8
Address copilot PR comments
jpinz Apr 8, 2026
e0e81f9
Merge branch 'main' into jupinzer/add_container_detectors
jpinz Apr 10, 2026
ccfdd1b
Address Copilot comment
jpinz Apr 10, 2026
1cc4383
Fix IDE0057 error
jpinz Apr 10, 2026
6b7d6fe
Merge branch 'main' into jupinzer/add_container_detectors
jpinz Apr 13, 2026
035bdc9
Refactor ExtractImageReferences and TryRegisterStructuredImageReferen…
jpinz Apr 13, 2026
2f0d13c
Address PR comments
jpinz Apr 13, 2026
7307efc
Address copilot comments on the HelmComponentDetector
jpinz Apr 13, 2026
5c56424
Merge branch 'main' into jupinzer/add_container_detectors
jpinz Apr 14, 2026
2e5d0f5
Update apiVersion check in KubernetesComponentDetector to be case-ins…
jpinz Apr 14, 2026
8ab1513
Rework the HelmComponentDetector to find Chart/values yaml files usin…
jpinz Apr 15, 2026
77a8af2
Address copilot comment about Kubernetes logger, swapped it to a debu…
jpinz Apr 15, 2026
ade40f8
Merge branch 'main' into jupinzer/add_container_detectors
jpinz Apr 15, 2026
b52999a
Refactor component comparison logic to exclude experimental detectors…
jpinz Apr 16, 2026
d20304a
Revert integration test changes
jpinz Apr 16, 2026
0ef45f1
All 3 new detectors now are marked as experimental.
jpinz Apr 16, 2026
d438845
Fix typo in Kubernetes detector
jpinz Apr 16, 2026
f66238d
Remove the experimental detector reference as defaultoff takes preced…
jpinz Apr 16, 2026
b0a4661
Remove new detectors from VerificationTest.ps1
jpinz Apr 16, 2026
f102880
Remove new detectors from workflow snapshots.
jpinz Apr 16, 2026
4bc3c0a
Mark the Kubernetes Detector as IDefaultOffComponentDetector
jpinz Apr 16, 2026
78aacbf
Address PR comments.
jpinz Apr 16, 2026
40942a9
Update Helm detection documentation
jpinz Apr 16, 2026
930d0b2
Address PR comments
jpinz Apr 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Microsoft.ComponentDetection.Contracts/DetectorClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ public enum DetectorClass
/// <summary>Indicates a detector applies to Docker references.</summary>
DockerReference,

/// <summary>Indicates a detector applies to Docker Compose image references.</summary>
DockerCompose,

/// <summary> Indicates a detector applies to Swift packages.</summary>
Swift,
Comment thread
jpinz marked this conversation as resolved.

/// <summary>Indicates a detector applies to Helm chart image references.</summary>
Helm,

/// <summary>Indicates a detector applies to Kubernetes manifest image references.</summary>
Kubernetes,
Comment thread
jpinz marked this conversation as resolved.
}
Comment thread
jpinz marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
#nullable disable
Comment thread
jpinz marked this conversation as resolved.
Outdated
namespace Microsoft.ComponentDetection.Detectors.DockerCompose;

using System;
using System.Collections.Generic;
using System.IO;
Comment thread
jpinz marked this conversation as resolved.
using System.Threading;
using System.Threading.Tasks;
using Microsoft.ComponentDetection.Common;
using Microsoft.ComponentDetection.Contracts;
using Microsoft.ComponentDetection.Contracts.Internal;
using Microsoft.ComponentDetection.Contracts.TypedComponent;
Comment thread
jpinz marked this conversation as resolved.
using Microsoft.Extensions.Logging;
using YamlDotNet.RepresentationModel;

public class DockerComposeComponentDetector : FileComponentDetector, IDefaultOffComponentDetector
{
public DockerComposeComponentDetector(
IComponentStreamEnumerableFactory componentStreamEnumerableFactory,
IObservableDirectoryWalkerFactory walkerFactory,
ILogger<DockerComposeComponentDetector> logger)
{
this.ComponentStreamEnumerableFactory = componentStreamEnumerableFactory;
this.Scanner = walkerFactory;
this.Logger = logger;
}

public override string Id => "DockerCompose";

public override IList<string> SearchPatterns { get; } =
[
"docker-compose.yml", "docker-compose.yaml",
"docker-compose.*.yml", "docker-compose.*.yaml",
"compose.yml", "compose.yaml",
Comment thread
jpinz marked this conversation as resolved.
"compose.*.yml", "compose.*.yaml",
Comment thread
jpinz marked this conversation as resolved.
];
Comment thread
jpinz marked this conversation as resolved.

public override IEnumerable<ComponentType> SupportedComponentTypes => [ComponentType.DockerReference];

public override int Version => 1;

public override IEnumerable<string> Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.DockerCompose)];
Comment thread
jpinz marked this conversation as resolved.
Outdated

protected override async Task OnFileFoundAsync(ProcessRequest processRequest, IDictionary<string, string> detectorArgs, CancellationToken cancellationToken = default)
{
var singleFileComponentRecorder = processRequest.SingleFileComponentRecorder;
var file = processRequest.ComponentStream;

try
{
this.Logger.LogInformation("Discovered Docker Compose file: {Location}", file.Location);

string contents;
using (var reader = new StreamReader(file.Stream))
{
contents = await reader.ReadToEndAsync(cancellationToken);
}

var yaml = new YamlStream();
yaml.Load(new StringReader(contents));

if (yaml.Documents.Count == 0)
{
return;
}

foreach (var document in yaml.Documents)
{
if (document.RootNode is YamlMappingNode rootMapping)
{
this.ExtractImageReferences(rootMapping, singleFileComponentRecorder, file.Location);
}
}
}
catch (Exception e)
{
this.Logger.LogError(e, "Failed to parse Docker Compose file: {Location}", file.Location);
}
}

private static YamlMappingNode GetMappingChild(YamlMappingNode parent, string key)
{
foreach (var entry in parent.Children)
{
if (entry.Key is YamlScalarNode scalarKey && string.Equals(scalarKey.Value, key, StringComparison.OrdinalIgnoreCase))
{
return entry.Value as YamlMappingNode;
}
}

return null;
}

private void ExtractImageReferences(YamlMappingNode rootMapping, ISingleFileComponentRecorder recorder, string fileLocation)
{
Comment thread
jpinz marked this conversation as resolved.
Outdated
var services = GetMappingChild(rootMapping, "services");
if (services == null)
{
return;
}

foreach (var serviceEntry in services.Children)
{
if (serviceEntry.Value is not YamlMappingNode serviceMapping)
{
continue;
}

// Extract direct image: references
foreach (var entry in serviceMapping.Children)
{
var key = (entry.Key as YamlScalarNode)?.Value;
if (string.Equals(key, "image", StringComparison.OrdinalIgnoreCase))
{
var imageRef = (entry.Value as YamlScalarNode)?.Value;
if (!string.IsNullOrWhiteSpace(imageRef))
{
this.TryRegisterImageReference(imageRef, recorder, fileLocation);
}
}
}
}
}

private void TryRegisterImageReference(string imageReference, ISingleFileComponentRecorder recorder, string fileLocation)
Comment thread
jpinz marked this conversation as resolved.
Outdated
{
try
{
var dockerRef = DockerReferenceUtility.ParseFamiliarName(imageReference);
if (dockerRef != null)
{
recorder.RegisterUsage(new DetectedComponent(dockerRef.ToTypedDockerReferenceComponent()));
}
}
catch (Exception e)
{
this.Logger.LogWarning(e, "Failed to parse image reference '{ImageReference}' in {Location}", imageReference, fileLocation);
}
Comment thread
jpinz marked this conversation as resolved.
Outdated
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
#nullable disable
namespace Microsoft.ComponentDetection.Detectors.Helm;

using System;
using System.Collections.Generic;
Comment thread
jpinz marked this conversation as resolved.
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.ComponentDetection.Common;
using Microsoft.ComponentDetection.Contracts;
using Microsoft.ComponentDetection.Contracts.Internal;
using Microsoft.ComponentDetection.Contracts.TypedComponent;
Comment thread
jpinz marked this conversation as resolved.
Comment thread
jpinz marked this conversation as resolved.
using Microsoft.Extensions.Logging;
using YamlDotNet.RepresentationModel;

public class HelmComponentDetector : FileComponentDetector, IDefaultOffComponentDetector
{
public HelmComponentDetector(
IComponentStreamEnumerableFactory componentStreamEnumerableFactory,
IObservableDirectoryWalkerFactory walkerFactory,
ILogger<HelmComponentDetector> logger)
{
this.ComponentStreamEnumerableFactory = componentStreamEnumerableFactory;
this.Scanner = walkerFactory;
this.Logger = logger;
}

public override string Id => "Helm";

public override IList<string> SearchPatterns { get; } =
[
"Chart.yaml", "Chart.yml",
"chart.yaml", "chart.yml",
Comment thread
jpinz marked this conversation as resolved.
Outdated
Comment thread
jpinz marked this conversation as resolved.
Outdated
"*values*.yaml", "*values*.yml",
Comment thread
jpinz marked this conversation as resolved.
Comment thread
jpinz marked this conversation as resolved.
];
Comment on lines +32 to +36
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SearchPatterns/IsChartFile treat Chart.yml as a valid chart indicator, but the unit tests only cover Chart.yml without a values file (expecting no components). Add a test that verifies a co-located Chart.yml + values file is actually processed (or drop Chart.yml support if it’s not intended).

Copilot uses AI. Check for mistakes.

public override IEnumerable<ComponentType> SupportedComponentTypes => [ComponentType.DockerReference];

public override int Version => 1;

public override IEnumerable<string> Categories => [Enum.GetName(typeof(DetectorClass), DetectorClass.Helm)];
Comment thread
jpinz marked this conversation as resolved.
Outdated

protected override async Task OnFileFoundAsync(ProcessRequest processRequest, IDictionary<string, string> detectorArgs, CancellationToken cancellationToken = default)
{
var singleFileComponentRecorder = processRequest.SingleFileComponentRecorder;
var file = processRequest.ComponentStream;

try
{
var fileName = Path.GetFileName(file.Location);

// Only process files that are likely to contain image references. This is a heuristic to avoid parsing irrelevant YAML files.
if (!fileName.Contains("values", StringComparison.OrdinalIgnoreCase) ||
!(fileName.EndsWith(".yaml", StringComparison.OrdinalIgnoreCase) || fileName.EndsWith(".yml", StringComparison.OrdinalIgnoreCase)))
{
return;
}

this.Logger.LogInformation("Discovered Helm values file: {Location}", file.Location);

string contents;
using (var reader = new StreamReader(file.Stream))
{
contents = await reader.ReadToEndAsync(cancellationToken);
}

Comment thread
jpinz marked this conversation as resolved.
var yaml = new YamlStream();
yaml.Load(new StringReader(contents));

if (yaml.Documents.Count == 0)
{
return;
}

this.ExtractImageReferencesFromValues(yaml, singleFileComponentRecorder, file.Location);
}
catch (Exception e)
{
this.Logger.LogError(e, "Failed to parse Helm file: {Location}", file.Location);
}
}

private void ExtractImageReferencesFromValues(YamlStream yaml, ISingleFileComponentRecorder recorder, string fileLocation)
{
foreach (var document in yaml.Documents)
{
if (document.RootNode is YamlMappingNode rootMapping)
{
this.WalkYamlForImages(rootMapping, recorder, fileLocation);
}
}
}

/// <summary>
/// Walks the YAML tree looking for image references. Handles two common patterns:
/// 1. Direct image string: `image: nginx:1.21`
/// 2. Structured image object: `image: { repository: nginx, tag: "1.21" }`.
/// </summary>
private void WalkYamlForImages(YamlMappingNode mapping, ISingleFileComponentRecorder recorder, string fileLocation)
{
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fileLocation is threaded through ExtractImageReferencesFromValues/WalkYamlForImages but never used. Consider removing the parameter (and corresponding call-site arguments) or using it for logging/context to avoid dead parameters being propagated through the recursion.

Copilot uses AI. Check for mistakes.
foreach (var entry in mapping.Children)
{
var key = (entry.Key as YamlScalarNode)?.Value;

if (string.Equals(key, "image", StringComparison.OrdinalIgnoreCase))
{
switch (entry.Value)

Check failure on line 107 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 107 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 107 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 107 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 107 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / verify (ubuntu-latest)

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 107 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / verify (windows-latest)

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 107 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / CocoaPods

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 107 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Gradle

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 107 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Maven

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 107 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / NPM

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 107 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Pip

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 107 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / NuGet

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 107 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Pnpm

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 107 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Poetry

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 107 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Ruby

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 107 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Rust

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 107 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Yarn

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 107 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / verify (macos-latest)

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)
{
// image: nginx:1.21
case YamlScalarNode scalarValue when !string.IsNullOrWhiteSpace(scalarValue.Value):
this.TryRegisterImageReference(scalarValue.Value, recorder, fileLocation);
break;

// image:
// repository: nginx
// tag: "1.21"
case YamlMappingNode imageMapping:
this.TryRegisterStructuredImageReference(imageMapping, recorder, fileLocation);
break;
}
}
else if (entry.Value is YamlMappingNode childMapping)
{
this.WalkYamlForImages(childMapping, recorder, fileLocation);
}
else if (entry.Value is YamlSequenceNode sequenceNode)
{
foreach (var item in sequenceNode)
{
if (item is YamlMappingNode sequenceMapping)
{
this.WalkYamlForImages(sequenceMapping, recorder, fileLocation);
}
}
}
}
}

private void TryRegisterStructuredImageReference(YamlMappingNode imageMapping, ISingleFileComponentRecorder recorder, string fileLocation)
{
Comment thread
jpinz marked this conversation as resolved.
string repository = null;
string tag = null;
string digest = null;
string registry = null;

foreach (var child in imageMapping.Children)
{
var childKey = (child.Key as YamlScalarNode)?.Value;
var childValue = (child.Value as YamlScalarNode)?.Value;

switch (childKey?.ToLowerInvariant())

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

In method 'TryRegisterStructuredImageReference', replace the call to 'ToLowerInvariant' with 'ToUpperInvariant' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1308)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

In method 'TryRegisterStructuredImageReference', replace the call to 'ToLowerInvariant' with 'ToUpperInvariant' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1308)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

In method 'TryRegisterStructuredImageReference', replace the call to 'ToLowerInvariant' with 'ToUpperInvariant' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1308)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

In method 'TryRegisterStructuredImageReference', replace the call to 'ToLowerInvariant' with 'ToUpperInvariant' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1308)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / verify (ubuntu-latest)

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / verify (ubuntu-latest)

In method 'TryRegisterStructuredImageReference', replace the call to 'ToLowerInvariant' with 'ToUpperInvariant' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1308)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / verify (windows-latest)

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / verify (windows-latest)

In method 'TryRegisterStructuredImageReference', replace the call to 'ToLowerInvariant' with 'ToUpperInvariant' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1308)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / CocoaPods

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / CocoaPods

In method 'TryRegisterStructuredImageReference', replace the call to 'ToLowerInvariant' with 'ToUpperInvariant' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1308)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Gradle

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Gradle

In method 'TryRegisterStructuredImageReference', replace the call to 'ToLowerInvariant' with 'ToUpperInvariant' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1308)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Maven

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Maven

In method 'TryRegisterStructuredImageReference', replace the call to 'ToLowerInvariant' with 'ToUpperInvariant' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1308)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / NPM

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / NPM

In method 'TryRegisterStructuredImageReference', replace the call to 'ToLowerInvariant' with 'ToUpperInvariant' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1308)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Pip

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Pip

In method 'TryRegisterStructuredImageReference', replace the call to 'ToLowerInvariant' with 'ToUpperInvariant' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1308)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / NuGet

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / NuGet

In method 'TryRegisterStructuredImageReference', replace the call to 'ToLowerInvariant' with 'ToUpperInvariant' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1308)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Pnpm

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Pnpm

In method 'TryRegisterStructuredImageReference', replace the call to 'ToLowerInvariant' with 'ToUpperInvariant' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1308)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Poetry

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Poetry

In method 'TryRegisterStructuredImageReference', replace the call to 'ToLowerInvariant' with 'ToUpperInvariant' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1308)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Ruby

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Ruby

In method 'TryRegisterStructuredImageReference', replace the call to 'ToLowerInvariant' with 'ToUpperInvariant' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1308)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Rust

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Rust

In method 'TryRegisterStructuredImageReference', replace the call to 'ToLowerInvariant' with 'ToUpperInvariant' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1308)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Yarn

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / Yarn

In method 'TryRegisterStructuredImageReference', replace the call to 'ToLowerInvariant' with 'ToUpperInvariant' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1308)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / verify (macos-latest)

Populate switch (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0010)

Check failure on line 151 in src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

View workflow job for this annotation

GitHub Actions / verify (macos-latest)

In method 'TryRegisterStructuredImageReference', replace the call to 'ToLowerInvariant' with 'ToUpperInvariant' (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1308)
{
case "repository":
repository = childValue;
break;
case "tag":
tag = childValue;
break;
case "digest":
digest = childValue;
break;
case "registry":
registry = childValue;
break;
}
}

if (string.IsNullOrWhiteSpace(repository))
{
return;
}

var imageRef = !string.IsNullOrWhiteSpace(registry)
? $"{registry}/{repository}"
: repository;

if (!string.IsNullOrWhiteSpace(tag))
{
imageRef = $"{imageRef}:{tag}";
}

if (!string.IsNullOrWhiteSpace(digest))
{
imageRef = $"{imageRef}@{digest}";
}

this.TryRegisterImageReference(imageRef, recorder, fileLocation);
}

private void TryRegisterImageReference(string imageReference, ISingleFileComponentRecorder recorder, string fileLocation)
{
try
{
var dockerRef = DockerReferenceUtility.ParseFamiliarName(imageReference);
if (dockerRef != null)
{
recorder.RegisterUsage(new DetectedComponent(dockerRef.ToTypedDockerReferenceComponent()));
}
}
catch (Exception e)
{
this.Logger.LogWarning(e, "Failed to parse image reference '{ImageReference}' in {Location}", imageReference, fileLocation);
}
Comment thread
jpinz marked this conversation as resolved.
Outdated
}
}
Loading
Loading