From 4c6f67e90ae8a9b088c15f3c816e251a2eded56c Mon Sep 17 00:00:00 2001 From: jonathanschlue-as Date: Tue, 29 Mar 2022 15:01:51 +0200 Subject: [PATCH 1/2] Adapt api requests to new manifest-based schema --- lib/quayio/scanner/repository.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/quayio/scanner/repository.rb b/lib/quayio/scanner/repository.rb index 1ee22d6..8c1e6d3 100644 --- a/lib/quayio/scanner/repository.rb +++ b/lib/quayio/scanner/repository.rb @@ -6,19 +6,19 @@ module Scanner Repository = Struct.new(:quayio_token, :org, :repo, :tag) do MAX_ATTEMPTS = 5 - def id - @id ||= fetch_id - end - def scan - api_call("/image/#{id}/security?vulnerabilities=true") + api_call("/manifest/#{manifest_ref}/security?vulnerabilities=true") end private - def fetch_id - result = api_call("/tag/#{tag}/images") - (result['images'].first)['id'] + def manifest_ref + @manifest_ref ||= fetch_manifest_ref + end + + def fetch_manifest_ref + result = api_call("/tag/?specificTag=#{tag}&onlyActiveTags=1") + (result['tags'].first)['manifest_digest'] end def api_call(uri) From 8ebdaaa8b3c03cde63b6bffbc6c0c26e96e5ba94 Mon Sep 17 00:00:00 2001 From: jonathanschlue-as Date: Tue, 29 Mar 2022 15:02:47 +0200 Subject: [PATCH 2/2] Remove redundant regex excape --- lib/quayio/scanner/image.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/quayio/scanner/image.rb b/lib/quayio/scanner/image.rb index 492182f..6c0d553 100644 --- a/lib/quayio/scanner/image.rb +++ b/lib/quayio/scanner/image.rb @@ -2,7 +2,7 @@ module Quayio module Scanner class Image RELEVANT_SEVERITIES = %w[High Critical].freeze - QUAY_IO_REPO_NAME = %r{quay.io\/(?[\w-]+)\/(?[\w-]+):(?[\w\.-]+)}.freeze + QUAY_IO_REPO_NAME = %r{quay.io\/(?[\w-]+)\/(?[\w-]+):(?[\w.-]+)}.freeze attr_reader :name, :whitelist, :repository