]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2566 in SNORT/snort3 from ~SHRARANG/snort3:appid_cppcheck to...
authorShravan Rangarajuvenkata (shrarang) <shrarang@cisco.com>
Mon, 2 Nov 2020 21:12:47 +0000 (21:12 +0000)
committerShravan Rangarajuvenkata (shrarang) <shrarang@cisco.com>
Mon, 2 Nov 2020 21:12:47 +0000 (21:12 +0000)
Squashed commit of the following:

commit 2770cb1dfb5f4cecedb478b0118df2d42a898de1
Author: Shravan Rangaraju <shrarang@cisco.com>
Date:   Thu Oct 22 10:43:47 2020 -0400

    appid: handle cppcheck warnings

12 files changed:
src/network_inspectors/appid/appid_config.cc
src/network_inspectors/appid/appid_config.h
src/network_inspectors/appid/appid_session.cc
src/network_inspectors/appid/appid_session.h
src/network_inspectors/appid/appid_utils/fw_avltree.cc
src/network_inspectors/appid/appid_utils/fw_avltree.h
src/network_inspectors/appid/service_plugins/service_discovery.cc
src/network_inspectors/appid/service_state.cc
src/network_inspectors/appid/service_state.h
src/network_inspectors/appid/test/appid_discovery_test.cc
src/network_inspectors/appid/test/appid_http_session_test.cc
src/network_inspectors/appid/test/appid_mock_session.h

index cf4fa027ba17663b7d2130238790a164546fcb70..0a3b92828881781dd3a011b76a0393599d5820d6 100644 (file)
@@ -225,34 +225,6 @@ AppId OdpContext::get_protocol_service_id(IpProtocol proto)
     return ip_protocol[(uint16_t)proto];
 }
 
-void OdpContext::display_port_config()
-{
-    bool first = true;
-
-    for ( auto& i : tcp_port_only )
-        if (tcp_port_only[i])
-        {
-            if (first)
-            {
-                LogMessage("    TCP Port-Only Services\n");
-                first = false;
-            }
-            LogMessage("        %5u - %u\n", i, tcp_port_only[i]);
-        }
-
-    first = true;
-    for ( auto& i : udp_port_only )
-        if (udp_port_only[i])
-        {
-            if (first)
-            {
-                LogMessage("    UDP Port-Only Services\n");
-                first = false;
-            }
-            LogMessage("        %5u - %u\n", i, udp_port_only[i]);
-        }
-}
-
 void OdpContext::add_af_indicator(AppId indicator, AppId forecast, AppId target)
 {
     if (AF_indicators.find(indicator) != AF_indicators.end())
index 4452e6e4d783143b2faba11771530a44ca763823..0a12c658c953c1ad72d206875112e22366193995 100644 (file)
@@ -203,7 +203,6 @@ public:
     void add_protocol_service_id(IpProtocol, AppId);
     AppId get_port_service_id(IpProtocol, uint16_t);
     AppId get_protocol_service_id(IpProtocol);
-    void display_port_config();
     void add_af_indicator(AppId, AppId, AppId);
 
 private:
index 3d9d34d62f05ff23b08fd1debc08a912f11fdea3..f68647f7aa7a4fcc26034b71e3f58b7c97c46c33 100644 (file)
@@ -678,20 +678,6 @@ void* AppIdSession::get_flow_data(unsigned id) const
         return nullptr;
 }
 
-void* AppIdSession::remove_flow_data(unsigned id)
-{
-    void* data = nullptr;
-
-    AppIdFlowDataIter it = flow_data.find(id);
-    if (it != flow_data.end())
-    {
-        data = it->second->fd_data;
-        delete it->second;
-        flow_data.erase(it);
-    }
-    return data;
-}
-
 void AppIdSession::free_flow_data()
 {
     for (AppIdFlowDataIter it = flow_data.cbegin();
@@ -918,11 +904,6 @@ void AppIdSession::set_application_ids_service(AppId service_id, AppidChangeBits
     api.set_application_ids_service(service_id, change_bits);
 }
 
-bool AppIdSession::is_ssl_session_decrypted() const
-{
-    return get_session_flags(APPID_SESSION_DECRYPTED);
-}
-
 void AppIdSession::reset_session_data(AppidChangeBits& change_bits)
 {
     delete_session_data();
@@ -943,11 +924,6 @@ void AppIdSession::reset_session_data(AppidChangeBits& change_bits)
     change_bits.set(APPID_RESET_BIT);
 }
 
-bool AppIdSession::is_payload_appid_set() const
-{
-    return (api.payload.get_id() || tp_payload_app_id);
-}
-
 void AppIdSession::clear_http_flags()
 {
     if (!get_session_flags(APPID_SESSION_SPDY_SESSION))
index 20307e0a71255e70d40d5ee1036d10c1fd4ad47d..65c86b74b1921f926aa75c0e94e88e1ceb2a2779 100644 (file)
@@ -336,7 +336,6 @@ public:
     void* get_flow_data(unsigned id) const;
     int add_flow_data(void* data, unsigned id, AppIdFreeFCN);
     int add_flow_data_id(uint16_t port, ServiceDetector*);
-    void* remove_flow_data(unsigned id);
     void free_flow_data_by_id(unsigned id);
     void free_flow_data_by_mask(unsigned mask);
     void free_flow_data();
@@ -356,7 +355,6 @@ public:
     void set_ss_application_ids(AppId client, AppId payload, AppidChangeBits& change_bits);
     void set_application_ids_service(AppId service_id, AppidChangeBits& change_bits);
 
-    bool is_ssl_session_decrypted() const;
     void examine_ssl_metadata(AppidChangeBits& change_bits);
     void set_client_appid_data(AppId, AppidChangeBits& change_bits, char* version = nullptr);
     void set_service_appid_data(AppId, AppidChangeBits& change_bits, char* version = nullptr);
@@ -371,7 +369,6 @@ public:
     void sync_with_snort_protocol_id(AppId, snort::Packet*);
     void stop_service_inspection(snort::Packet*,  AppidSessionDirection);
 
-    bool is_payload_appid_set() const;
     void clear_http_flags();
     void clear_http_data();
     void reset_session_data(AppidChangeBits& change_bits);
index 8446d6055d48c3ac5a36468e0eff4f1114dbed32..62d96165f881e6f36ab4508957c3925b3454d35a 100644 (file)
@@ -55,13 +55,6 @@ static inline FwAvlNode* get_first(FwAvlNode* node)
     return node;
 }
 
-static inline FwAvlNode* get_last(FwAvlNode* node)
-{
-    while (node->right != nullptr)
-        node = node->right;
-    return node;
-}
-
 FwAvlNode* fwAvlFirst(const FwAvlTree* tree)
 {
     if ((tree != nullptr) && (tree->root != nullptr))
@@ -70,14 +63,6 @@ FwAvlNode* fwAvlFirst(const FwAvlTree* tree)
         return nullptr;
 }
 
-FwAvlNode* fwAvlLast(const FwAvlTree* tree)
-{
-    if ((tree != nullptr) && (tree->root != nullptr))
-        return get_last(tree->root);
-    else
-        return nullptr;
-}
-
 FwAvlNode* fwAvlNext(FwAvlNode* node)
 {
 
@@ -96,24 +81,6 @@ FwAvlNode* fwAvlNext(FwAvlNode* node)
     }
 }
 
-FwAvlNode* fwAvlPrev(FwAvlNode* node)
-{
-    FwAvlNode* parent;
-    FwAvlNode* tmp;
-
-    if (node->left != nullptr)
-    {
-        tmp = get_first(node->left);
-    }
-    else
-    {
-        tmp = node;
-        while ( ((parent = get_parent(tmp)) != nullptr) && (parent->left == tmp) )
-            tmp = parent;
-    }
-    return tmp;
-}
-
 static void rotate_left(FwAvlNode* node, FwAvlTree* tree)
 {
     FwAvlNode* p = node;
index c7167d51c962c53dbcd3617a404faf9f31d31102..d8bb4d45f30f177816045c1a725f5d97de1ff1ae 100644 (file)
@@ -54,9 +54,7 @@ FwAvlTree* fwAvlInit();
 int fwAvlInsert(uint32_t key, void* data, FwAvlTree*);
 void* fwAvlLookup(const uint32_t key, const FwAvlTree*);
 FwAvlNode* fwAvlFirst(const FwAvlTree*);
-FwAvlNode* fwAvlLast(const FwAvlTree*);
 FwAvlNode* fwAvlNext(FwAvlNode*);
-FwAvlNode* fwAvlPrev(FwAvlNode*);
 FwQNode* fwAvlSerialize(FwAvlTree*);
 void fwAvlDeleteTree(FwAvlTree*, void (* dataDelete)(void* data));
 
index c6c2849143474210dc0ff3557935f364d8858902..8a8030a71e4d84cfcabe87d2a1742f2450ecdaf6 100644 (file)
@@ -551,7 +551,7 @@ int ServiceDiscovery::identify_service(AppIdSession& asd, Packet* p,
                 asd.is_decrypted(), true);
 
         if (got_incompatible_service)
-            sds->update_service_incompatiable(tmp_ip);
+            sds->update_service_incompatible(tmp_ip);
 
         sds->set_service_id_failed(asd, tmp_ip);
     }
index 7d4179bb6a3b7337a40a7937056fbfe73691fb11..697cef59c0e6e6909ea958fb1904398e134480bd 100644 (file)
@@ -179,7 +179,7 @@ void ServiceDiscoveryState::set_service_id_failed(AppIdSession& asd, const SfIp*
     }
 }
 
-void ServiceDiscoveryState::update_service_incompatiable(const SfIp* ip)
+void ServiceDiscoveryState::update_service_incompatible(const SfIp* ip)
 {
     if ( invalid_client_count < STATE_ID_INVALID_CLIENT_THRESHOLD )
     {
index 19fbe4432b2890ef2f73d133ea77d4a95fd640c5..2c9879048135d7f7afc60be298cda98a11d57fdc 100644 (file)
@@ -89,7 +89,7 @@ public:
     void set_service_id_valid(ServiceDetector* sd);
     void set_service_id_failed(AppIdSession& asd, const snort::SfIp* client_ip,
         unsigned invalid_delta = 0);
-    void update_service_incompatiable(const snort::SfIp* ip);
+    void update_service_incompatible(const snort::SfIp* ip);
 
     ServiceState get_state() const
     {
index 1f188207072207f43e7c72f158e0bd5fbd955fa4..717f9a31c3ce4d562031f4d4ac388129bf6aa92b 100644 (file)
@@ -262,10 +262,6 @@ HostPortVal* HostPortCache::find(const SfIp*, uint16_t, IpProtocol, const OdpCon
 }
 void AppIdServiceState::check_reset(AppIdSession&, const SfIp*, uint16_t,
     int16_t, uint16_t) {}
-int dns_host_scan_hostname(const uint8_t*, size_t, AppId*, AppId*)
-{
-    return 0;
-}
 bool do_tp_discovery(ThirdPartyAppIdContext& , AppIdSession&, IpProtocol,
     Packet*, AppidSessionDirection&, AppidChangeBits&)
 {
@@ -275,10 +271,6 @@ TPLibHandler* TPLibHandler::self = nullptr;
 THREAD_LOCAL AppIdStats appid_stats;
 THREAD_LOCAL AppIdDebug* appidDebug = nullptr;
 void AppIdDebug::activate(const Flow*, const AppIdSession*, bool) { active = false; }
-AppId find_length_app_cache(const LengthKey&)
-{
-    return APP_ID_NONE;
-}
 void check_session_for_AF_indicator(Packet*, AppidSessionDirection, AppId, const OdpContext&) {}
 AppId check_session_for_AF_forecast(AppIdSession&, Packet*, AppidSessionDirection, AppId)
 {
index b02f3ad7680796c5e16e6e29bcd472ae2eb89b3b..7380dcf2941ba65d89111f1e31217009fb04d8e6 100644 (file)
@@ -138,11 +138,6 @@ void AppIdSession::reset_session_data(AppidChangeBits&)
 {
 }
 
-bool AppIdSession::is_payload_appid_set() const
-{
-    return true;
-}
-
 bool AppIdSession::is_tp_appid_available() const
 {
     return true;
index 803da1b83e4e2c73559382ed5fccfc69eb570141..afe169adaa9f0cc9aebf75c7850f3b8946572855 100644 (file)
@@ -154,11 +154,6 @@ AppId AppIdSession::pick_ss_referred_payload_app_id() const
     return APPID_UT_ID;
 }
 
-bool AppIdSession::is_ssl_session_decrypted() const
-{
-    return is_session_decrypted;
-}
-
 AppIdHttpSession* AppIdSession::create_http_session(uint32_t)
 {
     AppIdHttpSession* hsession = new MockAppIdHttpSession(*this);