]> git.saurik.com Git - apple/security.git/blob - OSX/utilities/SecABC.m
Security-59306.41.2.tar.gz
[apple/security.git] / OSX / utilities / SecABC.m
1 //
2 // SecABC.m
3 // Security
4 //
5
6 #import "SecABC.h"
7 #import <os/log.h>
8
9
10 #if ABC_BUGCAPTURE
11 #import <SymptomDiagnosticReporter/SDRDiagnosticReporter.h>
12 #endif
13
14 void SecABCTrigger(CFStringRef type,
15 CFStringRef subtype,
16 CFStringRef subtypeContext,
17 CFDictionaryRef payload)
18 {
19 [SecABC triggerAutoBugCaptureWithType:(__bridge NSString *)type
20 subType:(__bridge NSString *)subtype
21 subtypeContext:(__bridge NSString *)subtypeContext
22 events:nil
23 payload:(__bridge NSDictionary *)payload
24 detectedProcess:nil];
25 }
26
27
28 @implementation SecABC
29
30 + (void)triggerAutoBugCaptureWithType:(NSString *)type
31 subType:(NSString *)subType
32 subtypeContext:(NSString *)subtypeContext
33 events:(NSArray *)events
34 payload:(NSDictionary *)payload
35 detectedProcess:(NSString *)process
36 {
37 #if ABC_BUGCAPTURE
38 os_log(OS_LOG_DEFAULT, "TriggerABC for %{public}@/%{public}@/%{public}@",
39 type, subType, subtypeContext);
40
41 // no ABC on darwinos
42 if ([SDRDiagnosticReporter class] == nil) {
43 return;
44 }
45
46 SDRDiagnosticReporter *diagnosticReporter = [[SDRDiagnosticReporter alloc] init];
47 NSMutableDictionary *signature = [diagnosticReporter signatureWithDomain:@"com.apple.security.keychain"
48 type:type
49 subType:subType
50 subtypeContext:subtypeContext
51 detectedProcess:process?:[[NSProcessInfo processInfo] processName]
52 triggerThresholdValues:nil];
53 if (signature == NULL) {
54 os_log(OS_LOG_DEFAULT, "TriggerABC signature generation failed");
55 return;
56 }
57
58 (void)[diagnosticReporter snapshotWithSignature:signature
59 duration:30.0
60 events:events
61 payload:payload
62 actions:NULL
63 reply:^void(NSDictionary *response)
64 {
65 os_log(OS_LOG_DEFAULT, "Received response from Diagnostic Reporter - %{public}@/%{public}@/%{public}@: %{public}@",
66 type, subType, subtypeContext, response);
67 }];
68 #endif
69 }
70
71 @end