Skip to content

Commit

Permalink
detect/flow: fix DETECT_FLOW_FLAG_ESTABLISHED check
Browse files Browse the repository at this point in the history
Ticket: #6448
  • Loading branch information
xsnos-repo committed Nov 14, 2023
1 parent b6cd66f commit 9c49c49
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/detect-flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,10 @@ static DetectFlowData *DetectFlowParse (DetectEngineCtx *de_ctx, const char *flo
if (fd->flags & DETECT_FLOW_FLAG_ESTABLISHED) {
SCLogError("DETECT_FLOW_FLAG_ESTABLISHED flag is already set");
goto error;
} else if (fd->flags & DETECT_FLOW_FLAG_NOT_ESTABLISHED) {
SCLogError("cannot set DETECT_FLOW_FLAG_ESTABLISHED, "
"DETECT_FLOW_FLAG_NOT_ESTABLISHED already set");
goto error;
} else if (fd->flags & DETECT_FLOW_FLAG_STATELESS) {
SCLogError("DETECT_FLOW_FLAG_STATELESS already set");
goto error;
Expand All @@ -236,7 +240,7 @@ static DetectFlowData *DetectFlowParse (DetectEngineCtx *de_ctx, const char *flo
if (fd->flags & DETECT_FLOW_FLAG_NOT_ESTABLISHED) {
SCLogError("DETECT_FLOW_FLAG_NOT_ESTABLISHED flag is already set");
goto error;
} else if (fd->flags & DETECT_FLOW_FLAG_NOT_ESTABLISHED) {
} else if (fd->flags & DETECT_FLOW_FLAG_ESTABLISHED) {
SCLogError("cannot set DETECT_FLOW_FLAG_NOT_ESTABLISHED, "
"DETECT_FLOW_FLAG_ESTABLISHED already set");
goto error;
Expand Down Expand Up @@ -946,6 +950,19 @@ static int DetectFlowTestParse21 (void)
PASS;
}

/**
* \test DetectFlowTestParse22 is a test for setting the established,not_established flow opts both
*/
static int DetectFlowTestParse22(void)
{
DetectFlowData *fd = NULL;
fd = DetectFlowParse(NULL, "established,not_established");
FAIL_IF_NOT_NULL(fd);
fd = DetectFlowParse(NULL, "not_established,established");
FAIL_IF_NOT_NULL(fd);
PASS;
}

static int DetectFlowSigTest01(void)
{
uint8_t *buf = (uint8_t *)"supernovaduper";
Expand Down Expand Up @@ -1104,6 +1121,7 @@ static void DetectFlowRegisterTests(void)
UtRegisterTest("DetectFlowTestParse20", DetectFlowTestParse20);
UtRegisterTest("DetectFlowTestParseNocase20", DetectFlowTestParseNocase20);
UtRegisterTest("DetectFlowTestParse21", DetectFlowTestParse21);
UtRegisterTest("DetectFlowTestParse22", DetectFlowTestParse22);
UtRegisterTest("DetectFlowTestParseNotEstablished",
DetectFlowTestParseNotEstablished);
UtRegisterTest("DetectFlowTestParseNoFrag", DetectFlowTestParseNoFrag);
Expand Down

0 comments on commit 9c49c49

Please sign in to comment.