Added File Extension Limits
This commit is contained in:
@@ -69,6 +69,7 @@ def split_filepaths_grouped(df, col="filename", group_parts=4, min_parts=4):
|
|||||||
row["longestcfp"] = prefix_str
|
row["longestcfp"] = prefix_str
|
||||||
row["middle"] = middle
|
row["middle"] = middle
|
||||||
row["filename_only"] = filename
|
row["filename_only"] = filename
|
||||||
|
row["file_extension"] = os.path.splitext(filename)[1]
|
||||||
new_rows.append(row)
|
new_rows.append(row)
|
||||||
|
|
||||||
return pd.DataFrame(new_rows).drop(columns=["group_key"])
|
return pd.DataFrame(new_rows).drop(columns=["group_key"])
|
||||||
@@ -175,7 +176,7 @@ def generatePathReview(first_policy, second_policy, badpathparts, min_files_for_
|
|||||||
lcp_not_forbidden = haslcp[~forbidden_lcfp].copy()
|
lcp_not_forbidden = haslcp[~forbidden_lcfp].copy()
|
||||||
|
|
||||||
#For the review, drop down to only the columns we care, and then group by the commmon file path, consolidating and dropping dupes
|
#For the review, drop down to only the columns we care, and then group by the commmon file path, consolidating and dropping dupes
|
||||||
lcp_not_forbidden_review = lcp_not_forbidden[['longestcfp', 'middle', 'filename_only', 'sha256']]
|
lcp_not_forbidden_review = lcp_not_forbidden[['longestcfp', 'middle', 'filename_only', 'file_extension', 'sha256']]
|
||||||
|
|
||||||
# Count unique sha256 per longestcfp
|
# Count unique sha256 per longestcfp
|
||||||
unique_sha_counts = lcp_not_forbidden_review.groupby('longestcfp')['sha256'].nunique().reset_index()
|
unique_sha_counts = lcp_not_forbidden_review.groupby('longestcfp')['sha256'].nunique().reset_index()
|
||||||
|
|||||||
@@ -95,19 +95,23 @@ def sendToPolicy(url, first_policy, second_policy, destination_name, destination
|
|||||||
ct.areYouSure()
|
ct.areYouSure()
|
||||||
confirmation = input(ct.colorText("Type 'I AGREE' to continue: ","white"))
|
confirmation = input(ct.colorText("Type 'I AGREE' to continue: ","white"))
|
||||||
|
|
||||||
|
|
||||||
if confirmation.strip().upper() == "I AGREE":
|
if confirmation.strip().upper() == "I AGREE":
|
||||||
print(ct.colorText("Proceeding with the code...", "yellow"))
|
print(ct.colorText("Proceeding with the code...", "yellow"))
|
||||||
print(ct.colorText(f"Adding path exclusions to {destination_name}", "yellow"))
|
print(ct.colorText(f"Adding path exclusions to {destination_name}", "yellow"))
|
||||||
pathexcludelist = pathexclusions['longestcfp'].unique().tolist()
|
|
||||||
|
# Get unique combinations of longestcfp and file_extension
|
||||||
|
unique_combinations = pathexclusions[["longestcfp", "file_extension"]].drop_duplicates()
|
||||||
|
|
||||||
# Regex to match a Windows drive letter at the start (e.g., C:\)
|
# Regex to match a Windows drive letter at the start (e.g., C:\)
|
||||||
drive_letter_pattern = re.compile(r'^[a-zA-Z]:\\')
|
drive_letter_pattern = re.compile(r'^[a-zA-Z]:\\')
|
||||||
|
|
||||||
# Processed list
|
# Build processed paths like \\path\\**.exe or C:\path\**.jar
|
||||||
processed_paths = [
|
processed_paths = [
|
||||||
(path if drive_letter_pattern.match(path) else f"\\\\{path}") + "**"
|
(path if drive_letter_pattern.match(path) else f"\\\\{path}") + f"\\**{ext}"
|
||||||
for path in pathexcludelist
|
for path, ext in unique_combinations.itertuples(index=False, name=None)
|
||||||
]
|
]
|
||||||
|
|
||||||
addPath(url, destination_id,processed_paths)
|
addPath(url, destination_id,processed_paths)
|
||||||
|
|
||||||
print(ct.colorText(f"Adding hashes to {allowlist_parent_name}", "yellow"))
|
print(ct.colorText(f"Adding hashes to {allowlist_parent_name}", "yellow"))
|
||||||
|
|||||||
Reference in New Issue
Block a user