From a64501122f722fe009c6a97ad675c8feed48bac1 Mon Sep 17 00:00:00 2001 From: Mark Stemm Date: Wed, 3 Nov 2021 14:53:54 -0700 Subject: [PATCH] Skip plugins list/load/tests for MUSL_OPTIMIZED_BUILD When MUSL_OPTIMIZED_BUILD is specified, falco is statically linked under musl, and can't dlopen() files: see https://inbox.vuxu.org/musl/20200423162406.GV11469@brightrain.aerifal.cx/T/ So skip listing/loading/testing plugins when MUSL_OPTIMIZED_BUILD is specified. Signed-off-by: Mark Stemm --- .circleci/config.yml | 1 + test/run_regression_tests.sh | 7 ++++++- userspace/falco/falco.cpp | 19 ++++++++++++++----- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 535893906e7..6f485584d9b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -292,6 +292,7 @@ jobs: BUILD_DIR: "/build-static" BUILD_TYPE: "release" SKIP_PACKAGES_TESTS: "true" + SKIP_PLUGINS_TESTS: "true" steps: - setup_remote_docker - attach_workspace: diff --git a/test/run_regression_tests.sh b/test/run_regression_tests.sh index 0ba9241944b..fbb05b1e3be 100755 --- a/test/run_regression_tests.sh +++ b/test/run_regression_tests.sh @@ -20,6 +20,7 @@ set -euo pipefail SCRIPT=$(readlink -f $0) SCRIPTDIR=$(dirname "$SCRIPT") SKIP_PACKAGES_TESTS=${SKIP_PACKAGES_TESTS:-false} +SKIP_PLUGINS_TESTS=${SKIP_PLUGINS_TESTS:-false} TRACE_FILES_BASE_URL=${TRACE_FILES_BASE_URL:-"https://download.falco.org/fixtures/trace-files/"} # Trace file tarballs are now versioned. Any time a substantial change @@ -99,11 +100,15 @@ function run_tests() { # as we're watching the return status when running avocado. set +e TEST_RC=0 - suites=($SCRIPTDIR/falco_traces.yaml $SCRIPTDIR/falco_tests.yaml $SCRIPTDIR/falco_k8s_audit_tests.yaml $SCRIPTDIR/falco_tests_psp.yaml $SCRIPTDIR/falco_tests_exceptions.yaml $SCRIPTDIR/falco_tests_plugins.yaml) + suites=($SCRIPTDIR/falco_traces.yaml $SCRIPTDIR/falco_tests.yaml $SCRIPTDIR/falco_k8s_audit_tests.yaml $SCRIPTDIR/falco_tests_psp.yaml $SCRIPTDIR/falco_tests_exceptions.yaml) if [ "$SKIP_PACKAGES_TESTS" = false ] ; then suites+=($SCRIPTDIR/falco_tests_package.yaml) fi + + if [ "$SKIP_PLUGINS_TESTS" = false ] ; then + suites+=($SCRIPTDIR/falco_tests_plugins.yaml) + fi XUNIT_DIR="${OPT_BUILD_DIR}/integration-tests-xunit" mkdir -p "${XUNIT_DIR}" diff --git a/userspace/falco/falco.cpp b/userspace/falco/falco.cpp index 746a0af9656..41dccd9fd71 100644 --- a/userspace/falco/falco.cpp +++ b/userspace/falco/falco.cpp @@ -137,8 +137,8 @@ static void usage() " -l Show the name and description of the rule with name and exit.\n" " --list [] List all defined fields. If is provided, only list those fields for\n" " the source . Current values for are \"syscall\", \"k8s_audit\"\n" +#ifndef MUSL_OPTIMIZED_BUILD " --list-plugins Print info on all loaded plugins and exit.\n" -#ifndef MINIMAL_BUILD " -m , --mesos-api \n" " Enable Mesos support by connecting to the API server\n" " specified as argument. E.g. \"http://admin:password@127.0.0.1:5050\".\n" @@ -556,7 +556,9 @@ int falco_init(int argc, char **argv) {"k8s-api", required_argument, 0, 'k'}, {"k8s-node", required_argument, 0}, {"list", optional_argument, 0}, +#ifndef MUSL_OPTIMIZED_BUILD {"list-plugins", no_argument, 0}, +#endif {"mesos-api", required_argument, 0, 'm'}, {"option", required_argument, 0, 'o'}, {"pidfile", required_argument, 0, 'P'}, @@ -749,10 +751,12 @@ int falco_init(int argc, char **argv) list_flds_source = optarg; } } +#ifndef MUSL_OPTIMIZED_BUILD else if (string(long_options[long_index].name) == "list-plugins") { list_plugins = true; } +#endif else if (string(long_options[long_index].name) == "stats-interval") { stats_interval = atoi(optarg); @@ -942,12 +946,17 @@ int falco_init(int argc, char **argv) std::list> extractor_plugins; for(auto &p : config.m_plugins) { + std::shared_ptr plugin; +#ifdef MUSL_OPTIMIZED_BUILD + throw std::invalid_argument(string("Can not load/use plugins with musl optimized build")); +#else falco_logger::log(LOG_INFO, "Loading plugin (" + p.m_name + ") from file " + p.m_library_path + "\n"); - std::shared_ptr plugin = sinsp_plugin::register_plugin(inspector, - p.m_library_path, - (p.m_init_config.empty() ? NULL : (char *)p.m_init_config.c_str()), - plugin_filter_checks); + plugin = sinsp_plugin::register_plugin(inspector, + p.m_library_path, + (p.m_init_config.empty() ? NULL : (char *)p.m_init_config.c_str()), + plugin_filter_checks); +#endif if(plugin->type() == TYPE_SOURCE_PLUGIN) {