lib/contrast/utils/class_util.rb in contrast-agent-5.3.0 vs lib/contrast/utils/class_util.rb in contrast-agent-6.0.0
- old
+ new
@@ -48,12 +48,12 @@
# Return a String representing the object invoking this method in the form expected by our dataflow events.
# After implementing the LRU Cache, we firstly need to check if already had that object cached and if we have
# it - we can return it directly; otherwise we'll calculate and store the result before returning.
#
- # TODO: RUBY-1327
- # Once we move to 2.7+, we can combine the caches using ID b/c the memory location stops being the id
+ # Combining of the caches have close performance, but keeping the two with current implementation has
+ # a slight advantage in performance. For now we can keep the things the way they are.
#
# @param object [Object, nil] the entity to convert to a String
# @return [String, Object] the human readable form of the String, as defined by
# https://bitbucket.org/contrastsecurity/assess-specifications/src/master/vulnerability/capture-snapshot.md
def to_contrast_string object
@@ -96,19 +96,10 @@
# @param name [String] the name of the constant to look up
# @return [Boolean]
def truly_defined? name
return false unless name
- segments = name.split(Contrast::Utils::ObjectShare::DOUBLE_COLON)
- previous_module = Module
- segments.each do |segment|
- return false if previous_module.cs__autoload?(segment)
- return false unless previous_module.cs__const_defined?(segment)
-
- previous_module = previous_module.cs__const_get(segment)
- end
-
- true
+ Module.cs__const_defined?(name)
rescue NameError # account for nonsense / poorly formatted constants
false
end
private