if ((app_id = get_static_app_info_entry(entry->appId)))
{
app_info_table[app_id] = entry;
- AppIdPegCounts::add_app_peg_info(*entry, app_id);
+ AppIdPegCounts::add_app_peg_info(entry->app_name_key, app_id);
}
if ((app_id = get_static_app_info_entry(entry->serviceId)))
}
fclose(tableFile);
+ AppIdPegCounts::add_unknown_app_peg();
snprintf(filepath, sizeof(filepath), "%s/odp/%s", mod_config->app_detector_dir,
APP_CONFIG_FILE);
load_appid_config (mod_config, filepath);
appid_detectors_peg_info.push_back({CountType::SUM, snort_strdup(name.c_str()), snort_strdup(help.c_str())});
}
-void AppIdPegCounts::add_app_peg_info(AppInfoTableEntry& entry, AppId app_id )
+void AppIdPegCounts::add_app_peg_info(std::string app_name, AppId app_id )
{
- std::string app_name = entry.app_name_key;
std::replace(app_name.begin(), app_name.end(), ' ', '_');
appid_detector_pegs_idx[app_id] = appid_detectors_peg_info.size() + NUM_APPID_GLOBAL_PEGS;
init_detector_peg_info(app_name, "_misc", " misc detected");
}
+void AppIdPegCounts::add_unknown_app_peg()
+{
+ std::string app_name = "unknown_app";
+
+ AppIdPegCounts::unknown_app_idx = appid_detectors_peg_info.size() + NUM_APPID_GLOBAL_PEGS;
+ init_detector_peg_info(app_name, "_flows", " services detected");
+ init_detector_peg_info(app_name, "_clients", " clients detected");
+ init_detector_peg_info(app_name, "_users", " users detected");
+ init_detector_peg_info(app_name, "_payloads", " payloads detected");
+ init_detector_peg_info(app_name, "_misc", " misc detected");
+}
+
PegCount* AppIdPegCounts::get_peg_counts()
{
if ( AppIdPegCounts::detectors_configured )
{
if ( AppIdPegCounts::detectors_configured )
{
- std::string app_name = "unknown_app";
-
- AppIdPegCounts::unknown_app_idx = appid_detectors_peg_info.size() + NUM_APPID_GLOBAL_PEGS;
- init_detector_peg_info(app_name, "_flows", " services detected");
- init_detector_peg_info(app_name, "_clients", " clients detected");
- init_detector_peg_info(app_name, "_users", " users detected");
- init_detector_peg_info(app_name, "_payloads", " payloads detected");
- init_detector_peg_info(app_name, "_misc", " misc detected");
appid_pegs.insert( appid_pegs.end(), appid_detectors_peg_info.begin(), appid_detectors_peg_info.end());
// add the sentinel entry at the end
NUM_APPID_DETECTOR_PEGS
};
- static void add_app_peg_info(AppInfoTableEntry&, AppId);
+ static void add_app_peg_info(std::string app_name, AppId);
+ static void add_unknown_app_peg();
static PegCount* get_peg_counts();
static PegInfo* get_peg_info();
static void init_pegs();
void setup()
{
MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
- mock_init_appid_pegs();
}
void teardown()
{
app_info_mgr.cleanup_appid_info_table();
- mock_cleanup_appid_pegs();
MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
}
};
int main(int argc, char** argv)
{
- int return_value = CommandLineTestRunner::RunAllTests(argc, argv);
- return return_value;
+ mock_init_appid_pegs();
+ int rc = CommandLineTestRunner::RunAllTests(argc, argv);
+ mock_cleanup_appid_pegs();
+ return rc;
}
void setup() override
{
MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
- mock_init_appid_pegs();
flow = new Flow;
mock_session = new AppIdSession(IpProtocol::TCP, nullptr, 1492, appid_inspector);
mock_session->hsession = init_http_session(mock_session);
{
delete mock_session;
delete flow;
- mock_cleanup_appid_pegs();
-
MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
}
};
int main(int argc, char** argv)
{
- return CommandLineTestRunner::RunAllTests(argc, argv);
+ mock_init_appid_pegs();
+ int rc = CommandLineTestRunner::RunAllTests(argc, argv);
+ mock_cleanup_appid_pegs();
+ return rc;
}
void setup() override
{
MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
- mock_init_appid_pegs();
flow = new Flow;
mock_session = new AppIdSession(IpProtocol::TCP, nullptr, 1492, appid_inspector);
mock_session->hsession = init_http_session(mock_session);
{
delete mock_session;
delete flow;
- mock_cleanup_appid_pegs();
MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
}
};
int main(int argc, char** argv)
{
- int return_value = CommandLineTestRunner::RunAllTests(argc, argv);
- return return_value;
+ mock_init_appid_pegs();
+ int rc = CommandLineTestRunner::RunAllTests(argc, argv);
+ mock_cleanup_appid_pegs();
+ return rc;
}
void setup()
{
MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
- mock_init_appid_pegs();
parent = new AppIdSession(IpProtocol::TCP, nullptr, 1492, appid_inspector);
expected = new AppIdSession(IpProtocol::TCP, nullptr, 1492, appid_inspector);
}
{
delete parent;
delete expected;
- mock_cleanup_appid_pegs();
MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
}
};
int main(int argc, char** argv)
{
- return CommandLineTestRunner::RunAllTests(argc, argv);
+ mock_init_appid_pegs();
+ int rc = CommandLineTestRunner::RunAllTests(argc, argv);
+ mock_cleanup_appid_pegs();
+ return rc;
}
void setup() override
{
MemoryLeakWarningPlugin::turnOffNewDeleteOverloads();
- mock_init_appid_pegs();
flow = new Flow;
mock_session = new AppIdSession(IpProtocol::TCP, nullptr, 1492, appid_inspector);
flow->set_flow_data(mock_session);
fake_msg_header = nullptr;
delete mock_session;
delete flow;
- mock_cleanup_appid_pegs();
mock().clear();
MemoryLeakWarningPlugin::turnOnNewDeleteOverloads();
}
int main(int argc, char** argv)
{
- int return_value = CommandLineTestRunner::RunAllTests(argc, argv);
- return return_value;
+ mock_init_appid_pegs();
+ int rc = CommandLineTestRunner::RunAllTests(argc, argv);
+ mock_cleanup_appid_pegs();
+ return rc;
}
void mock_init_appid_pegs()
{
AppIdPegCounts::set_detectors_configured();
+ AppIdPegCounts::add_unknown_app_peg();
AppIdPegCounts::get_peg_info();
AppIdPegCounts::init_pegs();
}