• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

google / santa / 10309967616

08 Aug 2024 09:43PM UTC coverage: 62.69% (-0.4%) from 63.125%
10309967616

push

github

web-flow
sync: Fix Content-Type logic bug, add test (#1412)

5612 of 13404 branches covered (41.87%)

Branch coverage included in aggregate %.

12 of 12 new or added lines in 2 files covered. (100.0%)

170 existing lines in 8 files now uncovered.

18659 of 25312 relevant lines covered (73.72%)

6451.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

11.45
/Source/gui/SNTBinaryMessageWindowController.m
1
/// Copyright 2015 Google Inc. All rights reserved.
2
///
3
/// Licensed under the Apache License, Version 2.0 (the "License");
4
/// you may not use this file except in compliance with the License.
5
/// You may obtain a copy of the License at
6
///
7
///    http://www.apache.org/licenses/LICENSE-2.0
8
///
9
///    Unless required by applicable law or agreed to in writing, software
10
///    distributed under the License is distributed on an "AS IS" BASIS,
11
///    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
///    See the License for the specific language governing permissions and
13
///    limitations under the License.
14

15
#import "Source/gui/SNTBinaryMessageWindowController.h"
16

17
#import <MOLCertificate/MOLCertificate.h>
18
#import <SecurityInterface/SFCertificatePanel.h>
19

20
#import "Source/common/CertificateHelpers.h"
21
#import "Source/common/SNTBlockMessage.h"
22
#import "Source/common/SNTConfigurator.h"
23
#import "Source/common/SNTStoredEvent.h"
24

25
@interface SNTBinaryMessageWindowController ()
26
///  The custom message to display for this event
27
@property(copy) NSString *customMessage;
28

29
///  The custom URL to use for this event
30
@property(copy) NSString *customURL;
31

32
///  A 'friendly' string representing the certificate information
33
@property(readonly, nonatomic) NSString *publisherInfo;
34

35
///  An optional message to display with this block.
36
@property(readonly, nonatomic) NSAttributedString *attributedCustomMessage;
37

38
///  Reference to the "Application Name" label in the XIB. Used to remove if application
39
///  doesn't have a CFBundleName.
40
@property(weak) IBOutlet NSTextField *applicationNameLabel;
41

42
@end
43

44
@implementation SNTBinaryMessageWindowController
45

46
- (instancetype)initWithEvent:(SNTStoredEvent *)event
47
                    customMsg:(NSString *)message
48
                    customURL:(NSString *)url {
1✔
49
  self = [super initWithWindowNibName:@"MessageWindow"];
1✔
50
  if (self) {
1!
51
    _event = event;
1✔
52
    _customMessage = message;
1✔
53
    _customURL = url;
1✔
54
    _progress = [NSProgress discreteProgressWithTotalUnitCount:1];
1✔
55
    [_progress addObserver:self
1✔
56
                forKeyPath:@"fractionCompleted"
1✔
57
                   options:NSKeyValueObservingOptionNew
1✔
58
                   context:NULL];
1✔
59
  }
1✔
60
  return self;
1✔
61
}
1✔
62

63
- (void)dealloc {
×
64
  [_progress removeObserver:self forKeyPath:@"fractionCompleted"];
×
65
}
×
66

67
- (void)observeValueForKeyPath:(NSString *)keyPath
68
                      ofObject:(id)object
69
                        change:(NSDictionary *)change
70
                       context:(void *)context {
×
71
  if ([keyPath isEqualToString:@"fractionCompleted"]) {
×
72
    dispatch_async(dispatch_get_main_queue(), ^{
×
73
      NSProgress *progress = object;
×
74
      if (progress.fractionCompleted != 0.0) {
×
75
        self.hashingIndicator.indeterminate = NO;
×
76
      }
×
77
      self.hashingIndicator.doubleValue = progress.fractionCompleted;
×
78
    });
×
79
  }
×
80
}
×
81

UNCOV
82
- (void)loadWindow {
×
UNCOV
83
  [super loadWindow];
×
UNCOV
84
  NSURL *url = [SNTBlockMessage eventDetailURLForEvent:self.event customURL:self.customURL];
×
85

UNCOV
86
  if (!url) {
×
UNCOV
87
    [self.openEventButton removeFromSuperview];
×
UNCOV
88
  } else if (self.customURL.length == 0) {
×
89
    // Set the button text only if a per-rule custom URL is not used. If a
90
    // custom URL is used, it is assumed that the `EventDetailText` config value
91
    // does not apply and the default text will be used.
92
    NSString *eventDetailText = [[SNTConfigurator configurator] eventDetailText];
×
93
    if (eventDetailText) {
×
94
      [self.openEventButton setTitle:eventDetailText];
×
95
      // Require the button keyEquivalent set to be CMD + Return
96
      [self.openEventButton setKeyEquivalent:@"\r"];  // Return Key
×
97
      [self.openEventButton
×
98
        setKeyEquivalentModifierMask:NSEventModifierFlagCommand];  // Command Key
×
99
    }
×
100
  }
×
101

UNCOV
102
  NSString *dismissButtonText = [[SNTConfigurator configurator] dismissText];
×
UNCOV
103
  if (dismissButtonText.length) {
×
104
    [self.dismissEventButton setTitle:dismissButtonText];
×
105
  }
×
106

UNCOV
107
  if (!self.event.needsBundleHash) {
×
UNCOV
108
    [self.bundleHashLabel removeFromSuperview];
×
UNCOV
109
    [self.hashingIndicator removeFromSuperview];
×
UNCOV
110
    [self.foundFileCountLabel removeFromSuperview];
×
UNCOV
111
  } else {
×
112
    self.openEventButton.enabled = NO;
×
113
    self.hashingIndicator.indeterminate = YES;
×
114
    [self.hashingIndicator startAnimation:self];
×
115
    self.bundleHashLabel.hidden = YES;
×
116
    self.foundFileCountLabel.stringValue = @"";
×
117
  }
×
118

UNCOV
119
  if (!self.event.fileBundleName) {
×
120
    [self.applicationNameLabel removeFromSuperview];
×
121
  }
×
UNCOV
122
}
×
123

UNCOV
124
- (NSString *)messageHash {
×
UNCOV
125
  return self.event.fileSHA256;
×
UNCOV
126
}
×
127

128
- (IBAction)showCertInfo:(id)sender {
×
129
  // SFCertificatePanel expects an NSArray of SecCertificateRef's
130
  [[[SFCertificatePanel alloc] init] beginSheetForWindow:self.window
×
131
                                           modalDelegate:nil
×
132
                                          didEndSelector:nil
×
133
                                             contextInfo:nil
×
134
                                            certificates:CertificateChain(self.event.signingChain)
×
135
                                               showGroup:YES];
×
136
}
×
137

138
- (IBAction)openEventDetails:(id)sender {
×
139
  NSURL *url = [SNTBlockMessage eventDetailURLForEvent:self.event customURL:self.customURL];
×
140

141
  [self closeWindow:sender];
×
142
  [[NSWorkspace sharedWorkspace] openURL:url];
×
143
}
×
144

145
#pragma mark Generated properties
146

UNCOV
147
+ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key {
×
UNCOV
148
  if (![key isEqualToString:@"event"]) {
×
UNCOV
149
    return [NSSet setWithObject:@"event"];
×
UNCOV
150
  } else {
×
UNCOV
151
    return [NSSet set];
×
UNCOV
152
  }
×
UNCOV
153
}
×
154

UNCOV
155
- (NSString *)publisherInfo {
×
UNCOV
156
  return Publisher(self.event.signingChain, self.event.teamID);
×
UNCOV
157
}
×
158

UNCOV
159
- (NSAttributedString *)attributedCustomMessage {
×
UNCOV
160
  return [SNTBlockMessage attributedBlockMessageForEvent:self.event
×
UNCOV
161
                                           customMessage:self.customMessage];
×
UNCOV
162
}
×
163

164
- (void)updateBlockNotification:(SNTStoredEvent *)event withBundleHash:(NSString *)bundleHash {
×
165
  // UI updates must happen on the main thread.
166
  dispatch_async(dispatch_get_main_queue(), ^{
×
167
    if ([self.event.idx isEqual:event.idx]) {
×
168
      if (bundleHash) {
×
169
        [self.bundleHashLabel setHidden:NO];
×
170
      } else {
×
171
        [self.bundleHashLabel removeFromSuperview];
×
172
        [self.bundleHashTitle removeFromSuperview];
×
173
      }
×
174
      self.event.fileBundleHash = bundleHash;
×
175
      [self.foundFileCountLabel removeFromSuperview];
×
176
      [self.hashingIndicator setHidden:YES];
×
177
      [self.openEventButton setEnabled:YES];
×
178
    }
×
179
  });
×
180
}
×
181

182
@end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc