From fa398d0bb6caceab646cc6aca4e5f655f1a405ff Mon Sep 17 00:00:00 2001 From: Jason Rudolph Date: Wed, 10 Feb 2021 15:13:37 -0500 Subject: [PATCH 1/2] Fix media types in Accept header for Docker Registry --- docker/lib/dependabot/docker/update_checker.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/docker/lib/dependabot/docker/update_checker.rb b/docker/lib/dependabot/docker/update_checker.rb index d87c066278..bec79fbec6 100644 --- a/docker/lib/dependabot/docker/update_checker.rb +++ b/docker/lib/dependabot/docker/update_checker.rb @@ -14,16 +14,20 @@ class Registry private # By default the Docker Registry client sets the Accept header to - # `application/vnd.docker.distribution.manifest.v2+json` - # This results in the digest of a specific platform to be returned, we - # want to override this header so we can fetch the generic digest - # associated with the given repo/tag. + # `application/vnd.docker.distribution.manifest.v2+json`. This is fine for + # most images, but for multi-architecture images, it fetches the digest of a + # specific architecture instead of the digest for the multi-architecture + # image. We override the header to tell the Docker API to vary its behavior + # depending on whether the image is a uses a traditional (non-list) manifest + # or a manifest list. If the image uses a traditional manifest, the API will + # return the manifest digest. If the image uses a manifest list, the API + # will return the manifest list digest. def headers(payload: nil, bearer_token: nil) headers = {} headers["Authorization"] = "Bearer #{bearer_token}" unless bearer_token.nil? if payload.nil? headers["Accept"] = - "application/vnd.docker.distribution.manifest.list.v2+json, application/json" + "application/vnd.docker.distribution.manifest.v2+json, application/vnd.docker.distribution.manifest.list.v2+json, application/json" end headers["Content-Type"] = "application/vnd.docker.distribution.manifest.v2+json" unless payload.nil? From 9d16037ea7b75c47c187fa92fa70ee0b53f14be5 Mon Sep 17 00:00:00 2001 From: Jason Rudolph Date: Wed, 10 Feb 2021 17:57:35 -0500 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=91=95=20Fix=20linter=20violation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/lib/dependabot/docker/update_checker.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docker/lib/dependabot/docker/update_checker.rb b/docker/lib/dependabot/docker/update_checker.rb index bec79fbec6..834fcbc991 100644 --- a/docker/lib/dependabot/docker/update_checker.rb +++ b/docker/lib/dependabot/docker/update_checker.rb @@ -26,8 +26,11 @@ def headers(payload: nil, bearer_token: nil) headers = {} headers["Authorization"] = "Bearer #{bearer_token}" unless bearer_token.nil? if payload.nil? - headers["Accept"] = - "application/vnd.docker.distribution.manifest.v2+json, application/vnd.docker.distribution.manifest.list.v2+json, application/json" + headers["Accept"] = %w( + application/vnd.docker.distribution.manifest.v2+json + application/vnd.docker.distribution.manifest.list.v2+json + application/json" + ).join(",") end headers["Content-Type"] = "application/vnd.docker.distribution.manifest.v2+json" unless payload.nil?