Skip to content

Remove usages of "whitelist" in Firestore. #6846

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

Merged
merged 1 commit into from
Oct 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Firestore/core/src/remote/datastore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ void LogGrpcCallFinished(absl::string_view rpc_name,
status.error_message());
if (LogIsDebugEnabled()) {
auto headers =
Datastore::GetWhitelistedHeadersAsString(call->GetResponseHeaders());
LOG_DEBUG("RPC %s returned headers (whitelisted): %s", rpc_name, headers);
Datastore::GetAllowlistedHeadersAsString(call->GetResponseHeaders());
LOG_DEBUG("RPC %s returned headers (allowlisted): %s", rpc_name, headers);
}
}

Expand Down Expand Up @@ -332,15 +332,15 @@ bool Datastore::IsPermanentWriteError(const Status& error) {
return IsPermanentError(error) && !IsAbortedError(error);
}

std::string Datastore::GetWhitelistedHeadersAsString(
std::string Datastore::GetAllowlistedHeadersAsString(
const GrpcCall::Metadata& headers) {
static std::unordered_set<std::string> whitelist = {
static std::unordered_set<std::string> allowlist = {
"date", "x-google-backends", "x-google-netmon-label", "x-google-service",
"x-google-gfe-request-trace"};

std::string result;
for (const auto& kv : headers) {
if (whitelist.find(MakeString(kv.first)) != whitelist.end()) {
if (allowlist.find(MakeString(kv.first)) != allowlist.end()) {
absl::StrAppend(&result, MakeStringView(kv.first), ": ",
MakeStringView(kv.second), "\n");
}
Expand Down
4 changes: 2 additions & 2 deletions Firestore/core/src/remote/datastore.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class Datastore : public std::enable_shared_from_this<Datastore> {
*/
static bool IsPermanentWriteError(const util::Status& status);

static std::string GetWhitelistedHeadersAsString(
static std::string GetAllowlistedHeadersAsString(
const GrpcCall::Metadata& headers);

Datastore(const Datastore& other) = delete;
Expand Down Expand Up @@ -169,7 +169,7 @@ class Datastore : public std::enable_shared_from_this<Datastore> {

void RemoveGrpcCall(GrpcCall* to_remove);

static GrpcCall::Metadata ExtractWhitelistedHeaders(
static GrpcCall::Metadata ExtractAllowlistedHeaders(
const GrpcCall::Metadata& headers);

// In case Auth tries to invoke a callback after `Datastore` has been shut
Expand Down
4 changes: 2 additions & 2 deletions Firestore/core/src/remote/stream.cc
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ void Stream::OnStreamRead(const grpc::ByteBuffer& message) {
HARD_ASSERT(IsStarted(), "OnStreamRead called for a stopped stream.");

if (LogIsDebugEnabled()) {
LOG_DEBUG("%s headers (whitelisted): %s", GetDebugDescription(),
Datastore::GetWhitelistedHeadersAsString(
LOG_DEBUG("%s headers (allowlisted): %s", GetDebugDescription(),
Datastore::GetAllowlistedHeadersAsString(
grpc_stream_->GetResponseHeaders()));
}

Expand Down
6 changes: 3 additions & 3 deletions Firestore/core/test/unit/remote/datastore_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,17 @@ TEST_F(DatastoreTest, CanShutdownWithNoOperations) {
Shutdown();
}

TEST_F(DatastoreTest, WhitelistedHeaders) {
TEST_F(DatastoreTest, AllowlistedHeaders) {
GrpcStream::Metadata headers = {
{"date", "date value"},
{"x-google-backends", "backend value"},
{"x-google-foo", "should not be in result"}, // Not whitelisted
{"x-google-foo", "should not be in result"}, // Not allowlisted
{"x-google-gfe-request-trace", "request trace"},
{"x-google-netmon-label", "netmon label"},
{"x-google-service", "service 1"},
{"x-google-service", "service 2"}, // Duplicate names are allowed
};
std::string result = Datastore::GetWhitelistedHeadersAsString(headers);
std::string result = Datastore::GetAllowlistedHeadersAsString(headers);
EXPECT_EQ(result,
"date: date value\n"
"x-google-backends: backend value\n"
Expand Down