Merge in SNORT/snort3 from ~SATHIRKA/snort3:eve_http_process_client_detection to master
Squashed commit of the following:
commit
214fba55d508bd25ecbe05aa55618d17085daada
Author: Sreeja Athirkandathil Narayanan <sathirka@cisco.com>
Date: Thu Mar 9 11:20:54 2023 -0500
appid: give precedence to eve detected client over appid when eve_http_client_mapping config is set
{
set_app_info_flags(atoi(conf_val), APPINFO_FLAG_IGNORE);
}
+ else if (!(strcasecmp(conf_key, "eve_http_client")))
+ {
+ odp_ctxt.eve_http_client = atoi(conf_val) ? true : false;
+ }
else
ParseWarning(WARN_CONF, "appid: unsupported configuration: %s\n", conf_key);
}
my_version = version;
}
+ void reset_version()
+ {
+ my_version.clear();
+ }
+
private:
AppId my_id = APP_ID_NONE;
std::string my_version;
uint16_t max_packet_before_service_fail = MIN_MAX_PKTS_BEFORE_SERVICE_FAIL;
uint16_t max_packet_service_fail_ignore_bytes = MIN_MAX_PKT_BEFORE_SERVICE_FAIL_IGNORE_BYTES;
FirstPktAppIdDiscovered first_pkt_appid_prefix = NO_APPID_FOUND;
+ bool eve_http_client = true;
OdpContext(const AppIdConfig&, snort::SnortConfig*);
void initialize(AppIdInspector& inspector);
(api.service.get_id() == APP_ID_HTTP3 and !api.hsessions.empty()))
return APP_ID_NONE;
+ if (use_eve_client_app_id())
+ {
+ api.client.set_eve_client_app_detect_type(CLIENT_APP_DETECT_TLS_FP);
+ return api.client.get_eve_client_app_id();
+ }
+
AppId tmp_id = APP_ID_NONE;
if (!api.hsessions.empty())
tmp_id = api.hsessions[0]->client.get_id();
return tmp_id;
}
- if (use_eve_client_app_id())
- {
- api.client.set_eve_client_app_detect_type(CLIENT_APP_DETECT_TLS_FP);
- return api.client.get_eve_client_app_id();
- }
-
if (api.client.get_id() > APP_ID_NONE)
{
api.client.set_eve_client_app_detect_type(CLIENT_APP_DETECT_APPID);
bool use_eve_client_app_id() const
{
- return (api.client.get_eve_client_app_id() > APP_ID_NONE and
- (api.client.get_id() == APP_ID_SSL_CLIENT or api.client.get_id() <= APP_ID_NONE));
+ if (api.client.get_eve_client_app_id() <= APP_ID_NONE)
+ return false;
+
+ if (get_session_flags(APPID_SESSION_HTTP_SESSION))
+ {
+ if (odp_ctxt.eve_http_client)
+ api.client.reset_version();
+ return odp_ctxt.eve_http_client;
+ }
+ else
+ return (api.client.get_id() == APP_ID_SSL_CLIENT or api.client.get_id() <= APP_ID_NONE);
}
void set_alpn_service_app_id(AppId id)
const char* AppIdSessionApi::get_client_info(uint32_t stream_index) const
{
+ if (client.get_eve_client_app_id() > APP_ID_NONE and pkt_thread_odp_ctxt and
+ pkt_thread_odp_ctxt->eve_http_client)
+ return client.get_version();
if (uint32_t num_hsessions = get_hsessions_size())
{
if (stream_index >= num_hsessions)
TEST(appid_session_api, get_client_info)
{
const char* val;
+ mock_session->get_odp_ctxt().eve_http_client = false;
val = mock_session->get_api().get_client_info();
STRCMP_EQUAL(val, APPID_UT_CLIENT_VERSION);
mock_session->create_http_session();