Skip to content

Commit

Permalink
Redacted user key-values printed in logs.
Browse files Browse the repository at this point in the history
  • Loading branch information
yujingwei committed Oct 16, 2023
1 parent 076fb6e commit 62ec33f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 38 deletions.
36 changes: 0 additions & 36 deletions src/base/pegasus_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,41 +195,5 @@ int c_unescape_string(const std::string &src, std::string &dest)
return len;
}

template <>
std::string redact_sensitive_string(const std::string &src)
{
if (FLAGS_encrypt_data_at_rest) {
return "<redacted>";
} else {
return src;
}
}

template <>
dsn::blob redact_sensitive_string(const dsn::blob &src)
{
static dsn::blob rbb = dsn::blob::create_from_bytes(std::move("<redacted>"));
if (FLAGS_encrypt_data_at_rest) {
return rbb;
}

else {
return src;
}
}

template <>
rocksdb::Slice redact_sensitive_string(const rocksdb::Slice &src)
{
static rocksdb::Slice slice = rocksdb::Slice(std::move("<redacted>"));
if (FLAGS_encrypt_data_at_rest) {
return slice;
}

else {
return src;
}
}

} // namespace utils
} // namespace pegasus
11 changes: 9 additions & 2 deletions src/base/pegasus_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,15 @@ std::string c_escape_sensitive_string(const T &src, bool always_escape = false)
// ----------------------------------------------------------------------
int c_unescape_string(const std::string &src, std::string &dest);

template <typename T>
T redact_sensitive_string(const T &src);
template <class T>
std::string redact_sensitive_string(const T &src)
{
if (FLAGS_encrypt_data_at_rest) {
return "<redacted>";
} else {
return src;
}
}

inline dsn::string_view to_string_view(rocksdb::Slice s) { return {s.data(), s.size()}; }

Expand Down

0 comments on commit 62ec33f

Please sign in to comment.