Sha256: a1437fb123c2f6091d65b87193c1452bfa4103408369edc905e9891e23e0310a

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

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

cs__scoped_require 'contrast/components/interface'
cs__scoped_require 'contrast/utils/gemfile_reader'
cs__scoped_require 'contrast/api/decorators/application_update'

module Contrast
  module Agent
    # this module handles one time static analysis tasks
    class StaticAnalysis
      include Singleton
      include Contrast::Components::Interface
      access_component :logging, :analysis, :contrast_service, :scope
      class << self
        # After the first request is complete, we do a one-time manual catchup to review and
        # report the already-loaded gems.
        def catchup
          @_catchup ||= begin
                          with_contrast_scope do
                            Contrast::Utils::GemfileReader.instance.map_loaded_classes
                            send_inventory_message
                            true
                          end
                        end
        rescue StandardError => e
          logger.warn('Unable to run post-initialization static analysis', e)
        end

        def send_inventory_message
          return unless INVENTORY.enabled?

          app_update_msg = Contrast::Api::Dtm::ApplicationUpdate.build

          Contrast::Utils::InventoryUtil.append_db_config(app_update_msg)

          CONTRAST_SERVICE.queue_message app_update_msg
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
contrast-agent-3.11.0 lib/contrast/agent/static_analysis.rb