]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1295 in SNORT/snort3 from fix_warnings_appid to master
authorMike Stepanek (mstepane) <mstepane@cisco.com>
Fri, 29 Jun 2018 20:39:45 +0000 (16:39 -0400)
committerMike Stepanek (mstepane) <mstepane@cisco.com>
Fri, 29 Jun 2018 20:39:45 +0000 (16:39 -0400)
Squashed commit of the following:

commit 568dd4317b0dac192f3a9d1f2e1c032bde05a820
Author: Devendra Dahiphale <ddahipha@cisco.com>
Date:   Fri Jun 29 12:37:33 2018 -0400

    appid: fix review comments

commit b076a8d29d06a3db2e0c61ded0e85526bc1226d5
Author: Devendra Dahiphale <ddahipha@cisco.com>
Date:   Fri Jun 29 11:51:01 2018 -0400

    appid: fix review comments

commit b07837f571939787aa2b9cb815879c13b3d0f0c8
Author: Devendra Dahiphale <ddahipha@cisco.com>
Date:   Fri Jun 29 11:44:53 2018 -0400

    appid: fix review comments

commit d5920c2a3b2e46871e4d9a444a5e659767667077
Author: Devendra Dahiphale <ddahipha@cisco.com>
Date:   Thu Jun 28 15:21:04 2018 -0400

    appid: fix review comments

commit 20159ed03ccee5dc1760a19600b14f1e32713f99
Author: Devendra Dahiphale <ddahipha@cisco.com>
Date:   Thu Jun 28 15:16:40 2018 -0400

    appid: fix warnings

commit 7123e9b984ce710124df7417f8e9f322ea014d6f
Author: Devendra Dahiphale <ddahipha@cisco.com>
Date:   Wed Jun 27 14:58:09 2018 -0400

    appid: fix warnings related to change sign and variable hiding

src/network_inspectors/appid/appid_discovery.cc
src/network_inspectors/appid/detector_plugins/http_url_patterns.cc
src/network_inspectors/appid/lua_detector_api.h
src/network_inspectors/appid/service_plugins/service_ftp.cc
src/network_inspectors/appid/tp_appid_utils.cc
src/network_inspectors/appid/tp_appid_utils.h [new file with mode: 0644]

index 5a9390584252901049599a38084a4aa21e9d5202..c4045e38dcb1b5fb2fe6e38e9329270876519d6b 100644 (file)
 #include "service_plugins/service_discovery.h"
 #ifdef ENABLE_APPID_THIRD_PARTY
 #include "tp_lib_handler.h"
+#include "tp_appid_utils.h"
 #endif
 
 using namespace snort;
 
-bool do_tp_discovery(AppIdSession&, IpProtocol, Packet*, AppidSessionDirection&);
-
 AppIdDiscovery::AppIdDiscovery(AppIdInspector& ins)
     : inspector(ins)
 {
index 0c57faec7e26190a80184888cf34dadefff55ac9..202b37b5ab70815482dba606436d26d25573119d 100644 (file)
@@ -1705,15 +1705,15 @@ bool HttpPatternMatchers::get_appid_from_url(char* host, const char* url, char**
             patterns[1].pattern = (const uint8_t*)referer_path;
             patterns[1].patternSize = referer_path_len;
             patterns[2].pattern = nullptr;
-            HostUrlDetectorPattern* data = (HostUrlDetectorPattern*)mlmpMatchPatternUrl(matcher,
+            HostUrlDetectorPattern* url_pattern_data = (HostUrlDetectorPattern*)mlmpMatchPatternUrl(matcher,
                 patterns);
-            if ( data != nullptr )
+            if ( url_pattern_data != nullptr )
             {
                 if ( payload_found )
                     *referredPayloadAppId = *payloadAppId;
                 else
                     payload_found = true;
-                *payloadAppId = data->payload_id;
+                *payloadAppId = url_pattern_data->payload_id;
             }
         }
     }
index 49d9a47725f80a811eb288197f160db0bec14c1d..d4dafdbcbe9a581b910a93134aae6f5b71e9c5da 100644 (file)
@@ -81,7 +81,7 @@ public:
     // move it to the detector classes
     //int detector_user_data_ref = 0;    // key into LUA_REGISTRYINDEX
     DetectorPackageInfo package_info;
-    unsigned int service_id = APP_ID_UNKNOWN;
+    AppId service_id = APP_ID_UNKNOWN;
     int lua_validate(AppIdDiscoveryArgs&);
 };
 
index 31df782850c31fb13dc9744c8c7d126009e13e67..9966eddea3541013daf4723fa54ec29d7b189e73 100644 (file)
@@ -808,18 +808,18 @@ void FtpServiceDetector::create_expected_session(AppIdSession& asd, const Packet
 
     if (fp) // initialize data session
     {
-        uint64_t flags = asd.get_session_flags(APPID_SESSION_ENCRYPTED | APPID_SESSION_DECRYPTED);
-        if (flags == APPID_SESSION_ENCRYPTED)
+        uint64_t encrypted_flags = asd.get_session_flags(APPID_SESSION_ENCRYPTED | APPID_SESSION_DECRYPTED);
+        if (encrypted_flags == APPID_SESSION_ENCRYPTED)
         {
             fp->service.set_id(APP_ID_FTPSDATA);
         }
         else
         {
-            flags = 0; // reset (APPID_SESSION_ENCRYPTED | APPID_SESSION_DECRYPTED) bits
+            encrypted_flags = 0; // reset (APPID_SESSION_ENCRYPTED | APPID_SESSION_DECRYPTED) bits
             fp->service.set_id(APP_ID_FTP_DATA);
         }
 
-        initialize_expected_session(asd, *fp, APPID_SESSION_IGNORE_ID_FLAGS | flags, dir);
+        initialize_expected_session(asd, *fp, APPID_SESSION_IGNORE_ID_FLAGS | encrypted_flags, dir);
     }
 }
 
index 0f3334e05366d44fb60beaa557e196e5448ecd18..bfe709c1309f2afdd855d014d58687c2e9872cbf 100644 (file)
@@ -45,6 +45,7 @@
 #include "stream/stream.h"
 #ifdef ENABLE_APPID_THIRD_PARTY
 #include "tp_lib_handler.h"
+#include "tp_appid_utils.h"
 #endif
 
 using namespace std;
@@ -55,8 +56,6 @@ typedef AppIdHttpSession::pair_t pair_t;
 THREAD_LOCAL ProfileStats tpLibPerfStats;
 THREAD_LOCAL ProfileStats tpPerfStats;
 
-bool do_tp_discovery(AppIdSession&, IpProtocol, Packet*, AppidSessionDirection&);
-
 // std::vector does not have a convenient find() function.
 // There is a generic std::find() in <algorithm>, but this might be faster.
 template<class Type_t, class ValType_t>
diff --git a/src/network_inspectors/appid/tp_appid_utils.h b/src/network_inspectors/appid/tp_appid_utils.h
new file mode 100644 (file)
index 0000000..d3398f0
--- /dev/null
@@ -0,0 +1,31 @@
+//--------------------------------------------------------------------------
+// Copyright (C) 2018-2018 Cisco and/or its affiliates. All rights reserved.
+//
+// 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.
+//--------------------------------------------------------------------------
+
+// tp_appid_utils.h author Devendra Dahiphale<ddahipha@cisco.com>
+
+#ifndef TP_APPID_UTILS_H
+#define TP_APPID_UTILS_H
+
+#include "protocols/packet.h"
+#include "appid_types.h"
+
+class AppIdSession;
+
+bool do_tp_discovery(AppIdSession&, IpProtocol, snort::Packet*, AppidSessionDirection&);
+
+#endif