Skip to content

Commit 961e678

Browse files
ShivangNagtasev-
authored andcommitted
INTEGRITY: Avoid detection file overriding on a match, when a similar file exist in a different directory. Add it as a normal non detection file.
1 parent 4a3626a commit 961e678

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

db_functions.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,18 +1644,23 @@ def set_populate_file(fileset, fileset_id, conn, detection):
16441644
for target_file in target_files
16451645
}
16461646

1647+
seen_detection_files = set()
1648+
16471649
for file in fileset["rom"]:
16481650
if "md5" not in file:
16491651
continue
16501652
checksize, checktype, checksum = get_checksum_props("md5", file["md5"])
16511653

16521654
filename = os.path.basename(normalised_path(file["name"]))
16531655

1654-
if filename.lower() not in candidate_files or (
1655-
filename.lower() in candidate_files
1656-
and (
1657-
candidate_files[filename.lower()][1] != -1
1658-
and candidate_files[filename.lower()][1] != file["size"]
1656+
if ((filename.lower(), file["size"]) in seen_detection_files) or (
1657+
filename.lower() not in candidate_files
1658+
or (
1659+
filename.lower() in candidate_files
1660+
and (
1661+
candidate_files[filename.lower()][1] != -1
1662+
and candidate_files[filename.lower()][1] != file["size"]
1663+
)
16591664
)
16601665
):
16611666
name = normalised_path(file["name"])
@@ -1707,6 +1712,7 @@ def set_populate_file(fileset, fileset_id, conn, detection):
17071712
checksum,
17081713
),
17091714
)
1715+
seen_detection_files.add((filename.lower(), file["size"]))
17101716

17111717

17121718
def insert_new_fileset(

0 commit comments

Comments
 (0)