Skip to content

Commit

Permalink
Falco Bridge: Fix building on Windows.
Browse files Browse the repository at this point in the history
Fix Falco plugin installation in multi-config environments. Fix FindSinsp
on Windows.  Ignore a couple of warnings for now.
  • Loading branch information
geraldcombs committed Apr 27, 2022
1 parent 0f69587 commit 52db7e8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 11 deletions.
5 changes: 2 additions & 3 deletions CMakeLists.txt
Expand Up @@ -2700,11 +2700,10 @@ if(BUILD_logwolf AND QT_FOUND)
endif()

if (BUILD_logwolf AND SINSP_FOUND)
file(MAKE_DIRECTORY ${LOGWOLF_PLUGIN_DIR}/falco)
add_custom_target(copy_falco_plugins)
add_custom_command(TARGET copy_falco_plugins
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${SINSP_PLUGINS} ${LOGWOLF_PLUGIN_DIR}/falco
COMMAND ${CMAKE_COMMAND} -E make_directory ${LOGWOLF_PLUGIN_DIR}/falco
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SINSP_PLUGINS} ${LOGWOLF_PLUGIN_DIR}/falco
)
add_dependencies(logwolf copy_falco_plugins)
endif()
Expand Down
28 changes: 20 additions & 8 deletions cmake/modules/FindSinsp.cmake
Expand Up @@ -39,10 +39,13 @@ find_path(SINSP_PLUGIN_DIR
HINTS "${SINSP_PLUGINDIR}"
)

# https://github.com/falcosecurity/libs doesn't yet have any official releases
# or tags. Add RelWithDebInfo to our sinsp and scap path suffixes so that we
# can find what we need in a local build.
find_library(SINSP_LIBRARY
NAMES sinsp
HINTS "${SINSP_LIBDIR}" "${SINSP_HINTS}/lib"
PATH_SUFFIXES libsinsp
PATH_SUFFIXES libsinsp libsinsp/RelWithDebInfo
PATHS
/usr/lib
/usr/local/lib
Expand All @@ -51,7 +54,7 @@ find_library(SINSP_LIBRARY
find_library(SCAP_LIBRARY
NAMES scap
HINTS "${SINSP_LIBDIR}" "${SINSP_HINTS}/lib"
PATH_SUFFIXES libscap
PATH_SUFFIXES libscap libscap/RelWithDebInfo
PATHS
/usr/lib
/usr/local/lib
Expand All @@ -60,6 +63,7 @@ find_library(SCAP_LIBRARY
find_path(JSON_INCLUDE_DIR
NAMES json/json.h
HINTS "${SINSP_INCLUDEDIR}" "${SINSP_HINTS}/include"
PATH_SUFFIXES userspace/libsinsp/third-party/jsoncpp
/usr/include
/usr/include/jsoncpp
/usr/local/include
Expand Down Expand Up @@ -106,19 +110,27 @@ find_package_handle_standard_args(Sinsp
REQUIRED_VARS
SINSP_LIBRARY SINSP_INCLUDE_DIR
SCAP_LIBRARY SCAP_INCLUDE_DIR
JSONCPP_LIBRARY JSON_INCLUDE_DIR
TBB_LIBRARY TBB_INCLUDE_DIR
JSON_INCLUDE_DIR
SINSP_PLUGIN_DIR
# VERSION_VAR SINSP_VERSION
)

if( SINSP_FOUND )
set( SINSP_INCLUDE_DIRS ${SINSP_INCLUDE_DIR} ${SCAP_INCLUDE_DIR} ${JSON_INCLUDE_DIR} ${TBB_INCLUDE_DIR} )
set( SINSP_LIBRARIES ${SINSP_LIBRARY} ${SCAP_LIBRARY} ${JSONCPP_LIBRARY} ${TBB_LIBRARY} )
set(SINSP_INCLUDE_DIRS ${SINSP_INCLUDE_DIR} ${SCAP_INCLUDE_DIR} ${JSON_INCLUDE_DIR})
if(TBB_INCLUDE_DIR)
list(APPEND SINSP_INCLUDE_DIRS ${TBB_INCLUDE_DIR})
endif()
set(SINSP_LIBRARIES ${SINSP_LIBRARY} ${SCAP_LIBRARY})
if (JSONCPP_LIBRARY)
list(APPEND SINSP_LIBRARIES ${JSONCPP_LIBRARY})
endif()
if (TBB_LIBRARY)
list(APPEND SINSP_LIBRARIES ${TBB_LIBRARY})
endif()
if (WIN32)
set( SINSP_PLUGINS ${SINSP_PLUGIN_DIR}/plugins/cloudtrail/cloudtrail.dll )
set(SINSP_PLUGINS ${SINSP_PLUGIN_DIR}/plugins/cloudtrail/cloudtrail.dll)
else()
set( SINSP_PLUGINS ${SINSP_PLUGIN_DIR}/plugins/cloudtrail/libcloudtrail.so )
set(SINSP_PLUGINS ${SINSP_PLUGIN_DIR}/plugins/cloudtrail/libcloudtrail.so)
endif()
# if (WIN32)
# set ( SINSP_DLL_DIR "${SINSP_HINTS}/bin"
Expand Down
10 changes: 10 additions & 0 deletions plugins/epan/falco_bridge/sinsp-span.cpp
Expand Up @@ -17,6 +17,12 @@

#include <glib.h>

#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4100)
#pragma warning(disable:4267)
#endif

// epan/address.h and driver/ppm_events_public.h both define PT_NONE, so
// handle libsinsp calls here.

Expand Down Expand Up @@ -197,3 +203,7 @@ bool extract_sisnp_source_fields(sinsp_source_info_t *ssi, uint32_t evt_num, uin
}
return status;
}

#ifdef _MSC_VER
#pragma warning(pop)
#endif

0 comments on commit 52db7e8

Please sign in to comment.