Module: NewRelic::Security::API

Defined in:
lib/newrelic_security/newrelic-security-api/api.rb

Overview

This module contains most of the public API methods for the Ruby Security Agent.

Instance Method Summary collapse

Instance Method Details

#deactivate_securitynil

Deactivates security and stops sending events to security engine

Returns:

  • (nil)


42
43
44
# File 'lib/newrelic_security/newrelic-security-api/api.rb', line 42

def deactivate_security
  NewRelic::Security::Agent.config.disable_security
end

#is_security_active?Boolean

Check whether security is enabled

Returns:

  • (Boolean)

    true if security is enabled else false



16
17
18
# File 'lib/newrelic_security/newrelic-security-api/api.rb', line 16

def is_security_active?
  NewRelic::Security::Agent.config[:'agent.enabled'] && NewRelic::Security::Agent.config[:'security.enabled'] && NewRelic::Security::Agent.config[:enabled]
end

#manual_start(options = {}) ⇒ nil

Manually initializes the security agent

Parameters:

  • Unused (Hash)

    options Hash

Returns:

  • (nil)


29
30
31
32
33
# File 'lib/newrelic_security/newrelic-security-api/api.rb', line 29

def manual_start(options = {})
  raise "Options must be a hash" unless Hash === options
  NewRelic::Security::Agent.config.enable_security
  NewRelic::Security::Agent.agent.init
end

#send_event(event) ⇒ nil

Send and event to security engine

Parameters:

Returns:

  • (nil)


55
56
57
# File 'lib/newrelic_security/newrelic-security-api/api.rb', line 55

def send_event(event)
  NewRelic::Security::Agent.agent.event_processor.send_event(event)
end

#send_exit_event(exit_event) ⇒ nil

Send and exit event to security engine

Parameters:

Returns:

  • (nil)


68
69
70
# File 'lib/newrelic_security/newrelic-security-api/api.rb', line 68

def send_exit_event(exit_event)
  NewRelic::Security::Agent.agent.event_processor.send_exit_event(exit_event)
end