Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] docker: don't ignore version tag when consolidating dependencies #3251

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
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
12 changes: 9 additions & 3 deletions docker/lib/dependabot/docker/file_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class FileParser < Dependabot::FileParsers::Base
AWS_ECR_URL = /dkr\.ecr\.(?<region>[^.]+).amazonaws\.com/.freeze

def parse
dependency_set = DependencySet.new
dependencies = []

dockerfiles.each do |dockerfile|
dockerfile.content.each_line do |line|
Expand All @@ -47,7 +47,7 @@ def parse
version = version_from(parsed_from_line)
next unless version

dependency_set << Dependency.new(
current = Dependency.new(
name: parsed_from_line.fetch("image"),
version: version,
package_manager: "docker",
Expand All @@ -58,10 +58,16 @@ def parse
source: source_from(parsed_from_line)
]
)
existing = dependencies.find {|d| d.name == current.name && d.version == current.version }
if existing
existing.requirements.push(*current.requirements).uniq!
else
dependencies << current
end
end
end

dependency_set.dependencies
dependencies
end

private
Expand Down