Skip to content

Commit

Permalink
http1/detect: code simplification
Browse files Browse the repository at this point in the history
- DetectEngineInspectBufferHttpHeader is only used with ALPROTO_HTTP1
- engine->progress should be HTP_REQUEST_HEADERS or HTP_RESPONSE_HEADERS based on the direction
  • Loading branch information
catenacyber authored and victorjulien committed Nov 28, 2024
1 parent 13f420c commit 7682816
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/detect-http-header.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ static uint8_t DetectEngineInspectBufferHttpHeader(DetectEngineCtx *de_ctx,

const int list_id = engine->sm_list;
InspectionBuffer *buffer = InspectionBufferGet(det_ctx, list_id);
bool eof =
(AppLayerParserGetStateProgress(f->proto, f->alproto, txv, flags) > engine->progress);
if (buffer->inspect == NULL) {
SCLogDebug("setting up inspect buffer %d", list_id);

Expand Down Expand Up @@ -209,14 +211,8 @@ static uint8_t DetectEngineInspectBufferHttpHeader(DetectEngineCtx *de_ctx,
return DETECT_ENGINE_INSPECT_SIG_MATCH;
}
end:
if (flags & STREAM_TOSERVER) {
if (AppLayerParserGetStateProgress(IPPROTO_TCP, ALPROTO_HTTP1, txv, flags) >
HTP_REQUEST_HEADERS)
return DETECT_ENGINE_INSPECT_SIG_CANT_MATCH;
} else {
if (AppLayerParserGetStateProgress(IPPROTO_TCP, ALPROTO_HTTP1, txv, flags) >
HTP_RESPONSE_HEADERS)
return DETECT_ENGINE_INSPECT_SIG_CANT_MATCH;
if (eof) {
return DETECT_ENGINE_INSPECT_SIG_CANT_MATCH;
}
return DETECT_ENGINE_INSPECT_SIG_NO_MATCH;
}
Expand Down

0 comments on commit 7682816

Please sign in to comment.