Skip to content

Commit

Permalink
Review feedback and fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmarkowsky committed Mar 20, 2024
1 parent 83e3b8d commit 9d0834a
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions Source/santad/DataLayer/SNTRuleTable.m
Original file line number Diff line number Diff line change
Expand Up @@ -463,16 +463,16 @@ - (BOOL)addRules:(NSArray *)rules
}

- (BOOL)addedRulesShouldFlushDecisionCache:(NSArray *)rules {
uint64_t blockingRuleCount = 0;
uint64_t nonAllowRuleCount = 0;

for (SNTRule *rule in rules) {
if (rule.state != SNTRuleStateAllow) {
blockingRuleCount++;
nonAllowRuleCount++;
}
}

// Just flush if we have a lot of block rules.
if (blockingRuleCount >= 1000) {
if (nonAllowRuleCount >= 1000) {
return YES;
}

Expand All @@ -494,16 +494,19 @@ - (BOOL)addedRulesShouldFlushDecisionCache:(NSArray *)rules {
flushDecisionCache = YES;
break;
}
// Skip to check the next rule since we only want to check allows for
// compiler rules.
continue;
}

// Allowlist certificate rules are ignored
if (rule.type == SNTRuleTypeCertificate) continue;
// Allowlist certificate rules are ignored
if (rule.type == SNTRuleTypeCertificate || rule.type == SNTRuleTypeTeamID) continue;

if ([db longForQuery:
@"SELECT COUNT(*) FROM rules WHERE identifier=? AND type=? AND state=? LIMIT 1",
rule.identifier, @(SNTRuleTypeBinary), @(SNTRuleStateAllowCompiler)] > 0) {
flushDecisionCache = YES;
break;
}
if ([db longForQuery:
@"SELECT COUNT(*) FROM rules WHERE identifier=? AND type=? AND state=? LIMIT 1",
rule.identifier, @(SNTRuleTypeBinary), @(SNTRuleStateAllowCompiler)] > 0) {
flushDecisionCache = YES;
break;
}
}
}];
Expand Down

0 comments on commit 9d0834a

Please sign in to comment.