Skip to content

Commit

Permalink
Remove high security checks
Browse files Browse the repository at this point in the history
  • Loading branch information
TimPansino committed Nov 4, 2024
1 parent e124b79 commit 4dce5c4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 30 deletions.
29 changes: 13 additions & 16 deletions newrelic/core/data_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,22 +163,19 @@ def get_log_events_common_block(self):
try:
# Add global custom log attributes to common block
if self.configuration.application_logging.forwarding.custom_attributes:
if self.configuration.high_security:
_logger.debug("Cannot add custom attribute in High Security Mode.")
else:
# Retrieve and process attrs
custom_attributes = {}
for attr_name, attr_value in self.configuration.application_logging.forwarding.custom_attributes:
if len(custom_attributes) >= MAX_NUM_USER_ATTRIBUTES:
_logger.debug("Maximum number of custom attributes already added. Dropping attribute: %r=%r", attr_name, value)
break

key, val = process_user_attribute(attr_name, attr_value)

if key is not None:
custom_attributes[key] = val

common.update(custom_attributes)
# Retrieve and process attrs
custom_attributes = {}
for attr_name, attr_value in self.configuration.application_logging.forwarding.custom_attributes:
if len(custom_attributes) >= MAX_NUM_USER_ATTRIBUTES:
_logger.debug("Maximum number of custom attributes already added. Dropping attribute: %r=%r", attr_name, value)
break

key, val = process_user_attribute(attr_name, attr_value)

if key is not None:
custom_attributes[key] = val

common.update(custom_attributes)

# Add application labels as tags. prefixed attributes to common block
labels = self.configuration.labels
Expand Down
14 changes: 0 additions & 14 deletions tests/agent_features/test_log_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,17 +475,3 @@ def test_global_custom_attribute_forwarding():
common = session.get_log_events_common_block()
# Both attrs should appear, and the 2nd attr should be truncated to the max user attribute length
assert common == {"custom_attr_1": "value", "custom_attr_2": "a" * 255}


@override_application_settings({
"high_security": True,
"application_logging.forwarding.custom_attributes": [("custom_attr_1", "value"), ("custom_attr_2", "a" * 256)],
})
@background_task()
def test_global_custom_attribute_forwarding_high_security_enabled():
txn = current_transaction()
session = list(txn.application._agent._applications.values())[0]._active_session

common = session.get_log_events_common_block()
# No custom attrs should be attached with high security enabled
assert common == {}

0 comments on commit 4dce5c4

Please sign in to comment.