generated from falcosecurity/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: add capture_open/capture_close hooks
Signed-off-by: Gianmatteo Palmieri <[email protected]>
- Loading branch information
Showing
9 changed files
with
437 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
include/falcosecurity/internal/plugin_mixin_capture_listening.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
/* | ||
Copyright (C) 2023 The Falco Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
#include <falcosecurity/event_reader.h> | ||
#include <falcosecurity/events/decoders.h> | ||
#include <falcosecurity/internal/deps.h> | ||
#include <falcosecurity/types.h> | ||
#include <string> | ||
#include <type_traits> | ||
#include <vector> | ||
|
||
namespace falcosecurity | ||
{ | ||
namespace _internal | ||
{ | ||
template<class Plugin, class Base> | ||
class plugin_mixin_capture_listening : public Base | ||
{ | ||
static_assert(std::has_virtual_destructor<Plugin>::value, | ||
"Plugin type must have a virtual destructor"); | ||
|
||
public: | ||
plugin_mixin_capture_listening() = default; | ||
plugin_mixin_capture_listening(plugin_mixin_capture_listening&&) = default; | ||
plugin_mixin_capture_listening& | ||
operator=(plugin_mixin_capture_listening&&) = default; | ||
plugin_mixin_capture_listening(const plugin_mixin_capture_listening&) = | ||
default; | ||
plugin_mixin_capture_listening& | ||
operator=(const plugin_mixin_capture_listening&) = default; | ||
virtual ~plugin_mixin_capture_listening() = default; | ||
|
||
FALCOSECURITY_INLINE | ||
ss_plugin_rc capture_open(const ss_plugin_capture_listen_input* i) | ||
{ | ||
static_assert( | ||
std::is_same<bool (Plugin::*)(const capture_listen_input&), | ||
decltype(&Plugin::capture_open)>::value, | ||
"expected signature: bool " | ||
"capture_open(const capture_listen_input&)"); | ||
FALCOSECURITY_CATCH_ALL(Base::m_last_err_storage, { | ||
capture_listen_input in(i); | ||
if(!Plugin::capture_open(in)) | ||
{ | ||
return ss_plugin_rc::SS_PLUGIN_FAILURE; | ||
} | ||
return ss_plugin_rc::SS_PLUGIN_SUCCESS; | ||
}); | ||
return ss_plugin_rc::SS_PLUGIN_FAILURE; | ||
} | ||
|
||
FALCOSECURITY_INLINE | ||
ss_plugin_rc capture_close(const ss_plugin_capture_listen_input* i) | ||
{ | ||
static_assert( | ||
std::is_same<bool (Plugin::*)(const capture_listen_input&), | ||
decltype(&Plugin::capture_close)>::value, | ||
"expected signature: bool " | ||
"capture_close(const capture_listen_input&)"); | ||
FALCOSECURITY_CATCH_ALL(Base::m_last_err_storage, { | ||
capture_listen_input in(i); | ||
if(!Plugin::capture_close(in)) | ||
{ | ||
return ss_plugin_rc::SS_PLUGIN_FAILURE; | ||
} | ||
return ss_plugin_rc::SS_PLUGIN_SUCCESS; | ||
}); | ||
return ss_plugin_rc::SS_PLUGIN_FAILURE; | ||
} | ||
}; | ||
}; // namespace _internal | ||
}; // namespace falcosecurity |
Oops, something went wrong.