From 7a43a7fae139795e40cd802f6c319a85383da67b Mon Sep 17 00:00:00 2001 From: umaannamalai Date: Thu, 1 Jun 2023 18:08:32 +0000 Subject: [PATCH] [Mega-Linter] Apply linters fixes --- newrelic/config.py | 3 ++- newrelic/core/config.py | 40 +++++++++++++--------------------------- setup.py | 2 +- 3 files changed, 16 insertions(+), 29 deletions(-) diff --git a/newrelic/config.py b/newrelic/config.py index 8009938c0..d85611899 100644 --- a/newrelic/config.py +++ b/newrelic/config.py @@ -3184,9 +3184,10 @@ def _setup_security_module(): if not _settings.security.agent.enabled: return from newrelic_security.api.agent import Agent as SecurityAgent + # initialize security agent security_agent = SecurityAgent() - # create a callback to reinitialise the security module + # create a callback to reinitialise the security module newrelic.core.agent.Agent.run_on_startup(security_agent.refresh_agent) except Exception as k2error: _logger.error("K2 Startup failed with error %s", k2error) diff --git a/newrelic/core/config.py b/newrelic/core/config.py index cb8dccb7b..03758fc74 100644 --- a/newrelic/core/config.py +++ b/newrelic/core/config.py @@ -278,26 +278,31 @@ class ApplicationLoggingMetricsSettings(Settings): class ApplicationLoggingLocalDecoratingSettings(Settings): pass + class SecuritySettings(Settings): pass + class SecurityDetectionSettings(Settings): pass + class SecurityAgentSettings(Settings): pass + class SecurityDetectionRCISettings(Settings): pass + class SecurityDetectionRXSSSettings(Settings): pass + class SecurityDetectionDeserializationSettings(Settings): pass - class InfiniteTracingSettings(Settings): _trace_observer_host = None @@ -864,33 +869,14 @@ def default_host(license_key): "NEW_RELIC_APPLICATION_LOGGING_LOCAL_DECORATING_ENABLED", default=False ) -_settings.security.agent.enabled = _environ_as_bool( - "NEW_RELIC_SECURITY_AGENT_ENABLED", - False -) -_settings.security.enabled = _environ_as_bool( - "NEW_RELIC_SECURITY_ENABLED", - False -) -_settings.security.mode = os.environ.get( - "NEW_RELIC_SECURITY_MODE", - "IAST" -) -_settings.security.validator_service_url = os.environ.get( - "NEW_RELIC_SECURITY_VALIDATOR_SERVICE_URL", - None -) -_settings.security.detection.rci.enabled = _environ_as_bool( - "NEW_RELIC_SECURITY_DETECTION_RCI_ENABLED", - True -) -_settings.security.detection.rxss.enabled = _environ_as_bool( - "NEW_RELIC_SECURITY_DETECTION_RXSS_ENABLED", - True -) +_settings.security.agent.enabled = _environ_as_bool("NEW_RELIC_SECURITY_AGENT_ENABLED", False) +_settings.security.enabled = _environ_as_bool("NEW_RELIC_SECURITY_ENABLED", False) +_settings.security.mode = os.environ.get("NEW_RELIC_SECURITY_MODE", "IAST") +_settings.security.validator_service_url = os.environ.get("NEW_RELIC_SECURITY_VALIDATOR_SERVICE_URL", None) +_settings.security.detection.rci.enabled = _environ_as_bool("NEW_RELIC_SECURITY_DETECTION_RCI_ENABLED", True) +_settings.security.detection.rxss.enabled = _environ_as_bool("NEW_RELIC_SECURITY_DETECTION_RXSS_ENABLED", True) _settings.security.detection.deserialization.enabled = _environ_as_bool( - "NEW_RELIC_SECURITY_DETECTION_DESERIALIZATION_ENABLED", - True + "NEW_RELIC_SECURITY_DETECTION_DESERIALIZATION_ENABLED", True ) diff --git a/setup.py b/setup.py index 44b4957d3..acb5a4ad9 100644 --- a/setup.py +++ b/setup.py @@ -152,7 +152,7 @@ def build_extension(self, ext): "newrelic": ["newrelic.ini", "version.txt", "packages/urllib3/LICENSE.txt", "common/cacert.pem"], }, extras_require={"infinite-tracing": ["grpcio", "protobuf"]}, - install_requires=["git+https://github.com/newrelic/csec-python-agent.git@develop#egg=newrelic_security"] + install_requires=["git+https://github.com/newrelic/csec-python-agent.git@develop#egg=newrelic_security"], ) if with_setuptools: