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

Limit attribute value length for pinpoint #233

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ function sanitizeAttribute(value) {
// If null or undefined
if (value == null) return
if (Array.isArray(value)) {
return value.filter(notEmpty).map((val) => val.toString())
return value.filter(notEmpty).map((val) => val.toString().substring(0, 200))
}
// @TODO guard against null here
return isNullOrUndef(value) ? value : value.toString()
return isNullOrUndef(value) ? value : value.toString().substring(0, 200)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ test('should sanitize attributes', async (t) => {
})
})

test('should limit attribute length', async (t) => {
const sanitized = await prepareData.prepareAttributes({
foo: '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890___',
})

t.deepEqual(sanitized, {
foo: '12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890',
})
})

test('should remove undefined or null attributes', async (t) => {
const sanitized = await prepareData.prepareAttributes({
foo: undefined,
Expand Down