MCPcopy
hub / github.com/jipegit/OSXAuditor / UniversalReadPlist

Function UniversalReadPlist

osxauditor.py:357–392  ·  view source on GitHub ↗

Try to read a plist depending of the plateform and the available libs. Good luck Jim...

(PlistPath)

Source from the content-addressed store, hash-verified

355 return False
356
357def UniversalReadPlist(PlistPath):
358 ''' Try to read a plist depending of the plateform and the available libs. Good luck Jim... '''
359
360 plistDictionary = False
361
362 if FOUNDATION_IS_IMPORTED:
363 plistNSData, errorMessage = Foundation.NSData.dataWithContentsOfFile_options_error_(PlistPath, Foundation.NSUncachedRead, None)
364 if errorMessage is not None or plistNSData is None:
365 PrintAndLog(u'Unable to read in the data from the plist file: ' + PlistPath.decode('utf-8'), 'ERROR')
366 plistDictionary, plistFormat, errorMessage = Foundation.NSPropertyListSerialization.propertyListFromData_mutabilityOption_format_errorDescription_(plistNSData, Foundation.NSPropertyListMutableContainers, None, None)
367 if errorMessage is not None or plistDictionary is None:
368 PrintAndLog(u'Unable to read in the data from the plist file: ' + PlistPath.decode('utf-8'), 'ERROR')
369 if not hasattr(plistDictionary, 'has_key'):
370 PrintAndLog(u'The plist does not have a dictionary as its root as expected: ' + PlistPath.decode('utf-8'), 'ERROR')
371 return plistDictionary
372 else:
373 if BIPLIST_IS_IMPORTED:
374 try:
375 plistDictionary = biplist.readPlist(PlistPath)
376 except (IOError):
377 PrintAndLog (u'Cannot open ' + PlistPath.decode('utf-8') , 'ERROR')
378 except:
379 PrintAndLog(u'Cannot parse ' + PlistPath.decode('utf-8') + u' (Binary or JSON plist may FAIL) \n', 'ERROR')
380 return plistDictionary
381
382 elif PLISTLIB_IS_IMPORTED:
383 try:
384 plistDictionary = plistlib.readPlist(PlistPath)
385 except (IOError):
386 PrintAndLog (u'Cannot open ' + PlistPath.decode('utf-8') , 'ERROR')
387 except:
388 PrintAndLog(u'Cannot parse ' + PlistPath.decode('utf-8') + u' (Binary or JSON plist may FAIL) \n', 'ERROR')
389 return plistDictionary
390 else:
391 PrintAndLog(u'Cannot parse ' + PlistPath.decode('utf-8') + u'. No plist lib available.\n', 'ERROR')
392 return None
393
394def ParseQuarantines():
395 ''' Parse users\' quarantines '''

Callers 11

ParseStartupItemsFunction · 0.85
ParseLaunchAgentsFunction · 0.85
ParseStartupFunction · 0.85
ParseSafariProfileFunction · 0.85
ParsePackagesDirFunction · 0.85
ParseAirportPrefsFunction · 0.85
ParseMailAppAccountFunction · 0.85
ParseUsersRecentItemsFunction · 0.85
ParseSysUsersFunction · 0.85
ParseSysAdminsGroupFunction · 0.85
GetAuditedSystemVersionFunction · 0.85

Calls 1

PrintAndLogFunction · 0.85

Tested by

no test coverage detected