Skip to content

Commit

Permalink
fix: alignment with libs api
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Scolaro <[email protected]>
  • Loading branch information
therealbobo committed Feb 21, 2024
1 parent 07ed12d commit 9b5e2c4
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 65 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ endif()
set(PACKAGE_NAME "sysdig")

add_definitions(-DPLATFORM_NAME="${CMAKE_SYSTEM_NAME}")
if(NOT DEFINED CHISEL_TOOL_LIBRARY_NAME)
set(CHISEL_TOOL_LIBRARY_NAME "sysdig")
endif()
add_definitions(-DCHISEL_TOOL_LIBRARY_NAME="${CHISEL_TOOL_LIBRARY_NAME}")

option(BUILD_WARNINGS_AS_ERRORS "Enable building with -Wextra -Werror flags")

Expand Down
4 changes: 2 additions & 2 deletions cmake/modules/driver.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ else()
# In case you want to test against another driver version (or branch, or commit) just pass the variable -
# ie., `cmake -DDRIVER_VERSION=dev ..`
if(NOT DRIVER_VERSION)
set(DRIVER_VERSION "0.14.1")
set(DRIVER_CHECKSUM "SHA256=defdea24bf3b176c63f10900d3716fe4373151965cc09d3fe67a31a3a9af0b13")
set(DRIVER_VERSION "d8bfc3ce1311f8db82b7e0ecdfc0a699c6a85b4b")
set(DRIVER_CHECKSUM "SHA256=3586650f0165e15ad72ea5e8399543d31c5286c67bdd0cc151ff2b61e79c5502")
endif()

# cd /path/to/build && cmake /path/to/source
Expand Down
1 change: 0 additions & 1 deletion cmake/modules/falcosecurity-libs-repo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ ExternalProject_Add(
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
PATCH_COMMAND sh -c "patch -p1 <${CMAKE_SOURCE_DIR}/chisel.patch"
)
11 changes: 5 additions & 6 deletions cmake/modules/falcosecurity-libs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ else()
# In case you want to test against another falcosecurity/libs version (or branch, or commit) just pass the variable -
# ie., `cmake -DFALCOSECURITY_LIBS_VERSION=dev ..`
if(NOT FALCOSECURITY_LIBS_VERSION)
set(FALCOSECURITY_LIBS_VERSION "0.14.2")
set(FALCOSECURITY_LIBS_CHECKSUM "SHA256=b4ae7bbf3ad031deee4a808145f9fd64b71c537406cc5a92f512823b2e52cdd5")
set(FALCOSECURITY_LIBS_VERSION "d8bfc3ce1311f8db82b7e0ecdfc0a699c6a85b4b")
set(FALCOSECURITY_LIBS_CHECKSUM "SHA256=3586650f0165e15ad72ea5e8399543d31c5286c67bdd0cc151ff2b61e79c5502")
endif()

# cd /path/to/build && cmake /path/to/source
Expand All @@ -57,10 +57,9 @@ endif()

set(SCAP_HOST_ROOT_ENV_VAR_NAME "HOST_ROOT")

if(NOT LIBSCAP_DIR)
set(LIBSCAP_DIR "${FALCOSECURITY_LIBS_SOURCE_DIR}")
endif()
set(LIBSINSP_DIR "${FALCOSECURITY_LIBS_SOURCE_DIR}")
if(NOT LIBS_DIR)
set(LIBS_DIR "${FALCOSECURITY_LIBS_SOURCE_DIR}")
endif()

# configure gVisor support
set(BUILD_LIBSCAP_GVISOR ${BUILD_SYSDIG_GVISOR} CACHE BOOL "")
Expand Down
14 changes: 7 additions & 7 deletions userspace/sinspui/cursescomponents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ limitations under the License.
#include <set>
using namespace std;

#include "sinsp.h"
#include "sinsp_int.h"
#include "filter.h"
#include "filterchecks.h"
#include <libsinsp/sinsp.h>
#include <libsinsp/sinsp_int.h>
#include <libsinsp/filter.h>
#include <libsinsp/filterchecks.h>

#include "chisel_table.h"
#include <chisel/chisel_table.h>
#include <chisel/chisel_viewinfo.h>
#include "cursescomponents.h"
#include "cursestable.h"
#include "chisel_viewinfo.h"
#include "cursesui.h"
#include "utils.h"

Expand Down Expand Up @@ -150,7 +150,7 @@ const char* spy_text_renderer::process_event_spy(sinsp_evt* evt, int64_t* len)
return NULL;
}

sinsp_fdinfo_t* m_fdinfo = evt->get_fd_info();
sinsp_fdinfo* m_fdinfo = evt->get_fd_info();
if(m_fdinfo == NULL)
{
return NULL;
Expand Down
14 changes: 7 additions & 7 deletions userspace/sinspui/cursesspectro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ limitations under the License.
#include <set>
using namespace std;

#include "sinsp.h"
#include "filter.h"
#include "filterchecks.h"
#include <libsinsp/sinsp.h>
#include <libsinsp/filter.h>
#include <libsinsp/filterchecks.h>

#ifndef NOCURSESUI

#include <curses.h>
#include "chisel_table.h"
#include <chisel/chisel_table.h>
#include "ctext.h"
#include "cursescomponents.h"
#include "cursestable.h"
Expand Down Expand Up @@ -463,7 +463,7 @@ chisel_table_action curses_spectro::handle_input(int ch)
{
if(m_last_mevent.bstate & BUTTON1_CLICKED)
{
g_logger.format("mouse clicked");
libsinsp_logger()->format("mouse clicked");

if(m_last_mevent.y == (int)m_h - 2)
{
Expand Down Expand Up @@ -517,8 +517,8 @@ chisel_table_action curses_spectro::handle_input(int ch)
") and (evt.latency>=" + to_string(start_latency) +
" and evt.latency<" + to_string(end_latency) + ")";

g_logger.format("spectrogram drill down");
g_logger.format("filter: %s", m_selection_filter.c_str());
libsinsp_logger()->format("spectrogram drill down");
libsinsp_logger()->format("filter: %s", m_selection_filter.c_str());

m_selstart_x = -1;
m_selstart_y = -1;
Expand Down
12 changes: 6 additions & 6 deletions userspace/sinspui/cursestable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ limitations under the License.
#include <set>
using namespace std;

#include "sinsp.h"
#include "sinsp_int.h"
#include "filter.h"
#include "filterchecks.h"
#include <libsinsp/sinsp.h>
#include <libsinsp/sinsp_int.h>
#include <libsinsp/filter.h>
#include <libsinsp/filterchecks.h>

#ifndef NOCURSESUI

#include <curses.h>
#include "chisel_table.h"
#include <chisel/chisel_table.h>
#include "cursescomponents.h"
#include "cursestable.h"
#include "cursesui.h"
Expand Down Expand Up @@ -261,7 +261,7 @@ void curses_table::print_line_centered(string line, int32_t off)
for(uint32_t j = 0;; j++)
{
string ss = line.substr(spos, spos + m_parent->m_screenw);
glogf("2, %d %s\n", spos, ss.c_str());
libsinsp_logger()->format("2, %d %s\n", spos, ss.c_str());

mvwprintw(m_tblwin,
m_parent->m_screenh / 2 + off + j,
Expand Down
18 changes: 9 additions & 9 deletions userspace/sinspui/cursesui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@ limitations under the License.

#include <iostream>
#include <algorithm>
#include "sinsp.h"
#include "sinsp_int.h"
#include "filter.h"
#include "filterchecks.h"
#include <libsinsp/sinsp.h>
#include <libsinsp/sinsp_int.h>
#include <libsinsp/filter.h>
#include <libsinsp/filterchecks.h>

#ifndef _WIN32
#include <curses.h>
#else
#include <conio.h>
#define getch _getch
#endif
#include "chisel_table.h"
#include <chisel/chisel_table.h>
#include "cursescomponents.h"
#include "cursestable.h"
#include "cursesspectro.h"
Expand Down Expand Up @@ -2535,7 +2535,7 @@ chisel_table_action sinsp_cursesui::handle_input(int ch)
{
chisel_view_info* vinfo = get_selected_view();

g_logger.format("running action %d %s", m_selected_action_sidemenu_entry,
libsinsp_logger()->format("running action %d %s", m_selected_action_sidemenu_entry,
vinfo->m_name.c_str());
if(vinfo->m_actions.size() != 0)
{
Expand Down Expand Up @@ -3179,8 +3179,8 @@ void sinsp_cursesui::run_action(chisel_view_action_info* action)
#endif // NOCURSESUI
}

g_logger.format("original command: %s", action->m_command.c_str());
g_logger.format("running command: %s", resolved_command.c_str());
libsinsp_logger()->format("original command: %s", action->m_command.c_str());
libsinsp_logger()->format("running command: %s", resolved_command.c_str());

#ifndef NOCURSESUI
//
Expand Down Expand Up @@ -3225,7 +3225,7 @@ void sinsp_cursesui::run_action(chisel_view_action_info* action)
int sret = system(resolved_command.c_str());
if(sret == -1)
{
g_logger.format("command failed");
libsinsp_logger()->format("command failed");
}
}

Expand Down
1 change: 0 additions & 1 deletion userspace/sinspui/cursesui.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ std::string combine_filters(std::string flt1, std::string flt2);
class ctext;
class sinsp_chart;
class curses_spectro;
extern sinsp_logger g_logger;

class sinsp_menuitem_info
{
Expand Down
9 changes: 0 additions & 9 deletions userspace/sysdig/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ if(NOT WIN32)
include(ncurses)
endif() # NOT WIN32

include(libscap)
include(libsinsp)
include(zlib)

include_directories("${LIBSINSP_INCLUDE_DIRS}")
include_directories("${PROJECT_BINARY_DIR}/userspace/sinspui")
include_directories(../sinspui)
include_directories("${PROJECT_BINARY_DIR}/userspace/sysdig")
Expand Down Expand Up @@ -76,16 +71,12 @@ endif()
target_include_directories(
sysdig
PUBLIC
"${LIBSCAP_INCLUDE_DIRS}"
"${LIBSINSP_INCLUDE_DIRS}"
"${YAMLCPP_INCLUDE_DIR}"
"${NJSON_INCLUDE_DIR}")

target_include_directories(
csysdig
PUBLIC
"${LIBSCAP_INCLUDE_DIRS}"
"${LIBSINSP_INCLUDE_DIRS}"
"${YAMLCPP_INCLUDE_DIR}"
"${NJSON_INCLUDE_DIR}")

Expand Down
12 changes: 6 additions & 6 deletions userspace/sysdig/csysdig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ limitations under the License.
#include <assert.h>
#include <algorithm>

#include <sinsp.h>
#include <libsinsp/sinsp.h>
#ifdef HAS_CAPTURE
#ifndef WIN32
#include "driver_config.h"
#endif // WIN32
#endif // HAS_CAPTURE
#include "sysdig.h"
#ifdef HAS_CHISELS
#include "chisel.h"
#include "chisel_utils.h"
#include <chisel/chisel.h>
#include <chisel/chisel_utils.h>
#endif
#include "chisel_table.h"
#include "utils.h"
#include <chisel/chisel_table.h>
#include <libsinsp/utils.h>
#include "utils/plugin_utils.h"
#include "utils/sinsp_opener.h"
#include "utils/supported_fields.h"
Expand All @@ -58,7 +58,7 @@ limitations under the License.
#include "cursestable.h"
#include "cursesui.h"
#include "scap_open_exception.h"
#include "chisel_capture_interrupt_exception.h"
#include <chisel/chisel_capture_interrupt_exception.h>

#define MOUSE_CAPABLE_TERM "xterm-1003"
#define MOUSE_CAPABLE_TERM_COMPAT "xterm-1002"
Expand Down
27 changes: 17 additions & 10 deletions userspace/sysdig/sysdig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,20 @@ limitations under the License.
#include <unordered_set>
#include <atomic>

#include <sinsp.h>
#include <libsinsp/sinsp.h>
#include <libsinsp/sinsp_cycledumper.h>
#include "scap_open_exception.h"
#include "chisel_capture_interrupt_exception.h"
#include <chisel/chisel_capture_interrupt_exception.h>
#ifdef HAS_CAPTURE
#ifndef WIN32
#include "driver_config.h"
#endif // WIN32
#endif // HAS_CAPTURE
#include "sysdig.h"
#ifdef HAS_CHISELS
#include "chisel.h"
#include "chisel_utils.h"
#include "chisel_fields_info.h"
#include <chisel/chisel.h>
#include <chisel/chisel_utils.h>
#include <chisel/chisel_fields_info.h>
#endif
#include "utils.h"
#include "plugin.h"
Expand Down Expand Up @@ -542,7 +543,7 @@ static void initialize_chisels()
//
static void parse_chisel_args(
sinsp_chisel* ch,
std::shared_ptr<gen_event_filter_factory> filter_factory,
std::shared_ptr<sinsp_filter_factory> filter_factory,
int optind, int argc, char **argv, int32_t* n_filterargs)
{
uint32_t nargs = ch->get_n_args();
Expand Down Expand Up @@ -737,6 +738,7 @@ std::vector<std::string> split_nextrun_args(std::string na)
// Event processing loop
//
captureinfo do_inspect(sinsp* inspector,
sinsp_cycledumper* dumper,
uint64_t cnt,
uint64_t duration_to_tot_ns,
bool quiet,
Expand Down Expand Up @@ -785,6 +787,10 @@ captureinfo do_inspect(sinsp* inspector,
break;
}
res = inspector->next(&ev);
if(dumper && res != SCAP_EOF)
{
dumper->dump(ev);
}

if(res == SCAP_TIMEOUT || res == SCAP_FILTERED_EVENT)
{
Expand Down Expand Up @@ -983,6 +989,7 @@ sysdig_init_res sysdig_init(int argc, char **argv)
{
sysdig_init_res res;
std::unique_ptr<sinsp> inspector;
std::unique_ptr<sinsp_cycledumper> dumper;
std::vector<std::string> infiles;
std::string outfile;
int op;
Expand Down Expand Up @@ -1024,7 +1031,7 @@ sysdig_init_res sysdig_init(int argc, char **argv)
std::string plugin_config_file = "";
sinsp_opener opener;
std::unique_ptr<filter_check_list> filter_list;
std::shared_ptr<gen_event_filter_factory> filter_factory;
std::shared_ptr<sinsp_filter_factory> filter_factory;

// These variables are for the cycle_writer engine
int duration_seconds = 0;
Expand Down Expand Up @@ -1543,7 +1550,7 @@ sysdig_init_res sysdig_init(int argc, char **argv)
fprintf(stderr, "invalid log level %s\n", optarg);
return sysdig_init_res(EXIT_FAILURE);
}
g_logger.add_stdout_log();
libsinsp_logger()->add_stdout_log();
}
else if (optname == "list-chisels") {
std::vector<chisel_desc> chlist;
Expand Down Expand Up @@ -1917,8 +1924,7 @@ sysdig_init_res sysdig_init(int argc, char **argv)

if(outfile != "")
{
inspector->setup_cycle_writer(outfile, rollover_mb, duration_seconds, file_limit, event_limit, compress);
inspector->autodump_next_file();
dumper = std::make_unique<sinsp_cycledumper>(inspector.get(), outfile, rollover_mb, duration_seconds, file_limit, event_limit, compress);
}

//
Expand Down Expand Up @@ -1969,6 +1975,7 @@ sysdig_init_res sysdig_init(int argc, char **argv)
disable_tty_echo();
#endif
cinfo = do_inspect(inspector.get(),
dumper.get(),
cnt,
uint64_t(duration_to_tot*ONE_SECOND_IN_NS),
quiet,
Expand Down
2 changes: 1 addition & 1 deletion userspace/sysdig/utils/supported_fields.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ limitations under the License.
struct fields_info
{
std::set<std::string> compatible_sources;
gen_event_filter_factory::filter_fieldclass_info class_info;
sinsp_filter_factory::filter_fieldclass_info class_info;
};

void print_supported_fields(sinsp* inspector, plugin_utils& plugins, const std::string &source, bool verbose, bool markdown)
Expand Down

0 comments on commit 9b5e2c4

Please sign in to comment.