ApplicationDescriptor::reset();
my_username.clear();
my_user_id = APP_ID_NONE;
+ my_client_detect_type = CLIENT_APP_DETECT_APPID;
}
void update_user(AppId app_id, const char* username, AppidChangeBits& change_bits);
return efp_client_app_id;
}
+ void set_efp_client_app_detect_type(ClientAppDetectType client_app_detect_type)
+ {
+ my_client_detect_type = client_app_detect_type;
+ }
+
+ ClientAppDetectType get_client_app_detect_type() const
+ {
+ return my_client_detect_type;
+ }
+
private:
std::string my_username;
AppId my_user_id = APP_ID_NONE;
AppId efp_client_app_id = APP_ID_NONE;
+ ClientAppDetectType my_client_detect_type = CLIENT_APP_DETECT_APPID;
};
class PayloadAppDescriptor : public ApplicationDescriptor
if (!api.hsessions.empty())
tmp_id = api.hsessions[0]->client.get_id();
if (tmp_id > APP_ID_NONE)
+ {
+ api.client.set_efp_client_app_detect_type(CLIENT_APP_DETECT_APPID);
return tmp_id;
+ }
if (api.client.get_efp_client_app_id() > APP_ID_NONE and
(api.client.get_id() == APP_ID_SSL_CLIENT or
api.client.get_id() <= APP_ID_NONE))
+ {
+ api.client.set_efp_client_app_detect_type(CLIENT_APP_DETECT_TLS_FP);
return api.client.get_efp_client_app_id();
+ }
if (api.client.get_id() > APP_ID_NONE)
+ {
+ api.client.set_efp_client_app_detect_type(CLIENT_APP_DETECT_APPID);
return api.client.get_id();
+ }
+ api.client.set_efp_client_app_detect_type(CLIENT_APP_DETECT_APPID);
return encrypted.client_id;
}
#include "managers/inspector_manager.h"
#include "appid_inspector.h"
#include "appid_session.h"
+#include "appid_types.h"
#include "service_plugins/service_bootp.h"
#include "service_plugins/service_netbios.h"
return netbios_domain;
}
+ClientAppDetectType AppIdSessionApi::get_client_app_detect_type() const
+{
+ return client.get_client_app_detect_type();
+}
+
void AppIdSessionApi::set_netbios_name(AppidChangeBits& change_bits, const char* name)
{
if (netbios_name)
bool is_http_inspection_done() const;
const char* get_netbios_name() const;
const char* get_netbios_domain() const;
+ ClientAppDetectType get_client_app_detect_type() const;
// For protocols such as HTTP2 which can have multiple streams within a single flow,
// get_first_stream_* methods return the appids in the first stream seen in a packet.
APP_ID_APPID_SESSION_DIRECTION_MAX
};
+enum ClientAppDetectType
+{
+ CLIENT_APP_DETECT_APPID = 0,
+ CLIENT_APP_DETECT_TLS_FP
+};
+
#endif
AppId AppIdSession::pick_ss_client_app_id() const
{
- return get_client_id();
+ if (get_efp_client_app_id() > APP_ID_NONE and get_client_id() <= APP_ID_NONE)
+ {
+ api.client.set_efp_client_app_detect_type(CLIENT_APP_DETECT_TLS_FP);
+ return get_efp_client_app_id();
+ }
+ else
+ {
+ api.client.set_efp_client_app_detect_type(CLIENT_APP_DETECT_APPID);
+ return get_client_id();
+ }
}
AppId AppIdSession::pick_ss_payload_app_id() const
CHECK_TRUE(val);
}
+TEST(appid_session_api, get_client_app_detect_type)
+{
+ // Confirm that default detect type is APPID.
+ ClientAppDetectType detect_type = mock_session->get_api().get_client_app_detect_type();
+ CHECK_EQUAL(detect_type, CLIENT_APP_DETECT_APPID);
+
+ /* Set efp client app to some appid, but keep normal client id set to none.
+ The efp_client app should be picked, but the detect type should be TLS_FP. */
+ mock_session->set_client_id(APP_ID_NONE);
+ mock_session->set_efp_client_app_id(638);
+ AppId id = mock_session->pick_ss_client_app_id();
+ CHECK_EQUAL(id, 638);
+ detect_type = mock_session->get_api().get_client_app_detect_type();
+ CHECK_EQUAL(detect_type, CLIENT_APP_DETECT_TLS_FP);
+
+ /* Now set the normal client id to something. That is the appid that should be picked,
+ and the detect type should be APPID once more. */
+ mock_session->set_client_id(APP_ID_HTTP2);
+ id = mock_session->pick_ss_client_app_id();
+ CHECK_EQUAL(id, APP_ID_HTTP2);
+ detect_type = mock_session->get_api().get_client_app_detect_type();
+ CHECK_EQUAL(detect_type, CLIENT_APP_DETECT_APPID);
+}
+
int main(int argc, char** argv)
{
mock_init_appid_pegs();