File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ module Quayio
55 module Scanner
66 class Image < Struct . new ( :name , :quayio_token , :whitelist )
77 RELEVANT_SEVERITIES = %w( High Critical )
8+ MAX_ATTEMPTS = 5
89
910 def vulnerable?
1011 quayio? && image_exists? && scanned? && high_vulnerabilities_present?
@@ -44,14 +45,22 @@ def tag
4445 def raw_image
4546 return @raw_image if defined? @raw_image
4647
47- @raw_image = begin
48- JSON . parse (
49- RestClient . get ( "https://quay.io/api/v1/repository/#{ repo } /tag/#{ tag } /images" ,
50- authorization : "Bearer #{ quayio_token } " , accept : :json )
51- ) [ 'images' ] . first
52- rescue RestClient ::ExceptionWithResponse => err
53- return nil if err . http_code == 404 # ignore unknown repos
54- raise err
48+ ( 1 ..MAX_ATTEMPTS ) . each do |attempt |
49+ begin
50+ response = RestClient . get (
51+ "https://quay.io/api/v1/repository/#{ repo } /tag/#{ tag } /images" ,
52+ authorization : "Bearer #{ quayio_token } " ,
53+ accept : :json )
54+ rescue RestClient ::ExceptionWithResponse => err
55+ return nil if err . http_code == 404 # ignore unknown repos
56+ if err . http_code == 520 and attempt < MAX_ATTEMPTS
57+ sleep ( rand ( 10 ) )
58+ next
59+ end
60+ raise err
61+ end
62+ @raw_image = JSON . parse ( response ) [ 'images' ] . first
63+ return @raw_image
5564 end
5665 end
5766
You can’t perform that action at this time.
0 commit comments