Skip to content

Commit 03420f1

Browse files
Merge pull request #138 from root3nl/development
Development
2 parents c780c47 + 5242915 commit 03420f1

39 files changed

Lines changed: 1372 additions & 294 deletions
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#!/bin/bash
2+
3+
# Support App Extension - macOS Security Compliance Project Failed Results Count
4+
#
5+
#
6+
# Copyright 2023 Root3 B.V. All rights reserved.
7+
# This script is based on a script copyrighted by Jamf Software, LLC (2022).
8+
# Original project: https://github.com/usnistgov/macos_security
9+
#
10+
# Support App Extension to show the number of issues from a macOS Security
11+
# Compliance Project Baseline. Result is published to Extension A and triggers
12+
# a warning in the menu bar icon and extension when there are 1 or more issues.
13+
#
14+
# REQUIREMENTS:
15+
# - An active mSCP baseline
16+
# - SupportHelper
17+
#
18+
# EXAMPLE:
19+
# Here's an example how to configure the Support App preferences for Extension A
20+
# - ExtensionTitleA: Compliance
21+
# - ExtensionSymbolA: lock.fill
22+
# - ExtensionTypeA: DistributedNotification
23+
# - ExtensionLinkA: /usr/local/bin/compliance_status.sh
24+
# - OnAppearAction: /usr/local/bin/compliance_status.sh
25+
#
26+
# THE SOFTWARE IS PROVIDED BY ROOT3 B.V. "AS IS", WITHOUT WARRANTY OF ANY KIND,
27+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
29+
# EVENT SHALL ROOT3 B.V. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
30+
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
31+
# IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32+
33+
# --------------------- do not edit below this line ----------------------
34+
35+
audit=$(ls -l /Library/Preferences | /usr/bin/grep 'org.*.audit.plist' | /usr/bin/awk '{print $NF}')
36+
EXEMPT_RULES=()
37+
FAILED_RULES=()
38+
39+
if [[ ! -z "$audit" ]]; then
40+
41+
count=$(echo "$audit" | /usr/bin/wc -l | /usr/bin/xargs)
42+
if [[ "$count" == 1 ]]; then
43+
44+
# Get the Exemptions
45+
exemptfile="/Library/Managed Preferences/${audit}"
46+
if [[ ! -e "$exemptfile" ]];then
47+
exemptfile="/Library/Preferences/${audit}"
48+
fi
49+
50+
rules=($(/usr/libexec/PlistBuddy -c "print :" "${exemptfile}" | /usr/bin/awk '/Dict/ { print $1 }'))
51+
52+
for rule in ${rules[*]}; do
53+
if [[ $rule == "Dict" ]]; then
54+
continue
55+
fi
56+
EXEMPTIONS=$(/usr/libexec/PlistBuddy -c "print :$rule:exempt" "${exemptfile}" 2>/dev/null)
57+
if [[ "$EXEMPTIONS" == "true" ]]; then
58+
EXEMPT_RULES+=($rule)
59+
fi
60+
done
61+
62+
unset $rules
63+
64+
# Get the Findings
65+
auditfile="/Library/Preferences/${audit}"
66+
rules=($(/usr/libexec/PlistBuddy -c "print :" "${auditfile}" | /usr/bin/awk '/Dict/ { print $1 }'))
67+
68+
for rule in ${rules[*]}; do
69+
if [[ $rule == "Dict" ]]; then
70+
continue
71+
fi
72+
FINDING=$(/usr/libexec/PlistBuddy -c "print :$rule:finding" "${auditfile}")
73+
if [[ "$FINDING" == "true" ]]; then
74+
FAILED_RULES+=($rule)
75+
fi
76+
done
77+
# count items only in Findings
78+
count=0
79+
for finding in ${FAILED_RULES[@]}; do
80+
if [[ ! " ${EXEMPT_RULES[*]} " =~ " ${finding} " ]] ;then
81+
((count=count+1))
82+
fi
83+
done
84+
else
85+
count="-2"
86+
fi
87+
else
88+
count="-1"
89+
fi
90+
91+
#### Support App integration ####
92+
93+
# Start spinning indicator
94+
defaults write /Library/Preferences/nl.root3.support.plist ExtensionLoadingA -bool true
95+
96+
# Show placeholder value while loading
97+
defaults write /Library/Preferences/nl.root3.support.plist ExtensionValueA -string "KeyPlaceholder"
98+
99+
# Keep loading effect active for 0.5 seconds
100+
sleep 0.5
101+
102+
# Set compliance status. If there are 1 or more issues, show the issue count and trigger warning in menu bar icon and info item
103+
if [[ ${count} -gt 0 ]]; then
104+
defaults write "/Library/Preferences/nl.root3.support.plist" ExtensionValueA "Your \$LocalModelShortName has ${count} issues"
105+
defaults write "/Library/Preferences/nl.root3.support.plist" ExtensionAlertA -bool true
106+
else
107+
defaults write "/Library/Preferences/nl.root3.support.plist" ExtensionValueA "Your \$LocalModelShortName is secure"
108+
defaults write "/Library/Preferences/nl.root3.support.plist" ExtensionAlertA -bool false
109+
fi
110+
111+
# Stop loading effect
112+
defaults write "/Library/Preferences/nl.root3.support.plist" ExtensionLoadingA -bool false

Extension Sample Scripts/sap_privileges_change_permissions.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ else
4646
fi
4747

4848
# Run Support App Extension to report new permission status
49-
"/usr/local/bin/sap_privileges_status.zsh"
49+
"/usr/local/bin/user_permissions.zsh"

Jamf Pro Custom Schema/Jamf Pro Custom Schema.json

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,20 @@
120120
}
121121
]
122122
},
123+
"UpdateText": {
124+
"title": "Update Text",
125+
"description": "Optional text to shown in the macOS Managed Updates popover to tell users about the updates",
126+
"type": "string",
127+
"options": {
128+
"infoText": "Key name: UpdateText"
129+
},
130+
"links": [
131+
{
132+
"rel": "Documentation",
133+
"href": "https://github.com/root3nl/SupportApp"
134+
}
135+
]
136+
},
123137
"CustomColor": {
124138
"title": "Custom Color",
125139
"description": "HEX color in RGB format. Example: #8cc63f. Leave empty to use macOS Accent Color",
@@ -148,13 +162,58 @@
148162
}
149163
]
150164
},
151-
"HideFirstRow": {
152-
"title": "Hide the first row",
165+
"HideFirstRowInfoItems": {
166+
"title": "Hide first row Info Items",
167+
"description": "Hide the first row with Info Items",
168+
"type": "boolean",
169+
"options": {
170+
"enum_titles": ["Hide", "Show"],
171+
"infoText": "Key name: HideFirstRowInfoItems"
172+
},
173+
"links": [
174+
{
175+
"rel": "Documentation",
176+
"href": "https://github.com/root3nl/SupportApp"
177+
}
178+
]
179+
},
180+
"HideSecondRowInfoItems": {
181+
"title": "Hide second row Info Items",
182+
"description": "Hide the second row with Info Items",
183+
"type": "boolean",
184+
"options": {
185+
"enum_titles": ["Hide", "Show"],
186+
"infoText": "Key name: HideSecondRowInfoItems"
187+
},
188+
"links": [
189+
{
190+
"rel": "Documentation",
191+
"href": "https://github.com/root3nl/SupportApp"
192+
}
193+
]
194+
},
195+
"HideThirdRowInfoItems": {
196+
"title": "Hide third row Info Items",
197+
"description": "Hide the third row with Info Items",
198+
"type": "boolean",
199+
"options": {
200+
"enum_titles": ["Hide", "Show"],
201+
"infoText": "Key name: HideThirdRowInfoItems"
202+
},
203+
"links": [
204+
{
205+
"rel": "Documentation",
206+
"href": "https://github.com/root3nl/SupportApp"
207+
}
208+
]
209+
},
210+
"HideFirstRowButtons": {
211+
"title": "Hide first row configurable buttons",
153212
"description": "Hide the first row with configurable items",
154213
"type": "boolean",
155214
"options": {
156215
"enum_titles": ["Hide", "Show"],
157-
"infoText": "Key name: HideFirstRow"
216+
"infoText": "Key name: HideFirstRowButtons"
158217
},
159218
"links": [
160219
{
@@ -163,13 +222,13 @@
163222
}
164223
]
165224
},
166-
"HideSecondRow": {
167-
"title": "Hide the second row",
225+
"HideSecondRowButtons": {
226+
"title": "Hide second row configurable buttons",
168227
"description": "Hide the second row with configurable items",
169228
"type": "boolean",
170229
"options": {
171230
"enum_titles": ["Hide", "Show"],
172-
"infoText": "Key name: HideSecondRow"
231+
"infoText": "Key name: HideSecondRowButtons"
173232
},
174233
"links": [
175234
{
@@ -957,7 +1016,7 @@
9571016
"description": "Path to script script or command to be executed when the Support App is opened by clicking on the menu bar item. The SupportHelper is required for this feature.",
9581017
"type": "string",
9591018
"options": {
960-
"infoText": "Key name: OnAppearScript"
1019+
"infoText": "Key name: OnAppearAction"
9611020
},
9621021
"links": [
9631022
{

0 commit comments

Comments
 (0)