|
Network System 0.1.1
High-performance modular networking library for scalable client-server applications
|
Message validator for network input validation. More...
#include <message_validator.h>

Static Public Member Functions | |
| static bool | validate_size (size_t size, size_t max_size=message_limits::MAX_MESSAGE_SIZE) noexcept |
| Validate message size against limit. | |
| static void | validate_size_or_throw (size_t size, size_t max_size=message_limits::MAX_MESSAGE_SIZE) |
| Validate and throw if size exceeds limit. | |
| static size_t | safe_copy (void *dest, size_t dest_size, const void *src, size_t src_size) noexcept |
| Safe buffer copy with size validation. | |
| static size_t | safe_strcpy (char *dest, size_t dest_size, const char *src) noexcept |
| Safe string copy with null termination. | |
| static validation_result | validate_http_header (std::string_view header) noexcept |
| Validate HTTP header. | |
| static bool | validate_header_count (size_t count) noexcept |
| Validate HTTP header count. | |
| static bool | validate_websocket_frame (size_t payload_length, size_t max_size=message_limits::MAX_WEBSOCKET_FRAME) noexcept |
| Validate WebSocket frame payload size. | |
| static validation_result | validate_url (std::string_view url) noexcept |
| Validate URL length. | |
| static bool | contains_suspicious_pattern (std::string_view data) noexcept |
| Check if data contains potential injection patterns. | |
| static std::string | sanitize_string (std::string_view input) |
| Sanitize string by removing control characters. | |
| static size_t | safe_buffer_size (size_t requested_size, size_t max_size=message_limits::MAX_MESSAGE_SIZE) noexcept |
| Calculate safe buffer size for operations. | |
Message validator for network input validation.
Provides static methods for validating network input to prevent buffer overflow and other input-related vulnerabilities.
All methods are stateless and thread-safe.
Definition at line 121 of file message_validator.h.
|
inlinestaticnodiscardnoexcept |
Check if data contains potential injection patterns.
Basic check for common injection patterns. Should be used in conjunction with proper input sanitization.
| data | Data to check |
Definition at line 288 of file message_validator.h.
|
inlinestaticnodiscardnoexcept |
Calculate safe buffer size for operations.
Returns a buffer size that is safe to use, capped at max_size.
| requested_size | Requested buffer size |
| max_size | Maximum allowed size |
Definition at line 332 of file message_validator.h.
|
inlinestaticnodiscardnoexcept |
Safe buffer copy with size validation.
Copies data from source to destination, ensuring no buffer overflow. Copies the minimum of dest_size and src_size bytes.
| dest | Destination buffer |
| dest_size | Size of destination buffer |
| src | Source buffer |
| src_size | Size of source data |
Definition at line 165 of file message_validator.h.
|
inlinestaticnodiscardnoexcept |
Safe string copy with null termination.
| dest | Destination buffer |
| dest_size | Size of destination buffer |
| src | Source string |
Definition at line 187 of file message_validator.h.
|
inlinestaticnodiscard |
Sanitize string by removing control characters.
| input | String to sanitize |
Definition at line 309 of file message_validator.h.
|
inlinestaticnodiscardnoexcept |
Validate HTTP header count.
| count | Number of headers |
Definition at line 243 of file message_validator.h.
References kcenon::network::message_limits::MAX_HEADER_COUNT.
|
inlinestaticnodiscardnoexcept |
Validate HTTP header.
Checks for:
| header | Header string to validate |
Definition at line 215 of file message_validator.h.
References kcenon::network::invalid_character, kcenon::network::message_limits::MAX_HEADER_SIZE, kcenon::network::null_byte_detected, kcenon::network::ok, and kcenon::network::size_exceeded.
|
inlinestaticnodiscardnoexcept |
Validate message size against limit.
| size | Size to validate |
| max_size | Maximum allowed size (default: MAX_MESSAGE_SIZE) |
Definition at line 130 of file message_validator.h.
|
inlinestatic |
Validate and throw if size exceeds limit.
| size | Size to validate |
| max_size | Maximum allowed size |
| std::length_error | if size exceeds limit |
Definition at line 143 of file message_validator.h.
|
inlinestaticnodiscardnoexcept |
Validate URL length.
| url | URL to validate |
Definition at line 266 of file message_validator.h.
References kcenon::network::message_limits::MAX_URL_LENGTH, kcenon::network::null_byte_detected, kcenon::network::ok, and kcenon::network::size_exceeded.
|
inlinestaticnodiscardnoexcept |
Validate WebSocket frame payload size.
| payload_length | Payload length to validate |
| max_size | Maximum allowed size (default: MAX_WEBSOCKET_FRAME) |
Definition at line 254 of file message_validator.h.