From f85944511a689864cf2cd96a6354a803dbfacfac Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Thu, 16 Oct 2025 16:42:45 -0600 Subject: [PATCH] ike: don't log duplicate attributes Track what attributes have been logged and skip over duplicate attributes to avoid having duplicate fields in the JSON object, which is invalid JSON. This is lossy, subsequent attributes are lost. Ticket: #7923 (cherry picked from commit 35464150dec646f51d691be19250fcdf9e534d13) --- rust/src/ike/logger.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rust/src/ike/logger.rs b/rust/src/ike/logger.rs index cc5705f580..e7f8701859 100644 --- a/rust/src/ike/logger.rs +++ b/rust/src/ike/logger.rs @@ -22,14 +22,24 @@ use crate::ike::parser::{ExchangeType, IsakmpPayloadType, SaAttribute}; use crate::jsonbuilder::{JsonBuilder, JsonError}; use num_traits::FromPrimitive; use std; +use std::collections::HashSet; use std::convert::TryFrom; const LOG_EXTENDED: u32 = 0x01; fn add_attributes(transform: &Vec, js: &mut JsonBuilder) -> Result<(), JsonError> { + let mut logged: HashSet = HashSet::new(); + for attribute in transform { + let key = attribute.attribute_type.to_string(); + + if logged.contains(&key) { + continue; + } + logged.insert(key.clone()); + js.set_string( - attribute.attribute_type.to_string().as_str(), + &key, attribute.attribute_value.to_string().as_str(), )?;