Skip to content

Commit f648e3f

Browse files
authored
fix: Obfuscate custom attributes for logs added after PVE (#1622)
1 parent 7ffb0f4 commit f648e3f

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/features/logging/aggregate/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export class Aggregate extends AggregateBase {
116116
common: {
117117
/** Attributes in the `common` section are added to `all` logs generated in the payload */
118118
attributes: {
119-
...this.agentRef.info.jsAttributes, // user-provided custom attributes
119+
...(applyFnToProps(this.agentRef.info.jsAttributes, this.obfuscator.obfuscateString.bind(this.obfuscator), 'string')),
120120
...(this.harvestEndpointVersion === 1 && {
121121
'entity.guid': this.agentRef.runtime.appMetadata.agents[0].entityGuid,
122122
appId: this.agentRef.info.applicationID

tests/specs/obfuscate.e2e.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ describe('obfuscate rules', () => {
4747
})
4848

4949
it('should apply to all payloads', async () => {
50+
await browser.url(await browser.testHandle.assetURL('obfuscate-pii.html', config))
51+
.then(() => browser.waitForAgentLoad())
52+
await browser.execute(function () {
53+
// test log custom attributes added after PVE
54+
newrelic.setCustomAttribute('foo', 'foo pii')
55+
console.log('Test')
56+
})
5057
const [rumHarvests, timingEventsHarvests, ajaxEventsHarvests, errorsHarvests, insightsHarvests, tracesHarvests, interactionEventsHarvests, logsHarvests] = await Promise.all([
5158
rumCapture.waitForResult({ timeout: 10000 }),
5259
timingEventsCapture.waitForResult({ timeout: 10000 }),
@@ -55,9 +62,7 @@ describe('obfuscate rules', () => {
5562
insightsCapture.waitForResult({ timeout: 10000 }),
5663
tracesCapture.waitForResult({ timeout: 10000 }),
5764
interactionEventsCapture.waitForResult({ timeout: 10000 }),
58-
logsCapture.waitForResult({ timeout: 10000 }),
59-
browser.url(await browser.testHandle.assetURL('obfuscate-pii.html', config))
60-
.then(() => browser.waitForAgentLoad())
65+
logsCapture.waitForResult({ timeout: 10000 })
6166
])
6267

6368
expect(rumHarvests.length).toBeGreaterThan(0)
@@ -89,7 +94,7 @@ describe('obfuscate rules', () => {
8994
checkPayload(harvest.request.body)
9095
checkPayload(harvest.request.query)
9196
})
92-
expect(logsHarvests.length).toBeGreaterThan(0)
97+
expect(logsHarvests.length).toBe(2)
9398
logsHarvests.forEach(harvest => {
9499
checkPayload(harvest.request.body)
95100
checkPayload(harvest.request.query)

0 commit comments

Comments
 (0)