Skip to content

Commit

Permalink
cleanup: refuse EF_LARGE_PAYLOAD events
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Terzolo <[email protected]>
  • Loading branch information
Andreagit97 authored and poiana committed Dec 5, 2024
1 parent 14af8c8 commit 7f160ac
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/libscap/test_suites/engines/savefile/converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ limitations under the License.
*/
#include "convert_event_test.h"

TEST_F(convert_event_test, conversion_not_needed) {
uint64_t ts = 12;
int64_t tid = 25;
const char data[] = "hello world";

auto evt = create_safe_scap_event(ts,
tid,
PPME_CONTAINER_JSON_2_E,
1,
scap_const_sized_buffer{&data, strlen(data) + 1});
assert_single_conversion_failure(evt);
}

////////////////////////////
// READ
////////////////////////////
Expand Down
13 changes: 13 additions & 0 deletions userspace/libscap/engine/savefile/converter/converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ static uint16_t copy_old_params(scap_evt *new_evt, scap_evt *evt_to_convert) {
return new_evt_offset + size_to_copy;
}

static bool is_large_payload(scap_evt *evt_to_convert) {
return g_event_info[evt_to_convert->type].flags & EF_LARGE_PAYLOAD;
}

extern "C" bool is_conversion_needed(scap_evt *evt_to_convert) {
assert(evt_to_convert->type < PPM_EVENT_MAX);
const struct ppm_event_info *event_info = &(g_event_info[evt_to_convert->type]);
Expand Down Expand Up @@ -297,6 +301,15 @@ static conversion_result convert_event(scap_evt *new_evt,
scap_evt *evt_to_convert,
const conversion_info &ci,
char *error) {
// todo!: add the support for large payload events if we need to handle at least one of them.
if(is_large_payload(evt_to_convert)) {
snprintf(error,
SCAP_LASTERR_SIZE,
"The event '%d' has a large payload. We don't support it yet.",
evt_to_convert->type);
return CONVERSION_ERROR;
}

/////////////////////////////
// Dispatch the action
/////////////////////////////
Expand Down

0 comments on commit 7f160ac

Please sign in to comment.