Sha256: 058786939db5e97cd180a97e0ffe2b3112049fa5e80dee72ac93c17e2742ab95

Contents?: true

Size: 1.95 KB

Versions: 3

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

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

module Contrast
  module Api
    module Decorators
      # Used to decorate the 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

3 entries across 3 versions & 1 rubygems

Version Path
contrast-agent-3.13.2 lib/contrast/api/decorators/trace_event_signature.rb
contrast-agent-3.13.1 lib/contrast/api/decorators/trace_event_signature.rb
contrast-agent-3.13.0 lib/contrast/api/decorators/trace_event_signature.rb