Skip to main content
Solved

Xprotect Status Extension Attribute

  • March 8, 2016
  • 34 replies
  • 153 views

Show first post

34 replies

Forum|alt.badge.img+22
  • Honored Contributor
  • March 11, 2016

@scottb Thanks so much for sharing the code and @mm2270 thank you for taking the time to teach me that, I got it working now!


scottb
Forum|alt.badge.img+18
  • Valued Contributor
  • March 11, 2016

@TomDay - I posted that above but maybe I should have used bold on it.
Glad you guys are finding it useful. We use it in testing seed builds of the OS so I guess I forgot how cool it was when I started using it as well. Maybe a good item to put into Self Service for checking on Macs in the "Maintenance" tab. Not that anyone would know what to do with the info, but it looks nice. :)


Forum|alt.badge.img+17
  • Valued Contributor
  • March 15, 2016

Thanks scottb! Appreciate the share.

Forgive my ignorance, but anybody have any info on "Core Suggest"? I'm not familiar with it and didn't find much with a quick search.


scottb
Forum|alt.badge.img+18
  • Valued Contributor
  • March 16, 2016

@mbezzo - here's the contents of it. Still not really sure, but you can get some ideas looking at this:


Forum|alt.badge.img+17
  • Valued Contributor
  • March 16, 2016

@scottb Interesting - thanks!


scottb
Forum|alt.badge.img+18
  • Valued Contributor
  • May 27, 2016

Here's an updated rev that is a little nicer. A mix of contributions by a few people.
Gives you the below in the screenshot.

--start of script 

########################################## 
# Variables 
########################################## 
set updateMarker to " *"

set saveLocation to "~/Library/Preferences/com.appleseedCriticalUpdates.txt"

set lastUpdate to {}

set thisDate to {}

set hasBeenUpdated to ""

set TimeStrings to {"/System/Library/CoreServices/XProtect.bundle/Contents/Resources/XProtect.meta.plist", "/private/var/db/gkopaque.bundle/Contents/version.plist", "/System/Library/Sandbox/Compatibility.bundle/Contents/version.plist", "/System/Library/CoreServices/MRT.app/Contents/version.plist", "'/System/Library/Intelligent Suggestions/Assets.suggestionsassets/Contents/version.plist'", "/System/Library/Extensions/AppleKextExcludeList.kext/Contents/version.plist", "/usr/share/mecabra/updates/com.apple.inputmethod.SCIM.bundle/Contents/version.plist", "/usr/share/kdrl.bundle/info.plist"}

set VersionStrings to {"/System/Library/CoreServices/XProtect.bundle/Contents/Resources/XProtect.meta.plist Version", "/private/var/db/gkopaque.bundle/Contents/version.plist CFBundleShortVersionString", "/System/Library/Sandbox/Compatibility.bundle/Contents/version.plist CFBundleShortVersionString", "/System/Library/CoreServices/MRT.app/Contents/version CFBundleShortVersionString", "/System/Library/Intelligent\\ Suggestions/Assets.suggestionsassets/Contents/version.plist CFBundleShortVersionString", "/System/Library/Extensions/AppleKextExcludeList.kext/Contents/version CFBundleShortVersionString", "/usr/share/mecabra/updates/com.apple.inputmethod.SCIM.bundle/Contents/info SUVersionString", "/usr/share/kdrl.bundle/info CFBundleVersion"}

set theComponents to {"XProtect", "Gatekeeper", "System Integrity Protect...", "Malware Removal Tool", "Core Suggestions", "Incompatible Kernel Ext...", "Chinese Word List", "Core LSKD (dkrl)"}
set theTabSpaces to ""

set _multiTabs to tab & tab & tab & tab
set displayString to "Component" & _multiTabs & "Version" & tab & "Updated" & tab & tab & "Time" & return & "_______________________________________________________________" & return & return


########################################## 
# Handlers 
########################################## 


# calculate the number of tabs required for the display dialog 
on getTabs(aWord)
    set n to round (25 - (length of aWord)) / 4
    if n is less than 0 then set n to 1
    if length of aWord is 10 then set n to 3
    set this_tab to tab
    repeat n times
        set this_tab to this_tab & tab
    end repeat
    return this_tab
end getTabs

#get the last modification date 
on getUpdatedDate(aFile)
    set d to do shell script "stat -f "%Sc" -t "%d-%m-%Y %H:%M" " & aFile
    set end of my thisDate to d
    return d

end getUpdatedDate

#compare the dates to see if there's been a change 
on checkLastUpdate(aDateString, anIndex)
    set n to text 1 thru 10 of aDateString
    set o to text 1 thru 10 of my (item anIndex of lastUpdate)

    if (n is equal to o) then
        return ""
    else
        return my updateMarker
    end if
end checkLastUpdate


########################################## 
# Commands 
########################################## 

# read the dates into our script from the last run 
set oldTIDS to AppleScript's text item delimiters
set AppleScript's text item delimiters to ","
try
    set s to (do shell script "cat " & saveLocation)
    set lastUpdate to text items of s
end try
set AppleScript's text item delimiters to oldTIDS

# this is the workhorse, getting all the data for each component 
repeat with i from 1 to number of items in theComponents
    set component_item to item i of theComponents
    set version_item to item i of VersionStrings
    set time_item to item i of TimeStrings
    set theTabSpaces to getTabs(component_item)
    set updatedDate to getUpdatedDate(time_item)

    # check if we had some saved dates from a previous run 
    #and if so, check them against the current dates 
    if (count of (lastUpdate as list)) = (count of theComponents) then
        set my hasBeenUpdated to checkLastUpdate(updatedDate, i)
    end if

    # organise the display string 
    set v to (do shell script "defaults read " & version_item)
    if length of v < 4 or (length of v = 4 and v contains ".") then set v to v & tab
    set displayString to displayString & component_item & theTabSpaces & v & tab & updatedDate & my hasBeenUpdated & return
    set my hasBeenUpdated to ""
end repeat

#write out current dates to file 
set writeData to ""
repeat with i from 1 to number of items in thisDate
    set this_item to item i of thisDate
    if length of writeData is 0 then
        set writeData to this_item
    else
        set writeData to writeData & "," & this_item
    end if
end repeat
do shell script "echo " & writeData & "> " & saveLocation

# finally, get the OS version and build 
set theSysInfo to (do shell script "sw_vers")
set sysString to paragraph 2 of theSysInfo & return & paragraph 3 of theSysInfo
set displayString to displayString & return & sysString

# and... 
display dialog displayString buttons {"Close"} default button "Close" with title "Critical Updates (v1.1)"

--EOF


Forum|alt.badge.img+20
  • Valued Contributor
  • June 30, 2017

@scottb

Nice AppleScript! Hey have you updated this for 10.12?


scottb
Forum|alt.badge.img+18
  • Valued Contributor
  • June 30, 2017

@ClassicII - not yet. I'll see if that can be looked at and post back. Thanks for the reminder... Happy 4th!


scottb
Forum|alt.badge.img+18
  • Valued Contributor
  • June 30, 2017

Hey @ClassicII et.al, Phil has taken this over and is offering it up on his site (with other stuff). Check it out - he's a dev and a longtime fellow AppleSeeder. I pinged him about getting the script as he delivers it in .app form now. If he's cool with me posting the script here, I'll add it later. We used to pass it around and folks would edit to their needs...guess he's the gatekeeper (not intended) now.

Phil's site

Current screenie