Class: Contrast::Agent::Reporting::FindingEventSignature
- Inherits:
-
ReportableHash
- Object
- ReportableHash
- Contrast::Agent::Reporting::FindingEventSignature
- Defined in:
- lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb
Overview
This is the new FindingEventSignature class which will include all the needed information for the new reporting system to relay this information in the Finding/Trace messages. These FindingEventSignatures are used by TeamServer to construct the method signature for the assess feature. They represent the method invoked when the FindingEvent was generated.
Instance Attribute Summary collapse
-
#arg_types ⇒ String
readonly
The types of the arguments in this event; may be different for each invocation of the method.
-
#class_name ⇒ String
readonly
The name of the class of this object or the name itself if of Module type.
-
#constructor ⇒ Boolean
readonly
If the method is a constructor or not.
-
#expression_type ⇒ String
readonly
Unused.
-
#flags ⇒ Integer
readonly
The Java flags; static or not.
-
#method_name ⇒ String
readonly
The name of the method.
-
#operator ⇒ String
readonly
Unused.
-
#return_type ⇒ String
readonly
The type of the return in this event; may be different for each invocation of the method.
-
#signature ⇒ String
readonly
Unused.
-
#void_method ⇒ Boolean
readonly
If the method is void or not; may be different for each invocation of the method.
Instance Method Summary collapse
-
#initialize(policy_node, args, ret) ⇒ FindingEventSignature
constructor
invoked method.
-
#to_controlled_hash ⇒ Hash
Convert the instance variables on the class, and other information, into the identifiers required for TeamServer to process the JSON form of this message.
- #validate ⇒ Object
Methods inherited from ReportableHash
Methods included from Components::Logger::InstanceMethods
Constructor Details
#initialize(policy_node, args, ret) ⇒ FindingEventSignature
invoked method
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb', line 42 def initialize policy_node, args, ret node = policy_node @arg_types = [] args&.each { |arg| arg_types << type_name(arg) } @class_name = node.class_name @constructor = node.method_name == :new || node.method_name == :initialize # 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 @flags = 8 unless node.instance_method? @method_name = node.method_name.to_s @return_type = type_name(ret) # 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. @void_method = ret.nil? || ret.object.nil? || ret.object == Contrast::Utils::ObjectShare::NIL_STRING super() end |
Instance Attribute Details
#arg_types ⇒ String (readonly)
Returns the types of the arguments in this event; may be different for each invocation of the method.
17 18 19 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb', line 17 def arg_types @arg_types end |
#class_name ⇒ String (readonly)
Returns the name of the class of this object or the name itself if of Module type.
19 20 21 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb', line 19 def class_name @class_name end |
#constructor ⇒ Boolean (readonly)
Returns if the method is a constructor or not.
21 22 23 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb', line 21 def constructor @constructor end |
#expression_type ⇒ String (readonly)
Returns unused.
23 24 25 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb', line 23 def expression_type @expression_type end |
#flags ⇒ Integer (readonly)
Returns the Java flags; static or not.
25 26 27 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb', line 25 def flags @flags end |
#method_name ⇒ String (readonly)
Returns the name of the method.
27 28 29 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb', line 27 def method_name @method_name end |
#operator ⇒ String (readonly)
Returns unused.
29 30 31 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb', line 29 def operator @operator end |
#return_type ⇒ String (readonly)
Returns the type of the return in this event; may be different for each invocation of the method.
31 32 33 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb', line 31 def return_type @return_type end |
#signature ⇒ String (readonly)
Returns unused.
33 34 35 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb', line 33 def signature @signature end |
#void_method ⇒ Boolean (readonly)
Returns if the method is void or not; may be different for each invocation of the method.
35 36 37 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb', line 35 def void_method @void_method end |
Instance Method Details
#to_controlled_hash ⇒ Hash
Convert the instance variables on the class, and other information, into the identifiers required for TeamServer to process the JSON form of this message.
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb', line 64 def to_controlled_hash validate { argTypes: arg_types, className: class_name, constructor: constructor, # expressionType: expression_type, # This is unused by the Ruby agent flags: flags.to_i, methodName: method_name, # operator: operator, # This is unused by the Ruby agent returnType: return_type, # signature: signature, # This is unused by the Ruby agent voidMethod: void_method } end |
#validate ⇒ Object
80 81 82 83 |
# File 'lib/contrast/agent/reporting/reporting_events/finding_event_signature.rb', line 80 def validate raise(ArgumentError, "#{ self } did not have a proper argTypes. Unable to continue.") unless arg_types raise(ArgumentError, "#{ self } did not have a proper constructor. Unable to continue.") if constructor.nil? end |