]> git.saurik.com Git - apple/security.git/blob - OSX/utilities/SecABC.m
Security-59306.61.1.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 {
33 [self triggerAutoBugCaptureWithType: type
34 subType: subType
35 subtypeContext: nil
36 events: nil
37 payload: nil
38 detectedProcess: nil];
39 }
40
41
42 + (void)triggerAutoBugCaptureWithType:(NSString *)type
43 subType:(NSString *)subType
44 subtypeContext:(NSString *)subtypeContext
45 events:(NSArray *)events
46 payload:(NSDictionary *)payload
47 detectedProcess:(NSString *)process
48 {
49 #if ABC_BUGCAPTURE
50 os_log(OS_LOG_DEFAULT, "TriggerABC for %{public}@/%{public}@/%{public}@",
51 type, subType, subtypeContext);
52
53 // no ABC on darwinos
54 if ([SDRDiagnosticReporter class] == nil) {
55 return;
56 }
57
58 SDRDiagnosticReporter *diagnosticReporter = [[SDRDiagnosticReporter alloc] init];
59 NSMutableDictionary *signature = [diagnosticReporter signatureWithDomain:@"com.apple.security.keychain"
60 type:type
61 subType:subType
62 subtypeContext:subtypeContext
63 detectedProcess:process?:[[NSProcessInfo processInfo] processName]
64 triggerThresholdValues:nil];
65 if (signature == NULL) {
66 os_log(OS_LOG_DEFAULT, "TriggerABC signature generation failed");
67 return;
68 }
69
70 (void)[diagnosticReporter snapshotWithSignature:signature
71 duration:5.0
72 events:events
73 payload:payload
74 actions:NULL
75 reply:^void(NSDictionary *response)
76 {
77 os_log(OS_LOG_DEFAULT, "Received response from Diagnostic Reporter - %{public}@/%{public}@/%{public}@: %{public}@",
78 type, subType, subtypeContext, response);
79 }];
80 #endif
81 }
82
83 @end