Skip to content

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

feat: audit log proto and table (#11687)

p0ny068b509ea4d4
diff --git a/backend/migrator/migration/prod/2.16/0001##create_audit_log_table.sql b/backend/migrator/migration/prod/2.16/0001##create_audit_log_table.sql
new file mode 100644
index 0000000000..7e6ce2248e
--- /dev/null
+++ b/backend/migrator/migration/prod/2.16/0001##create_audit_log_table.sql
@@ -0,0 +1,15 @@
+CREATE TABLE audit_log (
+ id BIGSERIAL PRIMARY KEY,
+ created_ts BIGINT NOT NULL DEFAULT extract(epoch from now()),
+ payload JSONB NOT NULL DEFAULT '{}'
+);
+
+CREATE INDEX idx_audit_log_created_ts ON audit_log(created_ts);
+
+CREATE INDEX idx_audit_log_payload_method ON audit_log((payload->>'method'));
+
+CREATE INDEX idx_audit_log_payload_resource ON audit_log((payload->>'resource'));
+
+CREATE INDEX idx_audit_log_payload_user ON audit_log((payload->>'user'));
+
+ALTER SEQUENCE audit_log_id_seq RESTART WITH 101;
diff --git a/backend/migrator/migration/prod/LATEST.sql b/backend/migrator/migration/prod/LATEST.sql
index b15983cdef..ef4a484153 100644
--- a/backend/migrator/migration/prod/LATEST.sql
+++ b/backend/migrator/migration/prod/LATEST.sql
@@ -640,6 +640,22 @@ CREATE INDEX idx_activity_created_ts ON activity(created_ts);
ALTER SEQUENCE activity_id_seq RESTART WITH 101;
+CREATE TABLE audit_log (
+ id BIGSERIAL PRIMARY KEY,
+ created_ts BIGINT NOT NULL DEFAULT extract(epoch from now()),
+ payload JSONB NOT NULL DEFAULT '{}'
+);
+
+CREATE INDEX idx_audit_log_created_ts ON audit_log(created_ts);
+
+CREATE INDEX idx_audit_log_payload_method ON audit_log((payload->>'method'));
+
+CREATE INDEX idx_audit_log_payload_resource ON audit_log((payload->>'resource'));
+
+CREATE INDEX idx_audit_log_payload_user ON audit_log((payload->>'user'));
+
+ALTER SEQUENCE audit_log_id_seq RESTART WITH 101;
+
CREATE TABLE issue_comment (
id BIGSERIAL PRIMARY KEY,
row_status row_status NOT NULL DEFAULT 'NORMAL',
diff --git a/backend/migrator/migrator_test.go b/backend/migrator/migrator_test.go
index a10bdf6b64..2542ea4673 100644
--- a/backend/migrator/migrator_test.go
+++ b/backend/migrator/migrator_test.go
@@ -230,5 +230,5 @@ func TestMigrationCompatibility(t *testing.T) {
func TestGetCutoffVersion(t *testing.T) {
releaseVersion, err := getProdCutoffVersion()
require.NoError(t, err)
- require.Equal(t, semver.MustParse("2.16.0"), releaseVersion)
+ require.Equal(t, semver.MustParse("2.16.1"), releaseVersion)
}
diff --git a/frontend/src/types/proto/store/audit_log.ts b/frontend/src/types/proto/store/audit_log.ts
new file mode 100644
index 0000000000..337108af6b
--- /dev/null
+++ b/frontend/src/types/proto/store/audit_log.ts
@@ -0,0 +1,251 @@
+/* eslint-disable */
+import Long from "long";
+import _m0 from "protobufjs/minimal";
+
+export const protobufPackage = "bytebase.store";
+
+export interface AuditLog {
+ /** e.g. /bytebase.v1.SQLService/Query */
+ method: string;
+ /**
+ * resource name
+ * projects/{project}
+ */
+ resource: string;
+ /** Format: users/[email protected] */
+ user: string;
+ severity: AuditLog_Severity;
+ /** Marshalled request. */
+ request: string;
+ /**
+ * Marshalled response.
+ * Some fields are omitted because they are too large or contain sensitive information.
+ */
+ response: string;
+}
+
+export enum AuditLog_Severity {
+ DEFAULT = 0,
+ DEBUG = 1,
+ INFO = 2,
+ NOTICE = 3,
+ WARNING = 4,
+ ERROR = 5,
+ CRITICAL = 6,
+ ALERT = 7,
+ EMERGENCY = 8,
+ UNRECOGNIZED = -1,
+}
+
+export function auditLog_SeverityFromJSON(object: any): AuditLog_Severity {
+ switch (object) {
+ case 0:
+ case "DEFAULT":
+ return AuditLog_Severity.DEFAULT;
+ case 1:
+ case "DEBUG":
+ return AuditLog_Severity.DEBUG;
+ case 2:
+ case "INFO":
+ return AuditLog_Severity.INFO;
+ case 3:
+ case "NOTICE":
+ return AuditLog_Severity.NOTICE;
+ case 4:
+ case "WARNING":
+ return AuditLog_Severity.WARNING;
+ case 5:
+ case "ERROR":
+ return AuditLog_Severity.ERROR;
+ case 6:
+ case "CRITICAL":
+ return AuditLog_Severity.CRITICAL;
+ case 7:
+ case "ALERT":
+ return AuditLog_Severity.ALERT;
+ case 8:
+ case "EMERGENCY":
+ return AuditLog_Severity.EMERGENCY;
+ case -1:
+ case "UNRECOGNIZED":
+ default:
+ return AuditLog_Severity.UNRECOGNIZED;
+ }
+}
+
+export function auditLog_SeverityToJSON(object: AuditLog_Severity): string {
+ switch (object) {
+ case AuditLog_Severity.DEFAULT:
+ return "DEFAULT";
+ case AuditLog_Severity.DEBUG:
+ return "DEBUG";
+ case AuditLog_Severity.INFO:
+ return "INFO";
+ case AuditLog_Severity.NOTICE:
+ return "NOTICE";
+ case AuditLog_Severity.WARNING:
+ return "WARNING";
+ case AuditLog_Severity.ERROR:
+ return "ERROR";
+ case AuditLog_Severity.CRITICAL:
+ return "CRITICAL";
+ case AuditLog_Severity.ALERT:
+ return "ALERT";
+ case AuditLog_Severity.EMERGENCY:
+ return "EMERGENCY";
+ case AuditLog_Severity.UNRECOGNIZED:
+ default:
+ return "UNRECOGNIZED";
+ }
+}
+
+function createBaseAuditLog(): AuditLog {
+ return { method: "", resource: "", user: "", severity: 0, request: "", response: "" };
+}
+
+export const AuditLog = {
+ encode(message: AuditLog, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
+ if (message.method !== "") {
+ writer.uint32(10).string(message.method);
+ }
+ if (message.resource !== "") {
+ writer.uint32(18).string(message.resource);
+ }
+ if (message.user !== "") {
+ writer.uint32(26).string(message.user);
+ }
+ if (message.severity !== 0) {
+ writer.uint32(32).int32(message.severity);
+ }
+ if (message.request !== "") {
+ writer.uint32(42).string(message.request);
+ }
+ if (message.response !== "") {
+ writer.uint32(50).string(message.response);
+ }
+ return writer;
+ },
+
+ decode(input: _m0.Reader | Uint8Array, length?: number): AuditLog {
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseAuditLog();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1:
+ if (tag !== 10) {
+ break;
+ }
+
+ message.method = reader.string();
+ continue;
+ case 2:
+ if (tag !== 18) {
+ break;
+ }
+
+ message.resource = reader.string();
+ continue;
+ case 3:
+ if (tag !== 26) {
+ break;
+ }
+
+ message.user = reader.string();
+ continue;
+ case 4:
+ if (tag !== 32) {
+ break;
+ }
+
+ message.severity = reader.int32() as any;
+ continue;
+ case 5:
+ if (tag !== 42) {
+ break;
+ }
+
+ message.request = reader.string();
+ continue;
+ case 6:
+ if (tag !== 50) {
+ break;
+ }
+
+ message.response = reader.string();
+ continue;
+ }
+ if ((tag & 7) === 4 || tag === 0) {
+ break;
+ }
+ reader.skipType(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(object: any): AuditLog {
+ return {
+ method: isSet(object.method) ? globalThis.String(object.method) : "",
+ resource: isSet(object.resource) ? globalThis.String(object.resource) : "",
+ user: isSet(object.user) ? globalThis.String(object.user) : "",
+ 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) : "",
+ };
+ },
+
+ toJSON(message: AuditLog): unknown {
+ const obj: any = {};
+ if (message.method !== "") {
+ obj.method = message.method;
+ }
+ if (message.resource !== "") {
+ obj.resource = message.resource;
+ }
+ if (message.user !== "") {
+ obj.user = message.user;
+ }
+ if (message.severity !== 0) {
+ obj.severity = auditLog_SeverityToJSON(message.severity);
+ }
+ if (message.request !== "") {
+ obj.request = message.request;
+ }
+ if (message.response !== "") {
+ obj.response = message.response;
+ }
+ return obj;
+ },
+
+ create(base?: DeepPartial<AuditLog>): AuditLog {
+ return AuditLog.fromPartial(base ?? {});
+ },
+ fromPartial(object: DeepPartial<AuditLog>): AuditLog {
+ const message = createBaseAuditLog();
+ message.method = object.method ?? "";
+ message.resource = object.resource ?? "";
+ message.user = object.user ?? "";
+ message.severity = object.severity ?? 0;
+ message.request = object.request ?? "";
+ message.response = object.response ?? "";
+ 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/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.md
index cbc7a11e3b..aa3554568c 100644
--- a/proto/gen/grpc-doc/store/README.md
+++ b/proto/gen/grpc-doc/store/README.md
@@ -29,6 +29,11 @@
- [ActivityIssueCommentCreatePayload.ExternalApprovalEvent.Action](#bytebase-store-ActivityIssueCommentCreatePayload-ExternalApprovalEvent-Action)
- [ActivityIssueCommentCreatePayload.ExternalApprovalEvent.Type](#bytebase-store-ActivityIssueCommentCreatePayload-ExternalApprovalEvent-Type)
+- [store/audit_log.proto](#store_audit_log-proto)
+ - [AuditLog](#bytebase-store-AuditLog)
+
+ - [AuditLog.Severity](#bytebase-store-AuditLog-Severity)
+
- [store/database.proto](#store_database-proto)
- [ColumnConfig](#bytebase-store-ColumnConfig)
- [ColumnConfig.LabelsEntry](#bytebase-store-ColumnConfig-LabelsEntry)
@@ -592,6 +597,61 @@ convert to the expected struct there.
+<a name="store_audit_log-proto"></a>
+<p align="right"><a href="#top">Top</a></p>
+
+## store/audit_log.proto
+
+
+
+<a name="bytebase-store-AuditLog"></a>
+
+### AuditLog
+
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| method | [string](#string) | | e.g. /bytebase.v1.SQLService/Query |
+| resource | [string](#string) | | resource name projects/{project} |
+| user | [string](#string) | | Format: users/[email protected] |
+| 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. |
+
+
+
+
+
+
+
+
+<a name="bytebase-store-AuditLog-Severity"></a>
+
+### AuditLog.Severity
+
+
+| Name | Number | Description |
+| ---- | ------ | ----------- |
+| DEFAULT | 0 | |
+| DEBUG | 1 | |
+| INFO | 2 | |
+| NOTICE | 3 | |
+| WARNING | 4 | |
+| ERROR | 5 | |
+| CRITICAL | 6 | |
+| ALERT | 7 | |
+| EMERGENCY | 8 | |
+
+
+
+
+
+
+
+
+
+
<a name="store_database-proto"></a>
<p align="right"><a href="#top">Top</a></p>
diff --git a/proto/gen/grpc-doc/store/index.html b/proto/gen/grpc-doc/store/index.html
index 7757d56f4d..970058263c 100644
--- a/proto/gen/grpc-doc/store/index.html
+++ b/proto/gen/grpc-doc/store/index.html
@@ -276,6 +276,25 @@
</li>
+ <li>
+ <a href="#store%2faudit_log.proto">store/audit_log.proto</a>
+ <ul>
+
+ <li>
+ <a href="#bytebase.store.AuditLog"><span class="badge">M</span>AuditLog</a>
+ </li>
+
+
+ <li>
+ <a href="#bytebase.store.AuditLog.Severity"><span class="badge">E</span>AuditLog.Severity</a>
+ </li>
+
+
+
+ </ul>
+ </li>
+
+
<li>
<a href="#store%2fdatabase.proto">store/database.proto</a>
<ul>
@@ -1837,6 +1856,146 @@ If `true`, other fields are available. </p></td>
+ <div class="file-heading">
+ <h2 id="store/audit_log.proto">store/audit_log.proto</h2><a href="#title">Top</a>
+ </div>
+ <p></p>
+
+
+ <h3 id="bytebase.store.AuditLog">AuditLog</h3>
+ <p></p>
+
+
+ <table class="field-table">
+ <thead>
+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>method</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p>e.g. /bytebase.v1.SQLService/Query </p></td>
+ </tr>
+
+ <tr>
+ <td>resource</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p>resource name
+projects/{project} </p></td>
+ </tr>
+
+ <tr>
+ <td>user</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p>Format: users/[email protected] </p></td>
+ </tr>
+
+ <tr>
+ <td>severity</td>
+ <td><a href="#bytebase.store.AuditLog.Severity">AuditLog.Severity</a></td>
+ <td></td>
+ <td><p> </p></td>
+ </tr>
+
+ <tr>
+ <td>request</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p>Marshalled request. </p></td>
+ </tr>
+
+ <tr>
+ <td>response</td>
+ <td><a href="#string">string</a></td>
+ <td></td>
+ <td><p>Marshalled response.
+Some fields are omitted because they are too large or contain sensitive information. </p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
+
+
+ <h3 id="bytebase.store.AuditLog.Severity">AuditLog.Severity</h3>
+ <p></p>
+ <table class="enum-table">
+ <thead>
+ <tr><td>Name</td><td>Number</td><td>Description</td></tr>
+ </thead>
+ <tbody>
+
+ <tr>
+ <td>DEFAULT</td>
+ <td>0</td>
+ <td><p></p></td>
+ </tr>
+
+ <tr>
+ <td>DEBUG</td>
+ <td>1</td>
+ <td><p></p></td>
+ </tr>
+
+ <tr>
+ <td>INFO</td>
+ <td>2</td>
+ <td><p></p></td>
+ </tr>
+
+ <tr>
+ <td>NOTICE</td>
+ <td>3</td>
+ <td><p></p></td>
+ </tr>
+
+ <tr>
+ <td>WARNING</td>
+ <td>4</td>
+ <td><p></p></td>
+ </tr>
+
+ <tr>
+ <td>ERROR</td>
+ <td>5</td>
+ <td><p></p></td>
+ </tr>
+
+ <tr>
+ <td>CRITICAL</td>
+ <td>6</td>
+ <td><p></p></td>
+ </tr>
+
+ <tr>
+ <td>ALERT</td>
+ <td>7</td>
+ <td><p></p></td>
+ </tr>
+
+ <tr>
+ <td>EMERGENCY</td>
+ <td>8</td>
+ <td><p></p></td>
+ </tr>
+
+ </tbody>
+ </table>
+
+
+
+
+
+
+
<div class="file-heading">
<h2 id="store/database.proto">store/database.proto</h2><a href="#title">Top</a>
</div>
diff --git a/proto/generated-go/store/audit_log.pb.go b/proto/generated-go/store/audit_log.pb.go
new file mode 100644
index 0000000000..0f90864b9e
--- /dev/null
+++ b/proto/generated-go/store/audit_log.pb.go
@@ -0,0 +1,279 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// protoc-gen-go v1.33.0
+// protoc (unknown)
+// source: store/audit_log.proto
+
+package store
+
+import (
+ protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+ protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+ reflect "reflect"
+ sync "sync"
+)
+
+const (
+ // Verify that this generated code is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
+ // Verify that runtime/protoimpl is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
+)
+
+type AuditLog_Severity int32
+
+const (
+ AuditLog_DEFAULT AuditLog_Severity = 0
+ AuditLog_DEBUG AuditLog_Severity = 1
+ AuditLog_INFO AuditLog_Severity = 2
+ AuditLog_NOTICE AuditLog_Severity = 3
+ AuditLog_WARNING AuditLog_Severity = 4
+ AuditLog_ERROR AuditLog_Severity = 5
+ AuditLog_CRITICAL AuditLog_Severity = 6
+ AuditLog_ALERT AuditLog_Severity = 7
+ AuditLog_EMERGENCY AuditLog_Severity = 8
+)
+
+// Enum value maps for AuditLog_Severity.
+var (
+ AuditLog_Severity_name = map[int32]string{
+ 0: "DEFAULT",
+ 1: "DEBUG",
+ 2: "INFO",
+ 3: "NOTICE",
+ 4: "WARNING",
+ 5: "ERROR",
+ 6: "CRITICAL",
+ 7: "ALERT",
+ 8: "EMERGENCY",
+ }
+ AuditLog_Severity_value = map[string]int32{
+ "DEFAULT": 0,
+ "DEBUG": 1,
+ "INFO": 2,
+ "NOTICE": 3,
+ "WARNING": 4,
+ "ERROR": 5,
+ "CRITICAL": 6,
+ "ALERT": 7,
+ "EMERGENCY": 8,
+ }
+)
+
+func (x AuditLog_Severity) Enum() *AuditLog_Severity {
+ p := new(AuditLog_Severity)
+ *p = x
+ return p
+}
+
+func (x AuditLog_Severity) String() string {
+ return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
+}
+
+func (AuditLog_Severity) Descriptor() protoreflect.EnumDescriptor {
+ return file_store_audit_log_proto_enumTypes[0].Descriptor()
+}
+
+func (AuditLog_Severity) Type() protoreflect.EnumType {
+ return &file_store_audit_log_proto_enumTypes[0]
+}
+
+func (x AuditLog_Severity) Number() protoreflect.EnumNumber {
+ return protoreflect.EnumNumber(x)
+}
+
+// Deprecated: Use AuditLog_Severity.Descriptor instead.
+func (AuditLog_Severity) EnumDescriptor() ([]byte, []int) {
+ return file_store_audit_log_proto_rawDescGZIP(), []int{0, 0}
+}
+
+type AuditLog struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ // e.g. /bytebase.v1.SQLService/Query
+ Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"`
+ // resource name
+ // projects/{project}
+ Resource string `protobuf:"bytes,2,opt,name=resource,proto3" json:"resource,omitempty"`
+ // Format: users/[email protected]
+ User string `protobuf:"bytes,3,opt,name=user,proto3" json:"user,omitempty"`
+ Severity AuditLog_Severity `protobuf:"varint,4,opt,name=severity,proto3,enum=bytebase.store.AuditLog_Severity" json:"severity,omitempty"`
+ // Marshalled request.
+ 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"`
+}
+
+func (x *AuditLog) Reset() {
+ *x = AuditLog{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_store_audit_log_proto_msgTypes[0]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *AuditLog) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*AuditLog) ProtoMessage() {}
+
+func (x *AuditLog) ProtoReflect() protoreflect.Message {
+ mi := &file_store_audit_log_proto_msgTypes[0]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use AuditLog.ProtoReflect.Descriptor instead.
+func (*AuditLog) Descriptor() ([]byte, []int) {
+ return file_store_audit_log_proto_rawDescGZIP(), []int{0}
+}
+
+func (x *AuditLog) GetMethod() string {
+ if x != nil {
+ return x.Method
+ }
+ return ""
+}
+
+func (x *AuditLog) GetResource() string {
+ if x != nil {
+ return x.Resource
+ }
+ return ""
+}
+
+func (x *AuditLog) GetUser() string {
+ if x != nil {
+ return x.User
+ }
+ return ""
+}
+
+func (x *AuditLog) GetSeverity() AuditLog_Severity {
+ if x != nil {
+ return x.Severity
+ }
+ return AuditLog_DEFAULT
+}
+
+func (x *AuditLog) GetRequest() string {
+ if x != nil {
+ return x.Request
+ }
+ return ""
+}
+
+func (x *AuditLog) GetResponse() string {
+ if x != nil {
+ return x.Response
+ }
+ return ""
+}
+
+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,
+}
+
+var (
+ file_store_audit_log_proto_rawDescOnce sync.Once
+ file_store_audit_log_proto_rawDescData = file_store_audit_log_proto_rawDesc
+)
+
+func file_store_audit_log_proto_rawDescGZIP() []byte {
+ file_store_audit_log_proto_rawDescOnce.Do(func() {
+ file_store_audit_log_proto_rawDescData = protoimpl.X.CompressGZIP(file_store_audit_log_proto_rawDescData)
+ })
+ return file_store_audit_log_proto_rawDescData
+}
+
+var file_store_audit_log_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
+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
+}
+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
+}
+
+func init() { file_store_audit_log_proto_init() }
+func file_store_audit_log_proto_init() {
+ if File_store_audit_log_proto != nil {
+ return
+ }
+ if !protoimpl.UnsafeEnabled {
+ file_store_audit_log_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*AuditLog); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ }
+ type x struct{}
+ out := protoimpl.TypeBuilder{
+ File: protoimpl.DescBuilder{
+ GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+ RawDescriptor: file_store_audit_log_proto_rawDesc,
+ NumEnums: 1,
+ NumMessages: 1,
+ NumExtensions: 0,
+ NumServices: 0,
+ },
+ GoTypes: file_store_audit_log_proto_goTypes,
+ DependencyIndexes: file_store_audit_log_proto_depIdxs,
+ EnumInfos: file_store_audit_log_proto_enumTypes,
+ MessageInfos: file_store_audit_log_proto_msgTypes,
+ }.Build()
+ File_store_audit_log_proto = out.File
+ file_store_audit_log_proto_rawDesc = nil
+ file_store_audit_log_proto_goTypes = nil
+ file_store_audit_log_proto_depIdxs = nil
+}
diff --git a/proto/store/audit_log.proto b/proto/store/audit_log.proto
new file mode 100644
index 0000000000..d60fb6dccd
--- /dev/null
+++ b/proto/store/audit_log.proto
@@ -0,0 +1,38 @@
+syntax = "proto3";
+
+package bytebase.store;
+
+option go_package = "generated-go/store";
+
+message AuditLog {
+ // e.g. /bytebase.v1.SQLService/Query
+ string method = 1;
+
+ // resource name
+ // projects/{project}
+ string resource = 2;
+
+ // Format: users/[email protected]
+ string user = 3;
+
+ Severity severity = 4;
+
+ // Marshalled request.
+ string request = 5;
+
+ // Marshalled response.
+ // Some fields are omitted because they are too large or contain sensitive information.
+ string response = 6;
+
+ enum Severity {
+ DEFAULT = 0;
+ DEBUG = 1;
+ INFO = 2;
+ NOTICE = 3;
+ WARNING = 4;
+ ERROR = 5;
+ CRITICAL = 6;
+ ALERT = 7;
+ EMERGENCY = 8;
+ }
+}