Class: Quayio::Scanner::Check

Inherits:
Struct
  • Object
show all
Defined in:
lib/quayio/scanner/check.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#docker_urlObject

Returns the value of attribute docker_url

Returns:

  • (Object)

    the current value of docker_url



6
7
8
# File 'lib/quayio/scanner/check.rb', line 6

def docker_url
  @docker_url
end

#quayio_tokenObject

Returns the value of attribute quayio_token

Returns:

  • (Object)

    the current value of quayio_token



6
7
8
# File 'lib/quayio/scanner/check.rb', line 6

def quayio_token
  @quayio_token
end

Instance Method Details

#runObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/quayio/scanner/check.rb', line 7

def run
  Docker.url = docker_url
  containers = Docker::Container.all
                                .map { |dc| dc.json['Config']['Image'] }
                                .uniq

  vulnerable_images = containers
                      .map { |container| Image.new(container, quayio_token) }
                      .select(&:vulnerable?)
                      .map(&:name)

  if vulnerable_images.empty?
    [:ok, "#{containers.size} Containers are ok"]
  else
    [:critical, "The images are insecure: #{vulnerable_images.join(', ')}"]
  end
end