From: Mike Stepanek (mstepane) Date: Fri, 29 Jun 2018 20:39:45 +0000 (-0400) Subject: Merge pull request #1295 in SNORT/snort3 from fix_warnings_appid to master X-Git-Tag: 3.0.0-246~34 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=39840076322541bf0e0fde3261bfe90c38f7fc3e;p=thirdparty%2Fsnort3.git Merge pull request #1295 in SNORT/snort3 from fix_warnings_appid to master Squashed commit of the following: commit 568dd4317b0dac192f3a9d1f2e1c032bde05a820 Author: Devendra Dahiphale Date: Fri Jun 29 12:37:33 2018 -0400 appid: fix review comments commit b076a8d29d06a3db2e0c61ded0e85526bc1226d5 Author: Devendra Dahiphale Date: Fri Jun 29 11:51:01 2018 -0400 appid: fix review comments commit b07837f571939787aa2b9cb815879c13b3d0f0c8 Author: Devendra Dahiphale Date: Fri Jun 29 11:44:53 2018 -0400 appid: fix review comments commit d5920c2a3b2e46871e4d9a444a5e659767667077 Author: Devendra Dahiphale Date: Thu Jun 28 15:21:04 2018 -0400 appid: fix review comments commit 20159ed03ccee5dc1760a19600b14f1e32713f99 Author: Devendra Dahiphale Date: Thu Jun 28 15:16:40 2018 -0400 appid: fix warnings commit 7123e9b984ce710124df7417f8e9f322ea014d6f Author: Devendra Dahiphale Date: Wed Jun 27 14:58:09 2018 -0400 appid: fix warnings related to change sign and variable hiding --- diff --git a/src/network_inspectors/appid/appid_discovery.cc b/src/network_inspectors/appid/appid_discovery.cc index 5a9390584..c4045e38d 100644 --- a/src/network_inspectors/appid/appid_discovery.cc +++ b/src/network_inspectors/appid/appid_discovery.cc @@ -47,12 +47,11 @@ #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) { diff --git a/src/network_inspectors/appid/detector_plugins/http_url_patterns.cc b/src/network_inspectors/appid/detector_plugins/http_url_patterns.cc index 0c57faec7..202b37b5a 100644 --- a/src/network_inspectors/appid/detector_plugins/http_url_patterns.cc +++ b/src/network_inspectors/appid/detector_plugins/http_url_patterns.cc @@ -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; } } } diff --git a/src/network_inspectors/appid/lua_detector_api.h b/src/network_inspectors/appid/lua_detector_api.h index 49d9a4772..d4dafdbcb 100644 --- a/src/network_inspectors/appid/lua_detector_api.h +++ b/src/network_inspectors/appid/lua_detector_api.h @@ -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&); }; diff --git a/src/network_inspectors/appid/service_plugins/service_ftp.cc b/src/network_inspectors/appid/service_plugins/service_ftp.cc index 31df78285..9966eddea 100644 --- a/src/network_inspectors/appid/service_plugins/service_ftp.cc +++ b/src/network_inspectors/appid/service_plugins/service_ftp.cc @@ -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); } } diff --git a/src/network_inspectors/appid/tp_appid_utils.cc b/src/network_inspectors/appid/tp_appid_utils.cc index 0f3334e05..bfe709c13 100644 --- a/src/network_inspectors/appid/tp_appid_utils.cc +++ b/src/network_inspectors/appid/tp_appid_utils.cc @@ -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 , but this might be faster. template diff --git a/src/network_inspectors/appid/tp_appid_utils.h b/src/network_inspectors/appid/tp_appid_utils.h new file mode 100644 index 000000000..d3398f039 --- /dev/null +++ b/src/network_inspectors/appid/tp_appid_utils.h @@ -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 + +#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