diff --git a/userspace/falco/app_actions/print_support.cpp b/userspace/falco/app_actions/print_support.cpp index e3d13211..ad4671a9 100644 --- a/userspace/falco/app_actions/print_support.cpp +++ b/userspace/falco/app_actions/print_support.cpp @@ -16,7 +16,7 @@ limitations under the License. #include -#include "falco_engine_version.h" +#include "versions_info.h" #include "application.h" using namespace falco::app; @@ -37,21 +37,15 @@ application::run_result application::print_support() nlohmann::json support; struct utsname sysinfo; std::string cmdline; - std::unique_ptr s(new sinsp()); if(uname(&sysinfo) != 0) { return run_result::fatal(string("Could not uname() to find system info: ") + strerror(errno)); } - support["version"] = FALCO_VERSION; - - support["libs_version"] = FALCOSECURITY_LIBS_VERSION; - support["plugin_api_version"] = application::get_plugin_api_version(); - - support["driver_api_version"] = application::get_driver_api_version(); - support["driver_schema_version"] = application::get_driver_schema_version(); - support["default_driver_version"] = DRIVER_VERSION; + const versions_info infos(m_state->offline_inspector); + support["version"] = infos.falco_version; + support["engine_info"] = infos.as_json(); support["system_info"]["sysname"] = sysinfo.sysname; support["system_info"]["nodename"] = sysinfo.nodename; @@ -59,7 +53,6 @@ application::run_result application::print_support() support["system_info"]["version"] = sysinfo.version; support["system_info"]["machine"] = sysinfo.machine; support["cmdline"] = m_state->cmdline; - support["engine_info"]["engine_version"] = FALCO_ENGINE_VERSION; support["config"] = read_file(m_options.conf_filename); support["rules_files"] = nlohmann::json::array(); for(auto filename : m_state->config->m_loaded_rules_filenames) diff --git a/userspace/falco/app_actions/print_version.cpp b/userspace/falco/app_actions/print_version.cpp index c331213d..a1b97cc4 100644 --- a/userspace/falco/app_actions/print_version.cpp +++ b/userspace/falco/app_actions/print_version.cpp @@ -16,9 +16,8 @@ limitations under the License. #include -#include "config_falco.h" #include "application.h" -#include "falco_engine_version.h" +#include "versions_info.h" using namespace falco::app; @@ -26,28 +25,21 @@ application::run_result application::print_version() { if(m_options.print_version_info) { + const versions_info info(m_state->offline_inspector); if(m_state->config->m_json_output) { - nlohmann::json version_info; - version_info["falco_version"] = FALCO_VERSION; - version_info["libs_version"] = FALCOSECURITY_LIBS_VERSION; - version_info["plugin_api_version"] = application::get_plugin_api_version(); - version_info["driver_api_version"] = application::get_driver_api_version(); - version_info["driver_schema_version"] = application::get_driver_schema_version(); - version_info["default_driver_version"] = DRIVER_VERSION; - version_info["engine_version"] = std::to_string(FALCO_ENGINE_VERSION); - printf("%s\n", version_info.dump().c_str()); + printf("%s\n", info.as_json().dump().c_str()); } else { - printf("Falco version: %s\n", FALCO_VERSION); - printf("Libs version: %s\n", FALCOSECURITY_LIBS_VERSION); - printf("Plugin API: %s\n", application::get_plugin_api_version().c_str()); - printf("Engine: %d\n", FALCO_ENGINE_VERSION); + printf("Falco version: %s\n", info.falco_version.c_str()); + printf("Libs version: %s\n", info.libs_version.c_str()); + printf("Plugin API: %s\n", info.plugin_api_version.c_str()); + printf("Engine: %s\n", info.engine_version.c_str()); printf("Driver:\n"); - printf(" API version: %s\n", application::get_driver_api_version().c_str()); - printf(" Schema version: %s\n", application::get_driver_api_version().c_str()); - printf(" Default driver: %s\n", DRIVER_VERSION); + printf(" API version: %s\n", info.driver_api_version.c_str()); + printf(" Schema version: %s\n", info.driver_schema_version.c_str()); + printf(" Default driver: %s\n", info.default_driver_version.c_str()); } return run_result::exit(); } diff --git a/userspace/falco/application.h b/userspace/falco/application.h index 32938594..d08d3eb6 100644 --- a/userspace/falco/application.h +++ b/userspace/falco/application.h @@ -401,41 +401,6 @@ private: return g_reopen_outputs.load(std::memory_order_seq_cst) != APP_SIGNAL_NOT_SET; } - static inline std::string get_plugin_api_version() - { - std::unique_ptr s(new sinsp()); - return std::string(s->get_plugin_api_version()); - } - - // TODO: move string conversion to scap - static inline std::string get_driver_api_version() - { - char driver_api_version_string[32]; - std::unique_ptr s(new sinsp()); - - auto driver_api_version = s->get_scap_api_version(); - unsigned long driver_api_major = PPM_API_VERSION_MAJOR(driver_api_version); - unsigned long driver_api_minor = PPM_API_VERSION_MINOR(driver_api_version); - unsigned long driver_api_patch = PPM_API_VERSION_PATCH(driver_api_version); - - snprintf(driver_api_version_string, sizeof(driver_api_version_string), "%lu.%lu.%lu", driver_api_major, driver_api_minor, driver_api_patch); - return std::string(driver_api_version_string); - } - - static inline std::string get_driver_schema_version() - { - char driver_schema_version_string[32]; - std::unique_ptr s(new sinsp()); - - auto driver_schema_version = s->get_scap_schema_version(); - unsigned long driver_schema_major = PPM_API_VERSION_MAJOR(driver_schema_version); - unsigned long driver_schema_minor = PPM_API_VERSION_MINOR(driver_schema_version); - unsigned long driver_schema_patch = PPM_API_VERSION_PATCH(driver_schema_version); - snprintf(driver_schema_version_string, sizeof(driver_schema_version_string), "%lu.%lu.%lu", driver_schema_major, driver_schema_minor, driver_schema_patch); - - return std::string(driver_schema_version_string); - } - std::unique_ptr m_state; cmdline_options m_options; bool m_initialized;