Sha256: 6cef86538083e761ee6a676835403e52c6dfdd946641329bfb1afc22bde99475

Contents?: true

Size: 1.31 KB

Versions: 1

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 :analysis, :logging
          # 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('Error reporting database call', e, object: object)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
contrast-agent-3.11.0 lib/contrast/extensions/ruby_core/inventory/datastores.rb