Skip to content

Commit

Permalink
nil check for event processor and disable security on websocket close
Browse files Browse the repository at this point in the history
  • Loading branch information
prateeksen committed Dec 26, 2024
1 parent 6967292 commit 50c1d71
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/newrelic_security/agent/control/collector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def collect(case_type, args, event_category = nil, **keyword_args)
event.lineNumber = stk[0].lineno
end
event.stacktrace = stk[0..user_frame_index].map(&:to_s)
NewRelic::Security::Agent.agent.event_processor.send_event(event)
NewRelic::Security::Agent.agent.event_processor&.send_event(event)
if event.httpRequest[:headers].key?(NR_CSEC_FUZZ_REQUEST_ID) && event.apiId == event.httpRequest[:headers][NR_CSEC_FUZZ_REQUEST_ID].split(COLON_IAST_COLON)[0] && NewRelic::Security::Agent.agent.iast_client.completed_requests[event.parentId]
NewRelic::Security::Agent.agent.iast_client.completed_requests[event.parentId] << event.id
end
Expand Down
1 change: 1 addition & 0 deletions lib/newrelic_security/agent/control/websocket_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def send(message)
end

def close(reconnect = true)
NewRelic::Security::Agent.config.disable_security
NewRelic::Security::Agent.logger.info "Flushing eventQ (#{NewRelic::Security::Agent.agent.event_processor.eventQ.size} events) and closing websocket connection"
NewRelic::Security::Agent.agent.event_processor&.eventQ&.clear
@iast_client&.iast_data_transfer_request_processor_thread&.kill
Expand Down

0 comments on commit 50c1d71

Please sign in to comment.