67 char buffer_name[512] =
"";
71 if (!(is_tcp || is_udp)) {
72 SCLogError(
"'frame' keyword only supported for TCP and UDP");
76 char *dot = strchr(value,
'.');
79 const char *val = dot ? dot : value;
80 const char *
proto = dot ? value : NULL;
82 bool is_short =
false;
88 if (!AppProtoIsValid(keyword_alproto)) {
90 keyword_alproto = rule_alproto;
94 keyword_alproto = rule_alproto;
98 SCLogError(
"rule protocol unknown, can't use shorthand notation for frame '%s'",
str);
103 }
else if (!AppProtoEquals(rule_alproto, keyword_alproto)) {
104 SCLogError(
"frame '%s' protocol '%s' mismatch with rule protocol '%s'",
str,
109 const char *frame_str = is_short ?
str : val;
110 int raw_frame_type = -1;
112 if (strcmp(frame_str,
"stream") == 0) {
119 if (is_udp && raw_frame_type < 0)
121 if (raw_frame_type < 0) {
125 BUG_ON(raw_frame_type > UINT8_MAX);
131 strlcpy(buffer_name,
str,
sizeof(buffer_name));
135 uint8_t frame_type = (uint8_t)raw_frame_type;
151static int DetectFrameTestBadRules(
void)
156 const char *sigs[] = {
157 "alert tcp-pkt any any -> any any (frame:tls.pdu; content:\"a\"; sid:1;)",
158 "alert udp any any -> any any (frame:tls.pdu; content:\"a\"; sid:2;)",
159 "alert smb any any -> any any (frame:tls.pdu; content:\"a\"; sid:3;)",
160 "alert tcp any any -> any any (frame:tls; content:\"a\"; sid:4;)",
161 "alert tls any any -> any any (content:\"abc\"; frame:tls.pdu; content:\"a\"; sid:5;)",
162 "alert tls any any -> any any (tls.version:1.0; frame:tls.pdu; content:\"a\"; sid:6;)",
163 "alert tls any any -> any any (frame:smb1.pdu; content:\"a\"; sid:7;)",
167 const char **sig = sigs;
179static void DetectFrameRegisterTests(
void)
181 UtRegisterTest(
"DetectFrameTestBadRules", DetectFrameTestBadRules);
void FrameConfigEnable(const AppProto p, const uint8_t type)
#define FRAME_STREAM_TYPE
int AppLayerParserGetFrameIdByName(uint8_t ipproto, AppProto alproto, const char *name)
const char * AppProtoToString(AppProto alproto)
Maps the ALPROTO_*, to its string equivalent.
AppProto StringToAppProto(const char *proto_name)
Maps a string to its ALPROTO_* equivalent.
int SCDetectBufferSetActiveList(DetectEngineCtx *de_ctx, Signature *s, const int list)
int DetectProtoContainsProto(const DetectProto *dp, int proto)
see if a DetectProto contains a certain proto
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.
int DetectEngineBufferTypeRegisterWithFrameEngines(DetectEngineCtx *de_ctx, const char *name, const int direction, const AppProto alproto, const uint8_t frame_type)
void DetectFrameRegister(void)
Registration function for keyword: ja3_hash.
int SCDetectSignatureSetAppProto(Signature *s, AppProto alproto)
SigTableElmt * sigmatch_table
#define SIG_FLAG_TOCLIENT
#define SIGMATCH_INFO_STICKY_BUFFER
#define SIG_FLAG_TOSERVER
#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.
#define FAIL_IF_NOT_NULL(expr)
Fail a test if expression evaluates to non-NULL.
main detection engine ctx
int(* Setup)(DetectEngineCtx *, Signature *, const char *)
void(* RegisterTests)(void)
size_t strlcpy(char *dst, const char *src, size_t siz)
#define SCLogError(...)
Macro used to log ERROR messages.