Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new(falco): add more version fields to --support and --version #2325

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ This section provides more details around the versioning of all components that
Falco version: x.y.z (sem-ver like)
Libs version: x.y.z (sem-ver like)
Plugin API: x.y.z (sem-ver like)
Engine: x
Driver:
API version: x.y.z (sem-ver)
Schema version: x.y.z (sem-ver)
Expand Down
23 changes: 23 additions & 0 deletions userspace/falco/app_actions/print_support.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,36 @@ application::run_result application::print_support()
nlohmann::json support;
struct utsname sysinfo;
std::string cmdline;
std::unique_ptr<sinsp> s(new sinsp());
char driver_api_version_string[32], driver_schema_version_string[32];

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"] = s->get_plugin_api_version();

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);

support["driver_api_version"] = driver_api_version_string;

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);
Comment on lines +53 to +65
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be amazing if we had a sinsp API to do that instead of using low levels macro, but we can do that in a next step :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completely agree, since I wrote this when libs 0.10.0 was already about to be released I didn't want to add an API dependency right now, as harmless as it may be.


support["driver_schema_version"] = driver_schema_version_string;
support["default_driver_version"] = DRIVER_VERSION;

support["system_info"]["sysname"] = sysinfo.sysname;
support["system_info"]["nodename"] = sysinfo.nodename;
support["system_info"]["release"] = sysinfo.release;
Expand Down
2 changes: 2 additions & 0 deletions userspace/falco/app_actions/print_version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ limitations under the License.

#include "config_falco.h"
#include "application.h"
#include "falco_engine_version.h"

using namespace falco::app;

Expand All @@ -27,6 +28,7 @@ application::run_result application::print_version()
printf("Falco version: %s\n", FALCO_VERSION);
printf("Libs version: %s\n", FALCOSECURITY_LIBS_VERSION);
printf("Plugin API: %s\n", s->get_plugin_api_version());
printf("Engine: %d\n", FALCO_ENGINE_VERSION);

// todo(leogr): move string conversion to scap
auto driver_api_version = s->get_scap_api_version();
Expand Down