Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing K2 Integration #820

Draft
wants to merge 109 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
b5711e3
initial changes for k2 integration
AnupamJuniwal Sep 21, 2022
20d5117
minor fix
AnupamJuniwal Sep 21, 2022
dfbcf0a
k2 agent would now init without any args
AnupamJuniwal Sep 22, 2022
f399c3a
initial implementation of securty config, removal of switch based k2 …
AnupamJuniwal Sep 27, 2022
c3232c9
minor fix with incorrect value for configuration mapper
AnupamJuniwal Sep 28, 2022
206160e
changes corresponding to latest k2 agent changes
AnupamJuniwal Sep 29, 2022
dd7bd2d
minor fixes
AnupamJuniwal Sep 29, 2022
7578dc0
updated integration source for k2
AnupamJuniwal Sep 30, 2022
857f3f9
Added customer id
AnupamJuniwal Sep 30, 2022
f0c30a1
initial changes for application id propagation
AnupamJuniwal Oct 1, 2022
42d621a
minor fix in application_id extraction
AnupamJuniwal Oct 1, 2022
e700fb2
minor fix
AnupamJuniwal Oct 1, 2022
1d5964b
guid propagation instead of application_id
AnupamJuniwal Oct 2, 2022
a2da1ba
Merge branch 'feature/k2_integration' into k2_integration
AnupamJuniwal Oct 2, 2022
163645b
This implements propagation of all possible k2 config in NR's config
AnupamJuniwal Oct 2, 2022
52e59e2
changes to populate dictionary of policy and changes to reflect secur…
AnupamJuniwal Oct 3, 2022
a609df8
This contains changes for policy propagation to k2
AnupamJuniwal Oct 6, 2022
30a280a
Merge branch 'feature/k2i/policy_propagation' into k2_integration
AnupamJuniwal Oct 6, 2022
a5dd418
updated config for logs upload and exception handling in security mod…
AnupamJuniwal Oct 7, 2022
5f226e8
Merge branch 'feature/k2i/logs_config_propagation' into k2_integration
AnupamJuniwal Oct 9, 2022
6d515e8
Changes for setting the trasnsaction id catcher by handing over a lam…
AnupamJuniwal Oct 9, 2022
34d610b
changes to send trace metadata long with transaction id from metadata…
AnupamJuniwal Oct 10, 2022
e02eacf
Merge 'feature/k2i/logs_config_propagation' into k2_integration
AnupamJuniwal Oct 10, 2022
385b966
This contains multiple changes:
AnupamJuniwal Oct 12, 2022
ded8f48
minor change to reflect k2 module changes
AnupamJuniwal Oct 12, 2022
5298430
Merge branch 'feature/k2i/add_linking_metadata_deprecate_old_k2_auth_…
AnupamJuniwal Oct 12, 2022
a2f385e
Addition of enforce flag
AnupamJuniwal Oct 26, 2022
2f46837
Merge branch 'main' into k2_integration
AnupamJuniwal Oct 26, 2022
a8a7a88
Addition of account id in linking metadata
AnupamJuniwal Dec 21, 2022
d925658
Temp changes
AnupamJuniwal Dec 23, 2022
a741c2d
Let the connect be called with refresh (When linking metadata is avai…
AnupamJuniwal Dec 23, 2022
0ec4fe4
agent would not connect with startup
AnupamJuniwal Dec 28, 2022
f5a98ba
removal of rest server endpoint config, use of SingletonAgentConfig i…
AnupamJuniwal Jan 25, 2023
524b315
removal of all security agent initialization logic
AnupamJuniwal Jan 25, 2023
46637fe
updates to newrelic config for security module
AnupamJuniwal Mar 14, 2023
5be1836
minor fix
AnupamJuniwal Mar 23, 2023
ac7e712
point to nr_adaptation with updated newrelic_security package
AnupamJuniwal Apr 17, 2023
a028082
updated to latest csec statup update
AnupamJuniwal Apr 17, 2023
49d7a99
Merge remote-tracking branch 'nr-public/main' into feature/nr_adaptation
AnupamJuniwal Apr 17, 2023
28d789a
Refactoring and relocation of security settings in core config
AnupamJuniwal Apr 28, 2023
1f780c2
initialising security agent before configuring nr apm hooks
AnupamJuniwal May 4, 2023
f0505f8
Merge branch 'main' into feature/nr_adaptation
AnupamJuniwal May 10, 2023
5fb7a42
fixes in config default values for security config for python 2.7 sup…
AnupamJuniwal May 17, 2023
11c0049
Will use dev branch for security agent
AnupamJuniwal May 26, 2023
1313de9
Merge branch 'k2io/nr-python-agent/develop' into develop-k2-integration
AnupamJuniwal Jun 1, 2023
093fd3a
Updated remote for pulling newrelic_security module
AnupamJuniwal Jun 1, 2023
88cb32e
Update install requires line.
umaannamalai Jun 1, 2023
7a43a7f
[Mega-Linter] Apply linters fixes
umaannamalai Jun 1, 2023
33b51fc
Testing install requires.
umaannamalai Jun 1, 2023
0c2cbbc
Merge conflicts.
umaannamalai Jun 1, 2023
3d44b8c
Restore install requires.
umaannamalai Jun 1, 2023
fe17e36
[Mega-Linter] Apply linters fixes
umaannamalai Jun 1, 2023
b0e0a50
switch ordering
umaannamalai Jun 1, 2023
dada30b
Add dependency links.
umaannamalai Jun 1, 2023
78d90b6
[Mega-Linter] Apply linters fixes
umaannamalai Jun 1, 2023
1b0c1b5
Add security settings to web framework conftests.
umaannamalai Jun 1, 2023
14d7019
github ssh url.
umaannamalai Jun 2, 2023
874fd03
remove ssh prefix.
umaannamalai Jun 2, 2023
7041783
Fixed k2 reference to Security Agent
AnupamJuniwal Jun 12, 2023
5cba84e
Merge remote-tracking branch 'refs/remotes/newrelic-public-fork/devel…
AnupamJuniwal Nov 14, 2023
a7e4870
Merge branch 'main' into develop-k2-integration
AnupamJuniwal Nov 14, 2023
34fc7f4
branch update for develop branch to use k2-python-agent's dev branch
AnupamJuniwal Dec 13, 2023
140bb54
Merge branch 'main' into develop-k2-integration
AnupamJuniwal Dec 13, 2023
2da32e5
Merge branch 'develop-k2-integration' into develop
AnupamJuniwal Dec 13, 2023
941a38b
Fix for high security flag handling
AnupamJuniwal Dec 13, 2023
675e009
added log in case security is disabled due to config
AnupamJuniwal Jan 2, 2024
3909f52
branch update for newrelic_security module
AnupamJuniwal Feb 1, 2024
b969fc9
branch update
AnupamJuniwal Feb 23, 2024
6afb0ce
Updates as per new api changes
AnupamJuniwal Feb 28, 2024
6417d80
Merge pull request #1 from k2io/task/NR-181061/high_security_config_a…
AnupamJuniwal Feb 29, 2024
d1ef2f8
Rolledback SA branch to develop in setup.py
AnupamJuniwal Feb 29, 2024
9dd7cf8
introduced a new config: security.request.body_limit
AnupamJuniwal Mar 13, 2024
ec18d6f
Updated csec agent branch for testing
AnupamJuniwal Apr 22, 2024
8cc81eb
Merge pull request #3 from k2io/task/NR-181060/request_body_truncate
AnupamJuniwal Apr 22, 2024
d21f366
branch change rollback
AnupamJuniwal Apr 22, 2024
f941800
Temporary changes to update csec branch to task/python_27_support
AnupamJuniwal Apr 23, 2024
5377dde
Merge branch 'task/python_27_support' into develop
AnupamJuniwal Jun 27, 2024
7fb5280
Updated security agent branch after merge
AnupamJuniwal Jun 27, 2024
9b5754b
Merge branch 'main' into develop
AnupamJuniwal Jul 19, 2024
0757037
Updates to read security skip_iast_scan configurations
AnupamJuniwal Aug 15, 2024
6905d13
minor fix
AnupamJuniwal Aug 21, 2024
2c757b3
Changes for defining and reading security scan schedule config
AnupamJuniwal Aug 21, 2024
8b52f25
Refactored config change for iast scan exclude configs
AnupamJuniwal Aug 27, 2024
16e1c80
Fix to incorrectly read security config
AnupamJuniwal Sep 10, 2024
d97a15c
Updates for csec agent moved to newrelic org
AnupamJuniwal Sep 17, 2024
5e9eed9
Merge branch 'apm-main' into apm-test-k2-integration
AnupamJuniwal Sep 25, 2024
824a13b
Merge branch 'apm-test-k2-integration' into develop
AnupamJuniwal Sep 25, 2024
a936b71
Merge branch 'main' into test-k2-integration
AnupamJuniwal Oct 10, 2024
2179d76
Merge branch 'test-k2-integration' into k2-develop
AnupamJuniwal Oct 10, 2024
bfc5219
Removal of security.request.body_limit config
AnupamJuniwal Oct 11, 2024
4a5daeb
Updated remote for security agent
AnupamJuniwal Oct 15, 2024
99c3b77
Merge branch 'main' into test-k2-integration
AnupamJuniwal Oct 24, 2024
9f9a4d4
Branch update
AnupamJuniwal Oct 29, 2024
2778a11
Merge branch 'develop' into task/NR-333351/scheduled_agent
AnupamJuniwal Dec 18, 2024
126cd8c
Minor fix
AnupamJuniwal Dec 18, 2024
a01443f
Merge remote-tracking branch 'apm/main' into task/NR-301856/skip_scan
AnupamJuniwal Jan 20, 2025
e7b29f6
Merge remote-tracking branch 'apm/main' into develop
AnupamJuniwal Jan 20, 2025
3e38eb6
Merge branch 'develop' into task/NR-301856/skip_scan
AnupamJuniwal Jan 20, 2025
67481fe
newrelic_security dependency update
AnupamJuniwal Jan 29, 2025
8363ceb
Merge pull request #6 from k2io/task/NR-301856/skip_scan
AnupamJuniwal Jan 30, 2025
4379b60
Merge branch 'develop' into task/github_workflow_updates
AnupamJuniwal Jan 30, 2025
7e55661
Pushed newrelic security as extra
AnupamJuniwal Jan 30, 2025
a55766f
Update setup.py
himank-k2 Jan 31, 2025
bf416f1
Merge branch 'task/github_workflow_updates' into develop
AnupamJuniwal Jan 31, 2025
eeb534b
Added endpoint for security engine as default value and removed redun…
AnupamJuniwal Jan 31, 2025
8855f61
Merge branch 'apm-main' into develop
AnupamJuniwal Jan 31, 2025
c6d1d59
Merge branch 'develop' into apm-test-k2-integration
AnupamJuniwal Jan 31, 2025
4ebd060
minor update
AnupamJuniwal Jan 31, 2025
1b7c075
Merge branch 'develop' into apm-test-k2-integration
AnupamJuniwal Jan 31, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 52 additions & 1 deletion newrelic/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ def _map_default_host_value(license_key):

return license_key

def _map_comma_separated_values(s):
return list(map(str.strip, s.split(",")))


# Processing of a single setting from configuration file.

Expand Down Expand Up @@ -346,6 +349,32 @@ def _process_configuration(section):
_process_setting(section, "ca_bundle_path", "get", None)
_process_setting(section, "audit_log_file", "get", None)
_process_setting(section, "monitor_mode", "getboolean", None)
_process_setting(section, "security.agent.enabled", "getboolean", None)
_process_setting(section, "security.enabled", "getboolean", None)
_process_setting(section, "security.mode", "get", None)
_process_setting(section, "security.validator_service_url", "get", None)
_process_setting(section, "security.detection.rci.enabled", "getboolean", None)
_process_setting(section, "security.detection.rxss.enabled", "getboolean", None)
_process_setting(section, "security.detection.deserialization.enabled", "getboolean", None)
_process_setting(section, "security.exclude_from_iast_scan.api", "get", _map_comma_separated_values)
_process_setting(section, "security.exclude_from_iast_scan.http_request_parameters.header", "get", _map_comma_separated_values)
_process_setting(section, "security.exclude_from_iast_scan.http_request_parameters.query", "get", _map_comma_separated_values)
_process_setting(section, "security.exclude_from_iast_scan.http_request_parameters.body", "get", _map_comma_separated_values)
_process_setting(section, "security.exclude_from_iast_scan.iast_detection_category.insecure_settings", "getboolean", None)
_process_setting(section, "security.exclude_from_iast_scan.iast_detection_category.invalid_file_access", "getboolean", None)
_process_setting(section, "security.exclude_from_iast_scan.iast_detection_category.sql_injection", "getboolean", None)
_process_setting(section, "security.exclude_from_iast_scan.iast_detection_category.nosql_injection", "getboolean", None)
_process_setting(section, "security.exclude_from_iast_scan.iast_detection_category.ldap_injection", "getboolean", None)
_process_setting(section, "security.exclude_from_iast_scan.iast_detection_category.javascript_injection", "getboolean", None)
_process_setting(section, "security.exclude_from_iast_scan.iast_detection_category.command_injection", "getboolean", None)
_process_setting(section, "security.exclude_from_iast_scan.iast_detection_category.xpath_injection", "getboolean", None)
_process_setting(section, "security.exclude_from_iast_scan.iast_detection_category.ssrf", "getboolean", None)
_process_setting(section, "security.exclude_from_iast_scan.iast_detection_category.rxss", "getboolean", None)
_process_setting(section, "security.request.body_limit", "get", None)
_process_setting(section, "security.scan_schedule.schedule", "get", None)
_process_setting(section, "security.scan_schedule.duration", "getint", None)
_process_setting(section, "security.scan_schedule.delay", "getint", None)
_process_setting(section, "security.scan_schedule.always_sample_traces", "getboolean", None)
_process_setting(section, "developer_mode", "getboolean", None)
_process_setting(section, "high_security", "getboolean", None)
_process_setting(section, "capture_params", "getboolean", None)
Expand Down Expand Up @@ -4858,6 +4887,26 @@ def _setup_agent_control_health():
agent_control_health_thread.start()


def _setup_security_module():
"""Initiates security module and adds a
callback to agent startup to propagate NR config
"""
try:
if not _settings.security.agent.enabled or _settings.high_security:
_logger.warning("New Relic Security is disabled by one of the user provided config `security.agent.enabled` or `high_security`.")
return
from newrelic_security.api.agent import get_agent

# initialize security agent
security_agent = get_agent()
# create a callback to reinitialise the security module
newrelic.core.agent.Agent.run_on_startup(security_agent.refresh_agent)
except ImportError:
_logger.warn("Security Agent isn't available")
except Exception as csec_error:
_logger.error("Security Agent Startup failed with error %s", csec_error)


def initialize(
config_file=None,
environment=None,
Expand All @@ -4877,7 +4926,9 @@ def initialize(
ignore_errors = newrelic.core.config._environ_as_bool("NEW_RELIC_IGNORE_STARTUP_ERRORS", True)

_load_configuration(config_file, environment, ignore_errors, log_file, log_level)


_setup_security_module()

_setup_agent_control_health()

if _settings.monitor_mode:
Expand Down
111 changes: 110 additions & 1 deletion newrelic/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,44 @@ 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 SecurityRequestSettings(Settings):
pass

class SecurityScanScheduleSettings(Settings):
pass

class SecurityExcludeFromIASTScanSettings(Settings):
pass

class SecurityExcludeFromIASTScanHTTPRequestParametersSettings(Settings):
pass

class SecurityExcludeFromIASTScanIASTDetectionCategorySettings(Settings):
pass

class InfiniteTracingSettings(Settings):
_trace_observer_host = None

Expand Down Expand Up @@ -493,6 +531,19 @@ class EventHarvestConfigHarvestLimitSettings(Settings):
_settings.message_tracer = MessageTracerSettings()
_settings.process_host = ProcessHostSettings()
_settings.rum = RumSettings()
_settings.security = SecuritySettings()
_settings.security.agent = SecurityAgentSettings()
_settings.security.detection = SecurityDetectionSettings()
_settings.security.detection.deserialization = SecurityDetectionDeserializationSettings()
_settings.security.detection.rci = SecurityDetectionRCISettings()
_settings.security.detection.rxss = SecurityDetectionRXSSSettings()
_settings.security.exclude_from_iast_scan = SecurityExcludeFromIASTScanSettings()
_settings.security.exclude_from_iast_scan.http_request_parameters = \
SecurityExcludeFromIASTScanHTTPRequestParametersSettings()
_settings.security.exclude_from_iast_scan.iast_detection_category = \
SecurityExcludeFromIASTScanIASTDetectionCategorySettings()
_settings.security.request = SecurityRequestSettings()
_settings.security.scan_schedule = SecurityScanScheduleSettings()
_settings.serverless_mode = ServerlessModeSettings()
_settings.slow_sql = SlowSqlSettings()
_settings.span_events = SpanEventSettings()
Expand All @@ -510,7 +561,6 @@ class EventHarvestConfigHarvestLimitSettings(Settings):
_settings.transaction_tracer.attributes = TransactionTracerAttributesSettings()
_settings.utilization = UtilizationSettings()


_settings.log_file = os.environ.get("NEW_RELIC_LOG", None)
_settings.audit_log_file = os.environ.get("NEW_RELIC_AUDIT_LOG", None)

Expand Down Expand Up @@ -1007,6 +1057,65 @@ def default_otlp_host(host):
_settings.package_reporting.enabled = _environ_as_bool("NEW_RELIC_PACKAGE_REPORTING_ENABLED", default=True)
_settings.ml_insights_events.enabled = _environ_as_bool("NEW_RELIC_ML_INSIGHTS_EVENTS_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", "wss://csec.nr-data.net")
_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
)
_settings.security.request.body_limit = os.environ.get("NEW_RELIC_SECURITY_REQUEST_BODY_LIMIT", None)
_settings.security.scan_schedule.schedule = os.environ.get("NEW_RELIC_SECURITY_SCAN_SCHEDULE_SCHEDULE", None)
_settings.security.scan_schedule.duration = _environ_as_int("NEW_RELIC_SECURITY_SCAN_SCHEDULE_DURATION", -1)
_settings.security.scan_schedule.delay = _environ_as_int("NEW_RELIC_SECURITY_SCAN_SCHEDULE_DELAY", 0)
_settings.security.scan_schedule.always_sample_traces = _environ_as_bool(
"NEW_RELIC_SECURITY_SCAN_SCHEDULE_ALWAYS_SAMPLE_TRACES", False
)
_settings.security.exclude_from_iast_scan.api = _environ_as_set(
"NEW_RELIC_SECURITY_EXCLUDE_FROM_IAST_SCAN_API", default=""
)
_settings.security.exclude_from_iast_scan.http_request_parameters.header = _environ_as_set(
"NEW_RELIC_SECURITY_EXCLUDE_FROM_IAST_SCAN_HTTP_REQUEST_PARAMETERS_HEADER", default=""
)
_settings.security.exclude_from_iast_scan.http_request_parameters.query = _environ_as_set(
"NEW_RELIC_SECURITY_EXCLUDE_FROM_IAST_SCAN_HTTP_REQUEST_PARAMETERS_QUERY", default=""
)
_settings.security.exclude_from_iast_scan.http_request_parameters.body = _environ_as_set(
"NEW_RELIC_SECURITY_EXCLUDE_FROM_IAST_SCAN_HTTP_REQUEST_PARAMETERS_BODY", default=""
)
_settings.security.exclude_from_iast_scan.iast_detection_category.insecure_settings = _environ_as_bool(
"NEW_RELIC_SECURITY_EXCLUDE_FROM_IAST_SCAN_IAST_DETECTION_CATEGORY_INSECURE_SETTINGS", False
)
_settings.security.exclude_from_iast_scan.iast_detection_category.invalid_file_access = _environ_as_bool(
"NEW_RELIC_SECURITY_EXCLUDE_FROM_IAST_SCAN_IAST_DETECTION_CATEGORY_INVALID_FILE_ACCESS", False
)
_settings.security.exclude_from_iast_scan.iast_detection_category.sql_injection = _environ_as_bool(
"NEW_RELIC_SECURITY_EXCLUDE_FROM_IAST_SCAN_IAST_DETECTION_CATEGORY_SQL_INJECTION", False
)
_settings.security.exclude_from_iast_scan.iast_detection_category.nosql_injection = _environ_as_bool(
"NEW_RELIC_SECURITY_EXCLUDE_FROM_IAST_SCAN_IAST_DETECTION_CATEGORY_NOSQL_INJECTION", False
)
_settings.security.exclude_from_iast_scan.iast_detection_category.ldap_injection = _environ_as_bool(
"NEW_RELIC_SECURITY_EXCLUDE_FROM_IAST_SCAN_IAST_DETECTION_CATEGORY_LDAP_INJECTION", False
)
_settings.security.exclude_from_iast_scan.iast_detection_category.javascript_injection = _environ_as_bool(
"NEW_RELIC_SECURITY_EXCLUDE_FROM_IAST_SCAN_IAST_DETECTION_CATEGORY_JAVASCRIPT_INJECTION", False
)
_settings.security.exclude_from_iast_scan.iast_detection_category.command_injection = _environ_as_bool(
"NEW_RELIC_SECURITY_EXCLUDE_FROM_IAST_SCAN_IAST_DETECTION_CATEGORY_COMMAND_INJECTION", False
)
_settings.security.exclude_from_iast_scan.iast_detection_category.xpath_injection = _environ_as_bool(
"NEW_RELIC_SECURITY_EXCLUDE_FROM_IAST_SCAN_IAST_DETECTION_CATEGORY_XPATH_INJECTION", False
)
_settings.security.exclude_from_iast_scan.iast_detection_category.ssrf = _environ_as_bool(
"NEW_RELIC_SECURITY_EXCLUDE_FROM_IAST_SCAN_IAST_DETECTION_CATEGORY_SSRF", False
)
_settings.security.exclude_from_iast_scan.iast_detection_category.rxss = _environ_as_bool(
"NEW_RELIC_SECURITY_EXCLUDE_FROM_IAST_SCAN_IAST_DETECTION_CATEGORY_RXSS", False
)


def global_settings():
"""This returns the default global settings. Generally only used
Expand Down
109 changes: 108 additions & 1 deletion newrelic/newrelic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,114 @@ app_name = Python Application
# NEW_RELIC_MONITOR_MODE environment variable.
monitor_mode = true

# Indicates if attack detection security module is to be enabled
security.enabled = false

# To completely disable security set flag to false If the flag is
# set to false, the security module is not loaded. This property
# is read only once at application start.
security.agent.enabled = false


# security module provides two modes IAST or RASP
# RASP stands for Runtime Application Self Protection
# while IAST for Interactive Application Security Testing
# Default mode is IAST
security.mode = IAST


# web-protect agent endpoint connection URLs
security.validator_service_url = wss://csec.nr-data.net


# vulnerabilty detection flags
security.detection.rci.enabled = true
security.detection.rxss.enabled = true
security.detection.deserialization.enabled = true


# security request body read limiting in kb
security.request.body_limit = 300


# Schedule IAST will allow users to schedule
# the startup and scanning of IAST. Users will have
# the flexibility to start and stop IAST at specific
# times or simply add a delay from the application
# start time

# The schedule field specifies a cron expression that
# defines when the IAST scan should run. The cron
# expression consists of six fields separated by spaces:
#
# second: specifies the second of the hour (0-59)
# minute: specifies the minute of the hour (0-59)
# hour: specifies the hour of the day (0-23)
# day: specifies the day of the month (1-31)
# month: the month of the year (1-12)
# day_of_week: specifies the day of the week (0-6), where 0 = Sunday
# security.scan_schedule.schedule = 0 0 * * * ?

# The duration field specifies the duration of
# the IAST scan in minutes. This determines how
# long the scan will run.
# Default value is forever i.e. no limits
# security.scan_schedule.duration = 300

# The delay field specifies the delay in
# minutes before the IAST scan starts.
# This allows you to schedule the scan to
# start at a later time.
# Default value: 0 minutes i.e. no delay
# security.scan_schedule.delay = 300

# This allows the newrelic security agent to collect
# sample data even when scan is not active.
# Default value is false.
# security.scan_schedule.always_sample_traces = false

# The exclude_from_iast_scan configuration allows users to specify APIs,
# parameters, and categories that should not be scanned by Security Agents.

# APIs can be specified using regular expression (regex) patterns that
# follow the syntax of Perl 5. The regex pattern should provide a complete
# match for the URL without the endpoint.
# security.exclude_from_iast_scan.api = .*\/api\/v1\/.*?\/login, .*\/api\/v2\/.*?\/login

# The http_request_parameters configuration allows users to specify headers, query
# parameters, and body keys that should be excluded from IAST scans.

# A list of HTTP header keys. If a request includes any headers with
# these keys, the corresponding IAST scan will be skipped.
# security.exclude_from_iast_scan.http_request_parameters.header = X-Forwaded-For, Set-Cookie

# A list of query parameter keys. The presence of these parameters in
# the request's query string will lead to skipping the IAST scan.
# security.exclude_from_iast_scan.http_request_parameters.query = Query Parameter 1, Query Parameter 2

# A list of keys within the request body. If these keys are found in
# the body content, the IAST scan will be omitted. Supported content
# types for the request body include JSON, XML, and Form-URL-Encoded
# data.
# security.exclude_from_iast_scan.http_request_parameters.body = object.cc_number

# The iast_detection_category configuration allows users to specify
# which categories of vulnerabilities should not be detected by
# Security Agents. If any of these categories are set to true,
# Security Agents will not generate events or flag vulnerabilities
# for that category.
security.exclude_from_iast_scan.iast_detection_category.insecure_settings = false
security.exclude_from_iast_scan.iast_detection_category.invalid_file_access = false
security.exclude_from_iast_scan.iast_detection_category.sql_injection = false
security.exclude_from_iast_scan.iast_detection_category.nosql_injection = false
security.exclude_from_iast_scan.iast_detection_category.ldap_injection = false
security.exclude_from_iast_scan.iast_detection_category.javascript_injection = false
security.exclude_from_iast_scan.iast_detection_category.command_injection = false
security.exclude_from_iast_scan.iast_detection_category.xpath_injection = false
security.exclude_from_iast_scan.iast_detection_category.ssrf = false
security.exclude_from_iast_scan.iast_detection_category.rxss = false


# Sets the name of a file to log agent messages to. Whatever you
# set this to, you must ensure that the permissions for the
# containing directory and the file itself are correct, and
Expand Down Expand Up @@ -251,5 +359,4 @@ monitor_mode = true

[newrelic:production]
monitor_mode = true

# ---------------------------------------------------------------------------
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def build_extension(self, ext):
package_data={
"newrelic": ["newrelic.ini", "version.txt", "packages/urllib3/LICENSE.txt", "common/cacert.pem"],
},
extras_require={"infinite-tracing": ["grpcio", "protobuf"]},
extras_require={"infinite-tracing": ["grpcio", "protobuf"], "iast": ["newrelic_security"]},
)

if with_setuptools:
Expand Down
4 changes: 4 additions & 0 deletions tests/framework_bottle/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
"transaction_tracer.stack_trace_threshold": 0.0,
"debug.log_data_collector_payloads": True,
"debug.record_transaction_failure": True,
"security.agent.enabled": True,
"security.enabled": True,
"security.mode": "IAST",
"security.validator_service_url": "wss://csec-staging.nr-data.net"
}

collector_agent_registration = collector_agent_registration_fixture(
Expand Down
4 changes: 4 additions & 0 deletions tests/framework_django/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
"debug.record_transaction_failure": True,
"debug.log_autorum_middleware": True,
"feature_flag": set(["django.instrumentation.inclusion-tags.r1"]),
"security.agent.enabled": True,
"security.enabled": True,
"security.mode": "IAST",
"security.validator_service_url": "wss://csec-staging.nr-data.net"
}

collector_agent_registration = collector_agent_registration_fixture(
Expand Down
4 changes: 4 additions & 0 deletions tests/framework_flask/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
"debug.log_data_collector_payloads": True,
"debug.record_transaction_failure": True,
"debug.log_autorum_middleware": True,
"security.agent.enabled": True,
"security.enabled": True,
"security.mode": "IAST",
"security.validator_service_url": "wss://csec-staging.nr-data.net"
}

collector_agent_registration = collector_agent_registration_fixture(
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ deps =
coverage
WebTest==3.0.0
py313: legacy-cgi==2.6.1 # cgi was removed from the stdlib in 3.13, and is required for WebTest
[email protected]:newrelic/csec-python-agent.git#egg=newrelic-security


# Test Suite Dependencies
adapter_asgiref-asgireflatest: asgiref
Expand Down
Loading