From 548365ce2edb3ae7ea41b8394c86a1c248deeb4d Mon Sep 17 00:00:00 2001 From: Stephen Wakely Date: Sun, 30 Jul 2023 22:50:36 +0100 Subject: [PATCH 1/2] Update syslog_loose to properly handle escapes Signed-off-by: Stephen Wakely --- Cargo.lock | 14 ++++++++++++-- lib/codecs/Cargo.toml | 2 +- lib/codecs/src/decoding/format/syslog.rs | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a5f635dafc5cf..1450b586f82cb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1975,7 +1975,7 @@ dependencies = [ "similar-asserts", "smallvec", "snafu", - "syslog_loose", + "syslog_loose 0.19.0", "tokio", "tokio-util", "tracing 0.1.37", @@ -8136,6 +8136,16 @@ dependencies = [ "nom", ] +[[package]] +name = "syslog_loose" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acf5252d1adec0a489a0225f867c1a7fd445e41674530a396d0629cff0c4b211" +dependencies = [ + "chrono", + "nom", +] + [[package]] name = "take_mut" version = "0.2.2" @@ -9830,7 +9840,7 @@ dependencies = [ "sha3", "snafu", "strip-ansi-escapes", - "syslog_loose", + "syslog_loose 0.18.0", "termcolor", "thiserror", "tracing 0.1.37", diff --git a/lib/codecs/Cargo.toml b/lib/codecs/Cargo.toml index b987532c441dd..31d4e615ec96d 100644 --- a/lib/codecs/Cargo.toml +++ b/lib/codecs/Cargo.toml @@ -23,7 +23,7 @@ serde = { version = "1", default-features = false, features = ["derive"] } serde_json = { version = "1", default-features = false } smallvec = { version = "1", default-features = false, features = ["union"] } snafu = { version = "0.7.5", default-features = false, features = ["futures"] } -syslog_loose = { version = "0.18", default-features = false, optional = true } +syslog_loose = { version = "0.19", default-features = false, optional = true } tokio-util = { version = "0.7", default-features = false, features = ["codec"] } tracing = { version = "0.1", default-features = false } vrl.workspace = true diff --git a/lib/codecs/src/decoding/format/syslog.rs b/lib/codecs/src/decoding/format/syslog.rs index a7ab83aebbbaa..73bc920355213 100644 --- a/lib/codecs/src/decoding/format/syslog.rs +++ b/lib/codecs/src/decoding/format/syslog.rs @@ -5,7 +5,7 @@ use lookup::{event_path, owned_value_path, OwnedTargetPath, OwnedValuePath}; use smallvec::{smallvec, SmallVec}; use std::borrow::Cow; use std::collections::BTreeMap; -use syslog_loose::{IncompleteDate, Message, ProcId, Protocol}; +use syslog_loose::{IncompleteDate, Message, ProcId, Protocol, Variant}; use vector_config::configurable_component; use vector_core::config::{LegacyKey, LogNamespace}; use vector_core::{ @@ -282,7 +282,7 @@ impl Deserializer for SyslogDeserializer { false => Cow::from(std::str::from_utf8(&bytes)?), }; let line = line.trim(); - let parsed = syslog_loose::parse_message_with_year_exact(line, resolve_year)?; + let parsed = syslog_loose::parse_message_with_year_exact(line, resolve_year, Variant::Either)?; let log = match (self.source, log_namespace) { (Some(source), LogNamespace::Vector) => { From 21ebefd1cb9e769c3b3855fd2bbf0a36079a6a15 Mon Sep 17 00:00:00 2001 From: Stephen Wakely Date: Sun, 30 Jul 2023 23:15:16 +0100 Subject: [PATCH 2/2] fmt Signed-off-by: Stephen Wakely --- lib/codecs/src/decoding/format/syslog.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/codecs/src/decoding/format/syslog.rs b/lib/codecs/src/decoding/format/syslog.rs index 73bc920355213..041d6a4c93cc6 100644 --- a/lib/codecs/src/decoding/format/syslog.rs +++ b/lib/codecs/src/decoding/format/syslog.rs @@ -282,7 +282,8 @@ impl Deserializer for SyslogDeserializer { false => Cow::from(std::str::from_utf8(&bytes)?), }; let line = line.trim(); - let parsed = syslog_loose::parse_message_with_year_exact(line, resolve_year, Variant::Either)?; + let parsed = + syslog_loose::parse_message_with_year_exact(line, resolve_year, Variant::Either)?; let log = match (self.source, log_namespace) { (Some(source), LogNamespace::Vector) => {