diff --git a/cve_bin_tool/checkers/sqlite.py b/cve_bin_tool/checkers/sqlite.py index 186d5a2add..437dc0fed0 100644 --- a/cve_bin_tool/checkers/sqlite.py +++ b/cve_bin_tool/checkers/sqlite.py @@ -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 = [ @@ -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." @@ -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."