|
cwist
Modern C web framework with libttak runtime
|
Bounded, case-insensitive WAF-lite checks. More...
#include <cwist/sys/app/waf.h>#include <cwist/net/http/http.h>#include <cwist/core/mem/alloc.h>#include <string.h>#include <pthread.h>#include <stdint.h>#include <stdbool.h>
Go to the source code of this file.
Macros | |
| #define | WAF_MAX_PATTERNS 64 |
| #define | WAF_MAX_TEXT 4096 |
| #define | WAF_ALPHABET 128 |
Functions | |
| bool | cwist_waf_is_safe (const char *input, size_t length) |
| Check whether a byte string is free of hostile signatures. | |
| char * | cwist_sanitize_html (const char *input) |
| Escape HTML-special characters in a NUL-terminated string. | |
| cwist_middleware_func | cwist_mw_waf_lite (void) |
| Construct the WAF-lite middleware. | |
Bounded, case-insensitive WAF-lite checks.
Definition in file waf.c.
| cwist_middleware_func cwist_mw_waf_lite | ( | void | ) |
Escape HTML-special characters in a NUL-terminated string.
Replaces '&', '<', '>', '"', and '\'' with their HTML entity equivalents and returns a newly allocated buffer holding the escaped text.
| input | Input string; may be NULL. |
input is NULL, on allocation failure, or on size overflow. Definition at line 141 of file waf.c.
References cap, and cwist_alloc().
Check whether a byte string is free of hostile signatures.
Scans input once (O(length)) through the case-insensitive Aho-Corasick automaton, which is built lazily on first call. Matching is ASCII-only: bytes at or above 0x80 reset the automaton state, and control bytes other than tab, newline, and carriage return are rejected outright.
| input | Byte string to scan; may be NULL. |
| length | Number of bytes to scan. |
Definition at line 113 of file waf.c.
References cap, and WAF_ALPHABET.