From 3f3b07eefd16eda24f53500d921b113ae27b79e0 Mon Sep 17 00:00:00 2001 From: Pavlos Rontidis Date: Tue, 10 Sep 2024 18:23:55 -0400 Subject: [PATCH] chore(deps): update to latest VRL sha (#21259) * chore(deps): update chrono-tz to v0.10 * update Filter trait implementation --- Cargo.lock | 12 ++++---- Cargo.toml | 5 ++-- lib/vector-common/Cargo.toml | 2 +- lib/vector-config/Cargo.toml | 2 +- lib/vector-core/Cargo.toml | 3 +- lib/vector-vrl/tests/Cargo.toml | 2 +- src/conditions/datadog_search.rs | 47 ++++++++++++++++++++------------ 7 files changed, 43 insertions(+), 30 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2d225c263bf80..863cfc6c54041 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1968,9 +1968,9 @@ dependencies = [ [[package]] name = "chrono-tz" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93698b29de5e97ad0ae26447b344c482a7284c737d9ddc5f9e52b74a336671bb" +checksum = "cd6dd8046d00723a59a2f8c5f295c515b9bb9a331ee4f8f3d4dd49e428acd3b6" dependencies = [ "chrono", "chrono-tz-build", @@ -1980,12 +1980,11 @@ dependencies = [ [[package]] name = "chrono-tz-build" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c088aee841df9c3041febbb73934cfc39708749bf96dc827e3359cd39ef11b1" +checksum = "e94fea34d77a245229e7746bd2beb786cd2a896f306ff491fb8cecb3074b10a7" dependencies = [ "parse-zoneinfo", - "phf", "phf_codegen", ] @@ -10916,8 +10915,7 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] name = "vrl" version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78418b391bfef6a37127f5d7283a46b2a23e19b676640841fcf334e40740d919" +source = "git+https://github.com/vectordotdev/vrl?rev=cfcef6626e9131fbce5f45e7d05a6d82bc9f7116#cfcef6626e9131fbce5f45e7d05a6d82bc9f7116" dependencies = [ "aes", "ansi_term", diff --git a/Cargo.toml b/Cargo.toml index 394f58b8a1dc1..27e6f6695a84a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -131,6 +131,7 @@ members = [ [workspace.dependencies] chrono = { version = "0.4.38", default-features = false, features = ["clock", "serde"] } +chrono-tz = { version = "0.10.0", default-features = false, features = ["serde"] } clap = { version = "4.5.17", default-features = false, features = ["derive", "error-context", "env", "help", "std", "string", "usage", "wrap_help"] } futures = { version = "0.3.30", default-features = false, features = ["compat", "io-compat", "std"], package = "futures" } glob = { version = "0.3.1", default-features = false } @@ -148,7 +149,7 @@ toml = { version = "0.8.19", default-features = false, features = ["display", "p tonic = { version = "0.11", default-features = false, features = ["transport", "codegen", "prost", "tls", "tls-roots", "gzip"] } tonic-build = { version = "0.11", default-features = false, features = ["transport", "prost"] } uuid = { version = "1.10.0", features = ["v4", "v7", "serde"] } -vrl = { version = "0.18.0", features = ["arbitrary", "cli", "test", "test_framework"] } +vrl = { git = "https://github.com/vectordotdev/vrl", rev="cfcef6626e9131fbce5f45e7d05a6d82bc9f7116", features = ["arbitrary", "cli", "test", "test_framework"] } [dependencies] pin-project.workspace = true @@ -276,7 +277,7 @@ bollard = { version = "0.16.1", default-features = false, features = ["ssl", "ch bytes = { version = "1.7.1", default-features = false, features = ["serde"] } bytesize = { version = "1.3.0", default-features = false } chrono.workspace = true -chrono-tz = { version = "0.9.0", default-features = false } +chrono-tz.workspace = true cidr-utils = { version = "0.6.1", default-features = false } colored = { version = "2.1.0", default-features = false } csv = { version = "1.3", default-features = false } diff --git a/lib/vector-common/Cargo.toml b/lib/vector-common/Cargo.toml index a15945eda27e5..f205239e0b34f 100644 --- a/lib/vector-common/Cargo.toml +++ b/lib/vector-common/Cargo.toml @@ -41,8 +41,8 @@ tokenize = [ [dependencies] async-stream = "0.3.5" bytes = { version = "1.7.1", default-features = false, optional = true } -chrono-tz = { version = "0.9.0", default-features = false, features = ["serde"] } chrono.workspace = true +chrono-tz.workspace = true crossbeam-utils = { version = "0.8.20", default-features = false } derivative = { version = "2.2.0", default-features = false } futures.workspace = true diff --git a/lib/vector-config/Cargo.toml b/lib/vector-config/Cargo.toml index c758bfc5d453d..d08d34cf92671 100644 --- a/lib/vector-config/Cargo.toml +++ b/lib/vector-config/Cargo.toml @@ -12,7 +12,7 @@ path = "tests/integration/lib.rs" [dependencies] chrono.workspace = true -chrono-tz = { version = "0.9.0", default-features = false } +chrono-tz.workspace = true encoding_rs = { version = "0.8", default-features = false, features = ["alloc", "serde"] } indexmap.workspace = true inventory = { version = "0.3" } diff --git a/lib/vector-core/Cargo.toml b/lib/vector-core/Cargo.toml index cd1e86e60a413..15cdf32f5225f 100644 --- a/lib/vector-core/Cargo.toml +++ b/lib/vector-core/Cargo.toml @@ -11,6 +11,7 @@ async-trait = { version = "0.1", default-features = false } bitmask-enum = { version = "2.2.4", default-features = false } bytes = { version = "1.7.1", default-features = false, features = ["serde"] } chrono.workspace = true +chrono-tz.workspace = true crossbeam-utils = { version = "0.8.20", default-features = false } db-key = { version = "0.0.5", default-features = false, optional = true } derivative = { version = "2.2.0", default-features = false } @@ -79,7 +80,7 @@ prost-build = "0.12" [dev-dependencies] base64 = "0.22.1" -chrono-tz = { version = "0.9.0", default-features = false } +chrono-tz.workspace = true criterion = { version = "0.5.1", features = ["html_reports"] } env-test-util = "1.0.1" quickcheck = "1" diff --git a/lib/vector-vrl/tests/Cargo.toml b/lib/vector-vrl/tests/Cargo.toml index 54b7db24445ac..ec22d0754712b 100644 --- a/lib/vector-vrl/tests/Cargo.toml +++ b/lib/vector-vrl/tests/Cargo.toml @@ -6,13 +6,13 @@ edition = "2021" publish = false [dependencies] +chrono-tz.workspace = true enrichment = { path = "../../enrichment" } vrl.workspace = true vector-vrl-functions = { path = "../../vector-vrl/functions" } ansi_term = "0.12" chrono.workspace = true -chrono-tz = "0.9" clap.workspace = true glob.workspace = true prettydiff = "0.7" diff --git a/src/conditions/datadog_search.rs b/src/conditions/datadog_search.rs index bb36ef3f0dc09..a4452ed2ee6e0 100644 --- a/src/conditions/datadog_search.rs +++ b/src/conditions/datadog_search.rs @@ -1,4 +1,5 @@ use std::{borrow::Cow, str::FromStr}; +use vrl::path::PathParseError; use bytes::Bytes; use vector_lib::configurable::configurable_component; @@ -59,7 +60,7 @@ impl ConditionalConfig for DatadogSearchConfig { &self, _enrichment_tables: &vector_lib::enrichment::TableRegistry, ) -> crate::Result { - let matcher = as_log(build_matcher(&self.source, &EventFilter)); + let matcher = as_log(build_matcher(&self.source, &EventFilter).map_err(|e| e.to_string())?); Ok(Condition::DatadogSearch(DatadogSearchRunner { matcher })) } @@ -80,8 +81,8 @@ struct EventFilter; impl Resolver for EventFilter {} impl Filter for EventFilter { - fn exists(&self, field: Field) -> Box> { - match field { + fn exists(&self, field: Field) -> Result>, PathParseError> { + Ok(match field { Field::Tag(tag) => { let starts_with = format!("{}:", tag); @@ -101,11 +102,15 @@ impl Filter for EventFilter { .is_some() }) } - } + }) } - fn equals(&self, field: Field, to_match: &str) -> Box> { - match field { + fn equals( + &self, + field: Field, + to_match: &str, + ) -> Result>, PathParseError> { + Ok(match field { // Default fields are compared by word boundary. Field::Default(field) => { let re = word_regex(to_match); @@ -138,11 +143,15 @@ impl Filter for EventFilter { string_or_numeric_match(field, move |value| value == to_match) } - } + }) } - fn prefix(&self, field: Field, prefix: &str) -> Box> { - match field { + fn prefix( + &self, + field: Field, + prefix: &str, + ) -> Result>, PathParseError> { + Ok(match field { // Default fields are matched by word boundary. Field::Default(field) => { let re = word_regex(&format!("{}*", prefix)); @@ -161,11 +170,15 @@ impl Filter for EventFilter { string_match(field, move |value| value.starts_with(&prefix)) } - } + }) } - fn wildcard(&self, field: Field, wildcard: &str) -> Box> { - match field { + fn wildcard( + &self, + field: Field, + wildcard: &str, + ) -> Result>, PathParseError> { + Ok(match field { Field::Default(field) => { let re = word_regex(wildcard); @@ -181,7 +194,7 @@ impl Filter for EventFilter { string_match(field, move |value| re.is_match(&value)) } - } + }) } fn compare( @@ -189,10 +202,10 @@ impl Filter for EventFilter { field: Field, comparator: Comparison, comparison_value: ComparisonValue, - ) -> Box> { + ) -> Result>, PathParseError> { let rhs = Cow::from(comparison_value.to_string()); - match field { + Ok(match field { // Attributes are compared numerically if the value is numeric, or as strings otherwise. Field::Attribute(f) => { Run::boxed(move |log: &LogEvent| { @@ -286,7 +299,7 @@ impl Filter for EventFilter { Comparison::Gte => lhs >= rhs, }) } - } + }) } } @@ -1175,7 +1188,7 @@ mod test { for (source, pass, fail) in checks { let node: QueryNode = source.parse().unwrap(); - let matcher = build_matcher(&node, &filter); + let matcher = build_matcher(&node, &filter).unwrap(); assert!(matcher.run(&processor(pass))); assert!(!matcher.run(&processor(fail)));