From 5f0755efbfd0d0db9889ee47ce497998a47a733d Mon Sep 17 00:00:00 2001 From: Pete Markowsky Date: Mon, 4 Sep 2023 19:48:44 -0400 Subject: [PATCH] Add Tests for #1165 Behavior. (#1173) --- Source/santad/SNTExecutionControllerTest.mm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Source/santad/SNTExecutionControllerTest.mm b/Source/santad/SNTExecutionControllerTest.mm index d1d7df656..354b12ca6 100644 --- a/Source/santad/SNTExecutionControllerTest.mm +++ b/Source/santad/SNTExecutionControllerTest.mm @@ -464,6 +464,23 @@ - (void)testBinaryAllowTransitiveRuleDisabled { [self checkMetricCounters:kAllowTransitive expected:@0]; } +- (void)testThatPlatformBinaryCachedDecisionsSetModeCorrectly { + OCMStub([self.mockFileInfo isMachO]).andReturn(YES); + OCMStub([self.mockFileInfo SHA256]).andReturn(@"a"); + OCMStub([self.mockConfigurator clientMode]).andReturn(SNTClientModeLockdown); + OCMStub([self.mockConfigurator enableTransitiveRules]).andReturn(NO); + + SNTCachedDecision *cd = [[SNTCachedDecision alloc] init]; + cd.decision = SNTEventStateAllowBinary; + OCMStub([self.mockRuleDatabase criticalSystemBinaries]).andReturn(@{@"a" : cd}); + + [self validateExecEvent:SNTActionRespondAllow]; + [self checkMetricCounters:kAllowBinary expected:@1]; + [self checkMetricCounters:kAllowUnknown expected:@0]; + + XCTAssertEqual(cd.decisionClientMode, SNTClientModeLockdown); +} + - (void)testDefaultDecision { OCMStub([self.mockFileInfo isMachO]).andReturn(YES); OCMStub([self.mockFileInfo SHA256]).andReturn(@"a");