Sha256: 2d22ac934f8867712a89a51b067b37b6072b6fea2dfb48aec13d4da19098a2b7

Contents?: true

Size: 1.33 KB

Versions: 8

Compression:

Stored size: 1.33 KB

Contents

# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

require 'contrast/agent/inventory/dependencies'
require 'contrast/components/interface'
require 'contrast/utils/object_share'

module Contrast
  module Agent
    module Inventory
      # Used to collect dependencies of the application for reporting
      class DependencyAnalysis
        include Singleton
        include Contrast::Agent::Inventory::Dependencies
        include Contrast::Components::Interface

        access_component :analysis

        # Report the dependencies of this application
        #
        # @return [Array<Contrast::Api::Dtm::Library>] protobuf form of the
        #   Gem::Specification that have been loaded for this application.
        def library_pb_list
          return Contrast::Utils::ObjectShare::EMPTY_ARRAY unless INVENTORY.enabled?
          return Contrast::Utils::ObjectShare::EMPTY_ARRAY unless INVENTORY.analyze_libraries?

          loaded_specs.each_with_object([]) do |(_name, spec), reported_lib_list|
            next unless spec
            next unless (digest = Contrast::Utils::Sha256Builder.instance.build_from_spec(spec))

            reported_lib_list << Contrast::Api::Dtm::Library.build(digest, spec)
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
contrast-agent-4.4.1 lib/contrast/agent/inventory/dependency_analysis.rb
contrast-agent-4.4.0 lib/contrast/agent/inventory/dependency_analysis.rb
contrast-agent-4.3.2 lib/contrast/agent/inventory/dependency_analysis.rb
contrast-agent-4.3.1 lib/contrast/agent/inventory/dependency_analysis.rb
contrast-agent-4.3.0 lib/contrast/agent/inventory/dependency_analysis.rb
contrast-agent-4.2.0 lib/contrast/agent/inventory/dependency_analysis.rb
contrast-agent-4.1.0 lib/contrast/agent/inventory/dependency_analysis.rb
contrast-agent-4.0.0 lib/contrast/agent/inventory/dependency_analysis.rb