Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix probe reconnect send data and block #545

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions rasp/golang-ebpf/client/smith_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,17 @@ transfer(

uint32_t length = htonl(msg.length());

buffer->submit({(const std::byte *) &length, sizeof(uint32_t)});
buffer->submit({(const std::byte *) msg.data(), msg.size()});
auto result = buffer->submit({(const std::byte *) &length, sizeof(uint32_t)});

if (!result) {
LOG_WARNING("submit data failed");
return zero::async::promise::reject<void>({-1, "submit data failed"});
}
result = buffer->submit({(const std::byte *) msg.data(), msg.size()});
if (!result) {
LOG_WARNING("submit data failed");
return zero::async::promise::reject<void>({-1, "submit data failed"});
}

if (buffer->pending() > 1024 * 1024)
return buffer->drain();
Expand Down
13 changes: 11 additions & 2 deletions rasp/golang/client/smith_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,17 @@ transfer(

uint32_t length = htonl(msg.length());

buffer->submit({(const std::byte *) &length, sizeof(uint32_t)});
buffer->submit({(const std::byte *) msg.data(), msg.size()});
auto result = buffer->submit({(const std::byte *) &length, sizeof(uint32_t)});

if (!result) {
LOG_WARNING("submit data failed");
return zero::async::promise::reject<void>({-1, "submit data failed"});
}
result = buffer->submit({(const std::byte *) msg.data(), msg.size()});
if (!result) {
LOG_WARNING("submit data failed");
return zero::async::promise::reject<void>({-1, "submit data failed"});
}

if (buffer->pending() > 1024 * 1024)
return buffer->drain();
Expand Down
3 changes: 2 additions & 1 deletion rasp/golang/client/smith_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ void from_json(const nlohmann::json &j, StackFrame &stackFrame) {
void from_json(const nlohmann::json &j, Block &block) {
j.at("class_id").get_to(block.classID);
j.at("method_id").get_to(block.methodID);
j.at("policy_id").get_to(block.policyID);
if (j.contains("policy_id") && !j.at("policy_id").is_null())
j.at("policy_id").get_to(block.policyID);
j.at("rules").get_to(block.rules);

if (j.contains("stack_frame") && !j.at("stack_frame").is_null())
Expand Down
13 changes: 11 additions & 2 deletions rasp/php/client/smith_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,17 @@ transfer(

uint32_t length = htonl(msg.length());

buffer->submit({(const std::byte *) &length, sizeof(uint32_t)});
buffer->submit({(const std::byte *) msg.data(), msg.size()});
auto result = buffer->submit({(const std::byte *) &length, sizeof(uint32_t)});

if (!result) {
LOG_WARNING("submit data failed");
return zero::async::promise::reject<void>({-1, "submit data failed"});
}
result = buffer->submit({(const std::byte *) msg.data(), msg.size()});
if (!result) {
LOG_WARNING("submit data failed");
return zero::async::promise::reject<void>({-1, "submit data failed"});
}

if (buffer->pending() > 1024 * 1024)
return buffer->drain();
Expand Down
3 changes: 2 additions & 1 deletion rasp/php/client/smith_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ void from_json(const nlohmann::json &j, StackFrame &stackFrame) {
void from_json(const nlohmann::json &j, Block &block) {
j.at("class_id").get_to(block.classID);
j.at("method_id").get_to(block.methodID);
j.at("policy_id").get_to(block.policyID);
if (j.contains("policy_id") && !j.at("policy_id").is_null())
j.at("policy_id").get_to(block.policyID);
j.at("rules").get_to(block.rules);

if (j.contains("stack_frame") && !j.at("stack_frame").is_null())
Expand Down
13 changes: 11 additions & 2 deletions rasp/python/python-probe/rasp/probe/client/smith_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,17 @@ transfer(

uint32_t length = htonl(msg.length());

buffer->submit({(const std::byte *) &length, sizeof(uint32_t)});
buffer->submit({(const std::byte *) msg.data(), msg.size()});
auto result = buffer->submit({(const std::byte *) &length, sizeof(uint32_t)});

if (!result) {
LOG_WARNING("submit data failed");
return zero::async::promise::reject<void>({-1, "submit data failed"});
}
result = buffer->submit({(const std::byte *) msg.data(), msg.size()});
if (!result) {
LOG_WARNING("submit data failed");
return zero::async::promise::reject<void>({-1, "submit data failed"});
}

if (buffer->pending() > 1024 * 1024)
return buffer->drain();
Expand Down
3 changes: 2 additions & 1 deletion rasp/python/python-probe/rasp/probe/client/smith_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ void from_json(const nlohmann::json &j, StackFrame &stackFrame) {
void from_json(const nlohmann::json &j, Block &block) {
j.at("class_id").get_to(block.classID);
j.at("method_id").get_to(block.methodID);
j.at("policy_id").get_to(block.policyID);
if (j.contains("policy_id") && !j.at("policy_id").is_null())
j.at("policy_id").get_to(block.policyID);
j.at("rules").get_to(block.rules);

if (j.contains("stack_frame") && !j.at("stack_frame").is_null())
Expand Down
Loading