Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions cve_bin_tool/checkers/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ def get_version_map():

return version_map

mapdb = VersionSignatureDb("sqlite", get_version_map, 30)
VERSION_MAP = None


def _load_version_map():
global VERSION_MAP
if VERSION_MAP is None:
with mapdb:
VERSION_MAP = mapdb.get_mapping_data()
return VERSION_MAP


class SqliteChecker(Checker):
CONTAINS_PATTERNS = [
Expand All @@ -61,16 +72,13 @@ class SqliteChecker(Checker):
]
FILENAME_PATTERNS = [r"sqlite", r"sqlite3"]

mapdb = VersionSignatureDb("sqlite", get_version_map, 30)
with mapdb:
VERSION_MAP = mapdb.get_mapping_data()

def guess_contains(self, lines):
"""Tries to determine if a file includes sqlite"""
# since the version strings are super unique here, we can guess the version
# at the same time

for mapping in self.VERSION_MAP:

for mapping in _load_version_map():
# Truncate last four characters as "If the source code has been edited
# in any way since it was last checked in, then the last four
# hexadecimal digits of the hash may be modified."
Expand All @@ -90,7 +98,7 @@ def get_versions(self, lines, filename):

version_info = super().get_versions(lines, filename)

for mapping in self.VERSION_MAP:
for mapping in _load_version_map():
# Truncate last four characters as "If the source code has been edited
# in any way since it was last checked in, then the last four
# hexadecimal digits of the hash may be modified."
Expand Down
Loading