Class: NewRelic::Security::Agent::Control::Event
- Inherits:
-
Object
- Object
- NewRelic::Security::Agent::Control::Event
- Defined in:
- lib/newrelic_security/agent/control/event.rb
Instance Attribute Summary collapse
-
#apiId ⇒ Object
Returns the value of attribute apiId.
-
#caseType ⇒ Object
readonly
Returns the value of attribute caseType.
-
#eventCategory ⇒ Object
readonly
Returns the value of attribute eventCategory.
-
#httpRequest ⇒ Object
Returns the value of attribute httpRequest.
-
#httpResponse ⇒ Object
Returns the value of attribute httpResponse.
-
#id ⇒ Object
Returns the value of attribute id.
-
#isIASTEnable ⇒ Object
Returns the value of attribute isIASTEnable.
-
#isIASTRequest ⇒ Object
Returns the value of attribute isIASTRequest.
-
#jsonName ⇒ Object
readonly
Returns the value of attribute jsonName.
-
#lineNumber ⇒ Object
Returns the value of attribute lineNumber.
-
#metaData ⇒ Object
Returns the value of attribute metaData.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#parentId ⇒ Object
Returns the value of attribute parentId.
-
#sourceMethod ⇒ Object
Returns the value of attribute sourceMethod.
-
#stacktrace ⇒ Object
Returns the value of attribute stacktrace.
-
#userFileName ⇒ Object
Returns the value of attribute userFileName.
-
#userMethodName ⇒ Object
Returns the value of attribute userMethodName.
Instance Method Summary collapse
- #as_json ⇒ Object
- #copy_grpc_info(ctxt) ⇒ Object
-
#copy_http_info(ctxt) ⇒ Object
# This method needs, require ‘json’ def to_json(*options) as_json(*options).to_json(*options) end.
-
#initialize(case_type, args, event_category) ⇒ Event
constructor
A new instance of Event.
- #to_json ⇒ Object
Constructor Details
#initialize(case_type, args, event_category) ⇒ Event
Returns a new instance of Event.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/newrelic_security/agent/control/event.rb', line 17 def initialize(case_type, args, event_category) @collectorType = RUBY @language = Ruby @jsonName = :Event @eventType = :sec_event @framework = NewRelic::Security::Agent.config[:framework] @groupName = NewRelic::Security::Agent.config[:mode] @policyVersion = nil @collectorVersion = NewRelic::Security::VERSION @buildNumber = nil @jsonVersion = NewRelic::Security::Agent.config[:json_version] @applicationUUID = NewRelic::Security::Agent.config[:uuid] @appAccountId = NewRelic::Security::Agent.config[:account_id] @appEntityGuid = NewRelic::Security::Agent.config[:entity_guid] @httpRequest = Hash.new @httpResponse = Hash.new @metaData = { :reflectedMetaData => { :listen_port => NewRelic::Security::Agent.config[:listen_port].to_s }, :appServerInfo => { :applicationDirectory => NewRelic::Security::Agent.config[:app_root], :serverBaseDirectory => NewRelic::Security::Agent.config[:app_root] }, :skipScanParameters => { :header => NewRelic::Security::Agent.config[:'security.exclude_from_iast_scan.http_request_parameters.header'], :query => NewRelic::Security::Agent.config[:'security.exclude_from_iast_scan.http_request_parameters.query'], :body => NewRelic::Security::Agent.config[:'security.exclude_from_iast_scan.http_request_parameters.body'] } } @linkingMetadata = @pid = pid @parameters = args @sourceMethod = nil @userMethodName = nil @userFileName = nil @lineNumber = nil @caseType = case_type @eventCategory = event_category @id = event_id @eventGenerationTime = current_time_millis @startTime = current_time_millis @stacktrace = [] @apiId = nil @isAPIBlocked = nil @isIASTEnable = false @isIASTRequest = false @parentId = nil end |
Instance Attribute Details
#apiId ⇒ Object
Returns the value of attribute apiId.
14 15 16 |
# File 'lib/newrelic_security/agent/control/event.rb', line 14 def apiId @apiId end |
#caseType ⇒ Object (readonly)
Returns the value of attribute caseType.
15 16 17 |
# File 'lib/newrelic_security/agent/control/event.rb', line 15 def caseType @caseType end |
#eventCategory ⇒ Object (readonly)
Returns the value of attribute eventCategory.
15 16 17 |
# File 'lib/newrelic_security/agent/control/event.rb', line 15 def eventCategory @eventCategory end |
#httpRequest ⇒ Object
Returns the value of attribute httpRequest.
14 15 16 |
# File 'lib/newrelic_security/agent/control/event.rb', line 14 def httpRequest @httpRequest end |
#httpResponse ⇒ Object
Returns the value of attribute httpResponse.
14 15 16 |
# File 'lib/newrelic_security/agent/control/event.rb', line 14 def httpResponse @httpResponse end |
#id ⇒ Object
Returns the value of attribute id.
14 15 16 |
# File 'lib/newrelic_security/agent/control/event.rb', line 14 def id @id end |
#isIASTEnable ⇒ Object
Returns the value of attribute isIASTEnable.
14 15 16 |
# File 'lib/newrelic_security/agent/control/event.rb', line 14 def isIASTEnable @isIASTEnable end |
#isIASTRequest ⇒ Object
Returns the value of attribute isIASTRequest.
14 15 16 |
# File 'lib/newrelic_security/agent/control/event.rb', line 14 def isIASTRequest @isIASTRequest end |
#jsonName ⇒ Object (readonly)
Returns the value of attribute jsonName.
15 16 17 |
# File 'lib/newrelic_security/agent/control/event.rb', line 15 def jsonName @jsonName end |
#lineNumber ⇒ Object
Returns the value of attribute lineNumber.
14 15 16 |
# File 'lib/newrelic_security/agent/control/event.rb', line 14 def lineNumber @lineNumber end |
#metaData ⇒ Object
Returns the value of attribute metaData.
14 15 16 |
# File 'lib/newrelic_security/agent/control/event.rb', line 14 def @metaData end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
15 16 17 |
# File 'lib/newrelic_security/agent/control/event.rb', line 15 def parameters @parameters end |
#parentId ⇒ Object
Returns the value of attribute parentId.
14 15 16 |
# File 'lib/newrelic_security/agent/control/event.rb', line 14 def parentId @parentId end |
#sourceMethod ⇒ Object
Returns the value of attribute sourceMethod.
14 15 16 |
# File 'lib/newrelic_security/agent/control/event.rb', line 14 def sourceMethod @sourceMethod end |
#stacktrace ⇒ Object
Returns the value of attribute stacktrace.
14 15 16 |
# File 'lib/newrelic_security/agent/control/event.rb', line 14 def stacktrace @stacktrace end |
#userFileName ⇒ Object
Returns the value of attribute userFileName.
14 15 16 |
# File 'lib/newrelic_security/agent/control/event.rb', line 14 def userFileName @userFileName end |
#userMethodName ⇒ Object
Returns the value of attribute userMethodName.
14 15 16 |
# File 'lib/newrelic_security/agent/control/event.rb', line 14 def userMethodName @userMethodName end |
Instance Method Details
#as_json ⇒ Object
67 68 69 70 71 |
# File 'lib/newrelic_security/agent/control/event.rb', line 67 def as_json instance_variables.map! do |ivar| [ivar[1..-1].to_sym, instance_variable_get(ivar)] end.to_h end |
#copy_grpc_info(ctxt) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/newrelic_security/agent/control/event.rb', line 113 def copy_grpc_info(ctxt) # TODO: optimise this method and combine copy_http_info and copy_grpc_info return if ctxt.nil? http_request = {} http_request[:body] = ctxt.body.is_a?(Array) ? "[#{ctxt.body.join(',')}]" : ctxt.body http_request[:generationTime] = ctxt.time_stamp http_request[:dataTruncated] = false http_request[:method] = ctxt.method http_request[:route] = ctxt.route http_request[:url] = ctxt.url http_request[:serverName] = ctxt.server_name http_request[:serverPort] = ctxt.server_port http_request[:clientIP] = ctxt.client_ip http_request[:clientPort] = ctxt.client_port http_request[:protocol] = :grpc http_request[:headers] = ctxt.headers http_request[:contentType] = "TODO: " http_request[:isGrpc] = ctxt.is_grpc @httpRequest = http_request @metaData.merge!(ctxt.) end |
#copy_http_info(ctxt) ⇒ Object
# This method needs, require ‘json’ def to_json(*options)
as_json(*).to_json(*)
end
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/newrelic_security/agent/control/event.rb', line 90 def copy_http_info(ctxt) return if ctxt.nil? http_request = {} http_request[:parameterMap] = {} http_request[:body] = ctxt.body http_request[:generationTime] = ctxt.time_stamp http_request[:dataTruncated] = false http_request[:method] = ctxt.method http_request[:route] = ctxt.route.split(AT_THE_RATE)[1] if ctxt.route http_request[:url] = URI(ctxt.req[REQUEST_URI]).respond_to?(:request_uri) ? URI(ctxt.req[REQUEST_URI]).request_uri : ctxt.req[REQUEST_URI] http_request[:clientIP] = ctxt.headers.has_key?(X_FORWARDED_FOR) ? ctxt.headers[X_FORWARDED_FOR].split(COMMA)[0].to_s : ctxt.req[REMOTE_ADDR].to_s http_request[:serverPort] = ctxt.req[SERVER_PORT].to_i http_request[:protocol] = ctxt.req[RACK_URL_SCHEME] http_request[:contextPath] = ROOT_PATH http_request[:headers] = ctxt.headers http_request[:contentType] = ctxt.req[CONTENT_TYPE] if ctxt.req.has_key?(CONTENT_TYPE) http_request[:headers][CONTENT_TYPE1] = ctxt.req[CONTENT_TYPE] if ctxt.req.has_key?(CONTENT_TYPE) http_request[:customDataType] = ctxt.custom_data_type http_request[:dataTruncated] = ctxt.data_truncated @httpRequest = http_request @metaData[:isClientDetectedFromXFF] = ctxt.headers.has_key?(X_FORWARDED_FOR) ? true : false end |
#to_json ⇒ Object
73 74 75 |
# File 'lib/newrelic_security/agent/control/event.rb', line 73 def to_json as_json.to_json end |