diff --git a/docker/lib/dependabot/shared/utils/helpers.rb b/docker/lib/dependabot/shared/utils/helpers.rb index 09bbf5daca6..796b7d7096d 100644 --- a/docker/lib/dependabot/shared/utils/helpers.rb +++ b/docker/lib/dependabot/shared/utils/helpers.rb @@ -6,7 +6,7 @@ module Dependabot module Shared module Utils - HELM_REGEXP = /values[\-a-zA-Z_0-9]*\.ya?ml$/i + HELM_REGEXP = %r{(^|/)values(?:\.[\w-]+)?\.ya?ml$}i extend T::Sig diff --git a/helm/lib/dependabot/helm/file_parser.rb b/helm/lib/dependabot/helm/file_parser.rb index 0dbcb1bbfd2..91230edbbdc 100644 --- a/helm/lib/dependabot/helm/file_parser.rb +++ b/helm/lib/dependabot/helm/file_parser.rb @@ -12,7 +12,7 @@ class FileParser < Dependabot::Shared::SharedFileParser CHART_YAML = /.*chart\.ya?ml$/i CHART_LOCK = /.*chart\.lock$/i - VALUES_YAML = /.*values\.ya?ml$/i + VALUES_YAML = %r{.*(^|/)values(?:\.[\w-]+)?\.ya?ml$}i DEFAULT_REPOSITORY = "https://charts.helm.sh/stable" sig { returns(Ecosystem) } diff --git a/helm/spec/dependabot/helm/file_parser_spec.rb b/helm/spec/dependabot/helm/file_parser_spec.rb index 94258de4dc7..7fbfff00797 100644 --- a/helm/spec/dependabot/helm/file_parser_spec.rb +++ b/helm/spec/dependabot/helm/file_parser_spec.rb @@ -191,6 +191,34 @@ expect(dependency.version).to eq("1.25.3") end end + + context "with environment-specific values file (values.cass.yaml)" do + let(:helmfile_fixture_name) { "values_environment_specific.yaml" } + let(:helmfile) do + Dependabot::DependencyFile.new( + name: "values.cass.yaml", + content: helmfile_body + ) + end + + it "is able to parse environment-specific values files" do + expect(dependencies.length).to eq(3) + + mdsd_dependency = dependencies.find { |d| d.name == "linuxgeneva-microsoft.azurecr.io/distroless/genevamdsd" } + expect(mdsd_dependency).to be_a(Dependabot::Dependency) + expect(mdsd_dependency.version).to eq("1.35.9-20250722-2") + + mdm_dependency = dependencies.find { |d| d.name == "linuxgeneva-microsoft.azurecr.io/distroless/genevamdm" } + expect(mdm_dependency).to be_a(Dependabot::Dependency) + expect(mdm_dependency.version).to eq("2.202507220956.0-20250722-1") + + fluentd_dependency = dependencies.find do |d| + d.name == "linuxgeneva-microsoft.azurecr.io/distroless/genevafluentd" + end + expect(fluentd_dependency).to be_a(Dependabot::Dependency) + expect(fluentd_dependency.version).to eq("1.18.0-20250722-2") + end + end end end diff --git a/helm/spec/fixtures/helm/v3/values_environment_specific.yaml b/helm/spec/fixtures/helm/v3/values_environment_specific.yaml new file mode 100644 index 00000000000..49608865786 --- /dev/null +++ b/helm/spec/fixtures/helm/v3/values_environment_specific.yaml @@ -0,0 +1,15 @@ +# Test fixture for environment-specific values file like values.cass.yaml +mdsd: + image: + repository: linuxgeneva-microsoft.azurecr.io/distroless/genevamdsd + tag: 1.35.9-20250722-2 + +mdm: + image: + repository: linuxgeneva-microsoft.azurecr.io/distroless/genevamdm + tag: 2.202507220956.0-20250722-1 + +fluentd: + image: + repository: linuxgeneva-microsoft.azurecr.io/distroless/genevafluentd + tag: 1.18.0-20250722-2 \ No newline at end of file