|
1 | 1 | #include <plugin.h> |
| 2 | +#include <optional> |
2 | 3 |
|
3 | 4 | ////////////////////////// |
4 | 5 | // Extract capability |
@@ -546,7 +547,7 @@ bool my_plugin::extract(const falcosecurity::extract_fields_input &in) |
546 | 547 |
|
547 | 548 | std::shared_ptr<const container_info> cinfo; |
548 | 549 | std::string container_id; |
549 | | - falcosecurity::table_entry thread_entry; |
| 550 | + std::optional<falcosecurity::table_entry> thread_entry; |
550 | 551 |
|
551 | 552 | // Async event. Is that produced by us? |
552 | 553 | if(evt_type == PPME_ASYNCEVENT_E) |
@@ -575,7 +576,8 @@ bool my_plugin::extract(const falcosecurity::extract_fields_input &in) |
575 | 576 | // Retrieve the thread entry associated with this thread id |
576 | 577 | thread_entry = m_threads_table.get_entry(tr, thread_id); |
577 | 578 | // Retrieve container_id from the entry |
578 | | - m_container_id_field.read_value(tr, thread_entry, container_id); |
| 579 | + m_container_id_field.read_value(tr, thread_entry.value(), |
| 580 | + container_id); |
579 | 581 | } |
580 | 582 | catch(const std::exception &e) |
581 | 583 | { |
@@ -763,15 +765,18 @@ bool my_plugin::extract(const falcosecurity::extract_fields_input &in) |
763 | 765 | case TYPE_CONTAINER_START_TS: |
764 | 766 | case TYPE_CONTAINER_DURATION: |
765 | 767 | { |
766 | | - uint64_t pidns_init_start_ts; |
767 | | - try |
768 | | - { |
769 | | - m_threads_field_pidns_init_start_ts.read_value(tr, thread_entry, |
770 | | - pidns_init_start_ts); |
771 | | - } |
772 | | - catch(...) |
| 768 | + uint64_t pidns_init_start_ts{0}; |
| 769 | + if(thread_entry.has_value()) |
773 | 770 | { |
774 | | - pidns_init_start_ts = 0; |
| 771 | + try |
| 772 | + { |
| 773 | + m_threads_field_pidns_init_start_ts.read_value( |
| 774 | + tr, thread_entry.value(), pidns_init_start_ts); |
| 775 | + } |
| 776 | + catch(...) |
| 777 | + { |
| 778 | + pidns_init_start_ts = 0; |
| 779 | + } |
775 | 780 | } |
776 | 781 | if(pidns_init_start_ts != 0) |
777 | 782 | { |
@@ -927,48 +932,61 @@ bool my_plugin::extract(const falcosecurity::extract_fields_input &in) |
927 | 932 | break; |
928 | 933 | case TYPE_IS_CONTAINER_HEALTHCHECK: |
929 | 934 | { |
930 | | - int16_t category; |
| 935 | + int16_t category{CAT_NONE}; |
931 | 936 | // Since we do write thread category only if not NONE for containerized |
932 | 937 | // processes |
933 | | - try |
| 938 | + if(thread_entry.has_value()) |
934 | 939 | { |
935 | | - m_threads_field_category.read_value(tr, thread_entry, category); |
936 | | - } |
937 | | - catch(...) |
938 | | - { |
939 | | - category = CAT_NONE; |
| 940 | + try |
| 941 | + { |
| 942 | + m_threads_field_category.read_value(tr, thread_entry.value(), |
| 943 | + category); |
| 944 | + } |
| 945 | + catch(...) |
| 946 | + { |
| 947 | + category = CAT_NONE; |
| 948 | + } |
940 | 949 | } |
941 | 950 | req.set_value(category == CAT_HEALTHCHECK); |
942 | 951 | break; |
943 | 952 | } |
944 | 953 | case TYPE_IS_CONTAINER_LIVENESS_PROBE: |
945 | 954 | { |
946 | | - int16_t category; |
| 955 | + int16_t category{CAT_NONE}; |
947 | 956 | // Since we do write thread category only if not NONE for containerized |
948 | 957 | // processes |
949 | | - try |
| 958 | + if(thread_entry.has_value()) |
950 | 959 | { |
951 | | - m_threads_field_category.read_value(tr, thread_entry, category); |
952 | | - } |
953 | | - catch(...) |
954 | | - { |
955 | | - category = CAT_NONE; |
| 960 | + try |
| 961 | + { |
| 962 | + m_threads_field_category.read_value(tr, thread_entry.value(), |
| 963 | + category); |
| 964 | + } |
| 965 | + catch(...) |
| 966 | + { |
| 967 | + category = CAT_NONE; |
| 968 | + } |
956 | 969 | } |
957 | 970 | req.set_value(category == CAT_LIVENESS_PROBE); |
958 | 971 | break; |
959 | 972 | } |
960 | 973 | case TYPE_IS_CONTAINER_READINESS_PROBE: |
961 | 974 | { |
962 | | - int16_t category; |
| 975 | + int16_t category{CAT_NONE}; |
963 | 976 | // Since we do write thread category only if not NONE for containerized |
964 | 977 | // processes |
965 | | - try |
| 978 | + if(thread_entry.has_value()) |
966 | 979 | { |
967 | | - m_threads_field_category.read_value(tr, thread_entry, category); |
968 | | - } |
969 | | - catch(...) |
970 | | - { |
971 | | - category = CAT_NONE; |
| 980 | + |
| 981 | + try |
| 982 | + { |
| 983 | + m_threads_field_category.read_value(tr, thread_entry.value(), |
| 984 | + category); |
| 985 | + } |
| 986 | + catch(...) |
| 987 | + { |
| 988 | + category = CAT_NONE; |
| 989 | + } |
972 | 990 | } |
973 | 991 | req.set_value(category == CAT_READINESS_PROBE); |
974 | 992 | break; |
|
0 commit comments