Skip to content

Commit

Permalink
Project: Fix continuation indentation (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
russellhancox authored Dec 6, 2024
1 parent cc9795e commit 82fddd3
Show file tree
Hide file tree
Showing 150 changed files with 3,684 additions and 3,653 deletions.
1 change: 0 additions & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ BasedOnStyle: Google

IndentWidth: 2
ObjCBlockIndentWidth: 2
ContinuationIndentWidth: 2

# For ObjC, the line limit is 100
ColumnLimit: 100
Expand Down
2 changes: 1 addition & 1 deletion Fuzzing/common/MachOParse.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ int get_num_fds() {

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
static NSString *tmpPath =
[NSTemporaryDirectory() stringByAppendingPathComponent:[[NSUUID UUID] UUIDString]];
[NSTemporaryDirectory() stringByAppendingPathComponent:[[NSUUID UUID] UUIDString]];

int num_fds_pre = get_num_fds();

Expand Down
26 changes: 13 additions & 13 deletions Fuzzing/santad/src/checkCacheForVnodeID.mm
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@
[daemonConn resume];

[[daemonConn remoteObjectProxy]
checkCacheForVnodeID:vnodeID
withReply:^(SNTAction action) {
if (action == SNTActionRespondAllow) {
std::cerr << "File exists in [whitelist] kernel cache" << std::endl;
;
} else if (action == SNTActionRespondDeny) {
std::cerr << "File exists in [blacklist] kernel cache" << std::endl;
;
} else if (action == SNTActionUnset) {
std::cerr << "File does not exist in cache" << std::endl;
;
}
}];
checkCacheForVnodeID:vnodeID
withReply:^(SNTAction action) {
if (action == SNTActionRespondAllow) {
std::cerr << "File exists in [whitelist] kernel cache" << std::endl;
;
} else if (action == SNTActionRespondDeny) {
std::cerr << "File exists in [blacklist] kernel cache" << std::endl;
;
} else if (action == SNTActionUnset) {
std::cerr << "File does not exist in cache" << std::endl;
;
}
}];

return 0;
}
21 changes: 11 additions & 10 deletions Fuzzing/santad/src/databaseRuleAddRules.mm
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,18 @@

[daemonConn resume];
[[daemonConn remoteObjectProxy]
databaseRuleAddRules:@[ newRule ]
ruleCleanup:SNTRuleCleanupNone
reply:^(NSError *error) {
if (!error) {
if (newRule.state == SNTRuleStateRemove) {
printf("Removed rule for SHA-256: %s.\n", [newRule.identifier UTF8String]);
} else {
printf("Added rule for SHA-256: %s.\n", [newRule.identifier UTF8String]);
databaseRuleAddRules:@[ newRule ]
ruleCleanup:SNTRuleCleanupNone
reply:^(NSError *error) {
if (!error) {
if (newRule.state == SNTRuleStateRemove) {
printf("Removed rule for SHA-256: %s.\n",
[newRule.identifier UTF8String]);
} else {
printf("Added rule for SHA-256: %s.\n", [newRule.identifier UTF8String]);
}
}
}
}];
}];

return 0;
}
2 changes: 1 addition & 1 deletion Source/common/SNTBlockMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ NS_ASSUME_NONNULL_BEGIN
customMessage:(nullable NSString *)customMessage;

+ (NSAttributedString *)attributedBlockMessageForFileAccessEvent:
(nullable SNTFileAccessEvent *)event
(nullable SNTFileAccessEvent *)event
customMessage:(nullable NSString *)customMessage;

+ (NSAttributedString *)attributedBlockMessageForDeviceEvent:(nullable SNTDeviceEvent *)event;
Expand Down
54 changes: 27 additions & 27 deletions Source/common/SNTBlockMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ + (NSAttributedString *)formatMessage:(NSString *)message withFallback:(NSString
+ (NSAttributedString *)attributedBlockMessageForEvent:(SNTStoredEvent *)event
customMessage:(NSString *)customMessage {
NSString *defaultBlockedMessage = NSLocalizedString(
@"The following application has been blocked from executing<br />because its trustworthiness "
@"cannot be determined",
@"The default message to show the user when an unknown application is blocked");
@"The following application has been blocked from executing<br />because its trustworthiness "
@"cannot be determined",
@"The default message to show the user when an unknown application is blocked");
NSString *defaultBannedMessage = NSLocalizedString(
@"The following application has been blocked from<br />executing because it has "
@"been deemed malicious",
@"The default message to show the user when a banned application is blocked");
@"The following application has been blocked from<br />executing because it has "
@"been deemed malicious",
@"The default message to show the user when a banned application is blocked");

if (customMessage.length) {
return [self formatMessage:customMessage
Expand All @@ -85,22 +85,22 @@ + (NSAttributedString *)attributedBlockMessageForEvent:(SNTStoredEvent *)event
+ (NSAttributedString *)attributedBlockMessageForFileAccessEvent:(SNTFileAccessEvent *)event
customMessage:(NSString *)customMessage {
NSString *defaultBlockedMesage =
NSLocalizedString(@"Access to a file has been denied",
@"The default message to show the user when access to a file is blocked");
NSLocalizedString(@"Access to a file has been denied",
@"The default message to show the user when access to a file is blocked");

return [SNTBlockMessage
formatMessage:customMessage ?: [[SNTConfigurator configurator] fileAccessBlockMessage]
withFallback:defaultBlockedMesage];
formatMessage:customMessage ?: [[SNTConfigurator configurator] fileAccessBlockMessage]
withFallback:defaultBlockedMesage];
}

+ (NSAttributedString *)attributedBlockMessageForDeviceEvent:(SNTDeviceEvent *)event {
NSString *defaultRemountMessage =
NSLocalizedString(@"The following device has been remounted with reduced permissions",
@"The default message to show the user when a USB device is remounted with "
@"reduced permissions");
NSLocalizedString(@"The following device has been remounted with reduced permissions",
@"The default message to show the user when a USB device is remounted with "
@"reduced permissions");
NSString *defaultBannedMessage = NSLocalizedString(
@"The following device has been blocked from mounting",
@"The default message to show the user when a USB device is blocked from mounting");
@"The following device has been blocked from mounting",
@"The default message to show the user when a USB device is blocked from mounting");

if ([[SNTConfigurator configurator] remountUSBMode]) {
return [SNTBlockMessage formatMessage:[[SNTConfigurator configurator] remountUSBBlockMessage]
Expand All @@ -113,10 +113,10 @@ + (NSAttributedString *)attributedBlockMessageForDeviceEvent:(SNTDeviceEvent *)e
+ (NSString *)stringFromHTML:(NSString *)html {
NSError *error;
NSXMLDocument *xml = [[NSXMLDocument alloc]
initWithXMLString:html
options:NSXMLDocumentIncludeContentTypeDeclaration | NSXMLNodeCompactEmptyElement |
NSXMLNodeLoadExternalEntitiesNever | NSXMLNodeNeverEscapeContents
error:&error];
initWithXMLString:html
options:NSXMLDocumentIncludeContentTypeDeclaration | NSXMLNodeCompactEmptyElement |
NSXMLNodeLoadExternalEntitiesNever | NSXMLNodeNeverEscapeContents
error:&error];

if (error) {
LOGW(@"Failed to parse HTML message: %@", error);
Expand All @@ -126,13 +126,13 @@ + (NSString *)stringFromHTML:(NSString *)html {
// Strip any HTML tags out of the message. Also remove any content inside <style> tags and
// replace <br> elements with a newline.
NSString *stripXslt =
@"<?xml version='1.0' encoding='utf-8'?>"
@"<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'"
@" xmlns:xhtml='http://www.w3.org/1999/xhtml'>"
@"<xsl:output method='text'/>"
@"<xsl:template match='br'><xsl:text>\n</xsl:text></xsl:template>"
@"<xsl:template match='style'/>"
@"</xsl:stylesheet>";
@"<?xml version='1.0' encoding='utf-8'?>"
@"<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'"
@" xmlns:xhtml='http://www.w3.org/1999/xhtml'>"
@"<xsl:output method='text'/>"
@"<xsl:template match='br'><xsl:text>\n</xsl:text></xsl:template>"
@"<xsl:template match='style'/>"
@"</xsl:stylesheet>";
NSData *data = [xml objectByApplyingXSLTString:stripXslt arguments:NULL error:&error];
if (error || ![data isKindOfClass:[NSData class]]) {
LOGW(@"Failed to strip HTML message: %@", error);
Expand Down Expand Up @@ -177,7 +177,7 @@ + (NSDictionary *)eventDetailTemplateMappingForEvent:(SNTStoredEvent *)event {
@"%file_sha%" : ValueOrNull(event.fileSHA256 ? event.fileBundleHash ?: event.fileSHA256 : nil),
@"%file_identifier%" : ValueOrNull(event.fileSHA256),
@"%bundle_or_file_identifier%" :
ValueOrNull(event.fileSHA256 ? event.fileBundleHash ?: event.fileSHA256 : nil),
ValueOrNull(event.fileSHA256 ? event.fileBundleHash ?: event.fileSHA256 : nil),
@"%username%" : ValueOrNull(event.executingUser),
@"%file_bundle_id%" : ValueOrNull(event.fileBundleID),
@"%team_id%" : ValueOrNull(event.teamID),
Expand Down
8 changes: 4 additions & 4 deletions Source/common/SNTBlockMessageTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ - (void)testEventDetailURLForFileAccessEvent {
fae.executingUser = @"my_un";

NSString *url =
@"http://"
@"localhost?rv=%rule_version%&rn=%rule_name%&fi=%file_identifier%&"
@"fbid=%file_bundle_id%&ti=%team_id%&si=%signing_id%&ch=%cdhash%&"
@"ap=%accessed_path%&un=%username%&mid=%machine_id%&hn=%hostname%&u=%uuid%&s=%serial%";
@"http://"
@"localhost?rv=%rule_version%&rn=%rule_name%&fi=%file_identifier%&"
@"fbid=%file_bundle_id%&ti=%team_id%&si=%signing_id%&ch=%cdhash%&"
@"ap=%accessed_path%&un=%username%&mid=%machine_id%&hn=%hostname%&u=%uuid%&s=%serial%";
NSString *wantUrl = @"http://"
@"localhost?rv=my_rv&rn=my_rn&fi=my_fi&"
@"fbid=s.n.t&ti=SNT&si=SNT:s.n.t&ch=abc&"
Expand Down
4 changes: 2 additions & 2 deletions Source/common/SNTCommonEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,6 @@ enum class StatResult {
#endif

static const char *kSantaDPath =
"/Applications/Santa.app/Contents/Library/SystemExtensions/"
"com.northpolesec.santa.daemon.systemextension/Contents/MacOS/com.northpolesec.santa.daemon";
"/Applications/Santa.app/Contents/Library/SystemExtensions/"
"com.northpolesec.santa.daemon.systemextension/Contents/MacOS/com.northpolesec.santa.daemon";
static const char *kSantaAppPath = "/Applications/Santa.app";
32 changes: 16 additions & 16 deletions Source/common/SNTConfigurator.m
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ - (void)setSyncServerClientMode:(SNTClientMode)newMode {
- (BOOL)failClosed {
NSNumber *n = self.configState[kFailClosedKey];
BOOL runningInLockdownClientMode =
self.clientMode == SNTClientModeLockdown || self.clientMode == SNTClientModeStandalone;
self.clientMode == SNTClientModeLockdown || self.clientMode == SNTClientModeStandalone;
return [n boolValue] && runningInLockdownClientMode;
}

Expand Down Expand Up @@ -989,20 +989,20 @@ - (NSString *)spoolDirectory {

- (NSUInteger)spoolDirectoryFileSizeThresholdKB {
return self.configState[kSpoolDirectoryFileSizeThresholdKB]
? [self.configState[kSpoolDirectoryFileSizeThresholdKB] unsignedIntegerValue]
: 250;
? [self.configState[kSpoolDirectoryFileSizeThresholdKB] unsignedIntegerValue]
: 250;
}

- (NSUInteger)spoolDirectorySizeThresholdMB {
return self.configState[kSpoolDirectorySizeThresholdMB]
? [self.configState[kSpoolDirectorySizeThresholdMB] unsignedIntegerValue]
: 100;
? [self.configState[kSpoolDirectorySizeThresholdMB] unsignedIntegerValue]
: 100;
}

- (float)spoolDirectoryEventMaxFlushTimeSec {
return self.configState[kSpoolDirectoryEventMaxFlushTimeSec]
? [self.configState[kSpoolDirectoryEventMaxFlushTimeSec] floatValue]
: 15.0;
? [self.configState[kSpoolDirectoryEventMaxFlushTimeSec] floatValue]
: 15.0;
}

- (NSDictionary *)fileAccessPolicy {
Expand All @@ -1024,8 +1024,8 @@ - (NSString *)fileAccessBlockMessage {

- (uint32_t)fileAccessPolicyUpdateIntervalSec {
return self.configState[kFileAccessPolicyUpdateIntervalSec]
? [self.configState[kFileAccessPolicyUpdateIntervalSec] unsignedIntValue]
: 60 * 10;
? [self.configState[kFileAccessPolicyUpdateIntervalSec] unsignedIntValue]
: 60 * 10;
}

- (BOOL)enableMachineIDDecoration {
Expand Down Expand Up @@ -1236,7 +1236,7 @@ - (NSMutableDictionary *)readSyncStateFromDisk {
}

NSMutableDictionary *syncState =
[NSMutableDictionary dictionaryWithContentsOfFile:self.syncStateFilePath];
[NSMutableDictionary dictionaryWithContentsOfFile:self.syncStateFilePath];
for (NSString *key in syncState.allKeys) {
if (self.syncServerKeyTypes[key] == [NSRegularExpression class]) {
NSString *pattern = [syncState[key] isKindOfClass:[NSString class]] ? syncState[key] : nil;
Expand Down Expand Up @@ -1267,8 +1267,8 @@ - (BOOL)migrateDeprecatedSyncStateKeys {
// Otherwise, migrate the old value to be compatible with the new logic.
if (!self.syncState[kSyncTypeRequired]) {
syncState[kSyncTypeRequired] = [self.syncState[kSyncCleanRequiredDeprecated] boolValue]
? @(SNTSyncTypeClean)
: @(SNTSyncTypeNormal);
? @(SNTSyncTypeClean)
: @(SNTSyncTypeNormal);
}

// Delete the deprecated key
Expand Down Expand Up @@ -1400,9 +1400,9 @@ - (void)watchOverridesFile {
}

dispatch_source_t source =
dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE, descriptor,
DISPATCH_VNODE_WRITE | DISPATCH_VNODE_RENAME | DISPATCH_VNODE_DELETE,
dispatch_get_global_queue(QOS_CLASS_UTILITY, 0));
dispatch_source_create(DISPATCH_SOURCE_TYPE_VNODE, descriptor,
DISPATCH_VNODE_WRITE | DISPATCH_VNODE_RENAME | DISPATCH_VNODE_DELETE,
dispatch_get_global_queue(QOS_CLASS_UTILITY, 0));
dispatch_source_set_event_handler(source, ^{
dispatch_async(dispatch_get_main_queue(), ^{
[self defaultsChanged:nil];
Expand Down Expand Up @@ -1442,7 +1442,7 @@ - (void)cacheStaticRules {
if (![staticRules isKindOfClass:[NSArray class]]) return;

NSMutableDictionary<NSString *, SNTRule *> *rules =
[NSMutableDictionary dictionaryWithCapacity:staticRules.count];
[NSMutableDictionary dictionaryWithCapacity:staticRules.count];
for (id rule in staticRules) {
if (![rule isKindOfClass:[NSDictionary class]]) return;
SNTRule *r = [[SNTRule alloc] initWithDictionary:rule];
Expand Down
4 changes: 2 additions & 2 deletions Source/common/SNTConfiguratorTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ @implementation SNTConfiguratorTest
- (void)setUp {
self.fileMgr = [NSFileManager defaultManager];
self.testDir =
[NSString stringWithFormat:@"%@santa-configurator-%d", NSTemporaryDirectory(), getpid()];
[NSString stringWithFormat:@"%@santa-configurator-%d", NSTemporaryDirectory(), getpid()];

XCTAssertTrue([self.fileMgr createDirectoryAtPath:self.testDir
withIntermediateDirectories:YES
Expand All @@ -50,7 +50,7 @@ - (void)tearDown {
- (void)runMigrationTestsWithSyncState:(NSDictionary *)syncStatePlist
verifier:(void (^)(SNTConfigurator *))verifierBlock {
NSString *syncStatePlistPath =
[NSString stringWithFormat:@"%@/test-sync-state.plist", self.testDir];
[NSString stringWithFormat:@"%@/test-sync-state.plist", self.testDir];

XCTAssertTrue([syncStatePlist writeToFile:syncStatePlistPath atomically:YES]);

Expand Down
2 changes: 1 addition & 1 deletion Source/common/SNTDeepCopy.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ @implementation NSDictionary (SNTDeepCopy)

- (instancetype)sntDeepCopy {
NSMutableDictionary<__kindof NSObject *, __kindof NSObject *> *deepCopy =
[NSMutableDictionary dictionary];
[NSMutableDictionary dictionary];
for (id key in self) {
id value = self[key];
if ([value respondsToSelector:@selector(sntDeepCopy)]) {
Expand Down
4 changes: 2 additions & 2 deletions Source/common/SNTFileAccessEvent.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ - (instancetype)initWithCoder:(NSCoder *)decoder {
}

- (NSString *)description {
return [NSString
stringWithFormat:@"SNTFileAccessEvent: Accessed: %@, By: %@", self.accessedPath, self.filePath];
return [NSString stringWithFormat:@"SNTFileAccessEvent: Accessed: %@, By: %@", self.accessedPath,
self.filePath];
}

@end
Loading

0 comments on commit 82fddd3

Please sign in to comment.