Skip to content

Commit

Permalink
Merge pull request #14 from newrelic/prateek/public-apis
Browse files Browse the repository at this point in the history
exposed public apis
  • Loading branch information
prateeksen authored May 10, 2023
2 parents 860f05b + 0f062dd commit 298a126
Showing 1 changed file with 60 additions and 6 deletions.
66 changes: 60 additions & 6 deletions lib/newrelic_security/newrelic-security-api/api.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,72 @@
module NewRelic::Security
#
# This module contains most of the public API methods for the Ruby Security Agent.
#
# @api public
#
module API
def refresh_state()

#
# Check whether security is enabled
#
# @return [Boolean] true if security is enabled else false
#
# @api public
#
def is_security_active?
NewRelic::Security::Agent.config[:'agent.enabled'] && NewRelic::Security::Agent.config[:enabled]
end

#
# Manually initializes the security agent
#
# @param [Hash] Unused options Hash
#
# @return [nil]
#
# @api public
#
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

#
# Deactivates security and stops sending events to security engine
#
# @return [nil]
#
# @api public
#
def deactivate_security
NewRelic::Security::Agent.config.disable_security
end

def send_event()
#
# Send and event to security engine
#
# @param [NewRelic::Security::Agent::Control::Event] event IAST event to be sent to validator
#
# @return [nil]
#
# @api public
#
def send_event(event)
NewRelic::Security::Agent.agent.event_processor.send_event(event)
end

def is_security_active()
end

def send_exit_event
#
# Send and exit event to security engine
#
# @param [NewRelic::Security::Agent::Control::ExitEvent] exit_event IAST exit event for api call to be sent to validator
#
# @return [nil]
#
# @api public
#
def send_exit_event(exit_event)
NewRelic::Security::Agent.agent.event_processor.send_exit_event(exit_event)
end
end
end

0 comments on commit 298a126

Please sign in to comment.