suricata
detect-http2.c
Go to the documentation of this file.
1/* Copyright (C) 2020 Open Information Security Foundation
2 *
3 * You can copy, redistribute or modify this Program under the terms of
4 * the GNU General Public License version 2 as published by the Free
5 * Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * version 2 along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17
18#include "../suricata-common.h"
19
20#include "../detect-engine.h"
21
22#include "../detect-http2.h"
23
24#include "../util-unittest.h"
25
26/**
27 * \test signature with a valid http2.frametype value.
28 */
29
30static int DetectHTTP2frameTypeParseTest01 (void)
31{
34
36 "alert http2 any any -> any any (http2.frametype:GOAWAY; sid:1; rev:1;)");
37 FAIL_IF_NULL(sig);
38
40 PASS;
41}
42
43/**
44 * \brief this function registers unit tests for DetectHTTP2frameType
45 */
47{
48 UtRegisterTest("DetectHTTP2frameTypeParseTest01", DetectHTTP2frameTypeParseTest01);
49}
50
51/**
52 * \test signature with a valid http2.errorcode value.
53 */
54
55static int DetectHTTP2errorCodeParseTest01 (void)
56{
59
61 "alert http2 any any -> any any (http2.errorcode:NO_ERROR; sid:1; rev:1;)");
62 FAIL_IF_NULL(sig);
63
65 PASS;
66}
67
69{
70 UtRegisterTest("DetectHTTP2errorCodeParseTest01", DetectHTTP2errorCodeParseTest01);
71}
72
73/**
74 * \test signature with a valid http2.priority value.
75 */
76
77static int DetectHTTP2priorityParseTest01 (void)
78{
81
83 "alert http2 any any -> any any (http2.priority:>100; sid:1; rev:1;)");
84 FAIL_IF_NULL(sig);
85
87 PASS;
88}
89
91{
92 UtRegisterTest("DetectHTTP2priorityParseTest01", DetectHTTP2priorityParseTest01);
93}
94
95/**
96 * \test signature with a valid http2.window value.
97 */
98
99static int DetectHTTP2windowParseTest01 (void)
100{
103
105 "alert http2 any any -> any any (http2.window:<42; sid:1; rev:1;)");
106 FAIL_IF_NULL(sig);
107
109 PASS;
110}
111
113{
114 UtRegisterTest("DetectHTTP2windowParseTest01", DetectHTTP2windowParseTest01);
115}
116
117
118/**
119 * \test signature with a valid http2.settings value.
120 */
121
122static int DetectHTTP2settingsParseTest01 (void)
123{
126
128 "alert http2 any any -> any any (http2.settings:SETTINGS_MAX_HEADER_LIST_SIZE >1024; sid:1; rev:1;)");
129 FAIL_IF_NULL(sig);
130
132 PASS;
133}
134
136{
137 UtRegisterTest("DetectHTTP2settingsParseTest01", DetectHTTP2settingsParseTest01);
138}
139
140
141/**
142* \test signature with a valid http2.size_update value.
143*/
144
145static int DetectHTTP2sizeUpdateParseTest01 (void)
146{
149
151 "alert http2 any any -> any any (http2.size_update:>4096; sid:1; rev:1;)");
152 FAIL_IF_NULL(sig);
153
155 PASS;
156}
157
159{
160 UtRegisterTest("DetectHTTP2sizeUpdateParseTest01", DetectHTTP2sizeUpdateParseTest01);
161}
DetectEngineCtx * DetectEngineCtxInit(void)
void DetectEngineCtxFree(DetectEngineCtx *)
Free a DetectEngineCtx::
Signature * DetectEngineAppendSig(DetectEngineCtx *, const char *)
Parse and append a Signature into the Detection Engine Context signature list.
void DetectHTTP2settingsRegisterTests(void)
void DetectHTTP2sizeUpdateRegisterTests(void)
void DetectHTTP2priorityRegisterTests(void)
void DetectHTTP2frameTypeRegisterTests(void)
this function registers unit tests for DetectHTTP2frameType
void DetectHTTP2errorCodeRegisterTests(void)
void DetectHTTP2windowRegisterTests(void)
DetectEngineCtx * de_ctx
#define FAIL_IF_NULL(expr)
Fail a test if expression evaluates to NULL.
void UtRegisterTest(const char *name, int(*TestFn)(void))
Register unit test.
#define PASS
Pass the test.
main detection engine ctx
Definition detect.h:932
Signature container.
Definition detect.h:668