Skip to content

Commit

Permalink
Hide sensitive info from Properties
Browse files Browse the repository at this point in the history
  • Loading branch information
kenneth-jia committed Jul 27, 2022
1 parent 338dc9a commit 764a6c0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/kafka/Properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Properties
const std::string& key = kv.first;
const std::string& value = kv.second;

static const std::regex reSensitiveKey(R"(.+\.password)");
static const std::regex reSensitiveKey(R"(.+\.password|.+\.username)");
bool isSensitive = std::regex_match(key, reSensitiveKey);

ret.append(ret.empty() ? "" : "|").append(key).append("=").append(isSensitive ? "*" : value);
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/TestProperties.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ TEST(Properties, SensitiveProperties)
{{
{ "ssl.key.password", "passwordA" },
{ "ssl.keystore.password", "passwordB" },
{ "sasl.username", "userName" },
{ "sasl.password", "passwordC" },
}};

EXPECT_EQ("sasl.password=*|ssl.key.password=*|ssl.keystore.password=*", props.toString());
EXPECT_EQ("sasl.password=*|sasl.username=*|ssl.key.password=*|ssl.keystore.password=*", props.toString());
}

0 comments on commit 764a6c0

Please sign in to comment.