def _osquery(sql, format='json'):
 ret = {'result': True}
 cmd = 'osqueryi --json "{0}"'.format(sql)
 res = __salt__['cmd.run_all'](cmd)
 if (res['retcode'] == 0):
  ret['data'] = json.loads(res['stdout'])
 else:
  ret['result'] = False
  ret['error'] = res['stderr']
 return ret

def _osquery ( sql , format = 'json' ) : ret = { 'result' : True } cmd = 'osqueryi --json "{0}"' . format ( sql ) res = __salt__ [ 'cmd.run_all' ] ( cmd ) if ( res [ 'retcode' ] == 0 ) : ret [ 'data' ] = json . loads ( res [ 'stdout' ] ) else : ret [ 'result' ] = False ret [ 'error' ] = res [ 'stderr' ] return ret
helper function to run raw osquery queries .