mirror of
https://github.com/openappsec/openappsec.git
synced 2025-09-29 19:24:26 +03:00
Jan_31_2024-Dev
This commit is contained in:
8
core/debug_is/debug.cc
Executable file → Normal file
8
core/debug_is/debug.cc
Executable file → Normal file
@@ -754,7 +754,13 @@ Debug::startStreams(
|
||||
void
|
||||
Debug::isCommunicationFlag(const DebugFlags &flag)
|
||||
{
|
||||
is_communication |= (flag == D_HTTP_REQUEST || flag == D_COMMUNICATION);
|
||||
is_communication |= (
|
||||
flag == D_MESSAGING ||
|
||||
flag == D_COMMUNICATION ||
|
||||
flag == D_CONNECTION ||
|
||||
flag == D_MESSAGING_BUFFER ||
|
||||
flag == D_HTTP_REQUEST
|
||||
);
|
||||
}
|
||||
|
||||
Debug::DebugLevel Debug::lowest_global_level = default_level;
|
||||
|
@@ -3,4 +3,4 @@ include_directories(${CMAKE_SOURCE_DIR}/cptest/include)
|
||||
include_directories(${Boost_INCLUDE_DIRS})
|
||||
link_directories(${BOOST_ROOT}/lib)
|
||||
|
||||
add_unit_test(debug_is_ut "debug_ut.cc" "agent_details;metric;event_is;-lboost_regex")
|
||||
add_unit_test(debug_is_ut "debug_ut.cc" "agent_details;metric;messaging;event_is;-lboost_regex")
|
||||
|
26
core/debug_is/debug_is_ut/debug_ut.cc
Executable file → Normal file
26
core/debug_is/debug_is_ut/debug_ut.cc
Executable file → Normal file
@@ -802,7 +802,11 @@ TEST(DebugFogTest, fog_stream)
|
||||
|
||||
StrictMock<MockMainLoop> mock_mainloop;
|
||||
StrictMock<MockTimeGet> mock_time;
|
||||
StrictMock<MockAgentDetails> mock_agent_details;
|
||||
NiceMock<MockAgentDetails> mock_agent_details;
|
||||
|
||||
ON_CALL(mock_agent_details, getFogDomain()).WillByDefault(Return(Maybe<string>(string("fog_domain.com"))));
|
||||
ON_CALL(mock_agent_details, getFogPort()).WillByDefault(Return(Maybe<uint16_t>(443)));
|
||||
|
||||
EXPECT_CALL(mock_agent_details, getAgentId()).WillRepeatedly(Return("Unknown"));
|
||||
EXPECT_CALL(mock_agent_details, getOrchestrationMode()).WillRepeatedly(Return(OrchestrationMode::ONLINE));
|
||||
|
||||
@@ -814,15 +818,14 @@ TEST(DebugFogTest, fog_stream)
|
||||
|
||||
StrictMock<MockMessaging> messaging_mock;
|
||||
string message_body;
|
||||
EXPECT_CALL(messaging_mock, mockSendPersistentMessage(
|
||||
false,
|
||||
_,
|
||||
|
||||
EXPECT_CALL(messaging_mock, sendAsyncMessage(
|
||||
_,
|
||||
"/api/v1/agents/events/bulk",
|
||||
_,
|
||||
_,
|
||||
MessageTypeTag::DEBUG
|
||||
)).WillRepeatedly(DoAll(SaveArg<1>(&message_body), Return(Maybe<string>(string("")))));
|
||||
_
|
||||
)).WillRepeatedly(SaveArg<2>(&message_body));
|
||||
|
||||
Singleton::Consume<Config::I_Config>::from(conf)->loadConfiguration(
|
||||
vector<string>{"--orchestration-mode=online_mode"}
|
||||
@@ -953,7 +956,7 @@ TEST(DebugFogTest, fog_stream)
|
||||
" \"agentId\": \"Unknown\",\n"
|
||||
" \"issuingFunction\": \"handleThresholdReach\",\n"
|
||||
" \"issuingFile\": \"debug_streams.cc\",\n"
|
||||
" \"issuingLine\": 345,\n"
|
||||
" \"issuingLine\": 344,\n"
|
||||
" \"eventTraceId\": \"\",\n"
|
||||
" \"eventSpanId\": \"\",\n"
|
||||
" \"issuingEngineVersion\": \"\",\n"
|
||||
@@ -977,12 +980,9 @@ TEST(DebugFogTest, fog_stream)
|
||||
.WillOnce(DoAll(InvokeMainLoopCB(), Return(0)));
|
||||
|
||||
string message_body_1, message_body_2;
|
||||
EXPECT_CALL(
|
||||
messaging_mock,
|
||||
mockSendPersistentMessage(false, _, _, "/api/v1/agents/events", _, _, MessageTypeTag::DEBUG)
|
||||
).WillOnce(DoAll(SaveArg<1>(&message_body_1), Return(Maybe<string>(string(""))))).WillOnce(
|
||||
DoAll(SaveArg<1>(&message_body_2), Return(Maybe<string>(string(""))))
|
||||
);
|
||||
EXPECT_CALL(messaging_mock, sendAsyncMessage(_, "/api/v1/agents/events", _, MessageCategory::DEBUG, _))
|
||||
.WillOnce(SaveArg<2>(&message_body_1))
|
||||
.WillOnce(SaveArg<2>(&message_body_2));
|
||||
|
||||
doFWError();
|
||||
line1 = line;
|
||||
|
@@ -296,8 +296,7 @@ DebugFogStream::sendBufferedMessages()
|
||||
|
||||
while (!reports.empty()) {
|
||||
auto rest = reports.pop();
|
||||
using Method = I_Messaging::Method;
|
||||
i_msg->sendObjectWithPersistence(rest, Method::POST, fog_debug_uri, "", true, MessageTypeTag::DEBUG);
|
||||
i_msg->sendAsyncMessage(HTTPMethod::POST, fog_debug_uri, rest, MessageCategory::DEBUG);
|
||||
}
|
||||
}
|
||||
void
|
||||
@@ -310,7 +309,7 @@ DebugFogStream::sendSingleMessage(const LogRest &rest)
|
||||
);
|
||||
|
||||
auto i_msg = Singleton::Consume<I_Messaging>::by<Debug>();
|
||||
i_msg->sendObjectWithPersistence(rest, I_Messaging::Method::POST, fog_debug_uri, "", true, MessageTypeTag::DEBUG);
|
||||
i_msg->sendAsyncMessage(HTTPMethod::POST, fog_debug_uri, rest, MessageCategory::DEBUG);
|
||||
}
|
||||
|
||||
void
|
||||
|
Reference in New Issue
Block a user