Skip to content

Commit 7a684fd

Browse files
temblekingpoiana
authored andcommittedAug 27, 2024
feat(cmake): add conditional builds for falcoctl and rules
There are systems, like Nix derivations where the build process does not have network access in order to enforce reproducibility. This patch allows people building Falco to optionally skip the build of falcoctl with `-DADD_FALCOCTL_DEPENDENCY=OFF` and point to their own self-backed, or pre-fetched rules files with `-DFALCOSECURITY_RULES_FALCO_PATH=<some-path>` and `-DFALCOSECURITY_RULES_LOCAL_PATH=<some-path>`. For context, I needed to apply these patches while building the project with Nix in https://github.com/tembleking/falco-nix but I think that would be benefitial for the community to have also these options open, and that would also make Falco feasible to be added to the nixpkgs repository at https://github.com/nixos/nixpkgs Signed-off-by: Fede Barcelona <[email protected]>
1 parent 8920701 commit 7a684fd

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed
 

‎cmake/modules/falcoctl.cmake

+8
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@
1414

1515
include(ExternalProject)
1616

17+
option(ADD_FALCOCTL_DEPENDENCY "Add falcoctl dependency while building falco" ON)
18+
19+
if(ADD_FALCOCTL_DEPENDENCY)
1720
string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} FALCOCTL_SYSTEM_NAME)
1821

1922
set(FALCOCTL_VERSION "0.8.0")
2023

24+
message(STATUS "Building with falcoctl: ${FALCOCTL_VERSION}")
25+
2126
if(${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64")
2227
set(FALCOCTL_SYSTEM_PROC_GO "amd64")
2328
set(FALCOCTL_HASH "7b763bfaf38faf582840af22750dca7150d03958a5dc47f6118748713d661589")
@@ -36,3 +41,6 @@ ExternalProject_Add(
3641

3742
install(PROGRAMS "${PROJECT_BINARY_DIR}/falcoctl-prefix/src/falcoctl/falcoctl" DESTINATION "${FALCO_BIN_DIR}" COMPONENT "${FALCO_COMPONENT_NAME}")
3843
install(DIRECTORY DESTINATION "${FALCO_ABSOLUTE_SHARE_DIR}/plugins" COMPONENT "${FALCO_COMPONENT_NAME}")
44+
else()
45+
message(STATUS "Won't build with falcoctl")
46+
endif()

‎cmake/modules/rules.cmake

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
include(GNUInstallDirs)
1616
include(ExternalProject)
1717

18+
if(NOT DEFINED FALCOSECURITY_RULES_FALCO_PATH)
1819
# falco_rules.yaml
1920
set(FALCOSECURITY_RULES_FALCO_VERSION "falco-rules-3.1.0")
2021
set(FALCOSECURITY_RULES_FALCO_CHECKSUM "SHA256=3b617920c0b66128627613e591a954eb9572747a4c287bc13b53b38786250162")
@@ -28,10 +29,13 @@ ExternalProject_Add(
2829
INSTALL_COMMAND ""
2930
TEST_COMMAND ""
3031
)
32+
endif()
3133

34+
if(NOT DEFINED FALCOSECURITY_RULES_LOCAL_PATH)
3235
# falco_rules.local.yaml
3336
set(FALCOSECURITY_RULES_LOCAL_PATH "${PROJECT_BINARY_DIR}/falcosecurity-rules-local-prefix/falco_rules.local.yaml")
3437
file(WRITE "${FALCOSECURITY_RULES_LOCAL_PATH}" "# Your custom rules!\n")
38+
endif()
3539

3640
if(NOT DEFINED FALCO_ETC_DIR)
3741
set(FALCO_ETC_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/falco")

0 commit comments

Comments
 (0)