Skip to content

Commit b5aaead

Browse files
committed
Modify to remove dup. oss
1 parent 07a4fba commit b5aaead

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/fosslight_binary/_binary.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __init__(self, value):
2929
self.binary_name_without_path = ""
3030
self.bin_name_with_path = value
3131
self.found_in_owasp = False
32-
self.is_binary = True
32+
self.found_in_bin_db = False
3333

3434
def __del__(self):
3535
pass

src/fosslight_binary/_binary_dao.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,30 @@ def get_oss_info_from_db(bin_info_list, dburl=""):
4545
oss_from_db = OssItem(row['ossname'], row['ossversion'], row['license'])
4646
bin_oss_items.append(oss_from_db)
4747

48+
if bin_oss_items:
49+
remove_same_item(bin_oss_items)
50+
4851
if bin_oss_items:
4952
item.set_oss_items(bin_oss_items)
5053
item.comment = "Binary DB result"
54+
item.found_in_binary = True
5155

5256
disconnect_lge_bin_db()
5357
return bin_info_list, _cnt_auto_identified
5458

5559

60+
def remove_same_item(db_oss_items: list):
61+
key_set = set()
62+
unique_oss_list = []
63+
64+
for item in db_oss_items:
65+
key = (item.name, item.version)
66+
if key not in key_set:
67+
key_set.add(key)
68+
unique_oss_list.append(item)
69+
db_oss_items[:] = unique_oss_list
70+
71+
5672
def get_connection_string(dburl):
5773
# dburl format : 'postgresql://username:password@host:port/database_name'
5874
connection_string = ""

0 commit comments

Comments
 (0)