Sha256: 6d3a73d8f96adf784e5386d439d0709a43a56bf036970042bde3d3493bcbd9e3

Contents?: true

Size: 1.31 KB

Versions: 5

Compression:

Stored size: 1.31 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/data_store_util'

module Contrast
  module CoreExtensions
    module Inventory
      # This Module is how we apply the Data Store detection required for the
      # FlowMap feature. It is called from our patches of the targeted methods
      # in which database operations occur. It is responsible for deciding if
      # the given invocation is worth reporting or not.
      module DataStores
        class << self
          include Contrast::Components::Interface

          access_component :logging, :analysis
          # The key used in policy.json to indicate the database type to
          # report.
          DATA_STORE_MARKER = 'data_store'

          def patched_report_data_store _method, _exception, properties, object, _args
            return unless INVENTORY.enabled?

            marker = properties[DATA_STORE_MARKER]
            return unless marker

            Contrast::Utils::DataStoreUtil.report_data_store(marker)
          rescue StandardError => e
            logger.error(e, "Error reporting database call in #{ object }")
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
contrast-agent-3.10.2 lib/contrast/extensions/ruby_core/inventory/datastores.rb
contrast-agent-3.10.1 lib/contrast/extensions/ruby_core/inventory/datastores.rb
contrast-agent-3.10.0 lib/contrast/extensions/ruby_core/inventory/datastores.rb
contrast-agent-3.9.1 lib/contrast/extensions/ruby_core/inventory/datastores.rb
contrast-agent-3.9.0 lib/contrast/extensions/ruby_core/inventory/datastores.rb