INNER CODE UNIT · Python

sortresults

idnahacks/GoodHound · goodhound/ghresults.py:76

def sortresults(args, results):
    """Sorts the results depending on the argument selected. By default this is by Risk Score.
    Also takes the number of results selected in the arguments. Default is 5."""
    if args.sort == 'users':
        top_results = (sorted(results, key=lambda i: -i[2])[0:args.results])
    elif args.sort == 'hops':
        top_results = (sorted(results, key=lambda i: i[3])[0:args.results])
    else:
        top_results = (sorted(results, key=lambda i: (-i[5], i[4], i[3]))[0:args.results])
    return top_results

def bh_query(path):
    """Generate a replayable query for each finding for Bloodhound visualisation."""
    query = """match p=(({name:'%s'})""" %path["nodeLabels"][0]
    n=1
    for r in path["relLabels"]:
        nextstring = "-[:%s]->({name:'%s'})" %(r, path["nodeLabels"][n])
        query = query + nextstring

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…