Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: impl audit log (#11701)

p0nyeeae17c90007
diff --git a/backend/api/v1/audit.go b/backend/api/v1/audit.go
new file mode 100644
index 0000000000..bda0993d5d
--- /dev/null
+++ b/backend/api/v1/audit.go
@@ -0,0 +1,154 @@
+package v1
+
+import (
+ "context"
+ "log/slog"
+ "reflect"
+
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/status"
+ "google.golang.org/protobuf/encoding/protojson"
+ "google.golang.org/protobuf/reflect/protoreflect"
+
+ "github.com/pkg/errors"
+
+ "github.com/bytebase/bytebase/backend/common"
+ "github.com/bytebase/bytebase/backend/common/log"
+ "github.com/bytebase/bytebase/backend/store"
+ storepb "github.com/bytebase/bytebase/proto/generated-go/store"
+ v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"
+)
+
+// ACLInterceptor is the v1 ACL interceptor for gRPC server.
+type AuditInterceptor struct {
+ store *store.Store
+}
+
+// NewAuditInterceptor returns a new v1 API ACL interceptor.
+func NewAuditInterceptor(store *store.Store) *AuditInterceptor {
+ return &AuditInterceptor{
+ store: store,
+ }
+}
+
+func getRequestResource(request any) string {
+ if request == nil || reflect.ValueOf(request).IsNil() {
+ return ""
+ }
+ switch r := request.(type) {
+ case *v1pb.QueryRequest:
+ return r.Name
+ case *v1pb.CreateUserRequest:
+ return ""
+ default:
+ return ""
+ }
+}
+
+func getRequestString(request any) (string, error) {
+ m := func() protoreflect.ProtoMessage {
+ if request == nil || reflect.ValueOf(request).IsNil() {
+ return nil
+ }
+ switch r := request.(type) {
+ case *v1pb.QueryRequest:
+ return r
+ case *v1pb.CreateUserRequest:
+ return r
+ default:
+ return nil
+ }
+ }()
+ if m == nil {
+ return "", nil
+ }
+ b, err := protojson.Marshal(m)
+ if err != nil {
+ return "", err
+ }
+ return string(b), nil
+}
+
+func getResponseString(response any) (string, error) {
+ m := func() protoreflect.ProtoMessage {
+ if response == nil || reflect.ValueOf(response).IsNil() {
+ return nil
+ }
+ switch r := response.(type) {
+ case *v1pb.QueryResponse:
+ return nil
+ case *v1pb.User:
+ return &v1pb.User{
+ Name: r.Name,
+ Email: r.Email,
+ Title: r.Title,
+ UserType: r.UserType,
+ }
+ default:
+ return nil
+ }
+ }()
+ if m == nil {
+ return "", nil
+ }
+ b, err := protojson.Marshal(m)
+ if err != nil {
+ return "", err
+ }
+ return string(b), nil
+}
+
+func isAuditMethod(method string) bool {
+ switch method {
+ case
+ v1pb.AuthService_CreateUser_FullMethodName,
+ v1pb.SQLService_Query_FullMethodName:
+ return true
+ default:
+ return false
+ }
+}
+
+func (in *AuditInterceptor) AuditInterceptor(ctx context.Context, request any, serverInfo *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error) {
+ response, rerr := handler(ctx, request)
+
+ if err := func() error {
+ if !isAuditMethod(serverInfo.FullMethod) {
+ return nil
+ }
+ requestString, err := getRequestString(request)
+ if err != nil {
+ return errors.Wrapf(err, "failed to get request string")
+ }
+ responseString, err := getResponseString(response)
+ if err != nil {
+ return errors.Wrapf(err, "failed to get response string")
+ }
+
+ var user string
+ if u, ok := ctx.Value(common.UserContextKey).(*store.UserMessage); ok {
+ user = common.FormatUserEmail(u.Email)
+ }
+
+ st, _ := status.FromError(rerr)
+
+ p := &storepb.AuditLog{
+ Method: serverInfo.FullMethod,
+ Resource: getRequestResource(request),
+ Severity: storepb.AuditLog_INFO,
+ User: user,
+ Request: requestString,
+ Response: responseString,
+ Status: st.Proto(),
+ }
+
+ if err := in.store.CreateAuditLog(ctx, p); err != nil {
+ return errors.Wrapf(err, "failed to create audit log")
+ }
+ return nil
+ }(); err != nil {
+ slog.Warn("audit interceptor: failed to create audit log", log.BBError(err))
+ }
+
+ return response, rerr
+}
diff --git a/backend/bin/server/cmd/profile.go b/backend/bin/server/cmd/profile.go
index e2cfbfe23e..bb85abdb1e 100644
--- a/backend/bin/server/cmd/profile.go
+++ b/backend/bin/server/cmd/profile.go
@@ -42,5 +42,6 @@ func getBaseProfile(dataDir string) config.Profile {
Lsp: flags.lsp,
PreUpdateBackup: flags.preUpdateBackup,
ExecuteDetail: flags.executeDetail,
+ DevelopmentAudit: flags.developmentAudit,
}
}
diff --git a/backend/bin/server/cmd/root.go b/backend/bin/server/cmd/root.go
index 424342a54f..2a2d4de9fb 100644
--- a/backend/bin/server/cmd/root.go
+++ b/backend/bin/server/cmd/root.go
@@ -88,7 +88,8 @@ var (
backupBucket string
backupCredential string
- executeDetail bool
+ executeDetail bool
+ developmentAudit bool
}
rootCmd = &cobra.Command{
@@ -142,6 +143,8 @@ func init() {
rootCmd.PersistentFlags().StringVar(&flags.backupCredential, "backup-credential", "", "credentials file to use for the backup bucket. It should be the same format as the AWS/GCP credential files.")
rootCmd.PersistentFlags().BoolVar(&flags.executeDetail, "execute-detail", true, "expose execute details")
+
+ rootCmd.PersistentFlags().BoolVar(&flags.developmentAudit, "development-audit", false, "enable audit logs")
}
// -----------------------------------Command Line Config END--------------------------------------
diff --git a/backend/component/config/profile.go b/backend/component/config/profile.go
index a999474389..eb6e5db9f8 100644
--- a/backend/component/config/profile.go
+++ b/backend/component/config/profile.go
@@ -72,6 +72,8 @@ type Profile struct {
Lsp bool
PreUpdateBackup bool
ExecuteDetail bool
+
+ DevelopmentAudit bool
}
// UseEmbedDB returns whether to use embedDB.
diff --git a/backend/server/server.go b/backend/server/server.go
index 4262f09663..2af29002a5 100644
--- a/backend/server/server.go
+++ b/backend/server/server.go
@@ -301,6 +301,7 @@ func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {
// Setup the gRPC and grpc-gateway.
authProvider := auth.New(s.store, s.secret, tokenDuration, s.licenseService, s.stateCfg, s.profile)
+ auditProvider := apiv1.NewAuditInterceptor(s.store)
aclProvider := apiv1.NewACLInterceptor(s.store, s.secret, s.licenseService, s.iamManager, s.profile)
debugProvider := apiv1.NewDebugInterceptor(&s.errorRecordRing, s.metricReporter)
onPanic := func(p any) error {
@@ -321,6 +322,7 @@ func NewServer(ctx context.Context, profile config.Profile) (*Server, error) {
debugProvider.DebugInterceptor,
authProvider.AuthenticationInterceptor,
aclProvider.ACLInterceptor,
+ auditProvider.AuditInterceptor,
recoveryUnaryInterceptor,
),
grpc.ChainStreamInterceptor(
diff --git a/backend/store/audit_log.go b/backend/store/audit_log.go
new file mode 100644
index 0000000000..eea0cce7fb
--- /dev/null
+++ b/backend/store/audit_log.go
@@ -0,0 +1,33 @@
+package store
+
+import (
+ "context"
+
+ "google.golang.org/protobuf/encoding/protojson"
+
+ "github.com/pkg/errors"
+
+ storepb "github.com/bytebase/bytebase/proto/generated-go/store"
+)
+
+type AuditLog struct {
+}
+
+func (s *Store) CreateAuditLog(ctx context.Context, payload *storepb.AuditLog) error {
+ if !s.profile.DevelopmentAudit {
+ return nil
+ }
+ query := `
+ INSERT INTO audit_log (payload) VALUES ($1)
+ `
+
+ p, err := protojson.Marshal(payload)
+ if err != nil {
+ return errors.Wrapf(err, "failed to marshal payload")
+ }
+
+ if _, err := s.db.db.ExecContext(ctx, query, p); err != nil {
+ return errors.Wrapf(err, "failed to create audit log")
+ }
+ return nil
+}
diff --git a/frontend/src/types/proto/google/protobuf/any.ts b/frontend/src/types/proto/google/protobuf/any.ts
new file mode 100644
index 0000000000..afc5514bd2
--- /dev/null
+++ b/frontend/src/types/proto/google/protobuf/any.ts
@@ -0,0 +1,243 @@
+/* eslint-disable */
+import Long from "long";
+import _m0 from "protobufjs/minimal";
+
+export const protobufPackage = "google.protobuf";
+
+/**
+ * `Any` contains an arbitrary serialized protocol buffer message along with a
+ * URL that describes the type of the serialized message.
+ *
+ * Protobuf library provides support to pack/unpack Any values in the form
+ * of utility functions or additional generated methods of the Any type.
+ *
+ * Example 1: Pack and unpack a message in C++.
+ *
+ * Foo foo = ...;
+ * Any any;
+ * any.PackFrom(foo);
+ * ...
+ * if (any.UnpackTo(&foo)) {
+ * ...
+ * }
+ *
+ * Example 2: Pack and unpack a message in Java.
+ *
+ * Foo foo = ...;
+ * Any any = Any.pack(foo);
+ * ...
+ * if (any.is(Foo.class)) {
+ * foo = any.unpack(Foo.class);
+ * }
+ * // or ...
+ * if (any.isSameTypeAs(Foo.getDefaultInstance())) {
+ * foo = any.unpack(Foo.getDefaultInstance());
+ * }
+ *
+ * Example 3: Pack and unpack a message in Python.
+ *
+ * foo = Foo(...)
+ * any = Any()
+ * any.Pack(foo)
+ * ...
+ * if any.Is(Foo.DESCRIPTOR):
+ * any.Unpack(foo)
+ * ...
+ *
+ * Example 4: Pack and unpack a message in Go
+ *
+ * foo := &pb.Foo{...}
+ * any, err := anypb.New(foo)
+ * if err != nil {
+ * ...
+ * }
+ * ...
+ * foo := &pb.Foo{}
+ * if err := any.UnmarshalTo(foo); err != nil {
+ * ...
+ * }
+ *
+ * The pack methods provided by protobuf library will by default use
+ * 'type.googleapis.com/full.type.name' as the type URL and the unpack
+ * methods only use the fully qualified type name after the last '/'
+ * in the type URL, for example "foo.bar.com/x/y.z" will yield type
+ * name "y.z".
+ *
+ * JSON
+ *
+ * The JSON representation of an `Any` value uses the regular
+ * representation of the deserialized, embedded message, with an
+ * additional field `@type` which contains the type URL. Example:
+ *
+ * package google.profile;
+ * message Person {
+ * string first_name = 1;
+ * string last_name = 2;
+ * }
+ *
+ * {
+ * "@type": "type.googleapis.com/google.profile.Person",
+ * "firstName": <string>,
+ * "lastName": <string>
+ * }
+ *
+ * If the embedded message type is well-known and has a custom JSON
+ * representation, that representation will be embedded adding a field
+ * `value` which holds the custom JSON in addition to the `@type`
+ * field. Example (for message [google.protobuf.Duration][]):
+ *
+ * {
+ * "@type": "type.googleapis.com/google.protobuf.Duration",
+ * "value": "1.212s"
+ * }
+ */
+export interface Any {
+ /**
+ * A URL/resource name that uniquely identifies the type of the serialized
+ * protocol buffer message. This string must contain at least
+ * one "/" character. The last segment of the URL's path must represent
+ * the fully qualified name of the type (as in
+ * `path/google.protobuf.Duration`). The name should be in a canonical form
+ * (e.g., leading "." is not accepted).
+ *
+ * In practice, teams usually precompile into the binary all types that they
+ * expect it to use in the context of Any. However, for URLs which use the
+ * scheme `http`, `https`, or no scheme, one can optionally set up a type
+ * server that maps type URLs to message definitions as follows:
+ *
+ * * If no scheme is provided, `https` is assumed.
+ * * An HTTP GET on the URL must yield a [google.protobuf.Type][]
+ * value in binary format, or produce an error.
+ * * Applications are allowed to cache lookup results based on the
+ * URL, or have them precompiled into a binary to avoid any
+ * lookup. Therefore, binary compatibility needs to be preserved
+ * on changes to types. (Use versioned type names to manage
+ * breaking changes.)
+ *
+ * Note: this functionality is not currently available in the official
+ * protobuf release, and it is not used for type URLs beginning with
+ * type.googleapis.com.
+ *
+ * Schemes other than `http`, `https` (or the empty scheme) might be
+ * used with implementation specific semantics.
+ */
+ typeUrl: string;
+ /** Must be a valid serialized protocol buffer of the above specified type. */
+ value: Uint8Array;
+}
+
+function createBaseAny(): Any {
+ return { typeUrl: "", value: new Uint8Array(0) };
+}
+
+export const Any = {
+ encode(message: Any, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
+ if (message.typeUrl !== "") {
+ writer.uint32(10).string(message.typeUrl);
+ }
+ if (message.value.length !== 0) {
+ writer.uint32(18).bytes(message.value);
+ }
+ return writer;
+ },
+
+ decode(input: _m0.Reader | Uint8Array, length?: number): Any {
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseAny();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1:
+ if (tag !== 10) {
+ break;
+ }
+
+ message.typeUrl = reader.string();
+ continue;
+ case 2:
+ if (tag !== 18) {
+ break;
+ }
+
+ message.value = reader.bytes();
+ continue;
+ }
+ if ((tag & 7) === 4 || tag === 0) {
+ break;
+ }
+ reader.skipType(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(object: any): Any {
+ return {
+ typeUrl: isSet(object.typeUrl) ? globalThis.String(object.typeUrl) : "",
+ value: isSet(object.value) ? bytesFromBase64(object.value) : new Uint8Array(0),
+ };
+ },
+
+ toJSON(message: Any): unknown {
+ const obj: any = {};
+ if (message.typeUrl !== "") {
+ obj.typeUrl = message.typeUrl;
+ }
+ if (message.value.length !== 0) {
+ obj.value = base64FromBytes(message.value);
+ }
+ return obj;
+ },
+
+ create(base?: DeepPartial<Any>): Any {
+ return Any.fromPartial(base ?? {});
+ },
+ fromPartial(object: DeepPartial<Any>): Any {
+ const message = createBaseAny();
+ message.typeUrl = object.typeUrl ?? "";
+ message.value = object.value ?? new Uint8Array(0);
+ return message;
+ },
+};
+
+function bytesFromBase64(b64: string): Uint8Array {
+ if (globalThis.Buffer) {
+ return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
+ } else {
+ const bin = globalThis.atob(b64);
+ const arr = new Uint8Array(bin.length);
+ for (let i = 0; i < bin.length; ++i) {
+ arr[i] = bin.charCodeAt(i);
+ }
+ return arr;
+ }
+}
+
+function base64FromBytes(arr: Uint8Array): string {
+ if (globalThis.Buffer) {
+ return globalThis.Buffer.from(arr).toString("base64");
+ } else {
+ const bin: string[] = [];
+ arr.forEach((byte) => {
+ bin.push(globalThis.String.fromCharCode(byte));
+ });
+ return globalThis.btoa(bin.join(""));
+ }
+}
+
+type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
+
+export type DeepPartial<T> = T extends Builtin ? T
+ : T extends Long ? string | number | Long : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
+ : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
+ : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
+ : Partial<T>;
+
+if (_m0.util.Long !== Long) {
+ _m0.util.Long = Long as any;
+ _m0.configure();
+}
+
+function isSet(value: any): boolean {
+ return value !== null && value !== undefined;
+}
diff --git a/frontend/src/types/proto/google/rpc/status.ts b/frontend/src/types/proto/google/rpc/status.ts
new file mode 100644
index 0000000000..3c7d462894
--- /dev/null
+++ b/frontend/src/types/proto/google/rpc/status.ts
@@ -0,0 +1,141 @@
+/* eslint-disable */
+import Long from "long";
+import _m0 from "protobufjs/minimal";
+import { Any } from "../protobuf/any";
+
+export const protobufPackage = "google.rpc";
+
+/**
+ * The `Status` type defines a logical error model that is suitable for
+ * different programming environments, including REST APIs and RPC APIs. It is
+ * used by [gRPC](https://github.com/grpc). Each `Status` message contains
+ * three pieces of data: error code, error message, and error details.
+ *
+ * You can find out more about this error model and how to work with it in the
+ * [API Design Guide](https://cloud.google.com/apis/design/errors).
+ */
+export interface Status {
+ /**
+ * The status code, which should be an enum value of
+ * [google.rpc.Code][google.rpc.Code].
+ */
+ code: number;
+ /**
+ * A developer-facing error message, which should be in English. Any
+ * user-facing error message should be localized and sent in the
+ * [google.rpc.Status.details][google.rpc.Status.details] field, or localized
+ * by the client.
+ */
+ message: string;
+ /**
+ * A list of messages that carry the error details. There is a common set of
+ * message types for APIs to use.
+ */
+ details: Any[];
+}
+
+function createBaseStatus(): Status {
+ return { code: 0, message: "", details: [] };
+}
+
+export const Status = {
+ encode(message: Status, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
+ if (message.code !== 0) {
+ writer.uint32(8).int32(message.code);
+ }
+ if (message.message !== "") {
+ writer.uint32(18).string(message.message);
+ }
+ for (const v of message.details) {
+ Any.encode(v!, writer.uint32(26).fork()).ldelim();
+ }
+ return writer;
+ },
+
+ decode(input: _m0.Reader | Uint8Array, length?: number): Status {
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseStatus();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1:
+ if (tag !== 8) {
+ break;
+ }
+
+ message.code = reader.int32();
+ continue;
+ case 2:
+ if (tag !== 18) {
+ break;
+ }
+
+ message.message = reader.string();
+ continue;
+ case 3:
+ if (tag !== 26) {
+ break;
+ }
+
+ message.details.push(Any.decode(reader, reader.uint32()));
+ continue;
+ }
+ if ((tag & 7) === 4 || tag === 0) {
+ break;
+ }
+ reader.skipType(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(object: any): Status {
+ return {
+ code: isSet(object.code) ? globalThis.Number(object.code) : 0,
+ message: isSet(object.message) ? globalThis.String(object.message) : "",
+ details: globalThis.Array.isArray(object?.details) ? object.details.map((e: any) => Any.fromJSON(e)) : [],
+ };
+ },
+
+ toJSON(message: Status): unknown {
+ const obj: any = {};
+ if (message.code !== 0) {
+ obj.code = Math.round(message.code);
+ }
+ if (message.message !== "") {
+ obj.message = message.message;
+ }
+ if (message.details?.length) {
+ obj.details = message.details.map((e) => Any.toJSON(e));
+ }
+ return obj;
+ },
+
+ create(base?: DeepPartial<Status>): Status {
+ return Status.fromPartial(base ?? {});
+ },
+ fromPartial(object: DeepPartial<Status>): Status {
+ const message = createBaseStatus();
+ message.code = object.code ?? 0;
+ message.message = object.message ?? "";
+ message.details = object.details?.map((e) => Any.fromPartial(e)) || [];
+ return message;
+ },
+};
+
+type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
+
+export type DeepPartial<T> = T extends Builtin ? T
+ : T extends Long ? string | number | Long : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>
+ : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
+ : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
+ : Partial<T>;
+
+if (_m0.util.Long !== Long) {
+ _m0.util.Long = Long as any;
+ _m0.configure();
+}
+
+function isSet(value: any): boolean {
+ return value !== null && value !== undefined;
+}
diff --git a/frontend/src/types/proto/store/audit_log.ts b/frontend/src/types/proto/store/audit_log.ts
index 337108af6b..d945727167 100644
--- a/frontend/src/types/proto/store/audit_log.ts
+++ b/frontend/src/types/proto/store/audit_log.ts
@@ -1,6 +1,7 @@
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal";
+import { Status } from "../google/rpc/status";
export const protobufPackage = "bytebase.store";
@@ -22,6 +23,7 @@ export interface AuditLog {
* Some fields are omitted because they are too large or contain sensitive information.
*/
response: string;
+ status: Status | undefined;
}
export enum AuditLog_Severity {
@@ -100,7 +102,7 @@ export function auditLog_SeverityToJSON(object: AuditLog_Severity): string {
}
function createBaseAuditLog(): AuditLog {
- return { method: "", resource: "", user: "", severity: 0, request: "", response: "" };
+ return { method: "", resource: "", user: "", severity: 0, request: "", response: "", status: undefined };
}
export const AuditLog = {
@@ -123,6 +125,9 @@ export const AuditLog = {
if (message.response !== "") {
writer.uint32(50).string(message.response);
}
+ if (message.status !== undefined) {
+ Status.encode(message.status, writer.uint32(58).fork()).ldelim();
+ }
return writer;
},
@@ -175,6 +180,13 @@ export const AuditLog = {
message.response = reader.string();
continue;
+ case 7:
+ if (tag !== 58) {
+ break;
+ }
+
+ message.status = Status.decode(reader, reader.uint32());
+ continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
@@ -192,6 +204,7 @@ export const AuditLog = {
severity: isSet(object.severity) ? auditLog_SeverityFromJSON(object.severity) : 0,
request: isSet(object.request) ? globalThis.String(object.request) : "",
response: isSet(object.response) ? globalThis.String(object.response) : "",
+ status: isSet(object.status) ? Status.fromJSON(object.status) : undefined,
};
},
@@ -215,6 +228,9 @@ export const AuditLog = {
if (message.response !== "") {
obj.response = message.response;
}
+ if (message.status !== undefined) {
+ obj.status = Status.toJSON(message.status);
+ }
return obj;
},
@@ -229,6 +245,9 @@ export const AuditLog = {
message.severity = object.severity ?? 0;
message.request = object.request ?? "";
message.response = object.response ?? "";
+ message.status = (object.status !== undefined && object.status !== null)
+ ? Status.fromPartial(object.status)
+ : undefined;
return message;
},
};
diff --git a/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.md
index d2c2811893..3d4b8cf36f 100644
--- a/proto/gen/grpc-doc/store/README.md
+++ b/proto/gen/grpc-doc/store/README.md
@@ -619,6 +619,7 @@ convert to the expected struct there.
| severity | [AuditLog.Severity](#bytebase-store-AuditLog-Severity) | | |
| request | [string](#string) | | Marshalled request. |
| response | [string](#string) | | Marshalled response. Some fields are omitted because they are too large or contain sensitive information. |
+| status | [google.rpc.Status](#google-rpc-Status) | | |
diff --git a/proto/gen/grpc-doc/store/index.html b/proto/gen/grpc-doc/store/index.html
index 744597b3c4..74dab13964 100644
--- a/proto/gen/grpc-doc/store/index.html
+++ b/proto/gen/grpc-doc/store/index.html
@@ -1920,6 +1920,13 @@ projects/{project} </p></td>
Some fields are omitted because they are too large or contain sensitive information. </p></td>
</tr>
+ <tr>
+ <td>status</td>
+ <td><a href="#google.rpc.Status">google.rpc.Status</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
</tbody>
</table>
diff --git a/proto/generated-go/store/audit_log.pb.go b/proto/generated-go/store/audit_log.pb.go
index 0f90864b9e..8dba9c80bd 100644
--- a/proto/generated-go/store/audit_log.pb.go
+++ b/proto/generated-go/store/audit_log.pb.go
@@ -7,6 +7,7 @@
package store
import (
+ status "google.golang.org/genproto/googleapis/rpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
@@ -104,7 +105,8 @@ type AuditLog struct {
Request string `protobuf:"bytes,5,opt,name=request,proto3" json:"request,omitempty"`
// Marshalled response.
// Some fields are omitted because they are too large or contain sensitive information.
- Response string `protobuf:"bytes,6,opt,name=response,proto3" json:"response,omitempty"`
+ Response string `protobuf:"bytes,6,opt,name=response,proto3" json:"response,omitempty"`
+ Status *status.Status `protobuf:"bytes,7,opt,name=status,proto3" json:"status,omitempty"`
}
func (x *AuditLog) Reset() {
@@ -181,34 +183,45 @@ func (x *AuditLog) GetResponse() string {
return ""
}
+func (x *AuditLog) GetStatus() *status.Status {
+ if x != nil {
+ return x.Status
+ }
+ return nil
+}
+
var File_store_audit_log_proto protoreflect.FileDescriptor
var file_store_audit_log_proto_rawDesc = []byte{
0x0a, 0x15, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x61, 0x75, 0x64, 0x69, 0x74, 0x5f, 0x6c, 0x6f,
0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73,
- 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x22, 0xc1, 0x02, 0x0a, 0x08, 0x41, 0x75, 0x64, 0x69,
- 0x74, 0x4c, 0x6f, 0x67, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01,
- 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x1a, 0x0a, 0x08,
- 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
- 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72,
- 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x3d, 0x0a, 0x08,
- 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x21,
- 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e,
- 0x41, 0x75, 0x64, 0x69, 0x74, 0x4c, 0x6f, 0x67, 0x2e, 0x53, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74,
- 0x79, 0x52, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x72,
- 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x65,
- 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
- 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
- 0x65, 0x22, 0x78, 0x0a, 0x08, 0x53, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x12, 0x0b, 0x0a,
- 0x07, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x44, 0x45,
- 0x42, 0x55, 0x47, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x4e, 0x46, 0x4f, 0x10, 0x02, 0x12,
- 0x0a, 0x0a, 0x06, 0x4e, 0x4f, 0x54, 0x49, 0x43, 0x45, 0x10, 0x03, 0x12, 0x0b, 0x0a, 0x07, 0x57,
- 0x41, 0x52, 0x4e, 0x49, 0x4e, 0x47, 0x10, 0x04, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x52, 0x52, 0x4f,
- 0x52, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x43, 0x52, 0x49, 0x54, 0x49, 0x43, 0x41, 0x4c, 0x10,
- 0x06, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x4c, 0x45, 0x52, 0x54, 0x10, 0x07, 0x12, 0x0d, 0x0a, 0x09,
- 0x45, 0x4d, 0x45, 0x52, 0x47, 0x45, 0x4e, 0x43, 0x59, 0x10, 0x08, 0x42, 0x14, 0x5a, 0x12, 0x67,
- 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f, 0x2f, 0x73, 0x74, 0x6f, 0x72,
- 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+ 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x1a, 0x17, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f,
+ 0x72, 0x70, 0x63, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
+ 0x22, 0xed, 0x02, 0x0a, 0x08, 0x41, 0x75, 0x64, 0x69, 0x74, 0x4c, 0x6f, 0x67, 0x12, 0x16, 0x0a,
+ 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d,
+ 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63,
+ 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63,
+ 0x65, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x73, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
+ 0x04, 0x75, 0x73, 0x65, 0x72, 0x12, 0x3d, 0x0a, 0x08, 0x73, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74,
+ 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x21, 0x2e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61,
+ 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x41, 0x75, 0x64, 0x69, 0x74, 0x4c, 0x6f,
+ 0x67, 0x2e, 0x53, 0x65, 0x76, 0x65, 0x72, 0x69, 0x74, 0x79, 0x52, 0x08, 0x73, 0x65, 0x76, 0x65,
+ 0x72, 0x69, 0x74, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18,
+ 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a,
+ 0x0a, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09,
+ 0x52, 0x08, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x06, 0x73, 0x74,
+ 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x67, 0x6f, 0x6f,
+ 0x67, 0x6c, 0x65, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06,
+ 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x78, 0x0a, 0x08, 0x53, 0x65, 0x76, 0x65, 0x72, 0x69,
+ 0x74, 0x79, 0x12, 0x0b, 0x0a, 0x07, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x10, 0x00, 0x12,
+ 0x09, 0x0a, 0x05, 0x44, 0x45, 0x42, 0x55, 0x47, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x49, 0x4e,
+ 0x46, 0x4f, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06, 0x4e, 0x4f, 0x54, 0x49, 0x43, 0x45, 0x10, 0x03,
+ 0x12, 0x0b, 0x0a, 0x07, 0x57, 0x41, 0x52, 0x4e, 0x49, 0x4e, 0x47, 0x10, 0x04, 0x12, 0x09, 0x0a,
+ 0x05, 0x45, 0x52, 0x52, 0x4f, 0x52, 0x10, 0x05, 0x12, 0x0c, 0x0a, 0x08, 0x43, 0x52, 0x49, 0x54,
+ 0x49, 0x43, 0x41, 0x4c, 0x10, 0x06, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x4c, 0x45, 0x52, 0x54, 0x10,
+ 0x07, 0x12, 0x0d, 0x0a, 0x09, 0x45, 0x4d, 0x45, 0x52, 0x47, 0x45, 0x4e, 0x43, 0x59, 0x10, 0x08,
+ 0x42, 0x14, 0x5a, 0x12, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f,
+ 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -228,14 +241,16 @@ var file_store_audit_log_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
var file_store_audit_log_proto_goTypes = []interface{}{
(AuditLog_Severity)(0), // 0: bytebase.store.AuditLog.Severity
(*AuditLog)(nil), // 1: bytebase.store.AuditLog
+ (*status.Status)(nil), // 2: google.rpc.Status
}
var file_store_audit_log_proto_depIdxs = []int32{
0, // 0: bytebase.store.AuditLog.severity:type_name -> bytebase.store.AuditLog.Severity
- 1, // [1:1] is the sub-list for method output_type
- 1, // [1:1] is the sub-list for method input_type
- 1, // [1:1] is the sub-list for extension type_name
- 1, // [1:1] is the sub-list for extension extendee
- 0, // [0:1] is the sub-list for field type_name
+ 2, // 1: bytebase.store.AuditLog.status:type_name -> google.rpc.Status
+ 2, // [2:2] is the sub-list for method output_type
+ 2, // [2:2] is the sub-list for method input_type
+ 2, // [2:2] is the sub-list for extension type_name
+ 2, // [2:2] is the sub-list for extension extendee
+ 0, // [0:2] is the sub-list for field type_name
}
func init() { file_store_audit_log_proto_init() }
diff --git a/proto/store/audit_log.proto b/proto/store/audit_log.proto
index d60fb6dccd..60726e79ae 100644
--- a/proto/store/audit_log.proto
+++ b/proto/store/audit_log.proto
@@ -2,6 +2,8 @@ syntax = "proto3";
package bytebase.store;
+import "google/rpc/status.proto";
+
option go_package = "generated-go/store";
message AuditLog {
@@ -24,6 +26,8 @@ message AuditLog {
// Some fields are omitted because they are too large or contain sensitive information.
string response = 6;
+ google.rpc.Status status = 7;
+
enum Severity {
DEFAULT = 0;
DEBUG = 1;