Skip to content

Commit fcdf2a8

Browse files
committed
fix: use the member filter check list
Signed-off-by: Roberto Scolaro <[email protected]>
1 parent 31456a2 commit fcdf2a8

File tree

8 files changed

+43
-30
lines changed

8 files changed

+43
-30
lines changed

userspace/chisel/chisel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,8 @@ void chiselinfo::init(string filterstr, string formatterstr)
204204

205205
void chiselinfo::set_filter(string filterstr)
206206
{
207-
208-
sinsp_filter_compiler compiler(m_inspector, filterstr);
207+
auto filter_factory = std::make_shared<sinsp_filter_factory>(m_inspector, *m_filter_check_list);
208+
sinsp_filter_compiler compiler(filter_factory, filterstr);
209209
if(m_filter)
210210
{
211211
delete m_filter;

userspace/chisel/chisel_api.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,8 @@ int lua_cbacks::get_thread_table_int(lua_State *ls, bool include_fds, bool bareb
738738
{
739739
try
740740
{
741-
compiler = std::make_unique<sinsp_filter_compiler>(ch->m_inspector, filterstr);
741+
auto filter_factory = std::make_shared<sinsp_filter_factory>(ch->m_inspector, *ch->m_filter_check_list);
742+
compiler = std::make_unique<sinsp_filter_compiler>(filter_factory, filterstr);
742743
filter = compiler->compile();
743744
}
744745
catch(const sinsp_exception& e)

userspace/chisel/chisel_table.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ draios/sysdig project.
2323
2424
*/
2525

26-
#include <algorithm>
27-
2826
#include <libsinsp/sinsp.h>
2927
#include <chisel/chisel_table.h>
3028

@@ -159,7 +157,8 @@ void chisel_table::configure(vector<chisel_view_column_info>* entries, const str
159157
//////////////////////////////////////////////////////////////////////////////////////
160158
if(filter != "")
161159
{
162-
sinsp_filter_compiler compiler(m_inspector, filter);
160+
auto filter_factory = std::make_shared<sinsp_filter_factory>(m_inspector, *m_filter_check_list);
161+
sinsp_filter_compiler compiler(filter_factory, filter);
163162
m_filter = compiler.compile().release();
164163
}
165164

userspace/chisel/chisel_viewinfo.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ falcosecurity/libs project, has been reintroduced to the
2222
draios/sysdig project.
2323
2424
*/
25-
#include <algorithm>
2625
#include <libsinsp/sinsp.h>
2726
#include <chisel/chisel_viewinfo.h>
2827

userspace/sinspui/cursescomponents.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,11 @@ using namespace std;
4747

4848
extern bool g_filterchecks_force_raw_times;
4949

50-
// todo(jasondellaluce): this list is static and prevents from using
51-
// plugin-defined extraction fields. The right way would be to have a filtercheck
52-
// list owned by each component and populate depending on the loaded plugins.
53-
// this is not something that we plan on supporting for now.
54-
static sinsp_filter_check_list s_filterlist;
55-
5650
///////////////////////////////////////////////////////////////////////////////
5751
// spy_text_renderer implementation
5852
///////////////////////////////////////////////////////////////////////////////
5953
spy_text_renderer::spy_text_renderer(sinsp* inspector,
54+
std::shared_ptr<sinsp_filter_check_list> filter_check_list,
6055
sinsp_cursesui* parent,
6156
int32_t viz_type,
6257
sysdig_output_type sotype,
@@ -65,6 +60,7 @@ spy_text_renderer::spy_text_renderer(sinsp* inspector,
6560
{
6661
m_formatter = NULL;
6762
m_inspector = inspector;
63+
m_filter_check_list = filter_check_list;
6864
m_viz_type = viz_type;
6965
m_linecnt = 0;
7066

@@ -79,13 +75,13 @@ spy_text_renderer::spy_text_renderer(sinsp* inspector,
7975
{
8076
m_formatter = new sinsp_evt_formatter(m_inspector,
8177
"*(latency=%evt.latency.human) (fd=%fd.name) %evt.num %evt.time %evt.cpu %container.name (%container.id) %proc.name (%thread.tid:%thread.vtid) %evt.dir %evt.type %evt.info",
82-
s_filterlist);
78+
*m_filter_check_list);
8379
}
8480
else
8581
{
8682
m_formatter = new sinsp_evt_formatter(m_inspector,
8783
"*(latency=%evt.latency.human) (fd=%fd.name) %evt.num %evt.time %evt.cpu %proc.name %thread.tid %evt.dir %evt.type %evt.info",
88-
s_filterlist);
84+
*m_filter_check_list);
8985
}
9086
}
9187
else
@@ -94,11 +90,11 @@ spy_text_renderer::spy_text_renderer(sinsp* inspector,
9490
{
9591
m_formatter = new sinsp_evt_formatter(m_inspector,
9692
"*%evt.num %evt.time %evt.cpu %container.name (%container.id) %proc.name (%thread.tid:%thread.vtid) %evt.dir %evt.type %evt.info",
97-
s_filterlist);
93+
*m_filter_check_list);
9894
}
9995
else
10096
{
101-
m_formatter = new sinsp_evt_formatter(m_inspector, DEFAULT_OUTPUT_STR, s_filterlist);
97+
m_formatter = new sinsp_evt_formatter(m_inspector, DEFAULT_OUTPUT_STR, *m_filter_check_list);
10298
}
10399
}
104100
}
@@ -737,7 +733,7 @@ chisel_table_action curses_table_sidemenu::handle_input(int ch)
737733
///////////////////////////////////////////////////////////////////////////////
738734
// curses_textbox implementation
739735
///////////////////////////////////////////////////////////////////////////////
740-
curses_textbox::curses_textbox(sinsp* inspector, sinsp_cursesui* parent, int32_t viz_type, spy_text_renderer::sysdig_output_type sotype)
736+
curses_textbox::curses_textbox(sinsp* inspector, std::shared_ptr<sinsp_filter_check_list> filter_check_list, sinsp_cursesui* parent, int32_t viz_type, spy_text_renderer::sysdig_output_type sotype)
741737
{
742738
ASSERT(inspector != NULL);
743739
ASSERT(parent != NULL);
@@ -748,6 +744,7 @@ curses_textbox::curses_textbox(sinsp* inspector, sinsp_cursesui* parent, int32_t
748744
m_filter = NULL;
749745
m_text_renderer = NULL;
750746
m_inspector = inspector;
747+
m_filter_check_list = filter_check_list;
751748
n_prints = 0;
752749
m_paused = false;
753750
m_sidemenu = NULL;
@@ -766,8 +763,9 @@ curses_textbox::curses_textbox(sinsp* inspector, sinsp_cursesui* parent, int32_t
766763
config.m_scroll_on_append = true;
767764
config.m_bounding_box = true;
768765

769-
m_text_renderer = new spy_text_renderer(inspector,
770-
parent,
766+
m_text_renderer = new spy_text_renderer(inspector,
767+
m_filter_check_list,
768+
parent,
771769
viz_type,
772770
sotype,
773771
m_parent->m_print_containers,
@@ -854,8 +852,12 @@ curses_textbox::~curses_textbox()
854852

855853
void curses_textbox::set_filter(string filter)
856854
{
857-
sinsp_filter_compiler compiler(m_inspector, filter);
858-
m_filter = compiler.compile();
855+
if(filter != "")
856+
{
857+
auto filter_factory = std::make_shared<sinsp_filter_factory>(m_inspector, *m_filter_check_list);
858+
sinsp_filter_compiler compiler(filter_factory, filter);
859+
m_filter = compiler.compile();
860+
}
859861
}
860862

861863
void curses_textbox::print_no_data()

userspace/sinspui/cursescomponents.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ class spy_text_renderer
5757
};
5858

5959
spy_text_renderer(sinsp* inspector,
60-
sinsp_cursesui* parent,
60+
std::shared_ptr<sinsp_filter_check_list> filter_check_list,
61+
sinsp_cursesui* parent,
6162
int32_t viz_type,
6263
sysdig_output_type sotype,
6364
bool print_containers,
@@ -67,6 +68,7 @@ class spy_text_renderer
6768

6869
sinsp_evt_formatter* m_formatter;
6970
sinsp* m_inspector;
71+
std::shared_ptr<sinsp_filter_check_list> m_filter_check_list;
7072
int32_t m_viz_type;
7173
uint64_t m_linecnt;
7274
};
@@ -186,7 +188,7 @@ class curses_textbox :
186188
public sinsp_chart, public search_caller_interface
187189
{
188190
public:
189-
curses_textbox(sinsp* inspector, sinsp_cursesui* parent, int32_t viz_type, spy_text_renderer::sysdig_output_type sotype);
191+
curses_textbox(sinsp* inspector, std::shared_ptr<sinsp_filter_check_list> filter_check_list, sinsp_cursesui* parent, int32_t viz_type, spy_text_renderer::sysdig_output_type sotype);
190192
~curses_textbox();
191193
void render();
192194
void set_filter(std::string filter);
@@ -214,6 +216,7 @@ public sinsp_chart, public search_caller_interface
214216
ctext* m_ctext;
215217
sinsp_cursesui* m_parent;
216218
sinsp* m_inspector;
219+
std::shared_ptr<sinsp_filter_check_list> m_filter_check_list;
217220
std::unique_ptr<sinsp_filter> m_filter;
218221
uint32_t n_prints;
219222
bool m_paused;

userspace/sinspui/cursesui.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,22 @@ int do_sleep(DWORD usec)
6363
///////////////////////////////////////////////////////////////////////////////
6464
// json_spy_renderer implementation
6565
///////////////////////////////////////////////////////////////////////////////
66-
json_spy_renderer::json_spy_renderer(sinsp* inspector,
66+
json_spy_renderer::json_spy_renderer(sinsp* inspector,
67+
std::shared_ptr<sinsp_filter_check_list> filter_check_list,
6768
sinsp_cursesui* parent,
6869
int32_t viz_type,
6970
spy_text_renderer::sysdig_output_type sotype,
7071
bool print_containers,
7172
sinsp_evt::param_fmt text_fmt)
7273
{
7374
m_inspector = inspector;
75+
m_filter_check_list = filter_check_list;
7476
m_filter = NULL;
7577
m_root = Json::Value(Json::arrayValue);
7678
m_linecnt = 0;
7779

78-
m_json_spy_renderer = new spy_text_renderer(inspector,
80+
m_json_spy_renderer = new spy_text_renderer(inspector,
81+
m_filter_check_list,
7982
parent,
8083
viz_type,
8184
sotype,
@@ -92,7 +95,8 @@ void json_spy_renderer::set_filter(string filter)
9295
{
9396
if(filter != "")
9497
{
95-
sinsp_filter_compiler compiler(m_inspector, filter);
98+
auto filter_factory = std::make_shared<sinsp_filter_factory>(m_inspector, *m_filter_check_list);
99+
sinsp_filter_compiler compiler(filter_factory, filter);
96100
m_filter = compiler.compile();
97101
}
98102
}
@@ -651,6 +655,7 @@ void sinsp_cursesui::start(bool is_drilldown, bool is_spy_switch)
651655
if(m_output_type == chisel_table::OT_JSON)
652656
{
653657
m_json_spy_renderer= new json_spy_renderer(m_inspector,
658+
m_filter_check_list,
654659
this,
655660
m_selected_view,
656661
spy_text_renderer::OT_NORMAL,
@@ -662,7 +667,7 @@ void sinsp_cursesui::start(bool is_drilldown, bool is_spy_switch)
662667
#ifndef NOCURSESUI
663668
else
664669
{
665-
m_spy_box = new curses_textbox(m_inspector, this, m_selected_view, dig_otype);
670+
m_spy_box = new curses_textbox(m_inspector, m_filter_check_list, this, m_selected_view, dig_otype);
666671
m_spy_box->reset();
667672
m_chart = m_spy_box;
668673
m_spy_box->set_filter(m_complete_filter);
@@ -2278,7 +2283,9 @@ chisel_table_action sinsp_cursesui::handle_textbox_input(int ch)
22782283
{
22792284
if(*str != "")
22802285
{
2281-
sinsp_filter_compiler compiler(m_inspector, *str);
2286+
// TODO(therealbobo): use a populated filter check list
2287+
auto filter_factory = std::make_shared<sinsp_filter_factory>(m_inspector, *m_filter_check_list);
2288+
sinsp_filter_compiler compiler(filter_factory, *str);
22822289
std::unique_ptr<sinsp_filter> f;
22832290

22842291
try

userspace/sinspui/cursesui.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ class sinsp_mouse_to_key_list
331331
class json_spy_renderer
332332
{
333333
public:
334-
json_spy_renderer(sinsp* inspector,
334+
json_spy_renderer(sinsp* inspector,
335+
std::shared_ptr<sinsp_filter_check_list> filter_check_list,
335336
sinsp_cursesui* parent,
336337
int32_t viz_type,
337338
spy_text_renderer::sysdig_output_type sotype,
@@ -350,6 +351,7 @@ class json_spy_renderer
350351

351352
spy_text_renderer* m_json_spy_renderer;
352353
sinsp* m_inspector;
354+
std::shared_ptr<sinsp_filter_check_list> m_filter_check_list;
353355
Json::Value m_root;
354356
std::unique_ptr<sinsp_filter> m_filter;
355357
uint64_t m_linecnt;

0 commit comments

Comments
 (0)