]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2069 in SNORT/snort3 from ~OZAIKA/snort3:http2_draft_test to...
authorShravan Rangarajuvenkata (shrarang) <shrarang@cisco.com>
Tue, 24 Mar 2020 22:40:00 +0000 (22:40 +0000)
committerShravan Rangarajuvenkata (shrarang) <shrarang@cisco.com>
Tue, 24 Mar 2020 22:40:00 +0000 (22:40 +0000)
Squashed commit of the following:

commit 3c70e324722c55684edd27c3689db0d699dfcad8
Author: Oleksii Zaika <ozaika@cisco.com>
Date:   Tue Mar 10 08:26:02 2020 -0400

    appid: support detection for first stream in http/2 session

src/network_inspectors/appid/CMakeLists.txt
src/network_inspectors/appid/appid_http_event_handler.cc
src/network_inspectors/appid/client_plugins/client_discovery.cc
src/network_inspectors/appid/detector_plugins/detector_http.cc [deleted file]
src/network_inspectors/appid/detector_plugins/detector_http.h [deleted file]
src/network_inspectors/appid/lua_detector_api.cc
src/network_inspectors/appid/lua_detector_module.cc
src/network_inspectors/appid/service_plugins/service_discovery.cc
src/network_inspectors/appid/test/appid_http_event_test.cc

index 49e83d0f37829e1b953f7026a093841885a45702..90afa09efab7f996e29c78da52d475c998906bc1 100644 (file)
@@ -116,8 +116,6 @@ set ( SP_APPID_SOURCES
 set ( DP_APPID_SOURCES
     detector_plugins/detector_dns.cc
     detector_plugins/detector_dns.h
-    detector_plugins/detector_http.cc
-    detector_plugins/detector_http.h
     detector_plugins/detector_imap.cc
     detector_plugins/detector_imap.h
     detector_plugins/detector_kerberos.cc
index 190650583d4807af34c70d1bd87db37774d026a3..cea15369e940bbf6dca73111923b60bb81d7e8f5 100644 (file)
@@ -137,6 +137,10 @@ void HttpEventHandler::handle(DataEvent& event, Flow* flow)
 
     if (asd->service.get_id() == APP_ID_HTTP)
     {
+        if (http_event->get_is_http2() && http_event->get_http2_stream_id() != 0)
+        {
+            asd->service.set_id(APP_ID_HTTP2, asd->ctxt.get_odp_ctxt());
+        }
         asd->set_application_ids(asd->pick_service_app_id(), asd->pick_client_app_id(),
             asd->pick_payload_app_id(), asd->pick_misc_app_id(), change_bits);
     }
index 1d95b8a1b7336ce442c0deab08050de86e40769d..caaa8465bba015ec68ec4094ccdb934e701903ac 100644 (file)
@@ -40,7 +40,6 @@
 #include "client_app_timbuktu.h"
 #include "client_app_tns.h"
 #include "client_app_vnc.h"
-#include "detector_plugins/detector_http.h"
 #include "detector_plugins/detector_imap.h"
 #include "detector_plugins/detector_kerberos.h"
 #include "detector_plugins/detector_pattern.h"
@@ -57,7 +56,6 @@ void ClientDiscovery::initialize()
     new AimClientDetector(this);
     new BitClientDetector(this);
     new BitTrackerClientDetector(this);
-    new HttpClientDetector(this);
     new ImapClientDetector(this);
     new KerberosClientDetector(this);
     new MsnClientDetector(this);
diff --git a/src/network_inspectors/appid/detector_plugins/detector_http.cc b/src/network_inspectors/appid/detector_plugins/detector_http.cc
deleted file mode 100644 (file)
index b0d4d86..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-//--------------------------------------------------------------------------
-// Copyright (C) 2014-2020 Cisco and/or its affiliates. All rights reserved.
-// Copyright (C) 2005-2013 Sourcefire, Inc.
-//
-// This program is free software; you can redistribute it and/or modify it
-// under the terms of the GNU General Public License Version 2 as published
-// by the Free Software Foundation.  You may not use, modify or distribute
-// this program under any other version of the GNU General Public License.
-//
-// 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 along
-// with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-//--------------------------------------------------------------------------
-
-// detector_http.cc author Sourcefire Inc.
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "detector_http.h"
-
-// Start of HTTP/2 detection logic.
-//
-// This is intended to simply detect the presence of HTTP version 2 as a
-// service protocol if it is seen (unencrypted) on non-std ports.  That way, we
-// can notify Snort for future reference.  this covers the "with prior
-// knowledge" case for HTTP/2 (i.e., the client knows the server supports
-// HTTP/2 and jumps right in with the preface).
-
-static const char HTTP2_PREFACE[] = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n";
-#define HTTP2_PREFACE_LEN (sizeof(HTTP2_PREFACE) - 1)
-#define HTTP2_PREFACE_MAXPOS (sizeof(HTTP2_PREFACE)-2)
-
-static HttpServiceDetector* http_service_detector;
-
-HttpClientDetector::HttpClientDetector(ClientDiscovery* cdm)
-{
-    handler = cdm;
-    name = "HTTP";
-    proto = IpProtocol::TCP;
-    minimum_matches = 1;
-
-    tcp_patterns =
-    {
-        { (const uint8_t*)HTTP2_PREFACE, HTTP2_PREFACE_LEN, 0, 0, APP_ID_HTTP }
-    };
-
-    appid_registry =
-    {
-        { APP_ID_HTTP, 0 }
-    };
-
-    handler->register_detector(name, this, proto);
-}
-
-
-int HttpClientDetector::validate(AppIdDiscoveryArgs& args)
-{
-    add_app(args.asd, APP_ID_HTTP, APP_ID_HTTP + GENERIC_APP_OFFSET, nullptr, args.change_bits);
-    args.asd.client_disco_state = APPID_DISCO_STATE_FINISHED;
-    http_service_detector->add_service(args.change_bits, args.asd, args.pkt,
-        args.dir, APP_ID_HTTP);
-    args.asd.service_disco_state = APPID_DISCO_STATE_FINISHED;
-    args.asd.set_session_flags(APPID_SESSION_CLIENT_DETECTED | APPID_SESSION_SERVICE_DETECTED);
-    args.asd.clear_session_flags(APPID_SESSION_CONTINUE);
-    args.asd.is_http2 = true;
-
-    return APPID_SUCCESS;
-}
-
-HttpServiceDetector::HttpServiceDetector(ServiceDiscovery* sd)
-{
-    http_service_detector = this;
-
-    handler = sd;
-    name = "HTTP";
-    proto = IpProtocol::TCP;
-    detectorType = DETECTOR_TYPE_DECODER;
-
-    appid_registry =
-    {
-        { APP_ID_HTTP, 0 }
-    };
-
-    handler->register_detector(name, this, proto);
-}
-
-
-int HttpServiceDetector::validate(AppIdDiscoveryArgs&)
-{
-    return APPID_INPROCESS;
-}
-
-// End of HTTP/2 detection logic.
-
diff --git a/src/network_inspectors/appid/detector_plugins/detector_http.h b/src/network_inspectors/appid/detector_plugins/detector_http.h
deleted file mode 100644 (file)
index 47b3804..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-//--------------------------------------------------------------------------
-// Copyright (C) 2014-2020 Cisco and/or its affiliates. All rights reserved.
-// Copyright (C) 2005-2013 Sourcefire, Inc.
-//
-// This program is free software; you can redistribute it and/or modify it
-// under the terms of the GNU General Public License Version 2 as published
-// by the Free Software Foundation.  You may not use, modify or distribute
-// this program under any other version of the GNU General Public License.
-//
-// 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 along
-// with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-//--------------------------------------------------------------------------
-
-// detector_http.h author Sourcefire Inc.
-
-#ifndef DETECTOR_HTTP_H
-#define DETECTOR_HTTP_H
-
-#include "client_plugins/client_detector.h"
-#include "service_plugins/service_detector.h"
-
-class HttpClientDetector : public ClientDetector
-{
-public:
-    HttpClientDetector(ClientDiscovery*);
-
-    int validate(AppIdDiscoveryArgs&) override;
-};
-
-class HttpServiceDetector : public ServiceDetector
-{
-public:
-    HttpServiceDetector(ServiceDiscovery*);
-
-    int validate(AppIdDiscoveryArgs&) override;
-};
-
-#endif
-
index 18de10ac6d458af86c86b68a1de5a4267148f1a1..b0744109fa54f8c95735ea1243b7f5172d4be972 100644 (file)
@@ -39,7 +39,6 @@
 #include "appid_inspector.h"
 #include "client_plugins/client_discovery.h"
 #include "detector_plugins/detector_dns.h"
-#include "detector_plugins/detector_http.h"
 #include "detector_plugins/detector_pattern.h"
 #include "detector_plugins/detector_sip.h"
 #include "detector_plugins/http_url_patterns.h"
index 998d434478a6ef8388130a6d3839c918725befa2..5788371d54ded39701b4be5c7c340bf8b7963efb 100644 (file)
@@ -35,7 +35,6 @@
 #include "lua_detector_util.h"
 #include "lua_detector_api.h"
 #include "lua_detector_flow_api.h"
-#include "detector_plugins/detector_http.h"
 #include "utils/util.h"
 #include "utils/sflsq.h"
 #include "log/messages.h"
index f726b393e3979cb7c4bf718f047883b0c7174f7e..c1ef13c032d2cc3418e79298fcb45da68121cac3 100644 (file)
@@ -37,7 +37,6 @@
 #include "appid_dns_session.h"
 #include "appid_session.h"
 #include "detector_plugins/detector_dns.h"
-#include "detector_plugins/detector_http.h"
 #include "detector_plugins/detector_imap.h"
 #include "detector_plugins/detector_kerberos.h"
 #include "detector_plugins/detector_pattern.h"
@@ -98,7 +97,6 @@ void ServiceDiscovery::initialize()
     new DnsUdpServiceDetector(this);
     new FlapServiceDetector(this);
     new FtpServiceDetector(this);
-    new HttpServiceDetector(this);
     new ImapServiceDetector(this);
     new IrcServiceDetector(this);
     new KerberosServiceDetector(this);
index 02111b54a002ec3d930b388ae193c6bce7a33257..277b3ea7da639b874f5477266581f1bc27f8ac77 100644 (file)
@@ -172,6 +172,16 @@ bool HttpEvent::contains_webdav_method()
     return true;
 }
 
+bool HttpEvent::get_is_http2() const
+{
+    return false;
+}
+
+uint32_t HttpEvent::get_http2_stream_id() const
+{
+    return 0;
+}
+
 Flow* flow = nullptr;
 AppIdSession* mock_session = nullptr;