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 Mar 12, 2024
1 parent 1e0fd10 commit 0c4aa51
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 93 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 "7.0.0+driver")
set(DRIVER_CHECKSUM "SHA256=9f2a0f14827c0d9d1c3d1abe45b8f074dea531ebeca9859363a92f0d2475757e")
set(DRIVER_VERSION "03f027a33d3c56fdaa252412ba800baecbfacea3")
set(DRIVER_CHECKSUM "SHA256=806546e1e64df0b903df252840c57902036e5ba176a2091b55da4f135ee94f84")
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 && patch -p1 <${CMAKE_SOURCE_DIR}/eof.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 "03f027a33d3c56fdaa252412ba800baecbfacea3")
set(FALCOSECURITY_LIBS_CHECKSUM "SHA256=806546e1e64df0b903df252840c57902036e5ba176a2091b55da4f135ee94f84")
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
21 changes: 8 additions & 13 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 Expand Up @@ -835,11 +835,6 @@ curses_textbox::~curses_textbox()
delete m_searcher;
}

if(m_filter != NULL)
{
delete m_filter;
}

if(m_text_renderer)
{
delete m_text_renderer;
Expand All @@ -860,7 +855,7 @@ curses_textbox::~curses_textbox()
void curses_textbox::set_filter(string filter)
{
sinsp_filter_compiler compiler(m_inspector, filter);
m_filter = compiler.compile();
m_filter = std::move(compiler.compile());
}

void curses_textbox::print_no_data()
Expand Down
2 changes: 1 addition & 1 deletion userspace/sinspui/cursescomponents.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public sinsp_chart, public search_caller_interface
ctext* m_ctext;
sinsp_cursesui* m_parent;
sinsp* m_inspector;
sinsp_filter* m_filter;
std::unique_ptr<sinsp_filter> m_filter;
uint32_t n_prints;
bool m_paused;
curses_table_sidemenu* m_sidemenu;
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
30 changes: 12 additions & 18 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 @@ -86,19 +86,14 @@ json_spy_renderer::json_spy_renderer(sinsp* inspector,
json_spy_renderer::~json_spy_renderer()
{
delete m_json_spy_renderer;

if(m_filter != NULL)
{
delete m_filter;
}
}

void json_spy_renderer::set_filter(string filter)
{
if(filter != "")
{
sinsp_filter_compiler compiler(m_inspector, filter);
m_filter = compiler.compile();
m_filter = std::move(compiler.compile());
}
}

Expand Down Expand Up @@ -2266,11 +2261,11 @@ chisel_table_action sinsp_cursesui::handle_textbox_input(int ch)
if(*str != "")
{
sinsp_filter_compiler compiler(m_inspector, *str);
sinsp_filter* f;
std::unique_ptr<sinsp_filter> f;

try
{
f = compiler.compile();
f = std::move(compiler.compile());
}
catch(const sinsp_exception& e)
{
Expand Down Expand Up @@ -2300,7 +2295,6 @@ chisel_table_action sinsp_cursesui::handle_textbox_input(int ch)
break;
}

delete f;
}
}

Expand Down Expand Up @@ -2535,7 +2529,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 +3173,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 +3219,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
5 changes: 3 additions & 2 deletions userspace/sinspui/cursesui.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ limitations under the License.
#include <unistd.h>
#endif

#include <memory>

#include "../sysdig/utils/sinsp_opener.h"

#define UI_USER_INPUT_CHECK_PERIOD_NS 10000000
Expand All @@ -31,7 +33,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 Expand Up @@ -350,7 +351,7 @@ class json_spy_renderer
spy_text_renderer* m_json_spy_renderer;
sinsp* m_inspector;
Json::Value m_root;
sinsp_filter* m_filter;
std::unique_ptr<sinsp_filter> m_filter;
uint64_t m_linecnt;
};

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
Loading

0 comments on commit 0c4aa51

Please sign in to comment.