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

docker-podman: stricter container ID regex to avoid bad matches #13307

Closed
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion plugins/providers/docker/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def build(dir, **opts, &block)
# Check for podman format when it is emulating docker CLI.
# Podman outputs the full hash of the container on
# the last line after a successful build.
match = result.split.select { |str| str.match?(/[0-9a-z]{64}/) }.last
match = result.split.select { |str| str.match?(/^[0-9a-z]{64}/) }.last
return match[0..7] unless match.nil?
else
matches = result.scan(/Successfully built (.+)$/i).last
Expand Down
2 changes: 1 addition & 1 deletion test/unit/plugins/providers/docker/driver_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@
end

context "using podman emulating docker CLI" do
let(:stdout) { "1a2b3c4d5e6f7g8h9i10j11k12l13m14n16o17p18q19r20s21t22u23v24w25x2" }
let(:stdout) { "1a2b3c4d5e6f7g8h9i10j11k12l13m14n16o17p18q19r20s21t22u23v24w25x2\nCopying config sha256:368a084ba17dcba88f5b23acfa47481131010219524fd9c41af87d709a04845b" }

it "builds a container with podman emulating docker CLI" do
allow(subject).to receive(:podman?).and_return(true)
Expand Down