Sha256: a038ee40c779bc1631277d11ee198e9cb43a5835edc4a40784e08a4372bc62f8

Contents?: true

Size: 1.24 KB

Versions: 9

Compression:

Stored size: 1.24 KB

Contents

# Copyright (c) 2022 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/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

        # 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 ::Contrast::INVENTORY.enabled?
          return Contrast::Utils::ObjectShare::EMPTY_ARRAY unless ::Contrast::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

9 entries across 9 versions & 1 rubygems

Version Path
contrast-agent-6.2.0 lib/contrast/agent/inventory/dependency_analysis.rb
contrast-agent-6.1.2 lib/contrast/agent/inventory/dependency_analysis.rb
contrast-agent-6.1.1 lib/contrast/agent/inventory/dependency_analysis.rb
contrast-agent-6.1.0 lib/contrast/agent/inventory/dependency_analysis.rb
contrast-agent-6.0.0 lib/contrast/agent/inventory/dependency_analysis.rb
contrast-agent-5.3.0 lib/contrast/agent/inventory/dependency_analysis.rb
contrast-agent-5.2.0 lib/contrast/agent/inventory/dependency_analysis.rb
contrast-agent-5.1.0 lib/contrast/agent/inventory/dependency_analysis.rb
contrast-agent-5.0.0 lib/contrast/agent/inventory/dependency_analysis.rb