quayio-scanner 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5870d44003c0600c96604760935938ecad1576818ae94f997e01ba5172390952
4
- data.tar.gz: e1476f3dc385413bfbfb47b26345710774889913767bb0c9d9fcd2ab00996c6e
3
+ metadata.gz: 5df176d74b68e0b31a5408b2be36bac9c0cb2171650acb160cfedd90a143de2c
4
+ data.tar.gz: aab6b7098d7a848294613428d8b514589c949f5d9f1fdf9041af06932d12856c
5
5
  SHA512:
6
- metadata.gz: e85522f956cca1178c249269124af889f9937c75e442894cddcd0c7e45e9d191d7fa1cff688e15e95eb28f62ae8de3b0fe6bdb285ef4d33c3053eb2b041e563d
7
- data.tar.gz: 1b763e457f3ed56c1d8a812fb567fd93a38e31c1d93f1dc7a6108ec455ca0263cc4c552eae3bfdf7150f11b8c29816b77d72303f4f132c77567e51a4366db95b
6
+ metadata.gz: 1da63def2a66714fff1b69b709150b444a0b149f7da03c1a9bcdec87f895a1b73a44887d9ded63c928dca958f5edc82ecc06a074957c3103f96958dccb0f2183
7
+ data.tar.gz: a0c809340d55c456aa639ecebe00926722ece6f156efee325f713fcb25ef371ca8cc44ad828665767175f31fce558300665eb976ebbb8d9d8ac346d386cd1b96
@@ -5,6 +5,7 @@ module Quayio
5
5
  module Scanner
6
6
  class Image < Struct.new(:name, :quayio_token, :whitelist)
7
7
  RELEVANT_SEVERITIES = %w(High Critical)
8
+ MAX_ATTEMPTS = 5
8
9
 
9
10
  def vulnerable?
10
11
  quayio? && image_exists? && scanned? && high_vulnerabilities_present?
@@ -44,14 +45,22 @@ module Quayio
44
45
  def raw_image
45
46
  return @raw_image if defined? @raw_image
46
47
 
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
55
64
  end
56
65
  end
57
66
 
@@ -1,5 +1,5 @@
1
1
  module Quayio
2
2
  module Scanner
3
- VERSION = '0.1.4'.freeze
3
+ VERSION = '0.1.5'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quayio-scanner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Meichsner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-10 00:00:00.000000000 Z
11
+ date: 2020-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docker-api