2019-06-28 18:34:08 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Peek
|
|
|
|
module Views
|
2019-07-24 14:42:45 +00:00
|
|
|
class RedisDetailed < DetailedView
|
2019-07-09 14:07:41 +00:00
|
|
|
REDACTED_MARKER = "<redacted>"
|
|
|
|
|
2019-07-17 19:33:49 +00:00
|
|
|
def key
|
|
|
|
'redis'
|
|
|
|
end
|
|
|
|
|
2020-06-04 12:08:21 +00:00
|
|
|
def detail_store
|
|
|
|
::Gitlab::Instrumentation::Redis.detail_store
|
|
|
|
end
|
|
|
|
|
2019-07-17 19:33:49 +00:00
|
|
|
private
|
|
|
|
|
2019-06-28 18:34:08 +00:00
|
|
|
def format_call_details(call)
|
2020-06-16 12:09:00 +00:00
|
|
|
super.merge(cmd: format_command(call[:cmd]),
|
|
|
|
instance: call[:storage])
|
2019-06-28 18:34:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def format_command(cmd)
|
2019-07-09 14:07:41 +00:00
|
|
|
if cmd.length >= 2 && cmd.first =~ /^auth$/i
|
|
|
|
cmd[-1] = REDACTED_MARKER
|
2019-06-28 18:34:08 +00:00
|
|
|
# Scrub out the value of the SET calls to avoid binary
|
|
|
|
# data or large data from spilling into the view
|
2019-07-09 14:07:41 +00:00
|
|
|
elsif cmd.length >= 3 && cmd.first =~ /set/i
|
|
|
|
cmd[2..-1] = REDACTED_MARKER
|
2019-06-28 18:34:08 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
cmd.join(' ')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|