suricata
detect-nocase.c
Go to the documentation of this file.
1/* Copyright (C) 2007-2010 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/**
19 * \file
20 *
21 * \author Victor Julien <victor@inliniac.net>
22 *
23 * Implements the nocase keyword
24 */
25
26#include "suricata-common.h"
27#include "suricata.h"
28#include "decode.h"
29
30#include "detect.h"
31#include "detect-parse.h"
32#include "detect-content.h"
33#include "detect-nocase.h"
34
35#include "util-debug.h"
36
37static int DetectNocaseSetup (DetectEngineCtx *, Signature *, const char *);
38
40{
42 sigmatch_table[DETECT_NOCASE].desc = "modify content match to be case insensitive";
43 sigmatch_table[DETECT_NOCASE].url = "/rules/payload-keywords.html#nocase";
44 sigmatch_table[DETECT_NOCASE].Setup = DetectNocaseSetup;
46}
47
48/**
49 * \internal
50 * \brief Apply the nocase keyword to the last pattern match, either content or uricontent
51 * \param det_ctx detection engine ctx
52 * \param s signature
53 * \param nullstr should be null
54 * \retval 0 ok
55 * \retval -1 failure
56 */
57static int DetectNocaseSetup (DetectEngineCtx *de_ctx, Signature *s, const char *nullstr)
58{
59 SCEnter();
60
61 SigMatch *pm = NULL;
62 int ret = -1;
63
64 if (nullstr != NULL) {
65 SCLogError("nocase has value");
66 goto end;
67 }
68
69 /* retrieve the sm to apply the nocase against */
71 if (pm == NULL) {
72 SCLogError("nocase needs "
73 "preceding content option");
74 goto end;
75 }
76
79 end:
80 SCReturnInt(ret);
81}
int DetectContentConvertToNocase(DetectEngineCtx *de_ctx, DetectContentData *cd)
void DetectNocaseRegister(void)
SigMatch * DetectGetLastSMFromLists(const Signature *s,...)
Returns the sm with the largest index (added latest) from the lists passed to us.
SigTableElmt * sigmatch_table
#define SIGMATCH_NOOPT
Definition detect.h:1651
DetectEngineCtx * de_ctx
main detection engine ctx
Definition detect.h:932
a single match condition for a signature
Definition detect.h:356
SigMatchCtx * ctx
Definition detect.h:359
const char * url
Definition detect.h:1462
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
Definition detect.h:1441
uint16_t flags
Definition detect.h:1450
const char * desc
Definition detect.h:1461
const char * name
Definition detect.h:1459
Signature container.
Definition detect.h:668
#define SCEnter(...)
Definition util-debug.h:277
#define SCReturnInt(x)
Definition util-debug.h:281
#define SCLogError(...)
Macro used to log ERROR messages.
Definition util-debug.h:267