From: Modupe Falodun Date: Wed, 26 Jan 2022 21:52:14 +0000 (+0100) Subject: http-response-line: remove unittest X-Git-Tag: suricata-7.0.0-beta1~974 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=154e4eb39580eb5df127c0142c164f89dff60e57;p=thirdparty%2Fsuricata.git http-response-line: remove unittest This test is reimplemented in Suricata-Verify Task: 4911 --- diff --git a/src/detect-http-response-line.c b/src/detect-http-response-line.c index a49e7ab08c..4c297ad977 100644 --- a/src/detect-http-response-line.c +++ b/src/detect-http-response-line.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2016 Open Information Security Foundation +/* Copyright (C) 2007-2022 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -165,103 +165,9 @@ static int DetectHttpResponseLineTest01(void) PASS; } - -/** - *\test Test that the http_response_line content matches against a http request - * which holds the content. - */ -static int DetectHttpResponseLineTest02(void) -{ - TcpSession ssn; - Packet *p = NULL; - ThreadVars th_v; - DetectEngineCtx *de_ctx = NULL; - DetectEngineThreadCtx *det_ctx = NULL; - HtpState *http_state = NULL; - Flow f; - uint8_t http_buf[] = - "GET /index.html HTTP/1.0\r\n" - "Host: www.openinfosecfoundation.org\r\n" - "User-Agent: This is dummy message body\r\n" - "Content-Type: text/html\r\n" - "\r\n"; - uint32_t http_len = sizeof(http_buf) - 1; - uint8_t http_buf2[] = - "HTTP/1.0 200 OK\r\n" - "Content-Type: text/html\r\n" - "Content-Length: 7\r\n" - "\r\n" - "message"; - uint32_t http_len2 = sizeof(http_buf2) - 1; - - AppLayerParserThreadCtx *alp_tctx = AppLayerParserThreadCtxAlloc(); - FAIL_IF_NULL(alp_tctx); - - memset(&th_v, 0, sizeof(th_v)); - memset(&f, 0, sizeof(f)); - memset(&ssn, 0, sizeof(ssn)); - - p = UTHBuildPacket(NULL, 0, IPPROTO_TCP); - FAIL_IF_NULL(p); - - FLOW_INITIALIZE(&f); - f.protoctx = (void *)&ssn; - f.proto = IPPROTO_TCP; - f.flags |= FLOW_IPV4; - - p->flow = &f; - p->flowflags |= (FLOW_PKT_TOSERVER|FLOW_PKT_ESTABLISHED); - p->flags |= PKT_HAS_FLOW | PKT_STREAM_EST; - f.alproto = ALPROTO_HTTP1; - - StreamTcpInitConfig(true); - - de_ctx = DetectEngineCtxInit(); - FAIL_IF_NULL(de_ctx); - - de_ctx->flags |= DE_QUIET; - - de_ctx->sig_list = SigInit(de_ctx,"alert http any any -> any any " - "(http_response_line; content:\"HTTP/1.0 200 OK\"; " - "sid:1;)"); - FAIL_IF_NULL(de_ctx->sig_list); - - SigGroupBuild(de_ctx); - DetectEngineThreadCtxInit(&th_v, (void *)de_ctx, (void *)&det_ctx); - - int r = AppLayerParserParse( - &th_v, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOSERVER, http_buf, http_len); - FAIL_IF(r != 0); - - http_state = f.alstate; - FAIL_IF_NULL(http_state); - - r = AppLayerParserParse( - &th_v, alp_tctx, &f, ALPROTO_HTTP1, STREAM_TOCLIENT, http_buf2, http_len2); - FAIL_IF(r != 0); - - /* do detect */ - SigMatchSignatures(&th_v, de_ctx, det_ctx, p); - FAIL_IF(PacketAlertCheck(p, 1)); - - p->flowflags = (FLOW_PKT_TOCLIENT|FLOW_PKT_ESTABLISHED); - - SigMatchSignatures(&th_v, de_ctx, det_ctx, p); - FAIL_IF(!(PacketAlertCheck(p, 1))); - - AppLayerParserThreadCtxFree(alp_tctx); - DetectEngineCtxFree(de_ctx); - - StreamTcpFreeConfig(true); - FLOW_DESTROY(&f); - UTHFreePackets(&p, 1); - PASS; -} - void DetectHttpResponseLineRegisterTests(void) { UtRegisterTest("DetectHttpResponseLineTest01", DetectHttpResponseLineTest01); - UtRegisterTest("DetectHttpResponseLineTest02", DetectHttpResponseLineTest02); } #endif /* UNITTESTS */ /**