mirror of https://github.com/OISF/suricata
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
72 lines
2.0 KiB
C
72 lines
2.0 KiB
C
5 years ago
|
/* Copyright (C) 2020 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
|
||
|
* Software Foundation.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU General Public License
|
||
|
* version 2 along with this program; if not, write to the Free Software
|
||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||
|
* 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
/**
|
||
|
* \file
|
||
|
*
|
||
|
* \author Philippe Antoine <p.antoine@catenacyber.fr>
|
||
|
*
|
||
|
* Parser for HTTP2, RFC 7540
|
||
|
*/
|
||
|
|
||
|
#include "suricata-common.h"
|
||
|
#include "stream.h"
|
||
|
#include "conf.h"
|
||
|
|
||
|
#include "util-unittest.h"
|
||
|
|
||
|
#include "app-layer-detect-proto.h"
|
||
|
#include "app-layer-parser.h"
|
||
|
|
||
|
#include "app-layer-http2.h"
|
||
|
#include "rust.h"
|
||
|
|
||
|
static int HTTP2RegisterPatternsForProtocolDetection(void)
|
||
|
{
|
||
|
/* Using the 24 bytes pattern makes AppLayerTest09 fail/leak
|
||
|
* The complete pattern is "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"
|
||
|
*/
|
||
|
if (AppLayerProtoDetectPMRegisterPatternCI(IPPROTO_TCP, ALPROTO_HTTP2,
|
||
|
"PRI * HTTP/2.0\r\n",
|
||
|
16, 0, STREAM_TOSERVER) < 0)
|
||
|
{
|
||
|
return -1;
|
||
|
}
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
static StreamingBufferConfig sbcfg = STREAMING_BUFFER_CONFIG_INITIALIZER;
|
||
|
static SuricataFileContext sfc = { &sbcfg };
|
||
|
|
||
|
void RegisterHTTP2Parsers(void)
|
||
|
{
|
||
|
const char *proto_name = "http2";
|
||
|
|
||
|
if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) {
|
||
|
AppLayerProtoDetectRegisterProtocol(ALPROTO_HTTP2, proto_name);
|
||
|
if (HTTP2RegisterPatternsForProtocolDetection() < 0)
|
||
|
return;
|
||
|
|
||
|
rs_http2_init(&sfc);
|
||
|
rs_http2_register_parser();
|
||
|
}
|
||
|
|
||
|
#ifdef UNITTESTS
|
||
|
//TODOask HTTP2ParserRegisterTests();
|
||
|
#endif
|
||
|
}
|