From 278ad2534bf1c38c934b837b2f5551d7d086cd19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Parada?= Date: Thu, 10 Oct 2024 12:45:26 -0300 Subject: [PATCH] feat: add support for auth digest in http_loader and added cloudflare schema (#110) --- schema.go | 76 ++++++++++++++++++++++++++++++++++++++------ service_port.go | 1 + service_port_test.go | 3 ++ 3 files changed, 71 insertions(+), 9 deletions(-) diff --git a/schema.go b/schema.go index 366c2f0..7816133 100644 --- a/schema.go +++ b/schema.go @@ -111,7 +111,7 @@ func (s Schema) findSections(kind SectionKind) ([]SchemaSection, bool) { func (s *Schema) InjectLTSPlugins() { s.Inputs = append(s.Inputs, SchemaSection{ - // See https://github.com/chronosphereio/calyptia-core-fluent-bit-s3-replay + // See https://github.com/chronosphereio/calyptia-core-fluent-bit/tree/main/goplugins/go-s3-replay-plugin Type: "input", Name: "go-s3-replay-plugin", Description: "Calyptia LTS advanced plugin providing logs replay from s3", @@ -147,12 +147,12 @@ func (s *Schema) InjectLTSPlugins() { }, }, }, SchemaSection{ - // See https://github.com/chronosphereio/calyptia-core-fluent-bit-dummy + // See https://github.com/chronosphereio/calyptia-core-fluent-bit/tree/main/goplugins/dummy Type: "input", Name: "gdummy", Description: "dummy GO!", }, SchemaSection{ - // See https://github.com/chronosphereio/calyptia-core-fluent-bit-gsuite-reporter + // See https://github.com/chronosphereio/calyptia-core-fluent-bit/tree/main/goplugins/gsuite-reporter Type: "input", Name: "gsuite-reporter", Description: "A Calyptia LTS advanced plugin providing activity streams from Gsuite", @@ -204,7 +204,7 @@ func (s *Schema) InjectLTSPlugins() { }, }, }, SchemaSection{ - // See https://github.com/chronosphereio/calyptia-core-fluent-bit-plugin-http-loader + // See https://github.com/chronosphereio/calyptia-core-fluent-bit/tree/main/goplugins/http_loader Type: "input", Name: "http_loader", Description: "HTTP Loader plugin provides a way to load/dump data from a paginated HTTP endpoint.", @@ -290,6 +290,16 @@ func (s *Schema) InjectLTSPlugins() { Type: "string", Description: "Cookie based authentication request body.", }, + { + Name: "auth_digest_username", + Type: "string", + Description: "Username for HTTP Digest authentication.", + }, + { + Name: "auth_digest_password", + Type: "string", + Description: "Password for HTTP Digest authentication.", + }, { Name: "wait", Type: "string", @@ -387,7 +397,7 @@ func (s *Schema) InjectLTSPlugins() { }, }, }, SchemaSection{ - // See https://github.com/chronosphereio/calyptia-core-fluent-bit-azure-event-grid + // See https://github.com/chronosphereio/calyptia-core-fluent-bit/tree/main/goplugins/azeventgrid Type: "input", Name: "azeventgrid", Description: "A Calyptia Core fluent-bit plugin providing input from Azure Event Grid.", @@ -416,7 +426,7 @@ func (s *Schema) InjectLTSPlugins() { }, }, }, SchemaSection{ - // See https://github.com/chronosphereio/calyptia-core-fluent-bit-aws-kinesis-stream-input + // See https://github.com/chronosphereio/calyptia-core-fluent-bit/tree/main/goplugins/aws_kinesis_stream Type: "input", Name: "aws_kinesis_stream", Description: "AWS Kinesis stream input plugin.", @@ -486,7 +496,7 @@ func (s *Schema) InjectLTSPlugins() { }, }, }, SchemaSection{ - // See https://github.com/chronosphereio/calyptia-core-fluent-bit-plugin-input-s3-sqs + // See https://github.com/chronosphereio/calyptia-core-fluent-bit/tree/main/goplugins/s3_sqs Type: "input", Name: "s3_sqs", Description: "Calyptia LTS advanced plugin providing logs replay from sqs events", @@ -598,7 +608,7 @@ func (s *Schema) InjectLTSPlugins() { }, }, }, SchemaSection{ - // See https://github.com/chronosphereio/calyptia-core-fluent-bit-plugin-datagen + // See https://github.com/chronosphereio/calyptia-core-fluent-bit/tree/main/goplugins/datagen Type: "input", Name: "datagen", Description: "Datagen input plugin generates fake logs at a given interval", @@ -618,7 +628,7 @@ func (s *Schema) InjectLTSPlugins() { }, }, }, SchemaSection{ - // See https://github.com/chronosphereio/calyptia-core-fluent-bit-plugin-sqldb + // See https://github.com/chronosphereio/calyptia-core-fluent-bit/tree/main/goplugins/sqldb Type: "input", Name: "sqldb", Description: "SQL Database input", @@ -676,5 +686,53 @@ func (s *Schema) InjectLTSPlugins() { }, }, }, + }, SchemaSection{ + // See https://github.com/chronosphereio/calyptia-core-fluent-bit/tree/main/goplugins/cloudflare + Type: "input", + Name: "cloudflare", + Description: "HTTP server input for cloudflare with chunked transfer encoding support", + Properties: SchemaProperties{ + Options: []SchemaOptions{ + { + Name: "addr", + Type: "string", + Description: "Address to listen on.", + Default: ":9880", + }, + { + Name: "resp_headers", + Type: "string", + Description: "Response headers to set, separated by new line. Supports templating.", + Default: "Content-Type: application/json", + }, + { + Name: "resp_status_code", + Type: "string", + Description: "Response status code to set. Supports templating. Should evaluate to an integer.", + Default: "200", + }, + { + Name: "resp_body", + Type: "string", + Description: "Response body to set. Supports templating.", + Default: "{\"status\": \"ok\"}", + }, + { + Name: "time_from", + Type: "string", + Description: "Optional time to set. Supports templating with record access. Should evaluate to a RFC3339 formatted string. Defaults to current time.", + }, + { + Name: "cert_file", + Type: "string", + Description: "Path to the certificate file to enable TLS.", + }, + { + Name: "key_file", + Type: "string", + Description: "Path to the key file to enable TLS.", + }, + }, + }, }) } diff --git a/service_port.go b/service_port.go index 53811ce..3d9a745 100644 --- a/service_port.go +++ b/service_port.go @@ -19,6 +19,7 @@ var servicePortDefaultsByPlugin = map[string]servicePortDefaults{ "syslog": {Port: 5140, Protocol: networking.ProtocolUDP}, // only if `mode` is not `unix_udp` (default) or `unix_tcp` "tcp": {Port: 5170, Protocol: networking.ProtocolTCP}, "udp": {Port: 5170, Protocol: networking.ProtocolUDP}, + "cloudflare": {Port: 9880, Protocol: networking.ProtocolTCP}, // Outputs. "prometheus_exporter": {Port: 2021, Protocol: networking.ProtocolTCP}, diff --git a/service_port_test.go b/service_port_test.go index cfb2724..a2489cb 100644 --- a/service_port_test.go +++ b/service_port_test.go @@ -34,6 +34,8 @@ func TestConfig_ServicePorts(t *testing.T) { name tcp [INPUT] name udp + [INPUT] + name cloudflare [OUTPUT] name prometheus_exporter `, FormatClassic) @@ -50,6 +52,7 @@ func TestConfig_ServicePorts(t *testing.T) { {Port: 5140, Protocol: networking.ProtocolUDP, Kind: SectionKindInput, Plugin: &Plugin{ID: "syslog.7", Name: "syslog"}}, {Port: 5170, Protocol: networking.ProtocolTCP, Kind: SectionKindInput, Plugin: &Plugin{ID: "tcp.8", Name: "tcp"}}, {Port: 5170, Protocol: networking.ProtocolUDP, Kind: SectionKindInput, Plugin: &Plugin{ID: "udp.9", Name: "udp"}}, + {Port: 9880, Protocol: networking.ProtocolTCP, Kind: SectionKindInput, Plugin: &Plugin{ID: "cloudflare.10", Name: "cloudflare"}}, {Port: 2021, Protocol: networking.ProtocolTCP, Kind: SectionKindOutput, Plugin: &Plugin{ID: "prometheus_exporter.0", Name: "prometheus_exporter"}}, }, config.ServicePorts()) })