Skip to content

Commit fd2ebf4

Browse files
committed
Merge branch 'main' into rah/cel-rules-4
2 parents a120bff + 70cb7ad commit fd2ebf4

15 files changed

Lines changed: 114 additions & 9 deletions

File tree

.github/workflows/ci.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,16 @@ jobs:
4040
bazelisk-cache: true
4141
disk-cache: ${{ matrix.os }}
4242
repository-cache: true
43+
- name: Setup Xcode
44+
uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # ratchet:maxim-lobanov/setup-xcode@v1
45+
with:
46+
xcode-version: latest-stable
4347
- name: Build Userspace
44-
run: bazel build --apple_generate_dsym -c opt :release --define=SANTA_BUILD_TYPE=adhoc
48+
if: matrix.os != 'macos-13'
49+
run: bazel build --verbose_failures --sandbox_debug --apple_generate_dsym -c opt :release --define=SANTA_BUILD_TYPE=adhoc
50+
- name: Build Userspace 13
51+
if: matrix.os == 'macos-13'
52+
run: bazel build --verbose_failures --sandbox_debug --apple_generate_dsym -c opt :release --define=SANTA_BUILD_TYPE=adhoc --define=SANTA_XCODE_VERSION=missing_xcode_16
4553
check_localization:
4654
runs-on: macos-latest
4755
steps:
@@ -71,4 +79,4 @@ jobs:
7179
disk-cache: ${{ matrix.os }}
7280
repository-cache: true
7381
- name: Run All Tests
74-
run: bazel test :unit_tests --define=SANTA_BUILD_TYPE=adhoc --test_output=errors
82+
run: bazel test :unit_tests --verbose_failures --sandbox_debug --define=SANTA_BUILD_TYPE=adhoc --test_output=errors

BUILD

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ config_setting(
6161
values = {"compilation_mode": "opt"},
6262
)
6363

64+
config_setting(
65+
name = "missing_xcode_16",
66+
values = {"define": "SANTA_XCODE_VERSION=missing_xcode_16"},
67+
visibility = [":santa_package_group"],
68+
)
69+
6470
package_group(
6571
name = "santa_package_group",
6672
packages = ["//..."],

MODULE.bazel

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ module(name = "santa")
22

33
bazel_dep(name = "abseil-cpp", version = "20250127.1")
44
bazel_dep(name = "apple_support", version = "1.22.0")
5-
bazel_dep(name = "googletest", version = "1.16.0")
6-
bazel_dep(name = "protobuf", version = "30.2")
5+
bazel_dep(name = "googletest", version = "1.17.0")
6+
bazel_dep(name = "protobuf", version = "31.1")
77
bazel_dep(name = "rules_apple", version = "3.21.0")
88
bazel_dep(name = "rules_cc", version = "0.1.1")
99
bazel_dep(name = "rules_fuzzing", version = "0.5.2")
@@ -15,10 +15,18 @@ bazel_dep(name = "xxhash", version = "0.8.2")
1515
bazel_dep(name = "protos", version = "1.0.1", repo_name = "northpolesec_protos")
1616
git_override(
1717
module_name = "protos",
18-
commit = "547a10d6b2e0502af11d54368a74c3b128715223",
18+
commit = "704246489aa55e6e2b60b47133a8668bc3656105",
1919
remote = "https://github.com/northpolesec/protos",
2020
)
2121

22+
# North Pole Rednose
23+
bazel_dep(name = "rednose", version = "1.0.0", repo_name = "northpolesec_rednose")
24+
git_override(
25+
module_name = "rednose",
26+
commit = "e5dbe6eb8ee55b306e953959ce85f672adce4aff",
27+
remote = "https://github.com/northpolesec/rednose",
28+
)
29+
2230
# cel-cpp
2331
# The 0.11.0 release has a bug in it that was fixed a few weeks later but hasn't
2432
# been released yet.

Source/common/SNTConfigurator.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,11 @@
496496
///
497497
@property(nullable, readonly, nonatomic) NSString *machineOwner;
498498

499+
///
500+
/// The machine owner's groups.
501+
///
502+
@property(nullable, readonly, nonatomic) NSArray<NSString *> *machineOwnerGroups;
503+
499504
///
500505
/// The last date of a successful full sync.
501506
///

Source/common/SNTConfigurator.m

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,11 @@ @implementation SNTConfigurator
9595
static NSString *const kStatsOrganizationID = @"StatsOrganizationID";
9696

9797
static NSString *const kMachineOwnerKey = @"MachineOwner";
98+
static NSString *const kMachineOwnerGroupsKey = @"MachineOwnerGroups";
9899
static NSString *const kMachineIDKey = @"MachineID";
99100
static NSString *const kMachineOwnerPlistFileKey = @"MachineOwnerPlist";
100101
static NSString *const kMachineOwnerPlistKeyKey = @"MachineOwnerKey";
102+
static NSString *const kMachineOwnerGroupsPlistKeyKey = @"MachineOwnerGroupsKey";
101103
static NSString *const kMachineIDPlistFileKey = @"MachineIDPlist";
102104
static NSString *const kMachineIDPlistKeyKey = @"MachineIDKey";
103105

@@ -284,9 +286,11 @@ - (instancetype)initWithSyncStateFile:(NSString *)syncStateFilePath
284286
kEnableStatsCollectionKey : number,
285287
kStatsOrganizationID : string,
286288
kMachineOwnerKey : string,
289+
kMachineOwnerGroupsKey : array,
287290
kMachineIDKey : string,
288291
kMachineOwnerPlistFileKey : string,
289292
kMachineOwnerPlistKeyKey : string,
293+
kMachineOwnerGroupsPlistKeyKey : string,
290294
kMachineIDPlistFileKey : string,
291295
kMachineIDPlistKeyKey : string,
292296
kEventLogType : string,
@@ -542,6 +546,10 @@ + (NSSet *)keyPathsForValuesAffectingMachineOwner {
542546
return [self configStateSet];
543547
}
544548

549+
+ (NSSet *)keyPathsForValuesAffectingMachineOwnerGroups {
550+
return [self configStateSet];
551+
}
552+
545553
+ (NSSet *)keyPathsForValuesAffectingMachineID {
546554
return [self configStateSet];
547555
}
@@ -1031,14 +1039,34 @@ - (NSString *)machineOwner {
10311039

10321040
NSString *plistPath = self.configState[kMachineOwnerPlistFileKey];
10331041
NSString *plistKey = self.configState[kMachineOwnerPlistKeyKey];
1034-
if (plistPath && plistKey) {
1042+
if (plistPath.length && plistKey.length) {
10351043
NSDictionary *plist = [NSDictionary dictionaryWithContentsOfFile:plistPath];
10361044
machineOwner = [plist[plistKey] isKindOfClass:[NSString class]] ? plist[plistKey] : nil;
10371045
}
10381046

10391047
return machineOwner ?: @"";
10401048
}
10411049

1050+
- (NSArray<NSString *> *)machineOwnerGroups {
1051+
NSArray<NSString *> *machineOwnerGroups = self.configState[kMachineOwnerGroupsKey];
1052+
if (machineOwnerGroups.count) return machineOwnerGroups;
1053+
1054+
NSString *plistPath = self.configState[kMachineOwnerPlistFileKey];
1055+
NSString *plistKey = self.configState[kMachineOwnerGroupsPlistKeyKey];
1056+
if (plistPath.length && plistKey.length) {
1057+
NSDictionary *plist = [NSDictionary dictionaryWithContentsOfFile:plistPath];
1058+
machineOwnerGroups = [plist[plistKey] isKindOfClass:[NSArray class]] ? plist[plistKey] : nil;
1059+
for (NSString *group in machineOwnerGroups) {
1060+
if (![group isKindOfClass:[NSString class]]) {
1061+
machineOwnerGroups = nil;
1062+
break;
1063+
}
1064+
}
1065+
}
1066+
1067+
return machineOwnerGroups;
1068+
}
1069+
10421070
- (NSString *)machineID {
10431071
NSString *machineId = self.configState[kMachineIDKey];
10441072
if (machineId) return machineId;

Source/common/SNTXPCSyncServiceInterface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
reply:(void (^)(SNTBundleEventAction))reply;
3333
- (void)pushNotificationStatus:(void (^)(SNTPushNotificationStatus))reply;
3434
- (void)exportTelemetryFile:(NSFileHandle *)fd
35+
fileName:(NSString *)fileName
3536
config:(SNTExportConfiguration *)config
3637
reply:(void (^)(BOOL))reply;
3738

Source/santad/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,7 @@ objc_library(
799799
"//Source/common:SNTExportConfiguration",
800800
"//Source/common:SNTLogging",
801801
"//Source/common:SNTStoredEvent",
802+
"//Source/common:SNTSystemInfo",
802803
"//Source/common:TelemetryEventMap",
803804
"//Source/common:Timer",
804805
"@abseil-cpp//absl/container:flat_hash_map",

Source/santad/Logs/EndpointSecurity/Logger.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#import "Source/common/SNTExportConfiguration.h"
2525
#include "Source/common/SNTLogging.h"
2626
#include "Source/common/SNTStoredEvent.h"
27+
#include "Source/common/SNTSystemInfo.h"
2728
#include "Source/common/TelemetryEventMap.h"
2829
#include "Source/santad/Logs/EndpointSecurity/Serializers/BasicString.h"
2930
#include "Source/santad/Logs/EndpointSecurity/Serializers/Empty.h"
@@ -169,8 +170,12 @@
169170
// in case the export times out.
170171
tracker_.Track(*file_to_export);
171172

173+
NSString *fileName = [NSString
174+
stringWithFormat:@"%@-%@", [SNTSystemInfo bootSessionUUID], [path lastPathComponent]];
175+
172176
dispatch_group_enter(group);
173177
[syncd_queue_ exportTelemetryFile:handle
178+
fileName:fileName
174179
config:export_config
175180
completionHandler:^(BOOL success) {
176181
[handle closeFile];

Source/santad/SNTSyncdQueue.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
- (void)addEvents:(NSArray<SNTStoredEvent *> *)events isFromBundle:(BOOL)isFromBundle;
2929
- (void)addBundleEvent:(SNTStoredEvent *)event reply:(void (^)(SNTBundleEventAction))reply;
3030
- (void)exportTelemetryFile:(NSFileHandle *)telemetryFile
31+
fileName:(NSString *)fileName
3132
config:(SNTExportConfiguration *)config
3233
completionHandler:(void (^)(BOOL))completionHandler;
3334

Source/santad/SNTSyncdQueue.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,13 @@ - (void)dispatchBlockOnSyncdQueue:(void (^)(void))block {
189189
}
190190

191191
- (void)exportTelemetryFile:(NSFileHandle *)telemetryFile
192+
fileName:(NSString *)fileName
192193
config:(SNTExportConfiguration *)config
193194
completionHandler:(void (^)(BOOL))completionHandler {
194195
[self dispatchBlockOnSyncdQueue:^{
195196
if (self.syncConnection.isConnected) {
196197
[self.syncConnection.remoteObjectProxy exportTelemetryFile:telemetryFile
198+
fileName:fileName
197199
config:config
198200
reply:completionHandler];
199201
} else {

0 commit comments

Comments
 (0)