Class: Contrast::Agent::Reporting::FindingEventObject
- Inherits:
-
ReportableHash
- Object
- ReportableHash
- Contrast::Agent::Reporting::FindingEventObject
- Defined in:
- lib/contrast/agent/reporting/reporting_events/finding_event_object.rb
Overview
This is the new FindingEventObject class which will include all the needed information for the new reporting system to relay this information in the Finding/Trace messages. These FindingEventObjects are used by TeamServer to construct the vulnerability information for the assess feature. They represent those parts of the objects that were acted on in a Dataflow Finding.
Constant Summary collapse
- ELLIPSIS =
We’ll truncate any object that isn’t important to the taint ranges of this event, so that we don’t murder TeamServer by, for instance, hypothetically sending the entire rendered HTML page >_> <_< >_>
'...'
- UNTRUNCATED_PORTION_LENGTH =
25
- TRUNCATION_LENGTH =
(UNTRUNCATED_PORTION_LENGTH * 2) + ELLIPSIS.length
Instance Attribute Summary collapse
-
#hash ⇒ Integer
readonly
The id of the Object this represents.
-
#tracked ⇒ Boolean
readonly
If the Object is tracked or not.
-
#value ⇒ String
readonly
The base64 of the human readable representation of the Object this represents.
Class Method Summary collapse
Instance Method Summary collapse
-
#attach_data(object, truncate) ⇒ Object
Parse the data from a Contrast::Agent::Assess::ContrastObject to attach what is required for reporting to TeamServer to this Contrast::Agent::Reporting::FindingEventObject.
-
#to_controlled_hash ⇒ Hash
Convert the instance variables on the class, and other information, into the identifiers required for TeamServer to process the JSON form of this message.
- #validate ⇒ Object
Methods inherited from ReportableHash
Methods included from Components::Logger::InstanceMethods
Instance Attribute Details
#hash ⇒ Integer (readonly)
Returns the id of the Object this represents.
17 18 19 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_object.rb', line 17 def hash @hash end |
#tracked ⇒ Boolean (readonly)
Returns if the Object is tracked or not.
19 20 21 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_object.rb', line 19 def tracked @tracked end |
#value ⇒ String (readonly)
Returns the base64 of the human readable representation of the Object this represents.
21 22 23 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_object.rb', line 21 def value @value end |
Class Method Details
.convert(object, truncate) ⇒ Contrast::Agent::Reporting::FindingEventObject
33 34 35 36 37 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_object.rb', line 33 def convert object, truncate report = new report.attach_data(object, truncate) report end |
Instance Method Details
#attach_data(object, truncate) ⇒ Object
Parse the data from a Contrast::Agent::Assess::ContrastObject to attach what is required for reporting to TeamServer to this Contrast::Agent::Reporting::FindingEventObject
44 45 46 47 48 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_object.rb', line 44 def attach_data object, truncate @hash = object ? object.tracked_object_id : nil.__id__ @tracked = !!object&.tracked? @value = reportable_value(object&.object, truncate) end |
#to_controlled_hash ⇒ Hash
Convert the instance variables on the class, and other information, into the identifiers required for TeamServer to process the JSON form of this message.
55 56 57 58 59 60 61 62 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_object.rb', line 55 def to_controlled_hash validate { hash: hash, tracked: tracked, value: value } end |
#validate ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_object.rb', line 65 def validate raise(ArgumentError, "#{ self } did not have a proper hash. Unable to continue.") unless hash raise(ArgumentError, "#{ self } did not have a proper tracked. Unable to continue.") if tracked.nil? return if value raise(ArgumentError, "#{ self } did not have a proper value. Unable to continue.") end |