PageRenderTime 23ms CodeModel.GetById 8ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/src/detect-file-data.c

https://github.com/decanio/suricata-tilera
C | 84 lines | 38 code | 10 blank | 36 comment | 3 complexity | 3b895c0a4136b9b02c6eeee7a597864a MD5 | raw file
 1/* Copyright (C) 2007-2011 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 */
24
25#include "suricata-common.h"
26#include "threads.h"
27#include "debug.h"
28#include "decode.h"
29
30#include "detect.h"
31#include "detect-parse.h"
32
33#include "detect-engine.h"
34#include "detect-engine-mpm.h"
35#include "detect-engine-state.h"
36
37#include "flow.h"
38#include "flow-var.h"
39#include "flow-util.h"
40
41#include "util-debug.h"
42#include "util-spm-bm.h"
43#include "util-unittest.h"
44#include "util-unittest-helper.h"
45
46static int DetectFiledataSetup (DetectEngineCtx *, Signature *, char *);
47
48/**
49 * \brief Registration function for keyword: file_data
50 */
51void DetectFiledataRegister(void) {
52    sigmatch_table[DETECT_FILE_DATA].name = "file_data";
53    sigmatch_table[DETECT_FILE_DATA].desc = "make content keywords match on HTTP response body";
54    sigmatch_table[DETECT_FILE_DATA].url = "https://redmine.openinfosecfoundation.org/projects/suricata/wiki/HTTP-keywords#file_data";
55    sigmatch_table[DETECT_FILE_DATA].Match = NULL;
56    sigmatch_table[DETECT_FILE_DATA].AppLayerMatch = NULL;
57    sigmatch_table[DETECT_FILE_DATA].alproto = ALPROTO_HTTP;
58    sigmatch_table[DETECT_FILE_DATA].Setup = DetectFiledataSetup;
59    sigmatch_table[DETECT_FILE_DATA].Free  = NULL;
60    sigmatch_table[DETECT_FILE_DATA].RegisterTests = NULL;
61}
62
63/**
64 * \brief this function is used to parse filedata options
65 * \brief into the current signature
66 *
67 * \param de_ctx pointer to the Detection Engine Context
68 * \param s pointer to the Current Signature
69 * \param str pointer to the user provided "filestore" option
70 *
71 * \retval 0 on Success
72 * \retval -1 on Failure
73 */
74static int DetectFiledataSetup (DetectEngineCtx *de_ctx, Signature *s, char *str)
75{
76    SCEnter();
77    if ((s->init_flags & SIG_FLAG_INIT_FLOW) && (s->flags & SIG_FLAG_TOSERVER) && !(s->flags & SIG_FLAG_TOCLIENT)) {
78        SCLogError(SC_ERR_INVALID_SIGNATURE, "Can't use file_data with flow:to_server or from_client with http.");
79        return -1;
80    }
81    s->init_flags |= SIG_FLAG_INIT_FILE_DATA;
82
83    return 0;
84}