Class: Contrast::Agent::Reporting::FindingEventStack

Inherits:
ReportingEvent show all
Defined in:
lib/contrast/agent/reporting/reporting_events/finding_event_stack.rb

Overview

This is the new FindingEventStack class which will include all the needed information for the new reporting system to relay this information in the Finding/Trace messages. These FindingEventStack are used by TeamServer to construct the vulnerability information for the assess feature. They represent the callstack at the time that each FindingEvent was generated.

Constant Summary collapse

AGENT_CLASS_MARKER =
'/lib/contrast/'

Instance Attribute Summary collapse

Attributes inherited from ReportingEvent

#event_endpoint, #event_method

Instance Method Summary collapse

Methods inherited from ReportingEvent

#attach_headers

Methods inherited from ReportableHash

#event_json, #valid?

Methods included from Components::Logger::InstanceMethods

#cef_logger, #logger

Constructor Details

#initialize(file_name) ⇒ FindingEventStack

To play nice with the way that TeamServer is rendering these values, we only populate the file_name field with exactly what we want them to display.



35
36
37
38
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_stack.rb', line 35

def initialize file_name
  @file = file_name
  super()
end

Instance Attribute Details

#evalString (readonly)



17
18
19
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_stack.rb', line 17

def eval
  @eval
end

#fileString (readonly)



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

def file
  @file
end

#line_numberString (readonly)



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

def line_number
  @line_number
end

#methodString (readonly)



23
24
25
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_stack.rb', line 23

def method
  @method
end

#signatureString (readonly)



25
26
27
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_stack.rb', line 25

def signature
  @signature
end

#typeString (readonly)



27
28
29
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_stack.rb', line 27

def type
  @type
end

Instance Method Details

#to_controlled_hashHash

Convert the instance variables on the class, and other information, into the identifiers required for TeamServer to process the JSON form of this message.

Raises:

  • (ArgumentError)


45
46
47
48
49
50
51
52
53
54
55
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_stack.rb', line 45

def to_controlled_hash
  validate
  {
      file: file
    # eval: eval, # This is unused by the Ruby agent
    # line_number: line_number, # This is unused by the Ruby agent
    # method: method, # This is unused by the Ruby agent
    # signature: signature, # This is unused by the Ruby agent
    # type: type  # This is unused by the Ruby agent
  }
end

#validateObject

Raises:

  • (ArgumentError)


57
58
59
60
61
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_stack.rb', line 57

def validate
  return unless Contrast::Utils::DuckUtils.empty_duck?(file)

  raise(ArgumentError, "#{ self } did not have a proper file. Unable to continue.")
end