vrl/stdlib/
mod.rs

1#![deny(warnings, clippy::pedantic)]
2pub use wasm_unsupported_function::WasmUnsupportedFunction;
3
4use crate::compiler::Function;
5
6mod ip_utils;
7mod json_utils;
8mod string_utils;
9mod util;
10mod wasm_unsupported_function;
11
12cfg_if::cfg_if! {
13    if #[cfg(feature = "stdlib-base")] {
14        // Base stdlib modules (always included with stdlib-base)
15        mod abs;
16        mod append;
17        mod array;
18        mod assert;
19        mod assert_eq;
20        mod basename;
21        mod boolean;
22        mod ceil;
23        mod casing;
24        mod chunks;
25        mod community_id;
26        mod compact;
27        mod contains;
28        mod contains_all;
29        mod crc;
30        mod decode_base16;
31        mod decode_base64;
32        mod decode_charset;
33        mod decode_gzip;
34        mod decode_lz4;
35        mod decode_mime_q;
36        mod decode_percent;
37        mod decode_punycode;
38        mod decode_snappy;
39        mod decode_zlib;
40        mod decode_zstd;
41        mod decrypt;
42        mod decrypt_ip;
43        mod del;
44        mod dirname;
45        mod downcase;
46        mod encode_base16;
47        mod encode_base64;
48        mod encode_charset;
49        mod encode_gzip;
50        mod encode_json;
51        mod encode_key_value;
52        mod encode_logfmt;
53        mod encode_lz4;
54        mod encode_percent;
55        mod encode_punycode;
56        mod encode_snappy;
57        mod encode_zlib;
58        mod encode_zstd;
59        mod encrypt;
60        mod encrypt_ip;
61        mod ends_with;
62        mod exists;
63        mod filter;
64        mod find;
65        mod flatten;
66        mod float;
67        mod floor;
68        mod for_each;
69        mod format_int;
70        mod format_number;
71        mod format_timestamp;
72        mod from_unix_timestamp;
73        mod get;
74        mod haversine;
75        mod hmac;
76        mod includes;
77        mod integer;
78        mod ip_aton;
79        mod ip_cidr_contains;
80        mod ip_ntoa;
81        mod ip_ntop;
82        mod ip_pton;
83        mod ip_subnet;
84        mod ip_to_ipv6;
85        mod ipv6_to_ipv4;
86        mod is_array;
87        mod is_boolean;
88        mod is_empty;
89        mod is_float;
90        mod is_integer;
91        mod is_ipv4;
92        mod is_ipv6;
93        mod is_json;
94        mod is_null;
95        mod is_nullish;
96        mod is_object;
97        mod is_regex;
98        mod is_string;
99        mod is_timestamp;
100        mod join;
101        mod keys;
102        mod length;
103        mod log;
104        mod log_util;
105        mod map_keys;
106        mod map_values;
107        mod r#match;
108        mod match_any;
109        mod match_array;
110        mod match_datadog_query;
111        mod md5;
112        mod merge;
113        mod mod_func;
114        mod now;
115        mod object;
116        mod object_from_array;
117        mod parse_apache_log;
118        mod parse_aws_alb_log;
119        mod parse_aws_cloudwatch_log_subscription_message;
120        mod parse_aws_vpc_flow_log;
121        mod parse_bytes;
122        mod parse_cbor;
123        mod parse_cef;
124        mod parse_common_log;
125        mod parse_csv;
126        mod parse_duration;
127        mod parse_float;
128        mod parse_glog;
129        mod parse_grok;
130        mod parse_groks;
131        mod parse_influxdb;
132        mod parse_int;
133        mod parse_json;
134        mod parse_key_value;
135        mod parse_klog;
136        mod parse_linux_authorization;
137        mod parse_logfmt;
138        mod parse_nginx_log;
139        mod parse_query_string;
140        mod parse_regex;
141        mod parse_regex_all;
142        mod parse_ruby_hash;
143        mod parse_syslog;
144        mod parse_timestamp;
145        mod parse_tokens;
146        mod parse_url;
147        mod parse_user_agent;
148        mod parse_xml;
149        mod parse_yaml;
150        mod pop;
151        mod push;
152        mod random_bool;
153        mod random_bytes;
154        mod random_float;
155        mod random_int;
156        mod redact;
157        mod remove;
158        mod replace;
159        mod replace_with;
160        mod round;
161        mod seahash;
162        mod set;
163        mod sha1;
164        mod sha2;
165        mod sha3;
166        mod shannon_entropy;
167        mod sieve;
168        mod slice;
169        mod split;
170        mod split_path;
171        mod starts_with;
172        mod string;
173        mod strip_ansi_escape_codes;
174        mod strip_whitespace;
175        mod strlen;
176        mod tag_types_externally;
177        mod tally;
178        mod tally_value;
179        mod timestamp;
180        mod to_bool;
181        mod to_float;
182        mod to_int;
183        mod to_regex;
184        mod to_string;
185        mod to_syslog_facility;
186        mod to_syslog_facility_code;
187        mod to_syslog_level;
188        mod to_syslog_severity;
189        mod to_unix_timestamp;
190        mod truncate;
191        mod type_def;
192        mod unflatten;
193        mod unique;
194        mod unnest;
195        mod upcase;
196        mod uuid_from_friendly_id;
197        mod uuid_v4;
198        mod uuid_v7;
199        mod values;
200        mod xxhash;
201        mod zip;
202
203        // Environment functions (gated by enable_env_functions)
204        cfg_if::cfg_if! {
205            if #[cfg(feature = "enable_env_functions")] {
206                mod get_env_var;
207            }
208        }
209
210        // System functions (gated by enable_system_functions)
211        cfg_if::cfg_if! {
212            if #[cfg(feature = "enable_system_functions")] {
213                mod encode_proto;
214                mod get_hostname;
215                mod get_timezone_name;
216                mod parse_etld;
217                mod parse_proto;
218                mod validate_json_schema;
219            }
220        }
221
222        // Network functions (gated by enable_network_functions)
223        cfg_if::cfg_if! {
224            if #[cfg(feature = "enable_network_functions")] {
225                mod dns_lookup;
226                mod http_request;
227                mod reverse_dns;
228            }
229        }
230
231        // -----------------------------------------------------------------------------
232
233        // Macro to keep pub use and all() function in sync
234        macro_rules! stdlib_functions {
235            (
236                $(
237                    $(#[$attr:meta])*
238                    $path:path
239                ),* $(,)?
240            ) => {
241                // Generate pub use statements
242                $(
243                    $(#[$attr])*
244                    pub use $path;
245                )*
246
247                // Generate the all() function
248                #[must_use]
249                #[allow(clippy::too_many_lines)]
250                pub fn all() -> Vec<Box<dyn Function>> {
251                    vec![
252                        $(
253                            $(#[$attr])*
254                            Box::new($path),
255                        )*
256                    ]
257                }
258            };
259        }
260
261        stdlib_functions! {
262            // ===== Base stdlib functions (always included with stdlib-base) =====
263            self::hmac::Hmac,
264            abs::Abs,
265            append::Append,
266            assert::Assert,
267            assert_eq::AssertEq,
268            basename::BaseName,
269            boolean::Boolean,
270            ceil::Ceil,
271            chunks::Chunks,
272            compact::Compact,
273            contains::Contains,
274            contains_all::ContainsAll,
275            decode_base16::DecodeBase16,
276            decode_base64::DecodeBase64,
277            decode_charset::DecodeCharset,
278            decode_gzip::DecodeGzip,
279            decode_lz4::DecodeLz4,
280            decode_mime_q::DecodeMimeQ,
281            decode_percent::DecodePercent,
282            decode_punycode::DecodePunycode,
283            decode_snappy::DecodeSnappy,
284            decode_zlib::DecodeZlib,
285            decode_zstd::DecodeZstd,
286            decrypt::Decrypt,
287            decrypt_ip::DecryptIp,
288            del::Del,
289            dirname::DirName,
290            downcase::Downcase,
291            casing::camelcase::Camelcase,
292            casing::pascalcase::Pascalcase,
293            casing::snakecase::Snakecase,
294            casing::screamingsnakecase::ScreamingSnakecase,
295            casing::kebabcase::Kebabcase,
296            encode_base16::EncodeBase16,
297            encode_base64::EncodeBase64,
298            encode_charset::EncodeCharset,
299            encode_gzip::EncodeGzip,
300            encode_lz4::EncodeLz4,
301            encode_json::EncodeJson,
302            encode_key_value::EncodeKeyValue,
303            encode_logfmt::EncodeLogfmt,
304            encode_percent::EncodePercent,
305            encode_punycode::EncodePunycode,
306            encode_snappy::EncodeSnappy,
307            encode_zlib::EncodeZlib,
308            encode_zstd::EncodeZstd,
309            encrypt::Encrypt,
310            encrypt_ip::EncryptIp,
311            ends_with::EndsWith,
312            exists::Exists,
313            filter::Filter,
314            find::Find,
315            flatten::Flatten,
316            float::Float,
317            floor::Floor,
318            for_each::ForEach,
319            format_int::FormatInt,
320            format_number::FormatNumber,
321            format_timestamp::FormatTimestamp,
322            from_unix_timestamp::FromUnixTimestamp,
323            self::community_id::CommunityID,
324            get::Get,
325            haversine::Haversine,
326            includes::Includes,
327            integer::Integer,
328            ip_aton::IpAton,
329            ip_cidr_contains::IpCidrContains,
330            ip_ntoa::IpNtoa,
331            ip_ntop::IpNtop,
332            ip_pton::IpPton,
333            ip_subnet::IpSubnet,
334            ip_to_ipv6::IpToIpv6,
335            ipv6_to_ipv4::Ipv6ToIpV4,
336            is_array::IsArray,
337            is_boolean::IsBoolean,
338            is_empty::IsEmpty,
339            is_float::IsFloat,
340            is_integer::IsInteger,
341            is_ipv4::IsIpv4,
342            is_ipv6::IsIpv6,
343            is_json::IsJson,
344            is_null::IsNull,
345            is_nullish::IsNullish,
346            is_object::IsObject,
347            is_regex::IsRegex,
348            is_string::IsString,
349            is_timestamp::IsTimestamp,
350            join::Join,
351            keys::Keys,
352            length::Length,
353            log::Log,
354            map_keys::MapKeys,
355            map_values::MapValues,
356            match_any::MatchAny,
357            match_array::MatchArray,
358            match_datadog_query::MatchDatadogQuery,
359            merge::Merge,
360            mod_func::Mod,
361            now::Now,
362            object::Object,
363            object_from_array::ObjectFromArray,
364            parse_apache_log::ParseApacheLog,
365            parse_aws_alb_log::ParseAwsAlbLog,
366            parse_aws_cloudwatch_log_subscription_message::ParseAwsCloudWatchLogSubscriptionMessage,
367            parse_aws_vpc_flow_log::ParseAwsVpcFlowLog,
368            parse_bytes::ParseBytes,
369            parse_cbor::ParseCbor,
370            parse_cef::ParseCef,
371            parse_common_log::ParseCommonLog,
372            parse_csv::ParseCsv,
373            parse_duration::ParseDuration,
374            parse_float::ParseFloat,
375            parse_glog::ParseGlog,
376            parse_grok::ParseGrok,
377            parse_groks::ParseGroks,
378            parse_influxdb::ParseInfluxDB,
379            parse_int::ParseInt,
380            parse_json::ParseJson,
381            parse_key_value::ParseKeyValue,
382            parse_klog::ParseKlog,
383            parse_linux_authorization::ParseLinuxAuthorization,
384            parse_logfmt::ParseLogFmt,
385            parse_nginx_log::ParseNginxLog,
386            parse_query_string::ParseQueryString,
387            parse_regex::ParseRegex,
388            parse_regex_all::ParseRegexAll,
389            parse_ruby_hash::ParseRubyHash,
390            parse_syslog::ParseSyslog,
391            parse_timestamp::ParseTimestamp,
392            parse_tokens::ParseTokens,
393            parse_url::ParseUrl,
394            parse_user_agent::ParseUserAgent,
395            parse_xml::ParseXml,
396            parse_yaml::ParseYaml,
397            pop::Pop,
398            push::Push,
399            r#match::Match,
400            random_bool::RandomBool,
401            random_bytes::RandomBytes,
402            random_float::RandomFloat,
403            random_int::RandomInt,
404            redact::Redact,
405            remove::Remove,
406            replace::Replace,
407            replace_with::ReplaceWith,
408            round::Round,
409            set::Set,
410            sha2::Sha2,
411            sha3::Sha3,
412            shannon_entropy::ShannonEntropy,
413            sieve::Sieve,
414            slice::Slice,
415            split::Split,
416            split_path::SplitPath,
417            starts_with::StartsWith,
418            string::String,
419            strip_ansi_escape_codes::StripAnsiEscapeCodes,
420            strip_whitespace::StripWhitespace,
421            strlen::Strlen,
422            tag_types_externally::TagTypesExternally,
423            tally::Tally,
424            tally_value::TallyValue,
425            timestamp::Timestamp,
426            to_bool::ToBool,
427            to_float::ToFloat,
428            to_int::ToInt,
429            to_regex::ToRegex,
430            to_string::ToString,
431            to_syslog_facility_code::ToSyslogFacilityCode,
432            to_syslog_facility::ToSyslogFacility,
433            to_syslog_level::ToSyslogLevel,
434            to_syslog_severity::ToSyslogSeverity,
435            to_unix_timestamp::ToUnixTimestamp,
436            truncate::Truncate,
437            type_def::TypeDef,
438            unflatten::Unflatten,
439            unique::Unique,
440            unnest::Unnest,
441            upcase::Upcase,
442            uuid_from_friendly_id::UuidFromFriendlyId,
443            uuid_v4::UuidV4,
444            uuid_v7::UuidV7,
445            values::Values,
446            zip::Zip,
447            self::array::Array,
448            self::md5::Md5,
449            self::seahash::Seahash,
450            self::sha1::Sha1,
451            self::xxhash::Xxhash,
452            self::crc::Crc,
453
454            // Environment functions (enable_env_functions)
455            #[cfg(feature = "enable_env_functions")]
456            get_env_var::GetEnvVar,
457
458            // System functions (enable_system_functions)
459            #[cfg(feature = "enable_system_functions")]
460            encode_proto::EncodeProto,
461            #[cfg(feature = "enable_system_functions")]
462            get_hostname::GetHostname,
463            #[cfg(feature = "enable_system_functions")]
464            get_timezone_name::GetTimezoneName,
465            #[cfg(feature = "enable_system_functions")]
466            parse_etld::ParseEtld,
467            #[cfg(feature = "enable_system_functions")]
468            parse_proto::ParseProto,
469            #[cfg(feature = "enable_system_functions")]
470            validate_json_schema::ValidateJsonSchema,
471
472            // Network functions (enable_network_functions)
473            #[cfg(feature = "enable_network_functions")]
474            self::dns_lookup::DnsLookup,
475            #[cfg(feature = "enable_network_functions")]
476            http_request::HttpRequest,
477            #[cfg(feature = "enable_network_functions")]
478            reverse_dns::ReverseDns,
479        }
480
481        #[cfg(feature = "enable_system_functions")]
482        pub use get_timezone_name::get_name_for_timezone;
483    }
484}