From d1265fdb161f0a86944a27184fb3923350c9b6d1 Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Sun, 21 Feb 2021 17:18:50 +0100 Subject: [PATCH] Squashed 'api/' changes from 27cd7f5..fe0a378 fe0a378 Add buf linting anf fix linter issues git-subtree-dir: api git-subtree-split: fe0a378cdc00040176eb05fcaaa12a175bd50f30 --- .editorconfig | 5 +-- .gitlab-ci.yml | 12 +++++++ buf.yaml | 20 +++++++++++ proto/audit/details/dns_details.proto | 43 ------------------------ proto/audit/details/http_details.proto | 33 ------------------- proto/audit/v1/dns_details.proto | 44 +++++++++++++++++++++++++ proto/audit/{ => v1}/event_entity.proto | 40 +++++++++++----------- proto/audit/v1/http_details.proto | 34 +++++++++++++++++++ proto/rpc/health.proto | 34 ------------------- proto/rpc/{ => v1}/audit.proto | 27 ++++++++------- proto/rpc/v1/health.proto | 34 +++++++++++++++++++ proto/rpc/{ => v1}/pcap.proto | 26 +++++++-------- 12 files changed, 193 insertions(+), 159 deletions(-) create mode 100644 .gitlab-ci.yml create mode 100644 buf.yaml delete mode 100644 proto/audit/details/dns_details.proto delete mode 100644 proto/audit/details/http_details.proto create mode 100644 proto/audit/v1/dns_details.proto rename proto/audit/{ => v1}/event_entity.proto (53%) create mode 100644 proto/audit/v1/http_details.proto delete mode 100644 proto/rpc/health.proto rename proto/rpc/{ => v1}/audit.proto (67%) create mode 100644 proto/rpc/v1/health.proto rename proto/rpc/{ => v1}/pcap.proto (59%) diff --git a/.editorconfig b/.editorconfig index 698c63d..ad442a8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,7 +4,8 @@ root = true end_of_line = lf insert_final_newline = true charset = utf-8 +indent_size = 2 +indent_style = space [*.proto] -indent_style = space -indent_size = 4 +indent_size = 2 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..d674fc4 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,12 @@ +image: + name: docker.io/bufbuild/buf:latest + entrypoint: [""] + +stages: + - test + +lint: + stage: test + script: + - buf ls-files + - buf lint diff --git a/buf.yaml b/buf.yaml new file mode 100644 index 0000000..1a3861e --- /dev/null +++ b/buf.yaml @@ -0,0 +1,20 @@ +# Below is not the lint and breaking configuration we recommend! +# This just just what googleapis passes. +# For lint, we recommend having the single value "DEFAULT" in "use" +# with no values in "except". +# For breaking, we recommend having the single value "FILE" in use. +# See https://docs.buf.build/lint-usage +# See https://docs.buf.build/breaking-usage +version: v1beta1 +build: + roots: + - proto +lint: + use: + - DEFAULT + except: + - PACKAGE_DIRECTORY_MATCH + allow_comment_ignores: true +breaking: + use: + - FILE diff --git a/proto/audit/details/dns_details.proto b/proto/audit/details/dns_details.proto deleted file mode 100644 index 5229643..0000000 --- a/proto/audit/details/dns_details.proto +++ /dev/null @@ -1,43 +0,0 @@ -syntax = "proto3"; - -package inetmock.audit.details; - -option csharp_namespace = "INetMock.Client.Audit.Details"; -option go_package = "gitlab.com/inetmock/inetmock/pkg/audit/details"; -option java_multiple_files = true; -option java_outer_classname = "HandlerEventProto"; -option java_package = "com.github.baez90.inetmock.audit.details"; - -enum DNSOpCode { - Query = 0; - Status = 2; - Notify = 4; - Update = 5; -} - -enum ResourceRecordType { - UnknownRR = 0; - A = 1; - NS = 2; - CNAME = 5; - SOA = 6; - PTR = 12; - HINFO = 13; - MINFO = 14; - MX = 15; - TXT = 16; - RP = 17; - AAAA = 28; - SRV = 33; - NAPTR = 35; -} - -message DNSQuestionEntity { - ResourceRecordType type = 1; - string name = 2; -} - -message DNSDetailsEntity { - DNSOpCode opcode = 1; - repeated DNSQuestionEntity questions = 2; -} diff --git a/proto/audit/details/http_details.proto b/proto/audit/details/http_details.proto deleted file mode 100644 index eef9806..0000000 --- a/proto/audit/details/http_details.proto +++ /dev/null @@ -1,33 +0,0 @@ -syntax = "proto3"; - -package inetmock.audit.details; - -option csharp_namespace = "INetMock.Client.Audit.Details"; -option go_package = "gitlab.com/inetmock/inetmock/pkg/audit/details"; -option java_multiple_files = true; -option java_outer_classname = "HandlerEventProto"; -option java_package = "com.github.baez90.inetmock.audit.details"; - -enum HTTPMethod { - GET = 0; - HEAD = 1; - POST = 2; - PUT = 3; - DELETE = 4; - CONNECT = 5; - OPTIONS = 6; - TRACE = 7; - PATCH = 8; -} - -message HTTPHeaderValue { - repeated string values = 1; -} - -message HTTPDetailsEntity { - HTTPMethod method = 1; - string host = 2; - string uri = 3; - string proto = 4; - map headers = 5; -} diff --git a/proto/audit/v1/dns_details.proto b/proto/audit/v1/dns_details.proto new file mode 100644 index 0000000..974e530 --- /dev/null +++ b/proto/audit/v1/dns_details.proto @@ -0,0 +1,44 @@ +syntax = "proto3"; + +package inetmock.audit.v1; + +option csharp_namespace = "INetMock.Client.Audit"; +option go_package = "gitlab.com/inetmock/inetmock/pkg/audit"; +option java_multiple_files = true; +option java_outer_classname = "HandlerEventProto"; +option java_package = "com.github.baez90.inetmock.audit"; + +enum DNSOpCode { + //buf:lint:ignore ENUM_ZERO_VALUE_SUFFIX + DNS_OP_CODE_QUERY = 0; + DNS_OP_CODE_STATUS = 2; + DNS_OP_CODE_NOTIFY = 4; + DNS_OP_CODE_UPDATE = 5; +} + +enum ResourceRecordType { + RESOURCE_RECORD_TYPE_UNSPECIFIED = 0; + RESOURCE_RECORD_TYPE_A = 1; + RESOURCE_RECORD_TYPE_NS = 2; + RESOURCE_RECORD_TYPE_CNAME = 5; + RESOURCE_RECORD_TYPE_SOA = 6; + RESOURCE_RECORD_TYPE_PTR = 12; + RESOURCE_RECORD_TYPE_HINFO = 13; + RESOURCE_RECORD_TYPE_MINFO = 14; + RESOURCE_RECORD_TYPE_MX = 15; + RESOURCE_RECORD_TYPE_TXT = 16; + RESOURCE_RECORD_TYPE_RP = 17; + RESOURCE_RECORD_TYPE_AAAA = 28; + RESOURCE_RECORD_TYPE_SRV = 33; + RESOURCE_RECORD_TYPE_NAPTR = 35; +} + +message DNSQuestionEntity { + ResourceRecordType type = 1; + string name = 2; +} + +message DNSDetailsEntity { + DNSOpCode opcode = 1; + repeated DNSQuestionEntity questions = 2; +} diff --git a/proto/audit/event_entity.proto b/proto/audit/v1/event_entity.proto similarity index 53% rename from proto/audit/event_entity.proto rename to proto/audit/v1/event_entity.proto index f438101..3b1047a 100644 --- a/proto/audit/event_entity.proto +++ b/proto/audit/v1/event_entity.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package inetmock.audit; +package inetmock.audit.v1; option csharp_namespace = "INetMock.Client.Audit"; option go_package = "gitlab.com/inetmock/inetmock/pkg/audit"; @@ -12,30 +12,30 @@ import "google/protobuf/any.proto"; import "google/protobuf/timestamp.proto"; enum TransportProtocol { - UNKNOWN_TRANSPORT = 0; - TCP = 1; - UDP = 2; + TRANSPORT_PROTOCOL_UNSPECIFIED = 0; + TRANSPORT_PROTOCOL_TCP = 1; + TRANSPORT_PROTOCOL_UDP = 2; } enum AppProtocol { - UNKNOWN_APPLICATION = 0; - DNS = 1; - HTTP = 2; - HTTP_PROXY = 3; + APP_PROTOCOL_UNSPECIFIED = 0; + APP_PROTOCOL_DNS = 1; + APP_PROTOCOL_HTTP = 2; + APP_PROTOCOL_HTTP_PROXY = 3; } enum TLSVersion { - SSLv30 = 0; - TLS10 = 1; - TLS11 = 2; - TLS12 = 3; - TLS13 = 4; + TLS_VERSION_UNSPECIFIED = 0; + TLS_VERSION_TLS10 = 1; + TLS_VERSION_TLS11 = 2; + TLS_VERSION_TLS12 = 3; + TLS_VERSION_TLS13 = 4; } message TLSDetailsEntity { TLSVersion version = 1; - string cipherSuite = 2; - string serverName = 3; + string cipher_suite = 2; + string server_name = 3; } message EventEntity { @@ -43,10 +43,10 @@ message EventEntity { google.protobuf.Timestamp timestamp = 2; TransportProtocol transport = 3; AppProtocol application = 4; - bytes sourceIP = 5; - bytes destinationIP = 6; - uint32 sourcePort = 7; - uint32 destinationPort = 8; + bytes source_ip = 5; + bytes destination_ip = 6; + uint32 source_port = 7; + uint32 destination_port = 8; TLSDetailsEntity tls = 9; - google.protobuf.Any protocolDetails = 10; + google.protobuf.Any protocol_details = 10; } diff --git a/proto/audit/v1/http_details.proto b/proto/audit/v1/http_details.proto new file mode 100644 index 0000000..9db4396 --- /dev/null +++ b/proto/audit/v1/http_details.proto @@ -0,0 +1,34 @@ +syntax = "proto3"; + +package inetmock.audit.v1; + +option csharp_namespace = "INetMock.Client.Audit"; +option go_package = "gitlab.com/inetmock/inetmock/pkg/audit"; +option java_multiple_files = true; +option java_outer_classname = "HandlerEventProto"; +option java_package = "com.github.baez90.inetmock.audit"; + +enum HTTPMethod { + HTTP_METHOD_UNSPECIFIED = 0; + HTTP_METHOD_GET = 1; + HTTP_METHOD_HEAD = 2; + HTTP_METHOD_POST = 3; + HTTP_METHOD_PUT = 4; + HTTP_METHOD_DELETE = 5; + HTTP_METHOD_CONNECT = 6; + HTTP_METHOD_OPTIONS = 7; + HTTP_METHOD_TRACE = 8; + HTTP_METHOD_PATCH = 9; +} + +message HTTPHeaderValue { + repeated string values = 1; +} + +message HTTPDetailsEntity { + HTTPMethod method = 1; + string host = 2; + string uri = 3; + string proto = 4; + map headers = 5; +} diff --git a/proto/rpc/health.proto b/proto/rpc/health.proto deleted file mode 100644 index 5dea669..0000000 --- a/proto/rpc/health.proto +++ /dev/null @@ -1,34 +0,0 @@ -syntax = "proto3"; - -package inetmock.rpc; - -option csharp_namespace = "INetMock.Client.Rpc"; -option go_package = "gitlab.com/inetmock/inetmock/internal/rpc"; -option java_multiple_files = true; -option java_outer_classname = "HealthProto"; -option java_package = "com.github.baez90.inetmock.rpc"; - -service Health { - rpc GetHealth(HealthRequest) returns (HealthResponse); -} - -enum HealthState { - HEALTHY = 0; - INITIALIZING = 1; - UNHEALTHY = 2; - UNKNOWN = 3; -} - -message HealthRequest { - repeated string components = 1; -} - -message ComponentHealth { - HealthState State = 1; - string message = 2; -} - -message HealthResponse { - HealthState overallHealthState = 1; - map componentsHealth = 2; -} diff --git a/proto/rpc/audit.proto b/proto/rpc/v1/audit.proto similarity index 67% rename from proto/rpc/audit.proto rename to proto/rpc/v1/audit.proto index ded0ae0..f296e77 100644 --- a/proto/rpc/audit.proto +++ b/proto/rpc/v1/audit.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package inetmock.rpc; +package inetmock.rpc.v1; option csharp_namespace = "INetMock.Client.Rpc"; option go_package = "gitlab.com/inetmock/inetmock/pkg/rpc"; @@ -8,31 +8,30 @@ option java_multiple_files = true; option java_outer_classname = "AuditProto"; option java_package = "com.github.baez90.inetmock.rpc"; -import "audit/event_entity.proto"; - -enum FileOpenMode { - TRUNCATE = 0; - APPEND = 1; -} +import "audit/v1/event_entity.proto"; message WatchEventsRequest { - string watcherName = 1; + string watcher_name = 1; +} + +message WatchEventsResponse { + inetmock.audit.v1.EventEntity entity = 1; } message RegisterFileSinkRequest { - string targetPath = 1; + string target_path = 1; } message RegisterFileSinkResponse { - string resolvedPath = 1; + string resolved_path = 1; } message RemoveFileSinkRequest { - string targetPath = 1; + string target_path = 1; } message RemoveFileSinkResponse { - bool SinkGotRemoved = 1; + bool sink_got_removed = 1; } message ListSinksRequest {} @@ -41,8 +40,8 @@ message ListSinksResponse { repeated string sinks = 1; } -service Audit { - rpc WatchEvents(WatchEventsRequest) returns (stream inetmock.audit.EventEntity); +service AuditService { + rpc WatchEvents(WatchEventsRequest) returns (stream WatchEventsResponse); rpc RegisterFileSink(RegisterFileSinkRequest) returns (RegisterFileSinkResponse); rpc RemoveFileSink(RemoveFileSinkRequest) returns (RemoveFileSinkResponse); rpc ListSinks(ListSinksRequest) returns (ListSinksResponse); diff --git a/proto/rpc/v1/health.proto b/proto/rpc/v1/health.proto new file mode 100644 index 0000000..16813a8 --- /dev/null +++ b/proto/rpc/v1/health.proto @@ -0,0 +1,34 @@ +syntax = "proto3"; + +package inetmock.rpc.v1; + +option csharp_namespace = "INetMock.Client.Rpc"; +option go_package = "gitlab.com/inetmock/inetmock/pkg/rpc"; +option java_multiple_files = true; +option java_outer_classname = "HealthProto"; +option java_package = "com.github.baez90.inetmock.rpc"; + +enum HealthState { + HEALTH_STATE_UNSPECIFIED = 0; + HEALTH_STATE_INITIALIZING = 1; + HEALTH_STATE_UNHEALTHY = 2; + HEALTH_STATE_HEALTHY = 3; +} + +message GetHealthRequest { + repeated string components = 1; +} + +message ComponentHealth { + HealthState state = 1; + string message = 2; +} + +message GetHealthResponse { + HealthState overall_health_state = 1; + map components_health = 2; +} + +service HealthService { + rpc GetHealth(GetHealthRequest) returns (GetHealthResponse); +} diff --git a/proto/rpc/pcap.proto b/proto/rpc/v1/pcap.proto similarity index 59% rename from proto/rpc/pcap.proto rename to proto/rpc/v1/pcap.proto index 3b41b5e..214d09a 100644 --- a/proto/rpc/pcap.proto +++ b/proto/rpc/v1/pcap.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package inetmock.rpc; +package inetmock.rpc.v1; option csharp_namespace = "INetMock.Client.Rpc"; option go_package = "gitlab.com/inetmock/inetmock/pkg/rpc"; @@ -17,37 +17,37 @@ message ListAvailableDevicesResponse { string name = 1; repeated bytes addresses = 2; } - repeated PCAPDevice availableDevices = 1; + repeated PCAPDevice available_devices = 1; } -message ListRecordingsRequest {} +message ListActiveRecordingsRequest {} -message ListRecordingsResponse { +message ListActiveRecordingsResponse { repeated string subscriptions = 1; } -message StartPCAPFileRecordRequest { +message StartPCAPFileRecordingRequest { string device = 1; - string targetPath = 2; + string target_path = 2; bool promiscuous = 3; - google.protobuf.Duration readTimeout = 4; + google.protobuf.Duration read_timeout = 4; } -message StartPCAPFileRecordResponse { - string resolvedPath = 1; +message StartPCAPFileRecordingResponse { + string resolved_path = 1; } message StopPCAPFileRecordRequest { - string consumerKey = 1; + string consumer_key = 1; } message StopPCAPFileRecordResponse { bool removed = 1; } -service PCAP { +service PCAPService { rpc ListAvailableDevices(ListAvailableDevicesRequest) returns (ListAvailableDevicesResponse); - rpc ListActiveRecordings(ListRecordingsRequest) returns (ListRecordingsResponse); - rpc StartPCAPFileRecording(StartPCAPFileRecordRequest) returns (StartPCAPFileRecordResponse); + rpc ListActiveRecordings(ListActiveRecordingsRequest) returns (ListActiveRecordingsResponse); + rpc StartPCAPFileRecording(StartPCAPFileRecordingRequest) returns (StartPCAPFileRecordingResponse); rpc StopPCAPFileRecord(StopPCAPFileRecordRequest) returns (StopPCAPFileRecordResponse); }