suricata
detect-bypass.c
Go to the documentation of this file.
1/* Copyright (C) 2016-2022 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 Giuseppe Longo <glongo@stamus-networks.com>
22 *
23 */
24
25#include "suricata-common.h"
26#include "threads.h"
27#include "app-layer.h"
28#include "app-layer-parser.h"
29#include "decode.h"
30
31#include "detect.h"
32#include "detect-parse.h"
33
34#include "detect-engine.h"
35#include "detect-engine-mpm.h"
36#include "detect-engine-state.h"
38#include "detect-bypass.h"
39
40#include "flow.h"
41#include "flow-var.h"
42#include "flow-util.h"
43
44#include "stream-tcp.h"
45
46#include "util-debug.h"
47#include "util-spm-bm.h"
48#include "util-unittest.h"
50#include "util-device-private.h"
51
52static int DetectBypassMatch(DetectEngineThreadCtx *, Packet *,
53 const Signature *, const SigMatchCtx *);
54static int DetectBypassSetup(DetectEngineCtx *, Signature *, const char *);
55
56/**
57 * \brief Registration function for keyword: bypass
58 */
60{
62 sigmatch_table[DETECT_BYPASS].desc = "call the bypass callback when the match of a sig is complete";
63 sigmatch_table[DETECT_BYPASS].url = "/rules/bypass-keyword.html";
64 sigmatch_table[DETECT_BYPASS].Match = DetectBypassMatch;
65 sigmatch_table[DETECT_BYPASS].Setup = DetectBypassSetup;
68}
69
70static int DetectBypassSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str)
71{
72
73 if (s->flags & SIG_FLAG_FILESTORE) {
74 SCLogError("bypass can't work with filestore keyword");
75 return -1;
76 }
78
80 NULL) {
81 return -1;
82 }
83
84 return 0;
85}
86
87static int DetectBypassMatch(DetectEngineThreadCtx *det_ctx, Packet *p,
88 const Signature *s, const SigMatchCtx *ctx)
89{
91
92 return 1;
93}
void DetectBypassRegister(void)
Registration function for keyword: bypass.
Data structures and function prototypes for keeping state for the detection engine.
SigMatch * SCSigMatchAppendSMToList(DetectEngineCtx *de_ctx, Signature *s, uint16_t type, SigMatchCtx *ctx, const int list)
Append a SigMatch to the list type.
SigTableElmt * sigmatch_table
#define SIG_FLAG_FILESTORE
Definition detect.h:269
#define SIGMATCH_NOOPT
Definition detect.h:1651
@ DETECT_SM_LIST_POSTMATCH
Definition detect.h:127
#define SIG_FLAG_BYPASS
Definition detect.h:276
DetectEngineCtx * de_ctx
void PacketBypassCallback(Packet *p)
Definition decode.c:530
struct Thresholds ctx
main detection engine ctx
Definition detect.h:932
Used to start a pointer to SigMatch context Should never be dereferenced without casting to something...
Definition detect.h:351
const char * url
Definition detect.h:1462
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
Definition detect.h:1441
void(* Free)(DetectEngineCtx *, void *)
Definition detect.h:1446
uint16_t flags
Definition detect.h:1450
const char * desc
Definition detect.h:1461
int(* Match)(DetectEngineThreadCtx *, Packet *, const Signature *, const SigMatchCtx *)
Definition detect.h:1421
const char * name
Definition detect.h:1459
Signature container.
Definition detect.h:668
uint32_t flags
Definition detect.h:669
#define str(s)
#define SCLogError(...)
Macro used to log ERROR messages.
Definition util-debug.h:267