varpulis_connectors/limits.rs
1//! Resource limits for event parsing to prevent denial-of-service attacks.
2//!
3//! These constants bound memory allocation during event ingestion.
4//! All connectors (Kafka, MQTT, HTTP, file) enforce these limits.
5
6/// Maximum raw payload size from any connector (1 MB).
7/// Events larger than this are rejected before JSON parsing.
8pub const MAX_EVENT_PAYLOAD_BYTES: usize = 1_048_576;
9
10/// Maximum number of top-level fields per event.
11/// Prevents OOM from events with millions of keys.
12pub const MAX_FIELDS_PER_EVENT: usize = 1_024;
13
14/// Maximum length of a single string value (256 KB).
15/// Prevents OOM from multi-gigabyte string fields.
16pub const MAX_STRING_VALUE_BYTES: usize = 262_144;
17
18/// Maximum nesting depth for JSON/Value structures.
19/// Prevents stack overflow from deeply nested payloads.
20pub const MAX_JSON_DEPTH: usize = 32;
21
22/// Maximum number of elements in an array value.
23pub const MAX_ARRAY_ELEMENTS: usize = 10_000;
24
25/// Maximum line length for streaming event file reader (1 MB).
26/// Lines longer than this are skipped with a warning.
27pub const MAX_LINE_LENGTH: usize = 1_048_576;