Class: Contrast::Agent::Reporting::LibraryUsageObservation

Inherits:
ReportableHash show all
Defined in:
lib/contrast/agent/reporting/reporting_events/library_usage_observation.rb

Overview

The usage, meaning loaded files, of a library seen during this request

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ReportableHash

#event_json, #valid?

Methods included from Components::Logger::InstanceMethods

#cef_logger, #logger

Constructor Details

#initialize(id, class_names) ⇒ LibraryUsageObservation

Returns a new instance of LibraryUsageObservation.

Parameters:

  • id (String)

    Sha256Sum of library as identified by the agent

  • class_names (Array<String>)

    List of file paths that have been loaded out of or executed by the library



19
20
21
22
23
# File 'lib/contrast/agent/reporting/reporting_events/library_usage_observation.rb', line 19

def initialize id, class_names
  @id = id
  @names = class_names
  super()
end

Instance Attribute Details

#idObject (readonly)

Parameters:

  • Sha256Sum (String)

    of library as identified by the agent



13
14
15
# File 'lib/contrast/agent/reporting/reporting_events/library_usage_observation.rb', line 13

def id
  @id
end

#namesObject (readonly)

Parameters:

  • List (Array<String>)

    of file paths that have been loaded out of or executed by the library



15
16
17
# File 'lib/contrast/agent/reporting/reporting_events/library_usage_observation.rb', line 15

def names
  @names
end

Instance Method Details

#to_controlled_hashObject

Raises:

  • (ArgumentError)


26
27
28
29
30
31
32
# File 'lib/contrast/agent/reporting/reporting_events/library_usage_observation.rb', line 26

def to_controlled_hash
  validate
  {
      id: @id,
      names: @names
  }
end

#validateObject

Raises:

  • (ArgumentError)


35
36
37
38
39
40
41
42
43
44
# File 'lib/contrast/agent/reporting/reporting_events/library_usage_observation.rb', line 35

def validate
  if Contrast::Utils::DuckUtils.empty_duck?(id)
    raise(ArgumentError, "#{ self } did not have a proper id. Unable to continue.")
  end
  if Contrast::Utils::DuckUtils.empty_duck?(names)
    raise(ArgumentError, "#{ self } did not have a proper names. Unable to continue.")
  end

  nil
end