diff --git a/Source/common/santa.proto b/Source/common/santa.proto index fc7da670c..7636e656a 100644 --- a/Source/common/santa.proto +++ b/Source/common/santa.proto @@ -213,9 +213,13 @@ message CertificateInfo { optional string common_name = 2; } +// Information about a single entitlement key/value pair message Entitlement { - string key = 1; - string value = 2; + // The name of an entitlement + optional string key = 1; + + // The value of an entitlement + optional string value = 2; } // Information about a process execution event diff --git a/Source/santad/Logs/EndpointSecurity/Serializers/Protobuf.mm b/Source/santad/Logs/EndpointSecurity/Serializers/Protobuf.mm index 1db360d7c..cc768c998 100644 --- a/Source/santad/Logs/EndpointSecurity/Serializers/Protobuf.mm +++ b/Source/santad/Logs/EndpointSecurity/Serializers/Protobuf.mm @@ -476,10 +476,10 @@ id StandardizedNestedObjects(id obj, int level) { } else if ([obj isKindOfClass:[NSDate class]]) { return [NSISO8601DateFormatter stringFromDate:obj timeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"] - formatOptions:NSISO8601DateFormatWithFractionalSeconds | NSISO8601DateFormatWithInternetDateTime]; + formatOptions:NSISO8601DateFormatWithFractionalSeconds | + NSISO8601DateFormatWithInternetDateTime]; } else { - NSLog(@"Got unknown... %d", level); LOGW(@"Unexpected object encountered: %@", obj); return [obj description]; } @@ -555,9 +555,11 @@ void EncodeEntitlements(::pbv1::Execution *pb_exec, NSDictionary *entitlements) } ::pbv1::Entitlement *pb_entitlement = pb_exec->add_entitlements(); - pb_entitlement->set_key(NSStringToUTF8StringView(key)); - pb_entitlement->set_value(NSStringToUTF8StringView( - [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding])); + EncodeString([pb_entitlement] { return pb_entitlement->mutable_key(); }, + NSStringToUTF8StringView(key)); + EncodeString([pb_entitlement] { return pb_entitlement->mutable_value(); }, + NSStringToUTF8StringView([[NSString alloc] initWithData:jsonData + encoding:NSUTF8StringEncoding])); }]; } diff --git a/Source/santad/Logs/EndpointSecurity/Serializers/ProtobufTest.mm b/Source/santad/Logs/EndpointSecurity/Serializers/ProtobufTest.mm index d98925d11..12561f724 100644 --- a/Source/santad/Logs/EndpointSecurity/Serializers/ProtobufTest.mm +++ b/Source/santad/Logs/EndpointSecurity/Serializers/ProtobufTest.mm @@ -489,8 +489,8 @@ - (void)testGetFileDescriptorType { }; for (const auto &kv : fdtypeToEnumType) { - XCTAssertEqual(GetFileDescriptorType(kv.first), kv.second, - @"Bad fd type name for fdtype: %u", kv.first); + XCTAssertEqual(GetFileDescriptorType(kv.first), kv.second, @"Bad fd type name for fdtype: %u", + kv.first); } } @@ -610,7 +610,7 @@ - (void)testEncodeEntitlements { EncodeEntitlements(&pbExec, ents); - int kMaxEncodeObjectEntries = 64; // From Protobuf.mm + int kMaxEncodeObjectEntries = 64; // From Protobuf.mm XCTAssertEqual(kMaxEncodeObjectEntries, pbExec.entitlements_size()); }