Skip to content

Commit 78aacbf

Browse files
committed
Address PR comments.
1 parent 4bc3c0a commit 78aacbf

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/Microsoft.ComponentDetection.Detectors/dockerfile/DockerfileComponentDetector.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ namespace Microsoft.ComponentDetection.Detectors.Dockerfile;
44
using System;
55
using System.Collections.Generic;
66
using System.IO;
7-
using System.Linq;
87
using System.Threading;
98
using System.Threading.Tasks;
109
using Microsoft.ComponentDetection.Common;
@@ -116,7 +115,6 @@ private Task ParseDockerFileAsync(string fileContents, string fileLocation, ISin
116115

117116
private DockerReference? ParseFromInstruction(DockerfileConstruct construct, char escapeChar, Dictionary<string, string> stageNameMap)
118117
{
119-
var tokens = construct.Tokens.ToArray();
120118
var resolvedFromStatement = construct.ResolveVariables(escapeChar)?.TrimEnd();
121119
var fromInstruction = (FromInstruction)construct;
122120
var reference = fromInstruction.ImageName;

src/Microsoft.ComponentDetection.Detectors/helm/HelmComponentDetector.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,15 @@ protected override async Task OnFileFoundAsync(ProcessRequest processRequest, ID
9797
}
9898
}
9999

100+
/// <summary>
101+
/// Checks if the given file name matches Helm chart file patterns (Chart.yaml or Chart.yml).
102+
/// </summary>
103+
/// <param name="fileName">The file name to check.</param>
104+
/// <returns>True if the file name matches Helm chart file patterns; otherwise, false.</returns>
105+
/// <remarks> The <c>C</c> in <c>Chart.yaml</c> is case-sensitive <see href="https://helm.sh/docs/chart_best_practices/conventions/#usage-of-the-words-helm-and-chart"/>.</remarks>
100106
private static bool IsChartFile(string fileName) =>
101-
fileName.Equals("Chart.yaml", StringComparison.OrdinalIgnoreCase) ||
102-
fileName.Equals("Chart.yml", StringComparison.OrdinalIgnoreCase);
107+
fileName.Equals("Chart.yaml", StringComparison.Ordinal) ||
108+
fileName.Equals("Chart.yml", StringComparison.Ordinal);
103109

104110
private static bool IsValuesFile(string fileName) =>
105111
fileName.Contains("values", StringComparison.OrdinalIgnoreCase) &&

test/Microsoft.ComponentDetection.Detectors.Tests/HelmComponentDetectorTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ public async Task TestHelm_LowercaseChartYamlAsync()
405405
version: 0.1.0
406406
";
407407

408+
// Helm's Chart.yml file has to be named with an uppercase 'C'. Verify that files not matching this pattern are ignored.
408409
var (scanResult, componentRecorder) = await this.DetectorTestUtility
409410
.WithFile("chart.yaml", chartYaml)
410411
.ExecuteDetectorAsync();

0 commit comments

Comments
 (0)