Skip to content

Commit

Permalink
new(examples): log on set_config
Browse files Browse the repository at this point in the history
Signed-off-by: Gianmatteo Palmieri <[email protected]>
  • Loading branch information
mrgian authored and poiana committed Feb 12, 2024
1 parent 18af04b commit 3c42154
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 7 deletions.
6 changes: 5 additions & 1 deletion examples/plugin_extract/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ class my_plugin
}

// (optional)
bool set_config(falcosecurity::set_config_input& i) { return false; }
bool set_config(falcosecurity::set_config_input& i)
{
logger.log("new config!");
return true;
}

// (optional)
void destroy() { logger.log("plugin destroyed"); }
Expand Down
6 changes: 5 additions & 1 deletion examples/plugin_source/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ class my_plugin
}

// (optional)
bool set_config(falcosecurity::set_config_input& i) { return false; }
bool set_config(falcosecurity::set_config_input& i)
{
logger.log("new config!");
return true;
}

// (optional)
void destroy() { logger.log("plugin destroyed"); }
Expand Down
10 changes: 9 additions & 1 deletion examples/syscall_async/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,20 @@ class my_plugin
std::string get_contact() { return "some contact"; }

// (optional)
bool set_config(falcosecurity::set_config_input& i) { return false; }
bool set_config(falcosecurity::set_config_input& i)
{
logger.log("new config!");
return true;
}

// (optional)
void destroy() {}

bool init(falcosecurity::init_input& i)
{
logger = i.get_logger();
logger.log("plugin initialized");

m_async_sleep_ms = 1000;
if(!i.get_config().empty())
{
Expand Down Expand Up @@ -109,6 +116,7 @@ class my_plugin
int m_async_sleep_ms;
std::thread m_async_thread;
std::atomic<bool> m_async_thread_quit;
falcosecurity::logger logger;
};

FALCOSECURITY_PLUGIN(my_plugin);
Expand Down
6 changes: 5 additions & 1 deletion examples/syscall_extract/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ class my_plugin
}

// (optional)
bool set_config(falcosecurity::set_config_input& i) { return false; }
bool set_config(falcosecurity::set_config_input& i)
{
logger.log("new config!");
return true;
}

// (optional)
void destroy() { logger.log("plugin destroyed"); }
Expand Down
6 changes: 5 additions & 1 deletion examples/syscall_parse/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ class my_plugin
std::vector<std::string> get_parse_event_sources() { return {"syscall"}; }

// (optional)
bool set_config(falcosecurity::set_config_input& i) { return false; }
bool set_config(falcosecurity::set_config_input& i)
{
logger.log("new config!");
return true;
}

// (optional)
void destroy() { logger.log("plugin destroyed"); }
Expand Down
3 changes: 1 addition & 2 deletions include/falcosecurity/internal/symbols_parsing.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ limitations under the License.
static plugin_mixin<__t> s_plugin_parsing; \
\
FALCOSECURITY_EXPORT \
uint16_t* plugin_get_parse_event_types(uint32_t* numtypes, \
ss_plugin_t* s) \
uint16_t* plugin_get_parse_event_types(uint32_t* numtypes, ss_plugin_t* s) \
{ \
auto p = static_cast<plugin_mixin<__t>*>(s); \
return p->get_parse_event_types(numtypes); \
Expand Down

0 comments on commit 3c42154

Please sign in to comment.