Various changes to fix import (#913)

This commit is contained in:
Matt W 2022-10-25 16:16:44 -04:00 committed by GitHub
parent 2df7e91c87
commit 2aaff051c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 5 deletions

View File

@ -6,6 +6,9 @@ build --copt=-Wno-error=deprecated-declarations
build --per_file_copt=.*\.mm\$@-std=c++17
build --cxxopt=-std=c++17
build --copt=-DSANTA_OPEN_SOURCE=1
build --cxxopt=-DSANTA_OPEN_SOURCE=1
build:asan --strip=never
build:asan --copt="-Wno-macro-redefined"
build:asan --copt="-D_FORTIFY_SOURCE=0"

View File

@ -111,7 +111,9 @@ REGISTER_COMMAND_NAME(@"printlog")
}
std::string json;
MessageToJsonString(santaMsg, &json, options);
if (!MessageToJsonString(santaMsg, &json, options).ok()) {
LOGE(@"Unable to convert message to JSON in file: '%@'", path);
}
std::cout << json;
}

View File

@ -440,6 +440,7 @@ objc_library(
"//Source/common:santa_cc_proto_library_wrapper",
"//Source/santad/Logs/EndpointSecurity/Writers/FSSpool:fsspool",
"//Source/santad/Logs/EndpointSecurity/Writers/FSSpool:fsspool_log_batch_writer",
"@com_google_absl//absl/strings",
],
)

View File

@ -16,6 +16,7 @@
#import "Source/common/SNTLogging.h"
#include "Source/common/santa_proto_include_wrapper.h"
#include "absl/strings/string_view.h"
static const char *kTypeGoogleApisComPrefix = "type.googleapis.com/";
@ -42,7 +43,7 @@ Spool::Spool(dispatch_queue_t q, dispatch_source_t timer_source, std::string_vie
void (^write_complete_f)(void), void (^flush_task_complete_f)(void))
: q_(q),
timer_source_(timer_source),
spool_writer_(base_dir, max_spool_disk_size),
spool_writer_(absl::string_view(base_dir.data(), base_dir.length()), max_spool_disk_size),
log_batch_writer_(&spool_writer_, max_spool_batch_size),
write_complete_f_(write_complete_f),
flush_task_complete_f_(flush_task_complete_f) {
@ -100,7 +101,11 @@ void Spool::Write(std::vector<uint8_t> &&bytes) {
// Manually pack an `Any` with a pre-serialized SantaMessage
google::protobuf::Any any;
#if SANTA_OPEN_SOURCE
any.set_value(moved_bytes.data(), moved_bytes.size());
#else
any.set_value(absl::string_view((const char*)moved_bytes.data(), moved_bytes.size()));
#endif
any.set_type_url(type_url_);
auto status = log_batch_writer_.WriteMessage(any);

View File

@ -36,9 +36,6 @@ class SpoolPeer : public Spool {
} // namespace santa::santad::logs::endpoint_security::writers
using ::fsspool::FsSpoolLogBatchWriter;
using ::fsspool::FsSpoolWriter;
using santa::santad::logs::endpoint_security::writers::Spool;
using santa::santad::logs::endpoint_security::writers::SpoolPeer;
@interface SpoolTest : XCTestCase