From c423e78351e485a46ed178ba33c95fc2d5d88f58 Mon Sep 17 00:00:00 2001 From: Florian Bacher Date: Thu, 7 Nov 2024 15:26:26 +0100 Subject: [PATCH] Extend user data filtering example and tests (#356) Signed-off-by: Florian Bacher --- .chloggen/add-client-address-filtering.yaml | 18 ++++++++++++++++++ config_examples/filtering_user_data.yaml | 3 +++ internal/testbed/integration/filtering_test.go | 2 ++ 3 files changed, 23 insertions(+) create mode 100644 .chloggen/add-client-address-filtering.yaml diff --git a/.chloggen/add-client-address-filtering.yaml b/.chloggen/add-client-address-filtering.yaml new file mode 100644 index 00000000..eef0459b --- /dev/null +++ b/.chloggen/add-client-address-filtering.yaml @@ -0,0 +1,18 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: transformprocessor + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Extend the user data filtering example with a statement for masking the `client.address` attribute + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [356] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: diff --git a/config_examples/filtering_user_data.yaml b/config_examples/filtering_user_data.yaml index 5d70214a..8e8c3e87 100644 --- a/config_examples/filtering_user_data.yaml +++ b/config_examples/filtering_user_data.yaml @@ -20,6 +20,9 @@ processors: - set(attributes["user.name"], "****") - set(attributes["user.full_name"], "****") - set(attributes["user.email"], "****") + # this will not only redact end user client IP addresses, + # but also the address of a server acting as a client when establishing a connection to another server + - set(attributes["client.address"], "****") metric_statements: - context: datapoint statements: *filter-statements diff --git a/internal/testbed/integration/filtering_test.go b/internal/testbed/integration/filtering_test.go index b10c64ab..4d830e59 100644 --- a/internal/testbed/integration/filtering_test.go +++ b/internal/testbed/integration/filtering_test.go @@ -352,6 +352,7 @@ func TestFilteringUserProperties(t *testing.T) { attributesNonMasked.PutStr("user.name", "username") attributesNonMasked.PutStr("user.full_name", "Firstname Lastname") attributesNonMasked.PutStr("user.email", "user@email.com") + attributesNonMasked.PutStr("client.address", "127.0.0.1") attributesNonMasked.PutStr("safe-attribute", "foo") attributesNonMasked.PutStr("another-attribute", "bar") @@ -360,6 +361,7 @@ func TestFilteringUserProperties(t *testing.T) { attributesMasked.PutStr("user.name", "****") attributesMasked.PutStr("user.full_name", "****") attributesMasked.PutStr("user.email", "****") + attributesMasked.PutStr("client.address", "****") attributesMasked.PutStr("safe-attribute", "foo") attributesMasked.PutStr("another-attribute", "bar")