Skip to content
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

[Audit Logging] Custom audit logger parsing in xDS registry. #32970

Merged
merged 35 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
4e6e356
Add third_party logger config conversion in xDS audit logger registry.
rockspore Apr 28, 2023
4aec3b7
Automated change: Fix sanity tests
rockspore Apr 28, 2023
13f4442
Merge pull request #17 from rockspore/create-pull-request/patch-4e6e356
rockspore Apr 28, 2023
6d37605
return empty json on error
rockspore Apr 28, 2023
16bd834
stdout audit logger impl
rockspore May 5, 2023
f8f5ee1
generate projects
rockspore May 5, 2023
195f90f
Automated change: Fix sanity tests
rockspore May 5, 2023
1c224f3
Merge pull request #21 from rockspore/create-pull-request/patch-f8f5ee1
rockspore May 5, 2023
5cb67df
address PR comments
rockspore May 5, 2023
fc13177
constexpr
rockspore May 5, 2023
3cbd452
Merge branch 'master' of github.com:grpc/grpc into stdout-logger
rockspore May 12, 2023
1064479
switch to public json hdr
rockspore May 12, 2023
db15d5c
sanity
rockspore May 12, 2023
4ecbc71
Automated change: Fix sanity tests
rockspore May 12, 2023
5c0fc5b
Merge pull request #23 from rockspore/create-pull-request/patch-db15d5c
rockspore May 12, 2023
defee80
address PR comments
rockspore May 12, 2023
6092130
fix build
rockspore May 12, 2023
eedd236
Automated change: Fix sanity tests
rockspore May 12, 2023
2738e47
log in seconds
rockspore May 15, 2023
f6427bb
Merge pull request #24 from rockspore/create-pull-request/patch-6092130
rockspore May 15, 2023
7c765ee
address PR comments
rockspore May 15, 2023
aca75f2
nanosecond
rockspore May 15, 2023
82a2406
allow equal time
rockspore May 16, 2023
ebddd57
Merge branch 'master' of github.com:grpc/grpc into xds-registry
rockspore May 16, 2023
f333b8b
Merge branch 'stdout-logger' of github.com:rockspore/grpc into xds-re…
rockspore May 16, 2023
a89fa3f
use new Json APIs
rockspore May 16, 2023
fc994c5
Merge branch 'master' of github.com:grpc/grpc into xds-registry
rockspore May 16, 2023
b5e1962
validate config for built-in loggers
rockspore May 16, 2023
e9e96b6
Automated change: Fix sanity tests
rockspore May 16, 2023
803e4da
Merge pull request #26 from rockspore/create-pull-request/patch-b5e1962
rockspore May 16, 2023
1f58adf
use match
rockspore May 17, 2023
e76be97
Merge branch 'xds-registry' of github.com:rockspore/grpc into xds-reg…
rockspore May 17, 2023
8a0fa4e
fix test
rockspore May 17, 2023
9b21f69
Automated change: Fix sanity tests
rockspore May 17, 2023
cf7d08c
Merge pull request #27 from rockspore/create-pull-request/patch-8a0fa4e
rockspore May 17, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 1 addition & 8 deletions CMakeLists.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 3 additions & 17 deletions build_autogenerated.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config.m4

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions config.w32

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion gRPC-C++.podspec

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions gRPC-Core.podspec

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions grpc.gemspec

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion grpc.gyp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4004,6 +4004,7 @@ grpc_cc_library(
"envoy_type_upb",
"error",
"google_rpc_status_upb",
"grpc_audit_logging",
"grpc_fake_credentials",
"grpc_fault_injection_filter",
"grpc_lb_xds_channel_args",
Expand Down
24 changes: 18 additions & 6 deletions src/core/ext/xds/xds_audit_logger_registry.cc
markdroth marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@

#include "src/core/ext/xds/xds_audit_logger_registry.h"

#include <string>
#include <utility>

#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "absl/types/variant.h"
Expand All @@ -29,17 +32,22 @@
#include "src/core/ext/xds/xds_common_types.h"
#include "src/core/lib/gprpp/validation_errors.h"
#include "src/core/lib/json/json.h"
#include "src/core/lib/security/authorization/audit_logging.h"

namespace grpc_core {

namespace {

using experimental::AuditLoggerRegistry;

class StdoutLoggerConfigFactory : public XdsAuditLoggerRegistry::ConfigFactory {
public:
Json::Object ConvertXdsAuditLoggerConfig(
const XdsResourceType::DecodeContext& /*context*/,
absl::string_view /*configuration*/,
ValidationErrors* /*errors*/) override {
// Stdout logger has no configuration right now. So we don't need to invoke
markdroth marked this conversation as resolved.
Show resolved Hide resolved
// the gRPC audit logger registry to validate the config.
return Json::Object{{"stdout_logger", Json::Object()}};
}

Expand Down Expand Up @@ -84,16 +92,20 @@ Json XdsAuditLoggerRegistry::ConvertXdsAuditLoggerConfig(
auto config_factory_it =
audit_logger_config_factories_.find(extension->type);
if (config_factory_it != audit_logger_config_factories_.end()) {
// TODO(lwge): Parse the config with the gRPC audit logger registry.
return config_factory_it->second->ConvertXdsAuditLoggerConfig(
context, *serialized_value, errors);
}
}
// TODO(lwge): Check for third-party audit logger type. For now, we disallow
// it by rejecting TypedStruct entries.
if (absl::get_if<Json>(&extension->value) != nullptr) {
errors->AddError("third-party audit logger is not supported");
return Json();
// Check for custom audit logger type.
Json* json = absl::get_if<Json>(&extension->value);
if (json != nullptr &&
AuditLoggerRegistry::FactoryExists(extension->type)) {
auto result = AuditLoggerRegistry::ParseConfig(extension->type, *json);
if (!result.ok()) {
errors->AddError(result.status().message());
return Json();
}
return Json::Object{{std::string(extension->type), std::move(*json)}};
}
}
// Add validation error only if the config is not marked optional.
Expand Down
1 change: 1 addition & 0 deletions src/python/grpcio/grpc_core_dependencies.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/core/xds/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ grpc_cc_test(
deps = [
"//:gpr",
"//:grpc",
"//src/core:grpc_audit_logging",
"//src/proto/grpc/testing/xds/v3:audit_logger_stream_proto",
"//src/proto/grpc/testing/xds/v3:rbac_proto",
"//src/proto/grpc/testing/xds/v3:typed_struct_proto",
Expand Down