Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

santad: Allow configuring a static set of rules via configuration profile #846

Merged
merged 11 commits into from
Jul 13, 2022

Conversation

russellhancox
Copy link
Contributor

This PR adds a new top-level configuration key StaticRules that allows setting a static set of rules utilized before any rules in the database. This allows for 2 things:

  1. Adding a set of critical rules for management tools that should always be allowed to run even if a sync has not occurred or for some reason the rules database has been cleared.
  2. For organizations that do not have a sync server, this can be used for configuring the ruleset.

Fixes #777 and #285

@russellhancox russellhancox linked an issue Jul 13, 2022 that may be closed by this pull request
Copy link
Contributor

@pmarkowsky pmarkowsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good, some minor things.

Source/common/SNTRule.m Show resolved Hide resolved
Source/common/SNTRule.m Outdated Show resolved Hide resolved
Source/common/SNTConfigurator.m Show resolved Hide resolved
Source/common/SNTRule.m Show resolved Hide resolved
Copy link
Contributor

@pmarkowsky pmarkowsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@russellhancox russellhancox merged commit 1cc40d5 into google:main Jul 13, 2022
@russellhancox russellhancox deleted the mdm-rules branch July 13, 2022 21:58
@@ -549,6 +560,21 @@ - (void)setRemountUSBMode:(NSArray<NSString *> *)args {
return args;
}

- (NSDictionary<NSString *, SNTRule *> *)staticRules {
NSArray *currentRules = self.configState[kStaticRules];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make sure this is indeed an NSArray.

@@ -549,6 +560,21 @@ - (void)setRemountUSBMode:(NSArray<NSString *> *)args {
return args;
}

- (NSDictionary<NSString *, SNTRule *> *)staticRules {
NSArray *currentRules = self.configState[kStaticRules];
if (currentRules.hash != self.cachedStaticRulesHash) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How expensive is this hashing? For a really large set I can see the cost adding up since we need to hash for every exec. Instead of initializing lazily here we should move the parsing closer to when the rules are added to the profile. We could add a new property for the unprocessed rules and KVO observe changes. We could do the parsing there. This method turns into a fast getter for the current set of rules.


self = [super init];
if (self) {
_identifier = dict[kRuleIdentifier];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything we get out of the dictionary we can’t trust. We need to check the types are what we expect.

russellhancox added a commit that referenced this pull request Jul 14, 2022
In #846 I forgot that  is only a count of the entries so if the config changes but the number of rules remains the same we would never update the cache. This PR moves the processing of the raw config into the KVO handler code so it is not at all in the hot-path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Permanent (local) whitelist exemptions Allow managing ruleset via .mobileconfig
3 participants