suricata
detect-http-uri.c
Go to the documentation of this file.
1/* Copyright (C) 2007-2018 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/** \file
19 *
20 * \author Victor Julien <victor@inliniac.net>
21 * \author Pablo Rincon Crespo <pablo.rincon.crespo@gmail.com>
22 */
23
24#include "../suricata-common.h"
25#include "../util-unittest.h"
26
27#include "../detect-isdataat.h"
28#include "../detect-engine-register.h"
29#include "../detect-engine.h"
30#include "../detect-parse.h"
31
32static int DetectHttpUriIsdataatParseTest(void)
33{
37
38 Signature *s = DetectEngineAppendSig(de_ctx, "alert tcp any any -> any any ("
39 "content:\"one\"; http_uri; "
40 "isdataat:!4,relative; sid:1;)");
41 FAIL_IF_NULL(s);
42
43 SigMatch *sm = DetectBufferGetLastSigMatch(s, g_http_uri_buffer_id);
44 FAIL_IF_NULL(sm);
46
48 FAIL_IF_NOT(data->flags & ISDATAAT_RELATIVE);
49 FAIL_IF_NOT(data->flags & ISDATAAT_NEGATED);
50 FAIL_IF(data->flags & ISDATAAT_RAWBYTES);
51
53 PASS;
54}
55
56/**
57 * \brief Register the UNITTESTS for the http_uri keyword
58 */
59static void DetectHttpUriRegisterTests (void)
60{
61 UtRegisterTest("DetectHttpUriIsdataatParseTest", DetectHttpUriIsdataatParseTest);
62}
SigMatch * DetectBufferGetLastSigMatch(const Signature *s, const uint32_t buf_id)
@ DETECT_ISDATAAT
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.
#define ISDATAAT_RELATIVE
#define ISDATAAT_NEGATED
#define ISDATAAT_RAWBYTES
#define DE_QUIET
Definition detect.h:330
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 FAIL_IF_NOT(expr)
Fail a test if expression evaluates to false.
#define PASS
Pass the test.
#define FAIL_IF(expr)
Fail a test if expression evaluates to true.
main detection engine ctx
Definition detect.h:932
uint8_t flags
Definition detect.h:934
a single match condition for a signature
Definition detect.h:356
uint16_t type
Definition detect.h:357
SigMatchCtx * ctx
Definition detect.h:359
Signature container.
Definition detect.h:668