update embedded nginx support for openappsec and bug fixes and schema changes

This commit is contained in:
dgambarin
2022-11-16 17:56:41 +02:00
parent 03949a3cb7
commit 8bbd856d92
13 changed files with 90 additions and 48 deletions

View File

@@ -245,6 +245,9 @@ DebugFogStream::finishMessage()
if (team.ok()) audience_team = *team;
}
string agent_uid =
(Report::isPlaygroundEnv() ? "playground-" : "") +
Singleton::Consume<I_AgentDetails>::by<DebugFogStream>()->getAgentId();
Report message_to_fog(
"Debug message",
curr_time,
@@ -256,7 +259,7 @@ DebugFogStream::finishMessage()
getSeverity(),
Priority::LOW,
chrono::seconds(0),
LogField("agentId", Singleton::Consume<I_AgentDetails>::by<DebugFogStream>()->getAgentId()),
LogField("agentId", agent_uid),
LogField("issuingFunction", func_name),
LogField("issuingFile", file_name),
LogField("issuingLine", line),
@@ -328,6 +331,9 @@ DebugFogStream::handleThresholdReach()
if (team.ok()) audience_team = *team;
}
string agent_uid =
(Report::isPlaygroundEnv() ? "playground-" : "") +
Singleton::Consume<I_AgentDetails>::by<DebugFogStream>()->getAgentId();
Report message_to_fog(
"Debug message",
curr_time,
@@ -339,7 +345,7 @@ DebugFogStream::handleThresholdReach()
Severity::MEDIUM,
Priority::LOW,
chrono::seconds(0),
LogField("agentId", Singleton::Consume<I_AgentDetails>::by<DebugFogStream>()->getAgentId()),
LogField("agentId", agent_uid),
LogField("issuingFunction", __FUNCTION__),
LogField("issuingFile", "debug_streams.cc"),
LogField("issuingLine", __LINE__),

View File

@@ -80,7 +80,11 @@ public:
_severity,
_priority,
std::chrono::seconds(0),
LogField("agentId", Singleton::Consume<I_AgentDetails>::by<LogGen>()->getAgentId()),
LogField(
"agentId",
(Report::isPlaygroundEnv() ? "playground-" : "") +
Singleton::Consume<I_AgentDetails>::by<LogGen>()->getAgentId()
),
std::forward<Args>(args)...
)
{

View File

@@ -16,6 +16,10 @@
#include <set>
#include <chrono>
#include <stdlib.h>
#include <algorithm>
#include <cctype>
#include <iostream>
#include "report/base_field.h"
#include "report/report_enums.h"
@@ -71,6 +75,26 @@ public:
setInstanceAwareness();
}
static bool
isPlaygroundEnv()
{
std::string playground_variable = "PLAYGROUND";
const char *env_string = getenv(playground_variable.c_str());
if (env_string) {
std::string env_value = env_string;
std::transform(
env_value.begin(),
env_value.end(),
env_value.begin(),
[](unsigned char c){ return std::tolower(c); }
);
return env_value == "true";
}
return false;
}
void serialize(cereal::JSONOutputArchive &ar) const;
std::string getSyslog() const;
std::string getCef() const;

View File

@@ -174,6 +174,9 @@ MainloopComponent::Impl::reportStartupEvent()
auto team = i_env->get<ReportIS::AudienceTeam>("Audience Team");
if (team.ok()) audience_team = *team;
string agent_uid =
(Report::isPlaygroundEnv() ? "playground-" : "") +
Singleton::Consume<I_AgentDetails>::by<MainloopComponent>()->getAgentId();
Report startup_message(
"Nano service successfully started",
curr_time,
@@ -185,7 +188,7 @@ MainloopComponent::Impl::reportStartupEvent()
ReportIS::Severity::INFO,
ReportIS::Priority::HIGH,
chrono::seconds(0),
LogField("agentId", Singleton::Consume<I_AgentDetails>::by<MainloopComponent>()->getAgentId()),
LogField("agentId", agent_uid),
ReportIS::Tags::INFORMATIONAL
);

View File

@@ -170,6 +170,9 @@ string GenericMetric::getListenerName() const { return metric_name; }
void
GenericMetric::generateLog()
{
string agent_uid =
(Report::isPlaygroundEnv() ? "playground-" : "") +
Singleton::Consume<I_AgentDetails>::by<GenericMetric>()->getAgentId();
set<ReportIS::Tags> tags;
Report metric_to_fog(
metric_name,
@@ -182,7 +185,7 @@ GenericMetric::generateLog()
Severity::INFO,
Priority::LOW,
report_interval,
LogField("agentId", Singleton::Consume<I_AgentDetails>::by<GenericMetric>()->getAgentId()),
LogField("agentId", agent_uid),
tags,
Tags::INFORMATIONAL,
issuing_engine