From 38a7f7ada01a5aefb0b1683e008d325dc6675440 Mon Sep 17 00:00:00 2001 From: Mark Stemm Date: Fri, 15 Oct 2021 16:33:12 -0700 Subject: [PATCH] cmake/build changes for plugins Add a cmake module "plugins" that does the following: - Downloads/installs the plugins artifacts from a known tag - Copies the resulting cloudtrail/json shared libraries to CMAKE_CURRENT_BINARY_DIR/plugins - Installs them to FALCO_SHARE_DIR/plugins The default config will define the plugins but they will be disabled by default. Co-authored-by: Leonardo Grasso Co-authored-by: Loris Degioanni Signed-off-by: Mark Stemm --- CMakeLists.txt | 3 +++ cmake/modules/plugins.cmake | 36 +++++++++++++++++++++++++++++++ tests/CMakeLists.txt | 2 ++ userspace/falco/config_falco.h.in | 1 + 4 files changed, 42 insertions(+) create mode 100644 cmake/modules/plugins.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index a0e43e95..4eeaa103 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -212,6 +212,7 @@ include(static-analysis) # Shared build variables set(FALCO_SINSP_LIBRARY sinsp) set(FALCO_SHARE_DIR share/falco) +set(FALCO_PLUGINS_DIR ${FALCO_SHARE_DIR}/plugins) set(FALCO_ABSOLUTE_SHARE_DIR "${CMAKE_INSTALL_PREFIX}/${FALCO_SHARE_DIR}") set(FALCO_BIN_DIR bin) @@ -220,5 +221,7 @@ add_subdirectory(userspace/engine) add_subdirectory(userspace/falco) add_subdirectory(tests) +include(plugins) + # Packages configuration include(CPackConfig) diff --git a/cmake/modules/plugins.cmake b/cmake/modules/plugins.cmake new file mode 100644 index 00000000..e5479c1f --- /dev/null +++ b/cmake/modules/plugins.cmake @@ -0,0 +1,36 @@ +# +# Copyright (C) 2021 The Falco Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. +# + +include(ExternalProject) + +set(PLUGINS_VERSION "0.1.0-rc1-28-g019437e") + +ExternalProject_Add( + cloudtrail-plugin + URL "https://download.falco.org/plugins/dev/cloudtrail-${PLUGINS_VERSION}-${CMAKE_HOST_SYSTEM_PROCESSOR}.tar.gz" + URL_HASH "SHA256=ad9692957c5435238e07d1625e1b247eabe98b85f54de9218367fdd73a6f3f0b" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "") + +install(FILES "${PROJECT_BINARY_DIR}/cloudtrail-plugin-prefix/src/cloudtrail-plugin/libcloudtrail.so" DESTINATION "${FALCO_PLUGINS_DIR}") + +ExternalProject_Add( + json-plugin + URL "https://download.falco.org/plugins/dev/json-${PLUGINS_VERSION}-${CMAKE_HOST_SYSTEM_PROCESSOR}.tar.gz" + URL_HASH "SHA256=721ea5226b0f623915d0d5c34870589ad33a8ff795b0daa1af72f21a67430077" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "") + +install(FILES "${PROJECT_BINARY_DIR}/json-plugin-prefix/src/json-plugin/libjson.so" DESTINATION "${FALCO_PLUGINS_DIR}") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index dfb87fb8..b0318095 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -46,6 +46,7 @@ if(FALCO_BUILD_TESTS) PUBLIC "${CATCH2_INCLUDE}" "${FAKEIT_INCLUDE}" "${PROJECT_SOURCE_DIR}/userspace/engine" + "${PROJECT_BINARY_DIR}/userspace/falco" "${YAMLCPP_INCLUDE_DIR}" "${PROJECT_SOURCE_DIR}/userspace/falco") else() @@ -54,6 +55,7 @@ if(FALCO_BUILD_TESTS) PUBLIC "${CATCH2_INCLUDE}" "${FAKEIT_INCLUDE}" "${PROJECT_SOURCE_DIR}/userspace/engine" + "${PROJECT_BINARY_DIR}/userspace/falco" "${YAMLCPP_INCLUDE_DIR}" "${CIVETWEB_INCLUDE_DIR}" "${PROJECT_SOURCE_DIR}/userspace/falco") diff --git a/userspace/falco/config_falco.h.in b/userspace/falco/config_falco.h.in index 1b95dae6..cd74a83a 100644 --- a/userspace/falco/config_falco.h.in +++ b/userspace/falco/config_falco.h.in @@ -28,6 +28,7 @@ limitations under the License. #define FALCO_SOURCE_DIR "${PROJECT_SOURCE_DIR}" #define FALCO_SOURCE_CONF_FILE "${PROJECT_SOURCE_DIR}/falco.yaml" #define FALCO_INSTALL_CONF_FILE "/etc/falco/falco.yaml" +#define FALCO_ENGINE_PLUGINS_DIR "${FALCO_ABSOLUTE_SHARE_DIR}/plugins/" #define PROBE_NAME "@PROBE_NAME@" #define DRIVER_VERSION "@PROBE_VERSION@" \ No newline at end of file