From 0f062ddff01aaf1b271d0a35e2824a9f45014b6f Mon Sep 17 00:00:00 2001 From: prateek-ap Date: Wed, 10 May 2023 17:19:45 +0530 Subject: [PATCH] exposed public apis --- .../newrelic-security-api/api.rb | 66 +++++++++++++++++-- 1 file changed, 60 insertions(+), 6 deletions(-) diff --git a/lib/newrelic_security/newrelic-security-api/api.rb b/lib/newrelic_security/newrelic-security-api/api.rb index 4fda54f6..b169fd92 100644 --- a/lib/newrelic_security/newrelic-security-api/api.rb +++ b/lib/newrelic_security/newrelic-security-api/api.rb @@ -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 \ No newline at end of file