示例#1
0
def get_version(lines, filename):
    """returns version information for libnss as found in a given file.
    The version info is returned as a tuple:
        [modulename, is_or_contains, version]

    VPkg: sqlite, sqlite
    """
    mapdb = VersionSignatureDb('sqlite', get_version_map, 30)
    with mapdb:
        mapping = mapdb.get_mapping_data()
    version_info = dict()
    if "sqlite" in filename or "sqlite3" in filename:
        version_info["is_or_contains"] = "is"
        version_info["version"] = guess_version(lines, mapping)

    else:
        version = guess_contains(lines, mapping)
        if version:
            version_info["is_or_contains"] = "contains"
            version_info["version"] = version

    if "is_or_contains" in version_info:
        version_info["modulename"] = "sqlite"

    return version_info
示例#2
0
class SqliteChecker(Checker):
    CONTAINS_PATTERNS = [
        r"unable to open a temporary database file for storing temporary tables",
        r"json_object() requires an even number of arguments",
        r"ESCAPE expression must be a single character",
        r"SQLite version %s",
    ]
    VENDOR_PACKAGE = [("sqlite", "sqlite")]
    VERSION_PATTERNS = [r"Id: SQLite version (\d+\.\d+\.\d+)", r"sqlite(\d+)\.debug"]
    FILENAME_PATTERNS = [r"sqlite", r"sqlite3"]
    MODULE_NAME = "sqlite"

    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 line in lines:
            for mapping in self.VERSION_MAP:
                if mapping[1] in line:
                    return True

        # If that fails, find a signature that might indicate presence of sqlite
        return super().guess_contains(lines)

    def get_version(self, lines, filename):
        """returns version information for sqlite as found in a given file.

        The most correct way to do this is to search for the sha1 sums per release.
        Fedora rpms have a simpler SQLite version string.
        If neither of those work, try to at least guess the major version
        """

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

        for line in lines:
            for mapping in self.VERSION_MAP:
                if mapping[1] in line:
                    # overwrite version with the version found by sha mapping
                    version_info["version"] = mapping[0]

        return version_info