Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into pt-3
- Loading branch information
Showing
55 changed files
with
1,234 additions
and
494 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/// Copyright 2024 Google LLC | ||
/// | ||
/// Licensed under the Apache License, Version 2.0 (the "License"); | ||
/// you may not use this file except in compliance with the License. | ||
/// You may obtain a copy of the License at | ||
/// | ||
/// https://www.apache.org/licenses/LICENSE-2.0 | ||
/// | ||
/// Unless required by applicable law or agreed to in writing, software | ||
/// distributed under the License is distributed on an "AS IS" BASIS, | ||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
/// See the License for the specific language governing permissions and | ||
/// limitations under the License. | ||
|
||
/** | ||
* This file declares two types that are mirrors of each other. | ||
* | ||
* The C struct serves as a way to group and pass valid rule identifiers around | ||
* in order to minimize interface changes needed when new rule types are added | ||
* and also alleviate the need to allocate a short lived object. | ||
* | ||
* The Objective C class is used for an XPC boundary to easily pass rule | ||
* identifiers between Santa components. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
struct RuleIdentifiers { | ||
NSString *cdhash; | ||
NSString *binarySHA256; | ||
NSString *signingID; | ||
NSString *certificateSHA256; | ||
NSString *teamID; | ||
}; | ||
|
||
@interface SNTRuleIdentifiers : NSObject <NSSecureCoding> | ||
@property(readonly) NSString *cdhash; | ||
@property(readonly) NSString *binarySHA256; | ||
@property(readonly) NSString *signingID; | ||
@property(readonly) NSString *certificateSHA256; | ||
@property(readonly) NSString *teamID; | ||
|
||
/// Please use `initWithRuleIdentifiers:` | ||
- (instancetype)init NS_UNAVAILABLE; | ||
|
||
- (instancetype)initWithRuleIdentifiers:(struct RuleIdentifiers)identifiers | ||
NS_DESIGNATED_INITIALIZER; | ||
|
||
- (struct RuleIdentifiers)toStruct; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/// Copyright 2024 Google LLC | ||
/// | ||
/// Licensed under the Apache License, Version 2.0 (the "License"); | ||
/// you may not use this file except in compliance with the License. | ||
/// You may obtain a copy of the License at | ||
/// | ||
/// https://www.apache.org/licenses/LICENSE-2.0 | ||
/// | ||
/// Unless required by applicable law or agreed to in writing, software | ||
/// distributed under the License is distributed on an "AS IS" BASIS, | ||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
/// See the License for the specific language governing permissions and | ||
/// limitations under the License. | ||
|
||
#import "Source/common/SNTRuleIdentifiers.h" | ||
|
||
@implementation SNTRuleIdentifiers | ||
|
||
- (instancetype)initWithRuleIdentifiers:(struct RuleIdentifiers)identifiers { | ||
self = [super init]; | ||
if (self) { | ||
_cdhash = identifiers.cdhash; | ||
_binarySHA256 = identifiers.binarySHA256; | ||
_signingID = identifiers.signingID; | ||
_certificateSHA256 = identifiers.certificateSHA256; | ||
_teamID = identifiers.teamID; | ||
} | ||
return self; | ||
} | ||
|
||
- (struct RuleIdentifiers)toStruct { | ||
return (struct RuleIdentifiers){.cdhash = self.cdhash, | ||
.binarySHA256 = self.binarySHA256, | ||
.signingID = self.signingID, | ||
.certificateSHA256 = self.certificateSHA256, | ||
.teamID = self.teamID}; | ||
} | ||
|
||
#pragma mark NSSecureCoding | ||
|
||
#pragma clang diagnostic push | ||
#pragma clang diagnostic ignored "-Wobjc-literal-conversion" | ||
#define ENCODE(obj, key) \ | ||
if (obj) [coder encodeObject:obj forKey:key] | ||
#define DECODE(cls, key) [decoder decodeObjectOfClass:[cls class] forKey:key] | ||
|
||
+ (BOOL)supportsSecureCoding { | ||
return YES; | ||
} | ||
|
||
- (instancetype)initWithCoder:(NSCoder *)decoder { | ||
self = [self init]; | ||
if (self) { | ||
_cdhash = DECODE(NSString, @"cdhash"); | ||
_binarySHA256 = DECODE(NSString, @"binarySHA256"); | ||
_signingID = DECODE(NSString, @"signingID"); | ||
_certificateSHA256 = DECODE(NSString, @"certificateSHA256"); | ||
_teamID = DECODE(NSString, @"teamID"); | ||
} | ||
return self; | ||
} | ||
|
||
- (void)encodeWithCoder:(NSCoder *)coder { | ||
ENCODE(self.cdhash, @"cdhash"); | ||
ENCODE(self.binarySHA256, @"binarySHA256"); | ||
ENCODE(self.signingID, @"signingID"); | ||
ENCODE(self.certificateSHA256, @"certificateSHA256"); | ||
ENCODE(self.teamID, @"teamID"); | ||
} | ||
|
||
#pragma clang diagnostic pop | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.