first draft of allowed filter
This commit is contained in:
@@ -4,6 +4,7 @@ import utils.getdeviceevents
|
|||||||
import utils.allowlist
|
import utils.allowlist
|
||||||
import utils.hashfunctions
|
import utils.hashfunctions
|
||||||
import utils.pathfunctions
|
import utils.pathfunctions
|
||||||
|
import utils.allowfunctions
|
||||||
import urllib3
|
import urllib3
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
@@ -84,6 +85,13 @@ def menu():
|
|||||||
categorized[1].to_html("approved.html", index=False)
|
categorized[1].to_html("approved.html", index=False)
|
||||||
categorized[2].to_html("remaining.html", index=False)
|
categorized[2].to_html("remaining.html", index=False)
|
||||||
|
|
||||||
|
allowpaths = utils.allowfunctions.filter_and_drop(categorized[1],path_eligible,2)
|
||||||
|
allowpaths.to_html("AllowedPaths.html", index=False)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,16 @@
|
|||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
def filter_and_drop(approved, eligiblepaths, min_hashes):
|
||||||
|
"""
|
||||||
|
Filters eligiblepaths to rows where all hashes are in approved,
|
||||||
|
then drops rows with fewer than min_hashes hashes.
|
||||||
|
"""
|
||||||
|
approved_hashes = set(approved['sha256'])
|
||||||
|
|
||||||
|
def all_hashes_approved(row):
|
||||||
|
return all(h in approved_hashes for h in row['sha256'])
|
||||||
|
|
||||||
|
filtered = eligiblepaths[eligiblepaths.apply(all_hashes_approved, axis=1)]
|
||||||
|
filtered = filtered[filtered['sha256'].apply(len) >= min_hashes]
|
||||||
|
|
||||||
|
return filtered
|
||||||
Reference in New Issue
Block a user