Skip to content

Commit

Permalink
Merge pull request #27 from Traceableai/adding-proto-go-mod
Browse files Browse the repository at this point in the history
  • Loading branch information
varkey98 authored Jul 19, 2024
2 parents f3ea941 + 1a8aa36 commit 6a2d87d
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gen/go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.19
require (
github.com/ghodss/yaml v1.0.0
github.com/stretchr/testify v1.9.0
google.golang.org/protobuf v1.34.1
google.golang.org/protobuf v1.34.2
)

require (
Expand Down
4 changes: 2 additions & 2 deletions gen/go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
Expand Down
183 changes: 183 additions & 0 deletions gen/go/proto/v1/config.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
syntax = "proto3";

package ai.traceable.agent.config.v1;

import "google/protobuf/wrappers.proto";

option go_package = "github.com/Traceableai/agent-config/gen/go/v1";

message AgentConfig {
Opa opa = 1 [deprecated = true];
BlockingConfig blocking_config = 2;
google.protobuf.BoolValue debug_log = 3 [deprecated = true];
RemoteConfig remote_config = 4;
ApiDiscoveryConfig api_discovery = 5 [deprecated = true];
SamplingConfig sampling = 6;
// javaagent has the configs specific to javaagent
Javaagent javaagent = 7;
LogConfig logging = 8;
MetricsConfig metrics_config = 9;
// represents the environment name of agent
google.protobuf.StringValue environment = 10;
}

// Opa covers the options related to the mechanics for getting Open Policy Agent configuration file.
// The client should use secure and token option from reporting settings.
message Opa {
// when `true` Open Policy Agent evaluation is enabled to block request
google.protobuf.BoolValue enabled = 1;

// endpoint represents the endpoint for polling OPA config file e.g. http://opa.traceableai:8181/
google.protobuf.StringValue endpoint = 2;

// poll period in seconds to query OPA service
google.protobuf.Int32Value poll_period_seconds = 3;

// Certificate filename containing the CA to verify the server's certificate.
// If this is non-empty, you shoulds `https` for the protocol in `endpoint` above.
google.protobuf.StringValue cert_file = 4;
// set this flag to use https connection when the provided certificate path is empty
google.protobuf.BoolValue use_secure_connection = 5;
}

// Blocking config
message BlockingConfig {
google.protobuf.BoolValue enabled = 1;
// debug_log has moved to top level
google.protobuf.BoolValue debug_log = 2 [deprecated = true];
ModsecurityConfig modsecurity = 3;
google.protobuf.BoolValue evaluate_body = 4;
RegionBlockingConfig region_blocking = 5;
// remote_config has moved to top level
RemoteConfig remote_config = 6 [deprecated = true];

// when `true`, blocking evaluation will be skipped for internal requests i.e. requests coming
// from private IPs
google.protobuf.BoolValue skip_internal_request = 7;

// Allows user to set a custom blocking status code value
google.protobuf.Int32Value response_status_code = 8;

// setting a maximum allowed depth for recursion while parsing combination policies
google.protobuf.Int32Value max_recursion_depth = 9;

// Allows user to set a custom blocking message
google.protobuf.StringValue response_message = 10;
}

message ModsecurityConfig {
google.protobuf.BoolValue enabled = 1;
}

message RegionBlockingConfig {
google.protobuf.BoolValue enabled = 1;
}

// RemoteConfig defines the remote endpoint where the config is fetched from
message RemoteConfig {
// enabled denotes if config needs to be fetched from remote or not
google.protobuf.BoolValue enabled = 1;
// endpoint denotes the agentmanager endpoint to connect to for config. eg: localhost:5441
google.protobuf.StringValue endpoint = 2;
// poll period in seconds to query for config updates
google.protobuf.Int32Value poll_period_seconds = 3;
// Certificate filename containing the CA to verify the server's certificate.
google.protobuf.StringValue cert_file = 4;
google.protobuf.Int32Value grpc_max_call_recv_msg_size = 5;
// set this flag to use https connection when the provided certificate path is empty
google.protobuf.BoolValue use_secure_connection = 6;
}

message ApiDiscoveryConfig {
google.protobuf.BoolValue enabled = 1;
}

message SamplingConfig {
google.protobuf.BoolValue enabled = 1;
RateLimitConfig default_rate_limit_config = 2;
}

message Javaagent {
// set this flag to export certificates configured in JKS to libtraceable for making HTTPS connection to TPA.
google.protobuf.BoolValue import_jks_certs = 1;
}

enum LogMode {
LOG_MODE_UNSPECIFIED = 0;
LOG_MODE_NONE = 1;
LOG_MODE_STDOUT = 2;
LOG_MODE_FILE = 3;
}

enum LogLevel {
LOG_LEVEL_UNSPECIFIED = 0;
LOG_LEVEL_TRACE = 1;
LOG_LEVEL_DEBUG = 2;
LOG_LEVEL_INFO = 3;
LOG_LEVEL_WARN = 4;
LOG_LEVEL_ERROR = 5;
LOG_LEVEL_CRITICAL = 6;
}

message LogConfig {
LogMode log_mode = 1;
LogLevel log_level = 2;
// if mode is LOG_MODE_FILE, provide this additional configuration
LogFileConfig log_file = 3;
}

message LogFileConfig {
// maximum number of log files to keep
google.protobuf.Int32Value max_files = 1;
// maximum file size of the log files. Default value is 10485760 (10MB).
google.protobuf.Int32Value max_file_size = 2;
// file path for the log file. Default value is /var/traceable/log/libtraceable.log
google.protobuf.StringValue file_path = 3;
}

message MetricsLogConfig {
// set this flag to print metrics in logs
google.protobuf.BoolValue enabled = 1;
// set the frequency at which metrics should be printed. Examples are '1s', '2m', '3h'. Default value is 30m
google.protobuf.StringValue frequency = 2;
}

message EndpointMetricsConfig {
// set this flag to enable endpoint level metrics
google.protobuf.BoolValue enabled = 1;
// set the max number of endpoints to track
google.protobuf.Int32Value max_endpoints = 2;
// config for printing endpoint metrics in logs
MetricsLogConfig logging = 3;
}

message MetricsConfig {
// set this flag to enable metrics
google.protobuf.BoolValue enabled = 1;
// endpoint level configuration
EndpointMetricsConfig endpoint_config = 2;
// config for printing metrics in logs
MetricsLogConfig logging = 3;
}

enum SpanType {
SPAN_TYPE_UNSPECIFIED = 0;
SPAN_TYPE_NO_SPAN = 1;
SPAN_TYPE_BARE_SPAN = 2;
SPAN_TYPE_FULL_SPAN = 3;
}

message RateLimitConfig {
// set this flag to enable rate limiter
google.protobuf.BoolValue enabled = 1;
// total number of requests to be rate limited in a given time window
google.protobuf.Int64Value max_count_global = 2;
// number of requests per endpoint to be rate limited in a given time window
google.protobuf.Int64Value max_count_per_endpoint = 3;
// set the interval for rate limiter buckets to be reset. Examples are '1s', '2m', '3h'.
google.protobuf.StringValue refresh_period = 4;
// set the interval for rate limiter cache to be reset. Examples are '1s', '2m', '3h'.
google.protobuf.StringValue value_expiration_period = 5;
// set the span type for rate limited spans
SpanType span_type = 6;
}
2 changes: 1 addition & 1 deletion gen/go/v1/config.pb.go

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

0 comments on commit 6a2d87d

Please sign in to comment.