Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
a2c8a4c
Added changelog entry for ty's fix
watkyn Oct 1, 2020
9a262a6
updated the changelog with author tags
watkyn Oct 1, 2020
b737070
adding in some unit tests to help with making changes to the structur…
watkyn Oct 1, 2020
0725bd7
Added allowed and authorization as optionals so they can be left out …
watkyn Oct 2, 2020
c7791e7
Updated the change log
watkyn Oct 2, 2020
dde4022
added some tests for handling the authoriztion vs allowed legacy prop…
watkyn Oct 5, 2020
11f0fbb
Added the new Authorization key as the default instead of Allowed
watkyn Oct 6, 2020
cd778ab
Added some more tests around importing a profile and making sure it h…
watkyn Oct 6, 2020
ca30501
Added constants for the key display values and some more tests around…
watkyn Oct 7, 2020
e3e2e99
Fixed the parsing issue when importing a profile with apple events an…
watkyn Oct 7, 2020
3595c41
Added the new key to the drop down for screen capture and listen event.
watkyn Oct 7, 2020
20ae824
Added some support for an info message if the user is trying to use t…
watkyn Oct 7, 2020
4373629
Working through some changes. There are currently failing unit tests …
watkyn Oct 12, 2020
832fef1
Fix application list layout
Oct 13, 2020
5f084fe
Revert "Fix application list layout"
Oct 13, 2020
c5847dc
Fix Applications table view cell height
Oct 13, 2020
c7bc881
Fixing some more UI issues and causing some others
watkyn Oct 13, 2020
dc66431
fixed up the unit tests
watkyn Oct 13, 2020
a551bc0
Fix table view cell height
Oct 13, 2020
9f3f146
Merge branch 'add-new-pppc-keys' of github.com:jamf/PPPC-Utility into…
Oct 13, 2020
43da4ec
Changed the width of the popup buttons to allow for the new value to …
watkyn Oct 14, 2020
8420641
More UI tweaks and also added a cancel option for the alert when user…
watkyn Oct 14, 2020
6268925
Added constrainsts for the big sur switch
watkyn Oct 14, 2020
37041be
Got rid of as many interface builder warnings as I could. There is st…
watkyn Oct 14, 2020
e5af14c
Moved the import button to the same row as the Save and Upload buttons.
watkyn Oct 14, 2020
18e1c6a
upgraded swiftlint and fixed the issue
watkyn Oct 14, 2020
8561d1b
Fixed some wording and spelling issues.
watkyn Oct 14, 2020
58f3331
Added spacing in the error message for better readablility
watkyn Oct 14, 2020
28e1570
added note to changelog that 10.15 is the min deployment target now
watkyn Oct 14, 2020
cb9b65a
changed to use a setup() method for the ModelTests
watkyn Oct 14, 2020
7a8ace4
Removed a comment and made the method name more descriptive.
watkyn Oct 15, 2020
fdb805c
Updated readme to reference 10.15 as the min version
watkyn Oct 15, 2020
c0ec9ab
changed the format of switch statments to be consistent
watkyn Oct 15, 2020
e2243d7
added guard in weak self pointer is actually nil
watkyn Oct 15, 2020
5bd7c60
disabled hardened runtime for debug builds so that unit tests can be …
watkyn Oct 15, 2020
05f2854
Added some internal jenkins related files.
watkyn Oct 20, 2020
aacfc9f
adding a sleep for troubleshooting
watkyn Oct 20, 2020
11f23ef
Adding import to the shared fastlane lib using ENV
watkyn Oct 20, 2020
14bb4d6
Trying to fix the build issues by taking of sign to run locally
watkyn Oct 20, 2020
60cf2a3
removed Jenkins changes and moved them to another experimental branch
watkyn Oct 20, 2020
0284f6f
changed back to use the hardented runtime for debug mode to try and f…
watkyn Oct 20, 2020
c2a4fae
Going back to setting the team explicitly.
watkyn Oct 20, 2020
5cd46ce
Disabled the hardened runtime again so the unit tests locally can be …
watkyn Oct 20, 2020
bb50ba9
One more try at the build by turning off automatic code signing
watkyn Oct 20, 2020
30982e7
Only changing back the main app not the unit tests to see if we can a…
watkyn Oct 20, 2020
3ad7a83
giving up, just leaving the team assigned
watkyn Oct 20, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added some support for an info message if the user is trying to use t…
…he new Authorization key, warning them it is only Big Sur and above
  • Loading branch information
watkyn committed Oct 7, 2020
commit 20ae824acd3397d9da17c447057e069205e13c43
34 changes: 34 additions & 0 deletions PPPC UtilityTests/ModelTests/ModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -413,4 +413,38 @@ class ModelTests: XCTestCase {
XCTAssertNil(policy, "should have errored out because of an invalid value")
}

/// MARK: - tests for requiresAuthorizationKey

func testWhenServiceIsUsingAllowStandarUsersToApprove() {
// given
let profile = TCCProfileBuilder().buildProfile(authorization: .allowStandardUserToSetSystemService)

// when
model.importProfile(tccProfile: profile)

// then
XCTAssertTrue(model.requiresAuthorizationKey())
}

func testWhenServiceIsUsingOnlyAllowKey() {
// given
let profile = TCCProfileBuilder().buildProfile(authorization: .allow)

// when
model.importProfile(tccProfile: profile)

// then
XCTAssertFalse(model.requiresAuthorizationKey())
}

func testWhenServiceIsUsingOnlyDenyKey() {
// given
let profile = TCCProfileBuilder().buildProfile(authorization: .deny)

// when
model.importProfile(tccProfile: profile)

// then
XCTAssertFalse(model.requiresAuthorizationKey())
}
}
31 changes: 12 additions & 19 deletions Resources/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -2380,19 +2380,6 @@
<binding destination="qId-iR-fmq" name="enabled" keyPath="canRemove" id="Rc1-zx-BZh"/>
</connections>
</button>
<button hidden="YES" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="UEk-m2-coJ">
<rect key="frame" x="15" y="13" width="83" height="32"/>
<constraints>
<constraint firstAttribute="width" constant="71" id="Azy-1R-K2D"/>
</constraints>
<buttonCell key="cell" type="push" title="Record" bezelStyle="rounded" alignment="center" enabled="NO" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="5OS-W8-49v">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="recordPressed:" target="ZfI-PN-mks" id="xch-3L-FAh"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="L3L-II-z9D">
<rect key="frame" x="230" y="654" width="80" height="19"/>
<textFieldCell key="cell" lineBreakMode="clipping" title="Properties" id="BL7-a9-Wo0">
Expand All @@ -2415,6 +2402,15 @@
<action selector="importProfile:" target="ZfI-PN-mks" id="CbR-lv-L7N"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="14r-fe-OXJ">
<rect key="frame" x="46" y="11" width="859" height="39"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" alignment="center" id="XZb-T8-8Se">
<font key="font" metaFont="system" size="16"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<constraints>
<constraint firstItem="JIN-BO-Fp8" firstAttribute="leading" secondItem="JSo-Ex-mKB" secondAttribute="leading" id="1XB-vJ-xiI"/>
Expand All @@ -2436,20 +2432,17 @@
<constraint firstItem="03S-CM-lPV" firstAttribute="leading" secondItem="3Am-A7-MGr" secondAttribute="trailing" constant="12" id="GSZ-Pk-E5b"/>
<constraint firstItem="SFg-90-Vi7" firstAttribute="leading" secondItem="pHR-Fa-o0o" secondAttribute="trailing" constant="8" id="MK7-4L-bS5"/>
<constraint firstItem="DB5-Ps-rWI" firstAttribute="baseline" secondItem="SFg-90-Vi7" secondAttribute="firstBaseline" id="Ntc-ET-tvQ"/>
<constraint firstItem="UEk-m2-coJ" firstAttribute="centerY" secondItem="Gwb-6x-mB1" secondAttribute="centerY" id="O0c-74-sVd"/>
<constraint firstItem="3Am-A7-MGr" firstAttribute="top" secondItem="bKS-CN-KZi" secondAttribute="top" constant="35" id="Prb-UA-Xca"/>
<constraint firstItem="5hq-Rl-ues" firstAttribute="top" secondItem="zBr-K2-oEH" secondAttribute="bottom" constant="5" id="QXd-Jh-Zyw"/>
<constraint firstItem="DB5-Ps-rWI" firstAttribute="leading" secondItem="pHR-Fa-o0o" secondAttribute="trailing" constant="81" id="Qgg-DM-0Sx"/>
<constraint firstItem="L3L-II-z9D" firstAttribute="leading" secondItem="03S-CM-lPV" secondAttribute="leading" id="St8-B9-At6"/>
<constraint firstItem="5hq-Rl-ues" firstAttribute="bottom" secondItem="03S-CM-lPV" secondAttribute="bottom" id="VaG-RW-D30"/>
<constraint firstItem="SFg-90-Vi7" firstAttribute="baseline" secondItem="v8I-Mx-BrF" secondAttribute="baseline" id="WcE-XK-GJk"/>
<constraint firstItem="n1N-Hx-bP6" firstAttribute="leading" secondItem="JSo-Ex-mKB" secondAttribute="leading" id="Wue-YV-KSd"/>
<constraint firstAttribute="bottom" secondItem="UEk-m2-coJ" secondAttribute="bottom" constant="20" id="ZMJ-yC-Aya"/>
<constraint firstItem="zBr-K2-oEH" firstAttribute="leading" secondItem="5hq-Rl-ues" secondAttribute="leading" id="cBU-bf-KJm"/>
<constraint firstItem="mSS-FZ-Sk0" firstAttribute="leading" secondItem="JSo-Ex-mKB" secondAttribute="leading" id="cHj-8V-DtF"/>
<constraint firstItem="YNV-Zn-1jp" firstAttribute="leading" secondItem="JSo-Ex-mKB" secondAttribute="leading" id="dB2-pF-h9K"/>
<constraint firstAttribute="bottom" secondItem="03S-CM-lPV" secondAttribute="bottom" constant="90" id="dLI-ZX-EdF"/>
<constraint firstItem="UEk-m2-coJ" firstAttribute="leading" secondItem="bKS-CN-KZi" secondAttribute="leading" constant="21" id="eFh-JA-kqH"/>
<constraint firstItem="3Am-A7-MGr" firstAttribute="top" secondItem="VBi-VJ-3w4" secondAttribute="bottom" constant="5" id="eKS-9Z-J2D"/>
<constraint firstItem="3Am-A7-MGr" firstAttribute="bottom" secondItem="dDB-re-qJn" secondAttribute="bottom" id="fMM-MI-13D"/>
<constraint firstItem="03S-CM-lPV" firstAttribute="width" secondItem="5hq-Rl-ues" secondAttribute="width" id="g5s-ug-Y6t"/>
Expand All @@ -2459,7 +2452,6 @@
<constraint firstAttribute="bottom" secondItem="RsL-5g-N88" secondAttribute="bottom" constant="61" id="jX5-qu-b9A"/>
<constraint firstItem="RsL-5g-N88" firstAttribute="top" secondItem="5hq-Rl-ues" secondAttribute="bottom" constant="8" id="pHo-Rk-OrR"/>
<constraint firstItem="v8I-Mx-BrF" firstAttribute="leading" secondItem="RsL-5g-N88" secondAttribute="trailing" constant="8" id="pVT-22-VSY"/>
<constraint firstItem="UEk-m2-coJ" firstAttribute="leading" secondItem="LpN-jq-LDz" secondAttribute="leading" id="qZR-EJ-bE7"/>
<constraint firstAttribute="trailing" secondItem="wba-mI-3Kz" secondAttribute="trailing" constant="18" id="rwL-U7-x5t"/>
<constraint firstItem="RsL-5g-N88" firstAttribute="leading" secondItem="dDB-re-qJn" secondAttribute="leading" id="vlB-ox-Uku"/>
<constraint firstItem="5hq-Rl-ues" firstAttribute="top" secondItem="03S-CM-lPV" secondAttribute="top" id="xkQ-C1-VJt"/>
Expand Down Expand Up @@ -2513,6 +2505,7 @@
<outlet property="fileProviderStackView" destination="woU-j8-E1d" id="WSS-Il-gtT"/>
<outlet property="iconView" destination="tCz-dw-VgH" id="cab-NC-Mg0"/>
<outlet property="identifierLabel" destination="psY-WF-7Yd" id="SN9-yB-GEa"/>
<outlet property="infoMessageLabel" destination="14r-fe-OXJ" id="M0E-KD-nAB"/>
<outlet property="listenEventHelpButton" destination="mFT-P4-Kyb" id="sXD-gm-erZ"/>
<outlet property="listenEventPopUp" destination="ouS-wx-aBC" id="07d-IY-dbD"/>
<outlet property="listenEventPopUpAC" destination="tlm-Wb-zyk" id="Opg-Q4-2lj"/>
Expand All @@ -2535,7 +2528,6 @@
<outlet property="postEventsPopUp" destination="EAK-oq-60p" id="to6-VI-Rt6"/>
<outlet property="postEventsPopUpAC" destination="FRk-mZ-ZAe" id="IDR-k5-oMf"/>
<outlet property="postEventsStackView" destination="M89-Vw-gT3" id="x8d-QU-b7b"/>
<outlet property="recordButton" destination="UEk-m2-coJ" id="VgX-Ge-uDk"/>
<outlet property="remindersHelpButton" destination="A1b-sQ-vR9" id="Kr1-JR-ZA6"/>
<outlet property="remindersPopUp" destination="6su-LE-zAT" id="rDG-Qq-Js1"/>
<outlet property="remindersPopUpAC" destination="77T-l2-xeW" id="pC4-LE-8ry"/>
Expand All @@ -2544,6 +2536,7 @@
<outlet property="removableVolumesPopUpAC" destination="sRi-eg-n1o" id="tk4-Eo-Caa"/>
<outlet property="removableVolumesStackView" destination="vzO-oY-aP0" id="Eg0-fA-AzS"/>
<outlet property="removeAppleEventButton" destination="v8I-Mx-BrF" id="Cp6-PC-kJg"/>
<outlet property="removeExecutableButton" destination="SFg-90-Vi7" id="H5X-h0-Xce"/>
<outlet property="saveButton" destination="Gwb-6x-mB1" id="1QM-S1-nRS"/>
<outlet property="screenCaptureHelpButton" destination="36m-yh-kC6" id="bw3-3e-Lld"/>
<outlet property="screenCapturePopUp" destination="mSS-FZ-Sk0" id="VfM-we-bww"/>
Expand Down Expand Up @@ -2587,7 +2580,7 @@
</connections>
</arrayController>
</objects>
<point key="canvasLocation" x="907" y="386.5"/>
<point key="canvasLocation" x="907" y="386"/>
</scene>
<!--Open View Controller-->
<scene sceneID="Ekk-cD-NPJ">
Expand Down
7 changes: 7 additions & 0 deletions Source/Model/Executable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,11 @@ class Policy: NSObject {
@objc dynamic var SystemPolicyNetworkVolumes: String = "-"
@objc dynamic var SystemPolicyRemovableVolumes: String = "-"
// swiftlint:enable identifier_name

func allPolicyValues() -> [String] {
let mirror = Mirror(reflecting: self)
return mirror.children.compactMap { _, value in
return value as? String
}
}
}
12 changes: 10 additions & 2 deletions Source/Model/Model.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@

import Cocoa

class Model: NSObject {
@objc class Model: NSObject {

var usingLegacyAllowKey = false
@objc dynamic var current: Executable?

@objc dynamic var current: Executable?
@objc dynamic static let shared = Model()
@objc dynamic var identities: [SigningIdentity] = []
@objc dynamic var selectedExecutables: [Executable] = []
Expand Down Expand Up @@ -90,6 +90,14 @@ typealias LoadExecutableCompletion = ((LoadExecutableResult) -> Void)

extension Model {

func requiresAuthorizationKey() -> Bool {
return selectedExecutables.contains { exe -> Bool in
return exe.policy.allPolicyValues().contains { value -> Bool in
return value == TCCProfileDisplayValue.allowStandardUsersToApprove.rawValue
}
}
}

// TODO - refactor this method so it isn't so complex
// swiftlint:disable:next cyclomatic_complexity
func loadExecutable(url: URL, completion: @escaping LoadExecutableCompletion) {
Expand Down
41 changes: 24 additions & 17 deletions Source/View Controllers/TCCProfileViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class TCCProfileViewController: NSViewController {
@IBOutlet weak var iconView: NSImageView!
@IBOutlet weak var identifierLabel: NSTextField!
@IBOutlet weak var codeRequirementLabel: NSTextField!
@IBOutlet weak var infoMessageLabel: NSTextField!

@IBOutlet weak var addressBookPopUp: NSPopUpButton!
@IBOutlet weak var photosPopUp: NSPopUpButton!
Expand Down Expand Up @@ -128,28 +129,14 @@ class TCCProfileViewController: NSViewController {
@IBOutlet weak var uploadButton: NSButton!
@IBOutlet weak var addAppleEventButton: NSButton!
@IBOutlet weak var removeAppleEventButton: NSButton!

@IBOutlet weak var recordButton: NSButton!

@IBAction func recordPressed(_ sender: NSButton) {
canEdit = !canEdit
if canEdit {
recordButton.title = "Record"
} else {
recordButton.title = "Stop"
}
}
@IBOutlet weak var removeExecutableButton: NSButton!

@IBAction func addToProfile(_ sender: NSButton) {
promptForExecutables {
self.model.selectedExecutables.append($0)
}
}

// Binding currently deletes at index
@IBAction func removeButtonPressed(_ sender: NSButton) {
}

@IBAction func addToExecutable(_ sender: NSButton) {
promptForExecutables {
self.insertIntoAppleEvents($0)
Expand Down Expand Up @@ -219,6 +206,18 @@ class TCCProfileViewController: NSViewController {
.urlReadingContentsConformToTypes: [ kUTTypeBundle, kUTTypeExecutable ]
]

@IBAction func checkForAuthorizationFeaturesUsed(_ sender: NSPopUpButton) {
if model.requiresAuthorizationKey() {
let message = """
Warning: The option '\(TCCProfileDisplayValue.allowStandardUsersToApprove.rawValue)' is only available on macOS 11.0 and higher.
Deploying this profile to devices running less than 11.0 will be treated as 'Deny'
"""
infoMessageLabel.stringValue = message
} else {
infoMessageLabel.stringValue = ""
}
}

override func viewDidLoad() {
super.viewDidLoad()

Expand All @@ -242,6 +241,7 @@ class TCCProfileViewController: NSViewController {

setupStandardUserAllowAndDeny(policies: [screenCapturePopUpAC,
listenEventPopUpAC])
setupActionForStandardUserAllowedDropDowns(dropDowns: [listenEventPopUp, screenCapturePopUp])

setupDenyOnly(policies: [cameraPopUpAC,
microphonePopUpAC])
Expand All @@ -264,14 +264,21 @@ class TCCProfileViewController: NSViewController {
executablesTable.dataSource = self
appleEventsTable.registerForDraggedTypes([.fileURL])
appleEventsTable.dataSource = self

// Record button
}

@IBAction func showHelpMessage(_ sender: InfoButton) {
sender.showHelpMessage()
}

/// Setup actions to display a warning when certain values are selected
/// that are not supported on all macOS versions
/// - Parameter dropDowns: NSPopupButtons to add the action to
private func setupActionForStandardUserAllowedDropDowns(dropDowns: [NSPopUpButton]) {
dropDowns.forEach { popup in
popup.action = #selector(self.checkForAuthorizationFeaturesUsed(_:))
}
}

private func setupStandardUserAllowAndDeny(policies: [NSArrayController]) {
for policy in policies {
policy.add(contentsOf: ["-",
Expand Down