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

Check query param sanitizer for arrays flattening the value #820

Closed
2 tasks done
tombruijn opened this issue Feb 9, 2022 · 0 comments · Fixed by #825
Closed
2 tasks done

Check query param sanitizer for arrays flattening the value #820

tombruijn opened this issue Feb 9, 2022 · 0 comments · Fixed by #825
Assignees
Labels

Comments

@tombruijn
Copy link
Member

tombruijn commented Feb 9, 2022

While we were working on #819 we noticed that the QueryParamsSanitizer sometimes returns a single object, when it was sanitizing an array.

It happens on this line:

sanitize(array[0], only_top_level, key_sanitizer)

To do

  • Reproduce the issue by sanitizing an object with a key that contains an array, and setting only_top_level to true
  • If the bug is confirmed, fix the issue.
@tombruijn tombruijn added the bug label Feb 9, 2022
@tombruijn tombruijn self-assigned this Feb 17, 2022
tombruijn added a commit that referenced this issue Feb 17, 2022
When an value sanitized by the QueryParamsSanitizer was an Array at the
root level, and `only_top_level = true` was set, it would not return a
sanitized Array object, only the child values.

The Array wrapper value would be removed, returning an inaccurate
picture of the structure of the sanitized value.

```ruby
# Before change
> Appsignal::Utils::QueryParamsSanitizer.sanitize(["foo" => "bar"], false)
# [{"foo"=>"?"}]
> Appsignal::Utils::QueryParamsSanitizer.sanitize(["foo" => "bar"], true)
# {"foo"=>"?"}

# After change
> Appsignal::Utils::QueryParamsSanitizer.sanitize(["foo" => "bar"], false)
# [{"foo"=>"?"}]
> Appsignal::Utils::QueryParamsSanitizer.sanitize(["foo" => "bar"], true)
# [{"foo"=>"?"}]
```

Part of #820
tombruijn added a commit that referenced this issue Feb 22, 2022
When an value sanitized by the QueryParamsSanitizer was an Array at the
root level, and `only_top_level = true` was set, it would not return a
sanitized Array object, only the child values.

The Array wrapper value would be removed, returning an inaccurate
picture of the structure of the sanitized value.

```ruby
# Before change
> Appsignal::Utils::QueryParamsSanitizer.sanitize(["foo" => "bar"], false)
# [{"foo"=>"?"}]
> Appsignal::Utils::QueryParamsSanitizer.sanitize(["foo" => "bar"], true)
# {"foo"=>"?"}

# After change
> Appsignal::Utils::QueryParamsSanitizer.sanitize(["foo" => "bar"], false)
# [{"foo"=>"?"}]
> Appsignal::Utils::QueryParamsSanitizer.sanitize(["foo" => "bar"], true)
# [{"foo"=>"?"}]
```

Part of #820
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant