Sha256: 04d261be76998927e27ed4d0b0189906fdf6274117c61e49ff035429823fcffe

Contents?: true

Size: 1.31 KB

Versions: 2

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 cs__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

2 entries across 2 versions & 1 rubygems

Version Path
contrast-agent-3.8.5 lib/contrast/core_extensions/inventory/datastores.rb
contrast-agent-3.8.4 lib/contrast/core_extensions/inventory/datastores.rb