Sha256: f588987e3e5caa6bc31915988b09a86527df4bc032517031b7e16cca83826207
Contents?: true
Size: 1.99 KB
Versions: 2
Compression:
Stored size: 1.99 KB
Contents
# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true require 'contrast/utils/class_util' require 'contrast/utils/object_share' require 'contrast/agent/assess/tracker' module Contrast module Agent module Assess # This class is a convenient holder of our version of an Object. It # creates a String version of the Object from the original provided # and keeps reference to the original's Tags, letting us determine if it # was tracked when we try to report to TeamServer. # # @attr_reader object [String, nil] the Contrast string representing the # object. # @attr_reader object_type [String] the name of the object's module. # @attr_reader tags [Hash{String => Contrast::Agent::Assess::Tag}, nil] # the tags on the object before it was captured. # # TODO: RUBY-1083 determine if this is expensive and/or worth not storing # these values directly on ContrastEvent and passing them around. Args # probably make the argument for wrapping them b/c otherwise we'll have # to keep two arrays in synch or make an array of arrays, at which # point, we may as well make this. class ContrastObject attr_reader :object, :object_type, :tags # Capture the details about the object which we need to render it in # TeamServer. # # @param object [Object, nil] the thing to keep a Contrast String of def initialize object if object @object = Contrast::Utils::ClassUtil.to_contrast_string(object) @object_type = object.cs__class.cs__name @tags = Contrast::Agent::Assess::Tracker.properties(object)&.get_tags else @object = Contrast::Utils::ObjectShare::NIL_STRING @object_type = nil.cs__class.cs__name end end def tracked? tags&.any? end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
contrast-agent-5.1.0 | lib/contrast/agent/assess/contrast_object.rb |
contrast-agent-5.0.0 | lib/contrast/agent/assess/contrast_object.rb |