diff --git a/Cargo.lock b/Cargo.lock index 6c175377a63c1..bb5478d575f5c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2631,6 +2631,7 @@ dependencies = [ "vector-config-macros", "vector-core", "vector-lookup", + "vector-vrl-functions", "vrl", ] @@ -3599,7 +3600,10 @@ dependencies = [ "prost-build 0.12.6", "snafu 0.8.9", "tracing 0.1.41", - "vector-lib", + "vector-common", + "vector-config", + "vector-core", + "vector-lookup", "vrl", ] @@ -13058,6 +13062,8 @@ dependencies = [ name = "vector-vrl-functions" version = "0.1.0" dependencies = [ + "dnstap-parser", + "enrichment", "vrl", ] @@ -13067,7 +13073,6 @@ version = "0.1.0" dependencies = [ "chrono-tz", "clap", - "dnstap-parser", "enrichment", "glob", "serde", diff --git a/Cargo.toml b/Cargo.toml index 9cc3b90078953..26e0f5b355f4c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -200,6 +200,7 @@ vector-config-common = { path = "lib/vector-config-common" } vector-config-macros = { path = "lib/vector-config-macros" } vector-common-macros = { path = "lib/vector-common-macros" } vector-lib = { path = "lib/vector-lib", default-features = false, features = ["vrl"] } +vector-vrl-functions = { path = "lib/vector-vrl/functions" } vrl = { git = "https://github.com/vectordotdev/vrl.git", branch = "main", features = ["arbitrary", "cli", "test", "test_framework"] } mock_instant = { version = "0.6" } serial_test = { version = "3.2" } @@ -227,7 +228,7 @@ vector-lib.workspace = true vector-config.workspace = true vector-config-common.workspace = true vector-config-macros.workspace = true -vector-vrl-functions = { path = "lib/vector-vrl/functions" } +vector-vrl-functions.workspace = true loki-logproto = { path = "lib/loki-logproto", optional = true } # Tokio / Futures @@ -654,7 +655,7 @@ sources-aws_s3 = ["aws-core", "dep:aws-sdk-sqs", "dep:aws-sdk-s3", "dep:async-co sources-aws_sqs = ["aws-core", "dep:aws-sdk-sqs"] sources-datadog_agent = ["sources-utils-http-encoding", "protobuf-build", "dep:prost"] sources-demo_logs = ["dep:fakedata"] -sources-dnstap = ["sources-utils-net-tcp", "dep:base64", "dep:hickory-proto", "dep:dnsmsg-parser", "dep:dnstap-parser", "protobuf-build", "dep:prost"] +sources-dnstap = ["sources-utils-net-tcp", "dep:base64", "dep:hickory-proto", "dep:dnsmsg-parser", "dep:dnstap-parser", "protobuf-build", "dep:prost", "vector-vrl-functions/dnstap"] sources-docker_logs = ["docker"] sources-eventstoredb_metrics = [] sources-exec = [] diff --git a/changelog.d/vrl_functions_consolidation.enhancement.md b/changelog.d/vrl_functions_consolidation.enhancement.md new file mode 100644 index 0000000000000..85d09cdd97ed5 --- /dev/null +++ b/changelog.d/vrl_functions_consolidation.enhancement.md @@ -0,0 +1,4 @@ +Vector-specific VRL functions are now available everywhere. Previously some functions were not +available inside codec VRL transforms and in the VRL cli (via `vector vrl`). + +authors: thomasqueirozb diff --git a/clippy.toml b/clippy.toml index 0aeae804db3c7..cbd8c640fdb71 100644 --- a/clippy.toml +++ b/clippy.toml @@ -5,6 +5,7 @@ allow-unwrap-in-tests = true # https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_method disallowed-methods = [ { path = "std::io::Write::write", reason = "This doesn't handle short writes, use `write_all` instead." }, + { path = "vrl::stdlib::all", reason = "Use `vector_vrl_functions::all()` instead for consistency across all Vector VRL functions." }, ] disallowed-types = [ diff --git a/lib/codecs/Cargo.toml b/lib/codecs/Cargo.toml index 7a622d52edc2b..d73b1177c0f34 100644 --- a/lib/codecs/Cargo.toml +++ b/lib/codecs/Cargo.toml @@ -46,6 +46,7 @@ vector-common = { path = "../vector-common", default-features = false } vector-config = { path = "../vector-config", default-features = false } vector-config-macros = { path = "../vector-config-macros", default-features = false } vector-core = { path = "../vector-core", default-features = false, features = ["vrl"] } +vector-vrl-functions.workspace = true [dev-dependencies] futures.workspace = true diff --git a/lib/codecs/src/decoding/format/vrl.rs b/lib/codecs/src/decoding/format/vrl.rs index 7ed5244768b5b..c67f60fdd8952 100644 --- a/lib/codecs/src/decoding/format/vrl.rs +++ b/lib/codecs/src/decoding/format/vrl.rs @@ -59,7 +59,7 @@ impl VrlDeserializerConfig { match compile_vrl( &self.vrl.source, - &vrl::stdlib::all(), + &vector_vrl_functions::all(), &state, CompileConfig::default(), ) { diff --git a/lib/dnstap-parser/Cargo.toml b/lib/dnstap-parser/Cargo.toml index 64220976d2398..8768274b3d3e0 100644 --- a/lib/dnstap-parser/Cargo.toml +++ b/lib/dnstap-parser/Cargo.toml @@ -15,7 +15,10 @@ hickory-proto.workspace = true prost.workspace = true snafu.workspace = true tracing.workspace = true -vector-lib.workspace = true +vector-config.workspace = true +vector-common = { path = "../vector-common" } +vector-lookup = { path = "../vector-lookup", features = ["test"] } +vector-core = { path = "../vector-core" } vrl.workspace = true paste.workspace = true diff --git a/lib/dnstap-parser/src/internal_events.rs b/lib/dnstap-parser/src/internal_events.rs index 8ff8763de9f71..fc8f52e2b6952 100644 --- a/lib/dnstap-parser/src/internal_events.rs +++ b/lib/dnstap-parser/src/internal_events.rs @@ -1,5 +1,5 @@ use tracing::warn; -use vector_lib::{ +use vector_common::{ NamedInternalEvent, internal_event::{InternalEvent, error_stage, error_type}, }; diff --git a/lib/dnstap-parser/src/parser.rs b/lib/dnstap-parser/src/parser.rs index b90589b8e890b..3876ff363bec6 100644 --- a/lib/dnstap-parser/src/parser.rs +++ b/lib/dnstap-parser/src/parser.rs @@ -16,10 +16,8 @@ use hickory_proto::{ }; use prost::Message; use snafu::Snafu; -use vector_lib::{ - Error, Result, emit, - event::{LogEvent, Value}, -}; +use vector_common::{Error, Result, internal_event::emit}; +use vector_core::event::{LogEvent, Value}; use vrl::{owned_value_path, path}; #[allow(warnings, clippy::all, clippy::pedantic, clippy::nursery)] @@ -38,10 +36,8 @@ use dnstap_proto::{ Dnstap, Message as DnstapMessage, SocketFamily, SocketProtocol, message::Type as DnstapMessageType, }; -use vector_lib::{ - config::log_schema, - lookup::{PathPrefix, lookup_v2::ValuePath}, -}; +use vector_core::config::log_schema; +use vector_lookup::{PathPrefix, lookup_v2::ValuePath}; use crate::{internal_events::DnstapParseWarning, schema::DNSTAP_VALUE_PATHS}; @@ -151,13 +147,13 @@ impl DnstapParser { && let Err(err) = DnstapParser::parse_dnstap_message(event, &root, message, parsing_options) { - emit!(DnstapParseWarning { error: &err }); + emit(DnstapParseWarning { error: &err }); need_raw_data = true; DnstapParser::insert(event, &root, &DNSTAP_VALUE_PATHS.error, err.to_string()); } } else { - emit!(DnstapParseWarning { - error: format!("Unknown dnstap data type: {dnstap_data_type_id}") + emit(DnstapParseWarning { + error: format!("Unknown dnstap data type: {dnstap_data_type_id}"), }); need_raw_data = true; } diff --git a/lib/dnstap-parser/src/schema.rs b/lib/dnstap-parser/src/schema.rs index e795cce9d9789..29a1b861f6e69 100644 --- a/lib/dnstap-parser/src/schema.rs +++ b/lib/dnstap-parser/src/schema.rs @@ -1,6 +1,6 @@ use std::{collections::BTreeMap, sync::LazyLock}; -use vector_lib::lookup::{OwnedValuePath, owned_value_path}; +use vector_lookup::{OwnedValuePath, owned_value_path}; use vrl::{ btreemap, value::{ @@ -135,8 +135,8 @@ impl DnstapEventSchema { /// Schema definition for fields stored in the root. fn root_schema_definition( &self, - schema: vector_lib::schema::Definition, - ) -> vector_lib::schema::Definition { + schema: vector_core::schema::Definition, + ) -> vector_core::schema::Definition { schema .optional_field(&DNSTAP_VALUE_PATHS.server_identity, Kind::bytes(), None) .optional_field(&DNSTAP_VALUE_PATHS.server_version, Kind::bytes(), None) @@ -152,8 +152,8 @@ impl DnstapEventSchema { /// Schema definition from the message. pub fn message_schema_definition( &self, - schema: vector_lib::schema::Definition, - ) -> vector_lib::schema::Definition { + schema: vector_core::schema::Definition, + ) -> vector_core::schema::Definition { schema .optional_field(&DNSTAP_VALUE_PATHS.socket_family, Kind::bytes(), None) .optional_field(&DNSTAP_VALUE_PATHS.socket_protocol, Kind::bytes(), None) @@ -179,8 +179,8 @@ impl DnstapEventSchema { /// The schema definition for a dns tap message. pub fn schema_definition( &self, - schema: vector_lib::schema::Definition, - ) -> vector_lib::schema::Definition { + schema: vector_core::schema::Definition, + ) -> vector_core::schema::Definition { self.root_schema_definition(self.message_schema_definition(schema)) } } diff --git a/lib/dnstap-parser/src/vrl_functions/parse_dnstap.rs b/lib/dnstap-parser/src/vrl_functions/parse_dnstap.rs index aec6934f23f5b..b32fdcfeb3106 100644 --- a/lib/dnstap-parser/src/vrl_functions/parse_dnstap.rs +++ b/lib/dnstap-parser/src/vrl_functions/parse_dnstap.rs @@ -1,6 +1,6 @@ use base64::prelude::{BASE64_STANDARD, Engine as _}; use dnsmsg_parser::dns_message_parser::DnsParserOptions; -use vector_lib::event::LogEvent; +use vector_core::event::LogEvent; use vrl::prelude::*; use crate::{parser::DnstapParser, schema::DnstapEventSchema}; diff --git a/lib/vector-common-macros/src/internal_event.rs b/lib/vector-common-macros/src/internal_event.rs index c34b8d01a7aee..aed9e71bfa9a0 100644 --- a/lib/vector-common-macros/src/internal_event.rs +++ b/lib/vector-common-macros/src/internal_event.rs @@ -27,7 +27,7 @@ pub fn derive_impl_named_internal_event(item: TokenStream) -> TokenStream { let pkg_name = std::env::var("CARGO_PKG_NAME").unwrap_or_default(); let internal_event_path = if pkg_name == "vector-common" { quote! { crate::internal_event } - } else if pkg_name.starts_with("vector-") { + } else if pkg_name.starts_with("vector-") || pkg_name == "dnstap-parser" { // Most vector-* crates depend on vector-common but not vector-lib quote! { ::vector_common::internal_event } } else { diff --git a/lib/vector-vrl/cli/Cargo.toml b/lib/vector-vrl/cli/Cargo.toml index d97acae8c3339..32f0b8ccce166 100644 --- a/lib/vector-vrl/cli/Cargo.toml +++ b/lib/vector-vrl/cli/Cargo.toml @@ -8,5 +8,5 @@ license = "MPL-2.0" [dependencies] clap.workspace = true -vector-vrl-functions = { path = "../functions" } +vector-vrl-functions.workspace = true vrl.workspace = true diff --git a/lib/vector-vrl/cli/src/main.rs b/lib/vector-vrl/cli/src/main.rs index 9aa4b09fdb0ea..6ecc982deab1f 100644 --- a/lib/vector-vrl/cli/src/main.rs +++ b/lib/vector-vrl/cli/src/main.rs @@ -2,8 +2,6 @@ use clap::Parser; use vrl::cli::{Opts, cmd::cmd}; fn main() { - let mut functions = vrl::stdlib::all(); - functions.extend(vector_vrl_functions::all()); - + let functions = vector_vrl_functions::all(); std::process::exit(cmd(&Opts::parse(), functions)); } diff --git a/lib/vector-vrl/functions/Cargo.toml b/lib/vector-vrl/functions/Cargo.toml index d6319b079cea5..8cc02c042b6f5 100644 --- a/lib/vector-vrl/functions/Cargo.toml +++ b/lib/vector-vrl/functions/Cargo.toml @@ -8,3 +8,9 @@ license = "MPL-2.0" [dependencies] vrl.workspace = true +enrichment = { path = "../../enrichment" } +dnstap-parser = { path = "../../dnstap-parser", optional = true } + +[features] +default = [] +dnstap = ["dep:dnstap-parser"] diff --git a/lib/vector-vrl/functions/src/lib.rs b/lib/vector-vrl/functions/src/lib.rs index 8216cf43092ab..a154597b50966 100644 --- a/lib/vector-vrl/functions/src/lib.rs +++ b/lib/vector-vrl/functions/src/lib.rs @@ -1,3 +1,12 @@ +//! Central location for all VRL functions used in Vector. +//! +//! This crate provides a single source of truth for the complete set of VRL functions +//! available throughout Vector, combining: +//! - Standard VRL library functions (`vrl::stdlib::all`) +//! - Vector-specific functions (`vector_vrl::secret_functions`) +//! - Enrichment table functions (`enrichment::vrl_functions`) +//! - DNS tap parsing functions (optional, with `dnstap` feature) + #![deny(warnings)] use vrl::{compiler::Function, path::OwnedTargetPath}; @@ -16,7 +25,8 @@ pub enum MetadataKey { pub const LEGACY_METADATA_KEYS: [&str; 2] = ["datadog_api_key", "splunk_hec_token"]; -pub fn all() -> Vec> { +/// Returns Vector-specific secret functions. +pub fn secret_functions() -> Vec> { vec![ Box::new(set_semantic_meaning::SetSemanticMeaning) as _, Box::new(get_secret::GetSecret) as _, @@ -24,3 +34,17 @@ pub fn all() -> Vec> { Box::new(set_secret::SetSecret) as _, ] } + +/// Returns all VRL functions available in Vector. +#[allow(clippy::disallowed_methods)] +pub fn all() -> Vec> { + let functions = vrl::stdlib::all() + .into_iter() + .chain(secret_functions()) + .chain(enrichment::vrl_functions()); + + #[cfg(feature = "dnstap")] + let functions = functions.chain(dnstap_parser::vrl_functions()); + + functions.collect() +} diff --git a/lib/vector-vrl/tests/Cargo.toml b/lib/vector-vrl/tests/Cargo.toml index ddcb78084ab92..671db99c9d989 100644 --- a/lib/vector-vrl/tests/Cargo.toml +++ b/lib/vector-vrl/tests/Cargo.toml @@ -7,10 +7,9 @@ publish = false [dependencies] chrono-tz.workspace = true -dnstap-parser = { path = "../../dnstap-parser" } +vector-vrl-functions = { workspace = true, features = ["dnstap"] } enrichment = { path = "../../enrichment" } vrl.workspace = true -vector-vrl-functions = { path = "../../vector-vrl/functions" } clap.workspace = true glob.workspace = true diff --git a/lib/vector-vrl/tests/src/main.rs b/lib/vector-vrl/tests/src/main.rs index a0eb07cb5c432..8210855ee9129 100644 --- a/lib/vector-vrl/tests/src/main.rs +++ b/lib/vector-vrl/tests/src/main.rs @@ -4,7 +4,7 @@ mod docs; mod test_enrichment; -use std::{env, path::PathBuf}; +use std::{collections::HashSet, env, path::PathBuf}; use chrono_tz::Tz; use clap::Parser; @@ -96,15 +96,10 @@ fn main() { timezone: cmd.timezone(), }; - let mut functions = vrl::stdlib::all(); - functions.extend(vector_vrl_functions::all()); - functions.extend(dnstap_parser::vrl_functions()); - functions.extend(enrichment::vrl_functions()); - run_tests( tests, &cfg, - &functions, + &vector_vrl_functions::all(), || { let mut config = CompileConfig::default(); let enrichment_table = test_enrichment::test_enrichment_table(); @@ -122,7 +117,21 @@ pub fn test_dir() -> PathBuf { fn test_glob_pattern() -> String { test_dir().join("**/*.vrl").to_str().unwrap().to_string() } + +#[allow(clippy::disallowed_methods)] fn get_tests(cmd: &Cmd) -> Vec { + // Don't test vrl stdlib functions examples since they are already tested in VRL and some will + // fail to compile since they are missing required source files such as proto definitions. + let ignore_examples_from_functions: HashSet = vrl::stdlib::all() + .into_iter() + .map(|f| format!("functions/{}", f.identifier())) + .collect(); + + let tests_from_functions = get_tests_from_functions(vector_vrl_functions::all()); + let tests_from_functions = tests_from_functions + .into_iter() + .filter(|test| !ignore_examples_from_functions.contains(&test.category)); + glob(test_glob_pattern().as_str()) .expect("valid pattern") .filter_map(|entry| { @@ -130,13 +139,7 @@ fn get_tests(cmd: &Cmd) -> Vec { Some(Test::from_path(&path)) }) .chain(docs::tests(cmd.ignore_cue)) - .chain(get_tests_from_functions( - vector_vrl_functions::all() - .into_iter() - .chain(enrichment::vrl_functions()) - .chain(dnstap_parser::vrl_functions()) - .collect(), - )) + .chain(tests_from_functions) .filter(|test| { should_run( &format!("{}/{}", test.category, test.name), diff --git a/lib/vector-vrl/web-playground/Cargo.toml b/lib/vector-vrl/web-playground/Cargo.toml index 3aaa7fda74929..a54dba46bd84b 100644 --- a/lib/vector-vrl/web-playground/Cargo.toml +++ b/lib/vector-vrl/web-playground/Cargo.toml @@ -17,7 +17,7 @@ vrl.workspace = true serde.workspace = true web-sys = { version = "0.3", features = ["Window", "Performance"] } gloo-utils = { version = "0.2", features = ["serde"] } -vector-vrl-functions = { path = "../functions" } +vector-vrl-functions.workspace = true enrichment = { path = "../../enrichment" } # Required per https://docs.rs/getrandom/latest/getrandom/#webassembly-support getrandom = { version = "0.2.15", features = ["js"] } diff --git a/lib/vector-vrl/web-playground/src/lib.rs b/lib/vector-vrl/web-playground/src/lib.rs index 4a74e32d9e0b1..07fcb4bb6b096 100644 --- a/lib/vector-vrl/web-playground/src/lib.rs +++ b/lib/vector-vrl/web-playground/src/lib.rs @@ -77,9 +77,7 @@ fn compile( mut input: Input, tz_str: Option, ) -> Result { - let mut functions = vrl::stdlib::all(); - functions.extend(vector_vrl_functions::all()); - functions.extend(enrichment::vrl_functions()); + let functions = vector_vrl_functions::all(); let event = &mut input.event; let state = TypeState::default(); diff --git a/src/cli.rs b/src/cli.rs index fd7d8d0ac9ce4..7df8ca67215be 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -369,11 +369,7 @@ impl SubCommand { #[cfg(feature = "top")] Self::Top(t) => top::cmd(t).await, Self::Validate(v) => validate::validate(v, color).await, - Self::Vrl(s) => { - let mut functions = vrl::stdlib::all(); - functions.extend(vector_vrl_functions::all()); - vrl::cli::cmd::cmd(s, functions) - } + Self::Vrl(s) => vrl::cli::cmd::cmd(s, vector_vrl_functions::all()), } } } diff --git a/src/common/http/server_auth.rs b/src/common/http/server_auth.rs index 6b79fb65d9b59..4001f1148555c 100644 --- a/src/common/http/server_auth.rs +++ b/src/common/http/server_auth.rs @@ -144,12 +144,6 @@ impl HttpServerAuthConfig { )) } HttpServerAuthConfig::Custom { source } => { - let functions = vrl::stdlib::all() - .into_iter() - .chain(vector_lib::enrichment::vrl_functions()) - .chain(vector_vrl_functions::all()) - .collect::>(); - let state = TypeState::default(); let mut config = CompileConfig::default(); @@ -160,7 +154,7 @@ impl HttpServerAuthConfig { program, warnings, config: _, - } = compile_vrl(source, &functions, &state, config) + } = compile_vrl(source, &vector_vrl_functions::all(), &state, config) .map_err(|diagnostics| format_vrl_diagnostics(source, diagnostics))?; if !program.final_type_info().result.is_boolean() { diff --git a/src/conditions/vrl.rs b/src/conditions/vrl.rs index 07ec8d213ee29..178c0ac3d0988 100644 --- a/src/conditions/vrl.rs +++ b/src/conditions/vrl.rs @@ -44,15 +44,7 @@ impl ConditionalConfig for VrlConfig { // }, // }; - let functions = vrl::stdlib::all() - .into_iter() - .chain(vector_lib::enrichment::vrl_functions()); - #[cfg(feature = "sources-dnstap")] - let functions = functions.chain(dnstap_parser::vrl_functions()); - - let functions = functions - .chain(vector_vrl_functions::all()) - .collect::>(); + let functions = vector_vrl_functions::all(); let state = TypeState::default(); diff --git a/src/config/unit_test/mod.rs b/src/config/unit_test/mod.rs index 485f8b59e75eb..a289e06cc1efc 100644 --- a/src/config/unit_test/mod.rs +++ b/src/config/unit_test/mod.rs @@ -611,8 +611,7 @@ fn build_input_event(input: &TestInput) -> Result { }, "vrl" => { if let Some(source) = &input.source { - let fns = vrl::stdlib::all(); - let result = vrl::compiler::compile(source, &fns) + let result = vrl::compiler::compile(source, &vector_vrl_functions::all()) .map_err(|e| Formatter::new(source, e.clone()).to_string())?; let mut target = TargetValue { diff --git a/src/sources/http_client/client.rs b/src/sources/http_client/client.rs index c26f7302e16aa..27d4643a73afc 100644 --- a/src/sources/http_client/client.rs +++ b/src/sources/http_client/client.rs @@ -183,15 +183,6 @@ fn headers_examples() -> HashMap> { ]) } -/// Helper function to get all VRL functions for compilation -fn get_vrl_functions() -> Vec> { - vrl::stdlib::all() - .into_iter() - .chain(vector_lib::enrichment::vrl_functions()) - .chain(vector_vrl_functions::all()) - .collect() -} - /// Helper function to compile a VRL parameter value into a Program fn compile_parameter_vrl( param: &ParameterValue, @@ -274,7 +265,7 @@ pub struct Query { impl Query { pub fn new(params: &HashMap) -> Result { - let functions = get_vrl_functions(); + let functions = vector_vrl_functions::all(); let mut compiled: HashMap = HashMap::new(); @@ -330,7 +321,7 @@ impl Query { impl SourceConfig for HttpClientConfig { async fn build(&self, cx: SourceContext) -> crate::Result { let query = Query::new(&self.query)?; - let functions = get_vrl_functions(); + let functions = vector_vrl_functions::all(); // Compile body if present let body = self diff --git a/src/transforms/remap.rs b/src/transforms/remap.rs index 219e2e3792fb9..49cb0dd683bdb 100644 --- a/src/transforms/remap.rs +++ b/src/transforms/remap.rs @@ -210,12 +210,6 @@ impl RemapConfig { _ => return Err(Box::new(BuildError::SourceAndOrFileOrFiles)), }; - let mut functions = vrl::stdlib::all(); - functions.append(&mut vector_lib::enrichment::vrl_functions()); - #[cfg(feature = "sources-dnstap")] - functions.append(&mut dnstap_parser::vrl_functions()); - functions.append(&mut vector_vrl_functions::all()); - let state = TypeState { local: Default::default(), external: ExternalEnv::new_with_kind( @@ -228,7 +222,7 @@ impl RemapConfig { config.set_custom(enrichment_tables.clone()); config.set_custom(MeaningList::default()); - let res = compile_vrl(&source, &functions, &state, config) + let res = compile_vrl(&source, &vector_vrl_functions::all(), &state, config) .map_err(|diagnostics| format_vrl_diagnostics(&source, diagnostics)) .map(|result| { ( diff --git a/website/cue/reference/remap/functions/decode_lz4.cue b/website/cue/reference/remap/functions/decode_lz4.cue index 25baf7d14b600..a77cd38f0ffb6 100644 --- a/website/cue/reference/remap/functions/decode_lz4.cue +++ b/website/cue/reference/remap/functions/decode_lz4.cue @@ -43,7 +43,7 @@ remap: functions: decode_lz4: { title: "Decode Lz4 data with prepended size." source: #""" encoded_text = decode_base64!("LAAAAPAdVGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIDEzIGxhenkgZG9ncy4=") - decode_lz4!(encoded_text, use_prepended_size: true) + decode_lz4!(encoded_text, prepended_size: true) """# return: "The quick brown fox jumps over 13 lazy dogs." }, diff --git a/website/cue/reference/remap/functions/decrypt_ip.cue b/website/cue/reference/remap/functions/decrypt_ip.cue index 5f6ac26faa8ee..8bc782c68c7ef 100644 --- a/website/cue/reference/remap/functions/decrypt_ip.cue +++ b/website/cue/reference/remap/functions/decrypt_ip.cue @@ -55,7 +55,7 @@ remap: functions: decrypt_ip: { { title: "Decrypt IPv6 address with AES128" source: #""" - decrypted_ip = decrypt_ip!("d09e:a5ea:585a:2547:dc6d:65ea:d9f1:d09d", "sixteen byte key", "aes128") + decrypted_ip = decrypt_ip!("c0e6:eb35:6887:f554:4c65:8ace:17ca:6c6a", "sixteen byte key", "aes128") decrypted_ip """# return: "2001:db8::1" @@ -63,7 +63,7 @@ remap: functions: decrypt_ip: { { title: "Decrypt IPv4 address with prefix-preserving mode" source: #""" - decrypted_ip = decrypt_ip!("b51c:3c43:4e89:819e:64ce:225f:d6d1:bf01", "thirty-two bytes key for pfx use", "pfx") + decrypted_ip = decrypt_ip!("33.245.248.61", "thirty-two bytes key for pfx use", "pfx") decrypted_ip """# return: "192.168.1.1" @@ -81,10 +81,10 @@ remap: functions: decrypt_ip: { source: #""" original_ip = "192.168.1.100" key = "sixteen byte key" - + encrypted = encrypt_ip!(original_ip, key, "aes128") decrypted = decrypt_ip!(encrypted, key, "aes128") - + decrypted == original_ip """# return: true diff --git a/website/cue/reference/remap/functions/encrypt_ip.cue b/website/cue/reference/remap/functions/encrypt_ip.cue index 83ceadd9926c2..5888f2c22055a 100644 --- a/website/cue/reference/remap/functions/encrypt_ip.cue +++ b/website/cue/reference/remap/functions/encrypt_ip.cue @@ -58,7 +58,7 @@ remap: functions: encrypt_ip: { encrypted_ip = encrypt_ip!("2001:db8::1", "sixteen byte key", "aes128") encrypted_ip """# - return: "d09e:a5ea:585a:2547:dc6d:65ea:d9f1:d09d" + return: "c0e6:eb35:6887:f554:4c65:8ace:17ca:6c6a" }, { title: "Encrypt IPv4 address with prefix-preserving mode" @@ -66,7 +66,7 @@ remap: functions: encrypt_ip: { encrypted_ip = encrypt_ip!("192.168.1.1", "thirty-two bytes key for pfx use", "pfx") encrypted_ip """# - return: "b51c:3c43:4e89:819e:64ce:225f:d6d1:bf01" + return: "33.245.248.61" }, { title: "Encrypt IPv6 address with prefix-preserving mode" diff --git a/website/cue/reference/remap/functions/find.cue b/website/cue/reference/remap/functions/find.cue index 6ed15f0de03b5..5cf6bd3ab1283 100644 --- a/website/cue/reference/remap/functions/find.cue +++ b/website/cue/reference/remap/functions/find.cue @@ -51,7 +51,7 @@ remap: functions: find: { source: #""" find("foobar", "baz") """# - return: -1 + return: null }, { title: "With an offset" diff --git a/website/cue/reference/remap/functions/parse_aws_alb_log.cue b/website/cue/reference/remap/functions/parse_aws_alb_log.cue index 0f357f5baa82f..21f87d19aa227 100644 --- a/website/cue/reference/remap/functions/parse_aws_alb_log.cue +++ b/website/cue/reference/remap/functions/parse_aws_alb_log.cue @@ -98,7 +98,7 @@ remap: functions: parse_aws_alb_log: { ssl_protocol: null target_group_arn: "arn:aws:elasticloadbalancing:us-east-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067" trace_id: "Root=1-58337364-23a8c76965a2ef7629b185e3" - traceability_id: null + traceability_id: "TID_12345" domain_name: null chosen_cert_arn: null matched_rule_priority: "0" diff --git a/website/cue/reference/remap/functions/split_path.cue b/website/cue/reference/remap/functions/split_path.cue index f1bc93034f547..981f64bfb6522 100644 --- a/website/cue/reference/remap/functions/split_path.cue +++ b/website/cue/reference/remap/functions/split_path.cue @@ -24,28 +24,28 @@ remap: functions: split_path: { { title: "Split path with trailing slash" source: """ - split_path!("/home/user/") + split_path("/home/user/") """ return: ["/", "home", "user"] }, { title: "Split path from file path" source: """ - split_path!("/home/user") + split_path("/home/user") """ return: ["/", "home", "user"] }, { title: "Split path from root" source: """ - split_path!("/") + split_path("/") """ return: ["/"] }, { title: "Empty path returns empty array" source: """ - split_path!("") + split_path("") """ return: [] }, diff --git a/website/cue/reference/remap/functions/validate_json_schema.cue b/website/cue/reference/remap/functions/validate_json_schema.cue index 4930e35ec904a..314d6fdee8bca 100644 --- a/website/cue/reference/remap/functions/validate_json_schema.cue +++ b/website/cue/reference/remap/functions/validate_json_schema.cue @@ -57,21 +57,23 @@ remap: functions: validate_json_schema: { { title: "Payload contains an invalid email." source: """ - validate_json_schema!(s'{ "productUser": "invalidEmail" }', "resources/json-schema_definition.json", false) + ok, _err = validate_json_schema(s'{ "productUser": "invalidEmail" }', "resources/json-schema_definition.json", false) + ok """ return: false }, { title: "Payload contains a custom format declaration." source: """ - validate_json_schema!(s'{ "productUser": "a-custom-formatted-string" }', "resources/json-schema_definition.json", false) + ok, _err = validate_json_schema(s'{ "productUser": "a-custom-formatted-string" }', "resources/json-schema_definition.json", false) + ok """ return: false }, { title: "Payload contains a custom format declaration, with ignore_unknown_formats set to true." source: """ - validate_json_schema!(s'{ "productUser": "a-custom-formatted-string" }', "resources/json-schema_definition.json", true) + validate_json_schema!(s'{ "productUser": "valid@email.com" }', "resources/json-schema_definition.json", true) """ return: true }, diff --git a/website/cue/reference/remap/functions/xxhash.cue b/website/cue/reference/remap/functions/xxhash.cue index 5e6a4ba712d93..f420bf9f80410 100644 --- a/website/cue/reference/remap/functions/xxhash.cue +++ b/website/cue/reference/remap/functions/xxhash.cue @@ -45,19 +45,19 @@ remap: functions: xxhash: { source: #""" xxhash("foo", "XXH64") """# - return: -3728699739546630719 + return: 3728699739546630719 }, { title: "Calculate a hash using the XXH3-64 algorithm" source: #""" - xxhash("foo", "XXH3-64) + xxhash("foo", "XXH3-64") """# return: -6093828362558603894 }, { title: "Calculate a hash using the XXH3-128 algorithm" source: #""" - xxhash("foo", "XXH3-128) + xxhash("foo", "XXH3-128") """# return: "161745101148472925293886522910304009610" },