forked from hardstriker/mSCP_EAs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mSCP-FailedResultsList.xml
52 lines (44 loc) · 1.54 KB
/
mSCP-FailedResultsList.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?xml version="1.0" encoding="UTF-8"?>
<extensionAttribute>
<displayName>mSCP - Failed Result List</displayName>
<displayInCategory>Operating System</displayInCategory>
<dataType>string</dataType>
<description>Displays a list of compliance controls that failed.</description>
<scriptContentsMac>#!/bin/sh
######
# mSCP-FailedItems.sh
# Original by Matt Woodruff @ Jamf
# Last modified 2022.10.04 by Jordan Burnette
# https://github.com/jordanburnette/mSCP_EAs
###### Description
# Displays a list of compliance controls that failed.
######
audit=$(ls -l /Library/Preferences | /usr/bin/grep 'org.*.audit.plist' | /usr/bin/awk '{print $NF}')
FAILED_RULES=()
if [[ ! -z "$audit" ]]; then
count=$(echo "$audit" | wc -l | xargs)
if [[ "$count" == 1 ]]; then
auditfile="/Library/Preferences/${audit}"
rules=($(/usr/libexec/PlistBuddy -c "print :" "${auditfile}" | awk '/Dict/ { print $1 }'))
for rule in ${rules[*]}; do
if [[ $rule == "Dict" ]]; then
continue
fi
FINDING=$(/usr/libexec/PlistBuddy -c "print :$rule:finding" "${auditfile}")
if [[ "$FINDING" == "true" ]]; then
FAILED_RULES+=($rule)
fi
done
else
FAILED_RULES="Multiple Baselines Found"
fi
else
FAILED_RULES="No Baseline Found"
fi
# sort the results
IFS=$'\n' sorted=($(sort <<<"${FAILED_RULES[*]}")); unset IFS
printf "<result>"
printf "%s\n" "${sorted[@]}"
printf "</result>"
</scriptContentsMac>
</extensionAttribute>