40 static void DetectTransformStripWhitespaceRegisterTests(
void);
42 static void TransformStripWhitespace(
InspectionBuffer *buffer,
void *options);
43 static bool TransformStripWhitespaceValidate(
const uint8_t *content, uint16_t content_len,
void *options);
49 "modify buffer to strip whitespace before inspection";
51 "/rules/transforms.html#strip-whitespace";
53 TransformStripWhitespace;
55 TransformStripWhitespaceValidate;
57 DetectTransformStripWhitespaceSetup;
60 DetectTransformStripWhitespaceRegisterTests;
89 static bool TransformStripWhitespaceValidate(
const uint8_t *content,
90 uint16_t content_len,
void *options)
93 for (uint32_t i = 0; i < content_len; i++) {
94 if (isspace(*content++)) {
102 static void TransformStripWhitespace(
InspectionBuffer *buffer,
void *options)
104 const uint8_t *input = buffer->
inspect;
106 if (input_len == 0) {
109 uint8_t output[input_len];
110 uint8_t *oi = output, *os = output;
113 for (uint32_t i = 0; i < input_len; i++) {
114 if (!isspace(*input)) {
119 uint32_t output_size = oi - os;
128 const uint8_t *input = buffer->
inspect;
130 uint8_t output[input_len * 2];
131 uint8_t *oi = output, *os = output;
134 for (uint32_t i = 0; i < input_len; i++) {
135 if (isspace(*input)) {
141 uint32_t output_size = oi - os;
148 static int DetectTransformStripWhitespaceTest01(
void)
150 const uint8_t *input = (
const uint8_t *)
" A B C D ";
151 uint32_t input_len = strlen((
char *)input);
157 TransformStripWhitespace(&buffer, NULL);
163 static int DetectTransformStripWhitespaceTest02(
void)
165 const uint8_t *input = (
const uint8_t *)
" A B C D ";
166 uint32_t input_len = strlen((
char *)input);
172 TransformDoubleWhitespace(&buffer);
174 TransformDoubleWhitespace(&buffer);
176 TransformStripWhitespace(&buffer, NULL);
182 static int DetectTransformStripWhitespaceTest03(
void)
184 const char rule[] =
"alert http any any -> any any (http_request_line; strip_whitespace; content:\"GET/HTTP\"; sid:1;)";
187 memset(&th_v, 0,
sizeof(th_v));
200 static void DetectTransformStripWhitespaceRegisterTests(
void)
203 DetectTransformStripWhitespaceTest01);
205 DetectTransformStripWhitespaceTest02);
207 DetectTransformStripWhitespaceTest03);