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

feat(insights): sanitize retention query #19979

Merged
merged 3 commits into from
Jan 26, 2024
Merged

feat(insights): sanitize retention query #19979

merged 3 commits into from
Jan 26, 2024

Conversation

mariusandra
Copy link
Collaborator

Problem

JSON parse error - 6 validation errors for QueryRequest
query.RetentionQuery.retentionFilter.returningEntity.math
Extra inputs are not permitted

Changes

Sanitizes the retention entity fields.

How did you test this code?

Nothing broke locally

Copy link
Contributor

Size Change: 0 B

Total Size: 2.21 MB

ℹ️ View Unchanged
Filename Size
frontend/dist/toolbar.js 2.21 MB

compressed-size-action

}
const record = { ...entity }
for (const key of Object.keys(record)) {
if (!['id', 'kind', 'name', 'type', 'order', 'uuid', 'custom_name'].includes(key)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we were to add a new key to RetentionEntity, would we need to add it here too? May be worth a comment somewhere, otherwise we may get some confused devs in the future

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps... but I hope we won't need this soon anymore. As soon as the filters object is gone, this will be as well.

The backend has a more sensible allow-list approach though

return {
"type": entity.get("type"),
"id": entity.get("id"),
"name": entity.get("name"),
"custom_name": entity.get("custom_name"),
"order": entity.get("order"),
}

But since the tests are all green, I'll use the opportunity and merge it in. There will be more adjustments...

@mariusandra mariusandra merged commit f447507 into master Jan 26, 2024
79 checks passed
@mariusandra mariusandra deleted the retention-sanity branch January 26, 2024 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants