Skip to content

Commit 7a37c7b

Browse files
committed
improve blintdb performance
Signed-off-by: Aryan Rajoria <[email protected]>
1 parent 0fb83ce commit 7a37c7b

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

blint/db.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@
1111

1212
import concurrent
1313

14-
def get_bnames_ename(symbols_name):
15-
"""
16-
Older algorithm with many false positives
17-
"""
18-
bin_name = []
19-
eid = get_export_id(symbols_name)
20-
bid_list = get_bid_using_fid(eid)
21-
if bid_list:
22-
bin_name.extend(get_bname(bid) for bid in bid_list)
23-
return bin_name
14+
# def get_bnames_ename(symbols_name):
15+
# """
16+
# Older algorithm with many false positives
17+
# """
18+
# bin_name = []
19+
# eid = get_export_id(symbols_name)
20+
# bid_list = get_bid_using_fid(eid)
21+
# if bid_list:
22+
# bin_name.extend(get_bname(bid) for bid in bid_list)
23+
# return bin_name
2424

2525
def return_binaries_detected(eid):
2626
"""
27-
New scoring algorithm
27+
Current scoring algorithm
2828
"""
2929
binaries_detected_dict = {}
3030
bid_list = get_bid_using_fid(eid)
@@ -64,6 +64,14 @@ def detect_binaries_utilized(sybmols_list) -> set:
6464

6565
return binary_detected
6666

67+
def get_bid_using_ename(export_name):
68+
BLINTDB_LOC = os.getenv("BLINTDB_LOC")
69+
with closing(sqlite3.connect(BLINTDB_LOC)) as connection:
70+
with closing(connection.cursor()) as c:
71+
c.execute("SELECT bid from BinariesExports where eid = (SELECT rowid from Exports where infunc=?)", (export_name,))
72+
res = c.fetchall()
73+
connection.commit()
74+
return map(lambda x: x[0], res) if res else None
6775

6876
def get_export_id(export_name):
6977
BLINTDB_LOC = os.getenv("BLINTDB_LOC")

blint/sbom.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,9 @@ def process_exe_file(
456456
if os.environ.get("USE_BLINTDB", "") in ["1", "true"]:
457457
# utilize voting logic along with blitndb
458458
# we iterate through each symbol and try to find a match in the database
459-
dynamic_symbols_list = metadata.get("dynamic_symbols", [])
459+
print("Utilizing blint_db")
460+
# TODO: utilize both symtab_symbols and dynamic_symbols
461+
dynamic_symbols_list = metadata.get("symtab_symbols", [])
460462
binaries_detected = detect_binaries_utilized(dynamic_symbols_list)
461463
# adds the components in a similar way to dynamic entries
462464
for binary in binaries_detected:

0 commit comments

Comments
 (0)