mirror of
https://github.com/falcosecurity/falco.git
synced 2025-07-03 01:46:38 +00:00
new(userspace/falco): store context metadata for future usage
Signed-off-by: Leonardo Di Donato <leodidonato@gmail.com>
This commit is contained in:
parent
21e588394f
commit
c389ec1b61
@ -29,16 +29,23 @@ context::context(grpc::ServerContext* ctx):
|
||||
get_metadata(meta_session, session_id);
|
||||
get_metadata(meta_session, request_id);
|
||||
|
||||
bool has_meta = false;
|
||||
std::stringstream meta;
|
||||
if(!session_id.empty())
|
||||
{
|
||||
meta << "[sid=" << session_id << "]";
|
||||
has_meta = true;
|
||||
}
|
||||
|
||||
if(!request_id.empty())
|
||||
{
|
||||
meta << "[rid=" << request_id << "]";
|
||||
has_meta = true;
|
||||
}
|
||||
if(has_meta)
|
||||
{
|
||||
meta << " ";
|
||||
}
|
||||
m_prefix = meta.str();
|
||||
}
|
||||
|
||||
void context::get_metadata(std::string key, std::string& val)
|
||||
|
@ -18,6 +18,8 @@ limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef GRPC_INCLUDE_IS_GRPCPP
|
||||
#include <grpcpp/grpcpp.h>
|
||||
#else
|
||||
@ -37,6 +39,7 @@ public:
|
||||
|
||||
private:
|
||||
grpc::ServerContext* m_ctx = nullptr;
|
||||
std::string m_prefix;
|
||||
};
|
||||
|
||||
class stream_context : public context
|
||||
|
Loading…
Reference in New Issue
Block a user