#include "appid_types.h"
#include "service_plugins/service_bootp.h"
#include "service_plugins/service_netbios.h"
+#include "network_inspectors/appid/service_plugins/service_ssl.h"
#define SSL_ALLOWLIST_PKT_LIMIT 20
return false;
}
+ // service is a TLS-wrapped service or SNI has been observed
+ if ( (is_service_over_ssl(get_service_app_id()) or (get_tls_host() != nullptr)) and
+ !asd->get_session_flags(APPID_SESSION_DECRYPTED) and
+ !asd->get_odp_ctxt().check_host_port_app_cache and
+ (asd->session_packet_count >= SSL_ALLOWLIST_PKT_LIMIT) )
+ {
+ return false;
+ }
+
if ( (get_service_app_id() == APP_ID_QUIC or get_service_app_id() == APP_ID_HTTP3) and
!asd->get_session_flags(APPID_SESSION_DECRYPTED) )
return false;
void appid_log(const snort::Packet*, unsigned char, char const*, ...) { }
+bool is_service_over_ssl(AppId appId)
+{
+ switch (appId)
+ {
+ case APP_ID_HTTPS:
+ case APP_ID_SSL:
+ return true;
+ default:
+ return false;
+ }
+}
+
namespace snort
{
unsigned get_instance_id()
CHECK_EQUAL(detect_type, CLIENT_APP_DETECT_APPID);
}
+TEST(appid_session_api, service_none_sni_reaches_threshold)
+{
+ SfIp ip{};
+ AppIdSession asd(IpProtocol::TCP, &ip, 1492, dummy_appid_inspector, odpctxt, 0
+#ifndef DISABLE_TENANT_ID
+ ,0
+#endif
+ );
+ asd.flow = &flow;
+
+ asd.service_disco_state = APPID_DISCO_STATE_FINISHED;
+ asd.client_disco_state = APPID_DISCO_STATE_FINISHED;
+
+ asd.clear_session_flags(APPID_SESSION_ENCRYPTED |
+ APPID_SESSION_DECRYPTED |
+ APPID_SESSION_HTTP_SESSION |
+ APPID_SESSION_CONTINUE |
+ APPID_SESSION_CLIENT_GETS_SERVER_PACKETS);
+
+ asd.set_service_id(APP_ID_NONE, asd.get_odp_ctxt());
+
+ AppidChangeBits change_bits;
+
+ char* sni = snort_strdup("random-sni.com");
+ asd.tsession->set_tls_sni(sni, 0);
+ asd.examine_ssl_metadata(change_bits, true);
+
+ asd.session_packet_count = SSL_ALLOWLIST_PKT_LIMIT;
+ bool val = asd.get_api().is_appid_inspecting_session();
+ CHECK_FALSE(val);
+
+ asd.tsession->set_tls_sni(nullptr, 0);
+ delete &asd.get_api();
+}
+
int main(int argc, char** argv)
{
mock_init_appid_pegs();
mock_cleanup_appid_pegs();
return rc;
}
-