Class: Contrast::Agent::Reporting::FindingEventTaintRange

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

Overview

This is the new FindingEventTaintRange class which will include all the needed information for the new reporting system to relay this information in the Finding/Trace messages. These FindingTaintRanges are used by TeamServer to construct the vulnerability information for the assess feature. They represent those parts of the objects that are tracked because of a security relevant operation acting on them.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ReportableHash

#event_json, #valid?

Methods included from Components::Logger::InstanceMethods

#cef_logger, #logger

Instance Attribute Details

#rangeString (readonly)

Returns the range (inclusive:exclusive), that this tag covers.

Returns:

  • (String)

    the range (inclusive:exclusive), that this tag covers.



18
19
20
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_taint_range.rb', line 18

def range
  @range
end

#tagString (readonly)

Returns the type of action this tag represents.

Returns:

  • (String)

    the type of action this tag represents.



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

def tag
  @tag
end

Class Method Details

.convert(tag) ⇒ Contrast::Agent::Reporting::FindingEventTaintRange

Parameters:

Returns:



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

def convert tag
  report = new
  report.attach_data(tag)
  report
end

Instance Method Details

#attach_data(tag) ⇒ Object

Parse the data from a Contrast::Agent::Assess::Tag to attach what is required for reporting to TeamServer to this Contrast::Agent::Reporting::FindingEventTaintRange

Parameters:



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

def attach_data tag
  @range = "#{ tag.start_idx }:#{ tag.end_idx }"
  @tag = tag.label
end

#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.

Returns:

Raises:

  • (ArgumentError)


46
47
48
49
50
51
52
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_taint_range.rb', line 46

def to_controlled_hash
  validate
  {
      range: range,
      tag: tag
  }
end

#validateObject

Raises:

  • (ArgumentError)


55
56
57
58
59
60
61
62
63
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_taint_range.rb', line 55

def validate
  if Contrast::Utils::DuckUtils.empty_duck?(range) # rubocop:disable Style/GuardClause
    raise(ArgumentError, "#{ self } did not have a proper range. Unable to continue.")
  elsif Contrast::Utils::DuckUtils.empty_duck?(tag)
    raise(ArgumentError, "#{ self } did not have a proper tag. Unable to continue.")
  end

  nil
end