Skip to content

Commit e8d4798

Browse files
authored
Ignore redis key if not UTF8 (#1997)
1 parent 266a576 commit e8d4798

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
- Fix sentry-rails' controller span nesting [#1973](https://github.com/getsentry/sentry-ruby/pull/1973)
5353
- Fixes [#1899](https://github.com/getsentry/sentry-ruby/issues/1899)
5454
- Do not report exceptions when a Rails runner exits with `exit 0` [#1988](https://github.com/getsentry/sentry-ruby/pull/1988)
55+
- Ignore redis key if not UTF8 [#1997](https://github.com/getsentry/sentry-ruby/pull/1997)
56+
- Fixes [#1992](https://github.com/getsentry/sentry-ruby/issues/1992)
5557
5658
### Miscellaneous
5759
[

sentry-ruby/lib/sentry/redis.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ def commands_description
5454
def parsed_commands
5555
commands.map do |statement|
5656
command, key, *arguments = statement
57-
command_set = { command: command.to_s.upcase, key: key }
57+
command_set = { command: command.to_s.upcase }
58+
command_set[:key] = key if Utils::EncodingHelper.valid_utf_8?(key)
5859

5960
if Sentry.configuration.send_default_pii
6061
command_set[:arguments] = arguments

sentry-ruby/spec/sentry/redis_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,17 @@
3030
expect(request_span.data).to eq({ server: "127.0.0.1:6379/0" })
3131
end
3232

33-
it "removes bad encoding commands gracefully" do
33+
it "removes bad encoding keys and arguments gracefully" do
3434
transaction = Sentry.start_transaction
3535
Sentry.get_current_scope.set_span(transaction)
3636

3737
# random bytes
38-
redis.set("key", "foo \x1F\xE6")
38+
redis.set("key \x1F\xE6", "val \x1F\xE6")
3939

4040
request_span = transaction.span_recorder.spans.last
4141
description = request_span.description
4242

43-
expect(description).to eq("SET key")
43+
expect(description).to eq("SET")
4444

4545
expect do
4646
JSON.generate(description)

0 commit comments

Comments
 (0)