mirror of
https://github.com/openappsec/openappsec.git
synced 2025-09-29 19:24:26 +03:00
Apr 27th Update
This commit is contained in:
@@ -103,6 +103,7 @@ public:
|
||||
void sendLog(const Report &log) override;
|
||||
|
||||
private:
|
||||
void sendLog(const std::vector<char> &data);
|
||||
void connect();
|
||||
|
||||
I_Socket *i_socket = nullptr;
|
||||
|
@@ -1489,7 +1489,7 @@ TEST_F(LogTest, ObfuscationTest)
|
||||
sysog_routine();
|
||||
EXPECT_EQ(capture_syslog_cef_data.size(), 2);
|
||||
for (const string &str : capture_syslog_cef_data) {
|
||||
EXPECT_THAT(str, AnyOf(HasSubstr("String='Another string'"), HasSubstr("String=Another string")));
|
||||
EXPECT_THAT(str, AnyOf(HasSubstr("String='Another string'"), HasSubstr("String=\"Another string\"")));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -54,31 +54,32 @@ SyslogStream::sendLog(const Report &log)
|
||||
vector<char> data(syslog_report.begin(), syslog_report.end());
|
||||
mainloop->addOneTimeRoutine(
|
||||
I_MainLoop::RoutineType::Offline,
|
||||
[this, data] ()
|
||||
{
|
||||
if (!socket.ok()) {
|
||||
connect();
|
||||
if (!socket.ok()) {
|
||||
dbgWarning(D_REPORT) << "Failed to connect to the syslog server, Log will not be sent.";
|
||||
return;
|
||||
}
|
||||
dbgTrace(D_REPORT) << "Successfully connect to the syslog server";
|
||||
}
|
||||
|
||||
int tries = 1;
|
||||
for (; tries <=3; tries++) {
|
||||
if (i_socket->writeData(socket.unpack(), data)) {
|
||||
dbgTrace(D_REPORT) << "log was sent to syslog server";
|
||||
return;
|
||||
} else {
|
||||
dbgWarning(D_REPORT) << "Failed to send log to syslog server";
|
||||
}
|
||||
}
|
||||
},
|
||||
[this, data] () { sendLog(data); },
|
||||
"Logging Syslog stream messaging"
|
||||
);
|
||||
}
|
||||
|
||||
void
|
||||
SyslogStream::sendLog(const vector<char> &data)
|
||||
{
|
||||
for (int tries = 0; tries < 3; ++tries) {
|
||||
if (!socket.ok()) {
|
||||
connect();
|
||||
if (!socket.ok()) {
|
||||
dbgWarning(D_REPORT) << "Failed to connect to the syslog server, Log will not be sent.";
|
||||
return;
|
||||
}
|
||||
dbgTrace(D_REPORT) << "Successfully connect to the syslog server";
|
||||
}
|
||||
|
||||
if (i_socket->writeData(socket.unpack(), data)) {
|
||||
dbgTrace(D_REPORT) << "log was sent to syslog server";
|
||||
return;
|
||||
}
|
||||
}
|
||||
dbgWarning(D_REPORT) << "Failed to send log to syslog server";
|
||||
}
|
||||
|
||||
void
|
||||
SyslogStream::connect()
|
||||
{
|
||||
|
Reference in New Issue
Block a user