Sha256: d8cd8e98e7004534fa54b87f264fc7dcd692539157d6343e1de3e544fbdf04bb

Contents?: true

Size: 1.95 KB

Versions: 6

Compression:

Stored size: 1.95 KB

Contents

# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

require 'contrast/utils/string_utils'
require 'contrast/utils/assess/tracking_util'
require 'base64'

module Contrast
  module Api
    module Decorators
      # Used to decorate the {Contrast::Api::Dtm::TraceEventSignature} protobuf
      # model.
      module TraceEventSignature
        def self.included klass
          klass.extend(ClassMethods)
        end

        # Class methods for TraceEventSignature
        module ClassMethods
          def build ret_obj, policy_node, args
            signature = new
            return_type = ret_obj ? ret_obj.cs__class.name : Contrast::Utils::ObjectShare::NIL_STRING
            signature.return_type = Contrast::Utils::StringUtils.force_utf8(return_type)
            signature.class_name = Contrast::Utils::StringUtils.force_utf8(policy_node.class_name)
            signature.method_name = Contrast::Utils::StringUtils.force_utf8(policy_node.method_name)
            if args
              args&.each do |arg|
                arg_type = arg ? arg.cs__class.name : Contrast::Utils::ObjectShare::NIL_STRING
                signature.arg_types << Contrast::Utils::StringUtils.force_utf8(arg_type)
              end
            end
            signature.constructor = policy_node.method_name == :new
            # if there's a ret, then this method isn't nil. not 100% full proof since you can
            # return nil, but this is the best we've got currently.
            signature.void_method = ret_obj.nil?
            # 8 is STATIC in Java... we have to placate them for now
            # it has been requested that flags be removed since it isn't used
            signature.flags = 8 unless policy_node.instance_method?
            signature
          end
        end
      end
    end
  end
end

Contrast::Api::Dtm::TraceEventSignature.include(Contrast::Api::Decorators::TraceEventSignature)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
contrast-agent-4.2.0 lib/contrast/api/decorators/trace_event_signature.rb
contrast-agent-4.1.0 lib/contrast/api/decorators/trace_event_signature.rb
contrast-agent-4.0.0 lib/contrast/api/decorators/trace_event_signature.rb
contrast-agent-3.16.0 lib/contrast/api/decorators/trace_event_signature.rb
contrast-agent-3.15.0 lib/contrast/api/decorators/trace_event_signature.rb
contrast-agent-3.14.0 lib/contrast/api/decorators/trace_event_signature.rb