Module: Contrast::Api::Decorators::TraceEventObject::ClassMethods
- Includes:
- Components::Interface
- Defined in:
- lib/contrast/api/decorators/trace_event_object.rb
Overview
Class methods for TraceEventObject
Constant Summary collapse
- ELLIPSIS =
Build the event object. We were originally going to include taint on each one, but TS doesn’t accept / use that, so it is a waste of time.
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 Method Summary collapse
Methods included from Components::Interface
Instance Method Details
#build(object, truncate) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/contrast/api/decorators/trace_event_object.rb', line 32 def build object, truncate event_object = new with_contrast_scope do obj_string = Contrast::Utils::StringUtils.force_utf8(object) obj_string = truncate(obj_string) if truncate && obj_string.length > TRUNCATION_LENGTH event_object.value = Base64.encode64(obj_string) event_object.tracked = Contrast::Utils::Assess::TrackingUtil.tracked?(object) end event_object end |
#truncate(obj_string) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/contrast/api/decorators/trace_event_object.rb', line 43 def truncate obj_string tmp = [] tmp << obj_string[0, UNTRUNCATED_PORTION_LENGTH] tmp << ELLIPSIS tmp << obj_string[ obj_string.length - UNTRUNCATED_PORTION_LENGTH, UNTRUNCATED_PORTION_LENGTH] tmp.join end |