def test_short_status(
            self, mock_get_tagged_experiment_specific_revisions) -> None:
        """Check if the case study can show a short status."""

        # block a revision
        mocked_gzip_source = block_revisions([SingleRevision("7620b81735")
                                              ])(DummyGit(remote="/dev/null",
                                                          local="/dev/null"))
        self.project_source_mock.return_value = mocked_gzip_source

        # Revision not in set
        mock_get_tagged_experiment_specific_revisions.return_value = [
            (ShortCommitHash('42b25e7f15'), FileStatusExtension.SUCCESS)
        ]

        status = PCM.get_short_status(self.case_study, MockExperiment, 5)
        self.assertEqual(status,
                         'CS: gzip_1: (  0/10) processed [0/0/0/0/9/1]')
        mock_get_tagged_experiment_specific_revisions.assert_called()

        mock_get_tagged_experiment_specific_revisions.reset_mock()
        mock_get_tagged_experiment_specific_revisions.return_value = [
            (ShortCommitHash('b8b25e7f15'), FileStatusExtension.SUCCESS)
        ]

        status = PCM.get_short_status(self.case_study, MockExperiment, 5)
        self.assertEqual(status,
                         'CS: gzip_1: (  1/10) processed [1/0/0/0/8/1]')
        mock_get_tagged_experiment_specific_revisions.assert_called()
Esempio n. 2
0
class X264(VProject):
    """Video encoder x264 (fetched by Git)"""

    NAME = 'x264'
    GROUP = 'c_projects'
    DOMAIN = ProjectDomains.CODEC

    SOURCE = [
        block_revisions([
            GoodBadSubgraph(["5dc0aae2f900064d1f58579929a2285ab289a436"],
                            ["6490f4398d9e28e65d7517849e729e14eede8c5b"],
                            "Does not build on x64 out of the box")
        ])(PaperConfigSpecificGit(
            project_name="x264",
            remote="https://code.videolan.org/videolan/x264.git",
            local="x264",
            refspec="origin/HEAD",
            limit=None,
            shallow=False))
    ]

    @staticmethod
    def binaries_for_revision(
            revision: ShortCommitHash) -> tp.List[ProjectBinaryWrapper]:
        binary_map = RevisionBinaryMap(get_local_project_git_path(X264.NAME))

        binary_map.specify_binary("x264", BinaryType.EXECUTABLE)

        return binary_map[revision]

    def run_tests(self) -> None:
        pass

    def compile(self) -> None:
        """Compile the project."""
        x264_version_source = local.path(self.source_of_primary)
        x264_version = ShortCommitHash(self.version_of_primary)

        fpic_revisions = get_all_revisions_between(
            "5dc0aae2f900064d1f58579929a2285ab289a436",
            "290de9638e5364c37316010ac648a6c959f6dd26", ShortCommitHash,
            x264_version_source)
        ldflags_revisions = get_all_revisions_between(
            "6490f4398d9e28e65d7517849e729e14eede8c5b",
            "275ef5332dffec445a0c5a78dbc00c3e0766011d", ShortCommitHash,
            x264_version_source)

        if x264_version in fpic_revisions:
            self.cflags += ["-fPIC"]

        clang = bb.compiler.cc(self)
        with local.cwd(x264_version_source):
            with local.env(CC=str(clang)):
                configure_flags = ["--disable-asm"]
                if x264_version in ldflags_revisions:
                    configure_flags.append("--extra-ldflags=\"-static\"")
                bb.watch(local["./configure"])(configure_flags)
            bb.watch(make)("-j", get_number_of_jobs(bb_cfg()))

            verify_binaries(self)
Esempio n. 3
0
class Poppler(VProject):
    """Poppler is a free software utility library for rendering Portable
    Document Format documents."""

    NAME = 'poppler'
    GROUP = 'cpp_projects'
    DOMAIN = ProjectDomains.RENDERING

    SOURCE = [
        block_revisions([
            RevisionRange("e225b4b804881de02a5d1beb3f3f908a8f8ddc3d",
                          "2b2808719d2c91283ae358381391bb0b37d9061d",
                          "requiers QT6 which is not easily available")
        ])(PaperConfigSpecificGit(
            project_name="poppler",
            remote="https://gitlab.freedesktop.org/poppler/poppler.git",
            local="poppler",
            refspec="origin/HEAD",
            limit=None,
            shallow=False))
    ]

    CONTAINER = get_base_image(ImageBase.DEBIAN_10).run(
        'apt', 'install', '-y', 'cmake', 'libfreetype6-dev',
        'libfontconfig-dev', 'libjpeg-dev', 'qt5-default', 'libopenjp2-7-dev')

    @staticmethod
    def binaries_for_revision(
            revision: ShortCommitHash) -> tp.List[ProjectBinaryWrapper]:
        binary_map = RevisionBinaryMap(get_local_project_git_path(
            Poppler.NAME))

        binary_map.specify_binary("libpoppler.so", BinaryType.SHARED_LIBRARY)

        return binary_map[revision]

    def run_tests(self) -> None:
        pass

    def compile(self) -> None:
        """Compile the project."""
        poppler_version_source = local.path(self.source_of(
            self.primary_source))

        c_compiler = bb.compiler.cc(self)
        cxx_compiler = bb.compiler.cxx(self)
        with local.cwd(poppler_version_source):
            with local.env(CC=str(c_compiler), CXX=str(cxx_compiler)):
                bb.watch(cmake)("-G", "Unix Makefiles", ".")
            bb.watch(make)("-j", get_number_of_jobs(bb_cfg()))

            verify_binaries(self)

    @classmethod
    def get_cve_product_info(cls) -> tp.List[tp.Tuple[str, str]]:
        return [("Poppler", "Poppler")]
Esempio n. 4
0
class Doxygen(VProject):
    """Doxygen."""

    NAME = 'doxygen'
    GROUP = 'cpp_projects'
    DOMAIN = ProjectDomains.DOCUMENTATION

    SOURCE = [
        block_revisions([
            # TODO: se-sic/VaRA#536
            GoodBadSubgraph(["a6238a4898e20422fe6ef03fce4891c5749b1553"],
                            ["cf936efb8ae99dd297b6afb9c6a06beb81f5b0fb"],
                            "Needs flex <= 2.5.4 and >= 2.5.33"),
            GoodBadSubgraph(["093381b3fc6cc1e97f0e737feca04ebd0cfe538d"],
                            ["cf936efb8ae99dd297b6afb9c6a06beb81f5b0fb"],
                            "Needs flex <= 2.5.4 and >= 2.5.33")
        ])(PaperConfigSpecificGit(
            project_name="doxygen",
            remote="https://github.com/doxygen/doxygen.git",
            local="doxygen",
            refspec="origin/HEAD",
            limit=None,
            shallow=False))
    ]

    @staticmethod
    def binaries_for_revision(
            revision: ShortCommitHash) -> tp.List[ProjectBinaryWrapper]:
        binary_map = RevisionBinaryMap(get_local_project_git_path(
            Doxygen.NAME))

        binary_map.specify_binary('doxygen', BinaryType.EXECUTABLE)

        return binary_map[revision]

    def run_tests(self) -> None:
        pass

    def compile(self) -> None:
        """Compile the project."""
        doxygen_source = local.path(self.source_of_primary)

        clangxx = bb.compiler.cxx(self)
        with local.cwd(doxygen_source):
            with local.env(CXX=str(clangxx)):
                delete("CMakeCache.txt")
                bb.watch(cmake)("-G", "Unix Makefiles", ".")
            bb.watch(make)("-j", get_number_of_jobs(bb_cfg()))

            bb.watch(cp)("bin/doxygen", ".")

            verify_binaries(self)

    @classmethod
    def get_cve_product_info(cls) -> tp.List[tp.Tuple[str, str]]:
        return [("doxygen", "doxygen")]
Esempio n. 5
0
 def setUp(self) -> None:
     self.blocked_revision = ['e207f0cc87', '109a1e6233']
     mocked_gravity_source = block_revisions([
         SingleRevision(rev) for rev in self.blocked_revision
     ])(DummyGit(remote="/dev/null", local="/dev/null"))
     project_source_patcher = mock.patch(
         'varats.revision.revisions.get_primary_project_source'
     )
     self.addCleanup(project_source_patcher.stop)
     project_source_patcher.start().return_value = mocked_gravity_source
Esempio n. 6
0
class Brotli(VProject):
    """Brotli compression format."""

    NAME = 'brotli'
    GROUP = 'c_projects'
    DOMAIN = ProjectDomains.COMPRESSION

    SOURCE = [
        block_revisions([
            RevisionRange('8f30907d0f2ef354c2b31bdee340c2b11dda0fb0',
                          'e1739826c04a9944672b99b98249dda021bdeb36',
                          'Encoder and Decoder don\'t have a shared Makefile'),
            SingleRevision("378485b097fd7b80a5e404a3cb912f7b18f78cdb",
                           "Missing required build files")
        ])(PaperConfigSpecificGit(
            project_name="brotli",
            remote="https://github.com/google/brotli.git",
            local="brotli_git",
            refspec="origin/HEAD",
            limit=None,
            shallow=False))
    ]

    CONTAINER = get_base_image(ImageBase.DEBIAN_10).run(
        'apt', 'install', '-y', 'cmake')

    @staticmethod
    def binaries_for_revision(
            revision: ShortCommitHash) -> tp.List[ProjectBinaryWrapper]:
        binary_map = RevisionBinaryMap(get_local_project_git_path(Brotli.NAME))

        binary_map.specify_binary(
            "out/brotli",
            BinaryType.EXECUTABLE,
            only_valid_in=RevisionRange(
                "03739d2b113afe60638069c4e1604dc2ac27380d", "HEAD"))
        binary_map.specify_binary(
            "out/bro",
            BinaryType.EXECUTABLE,
            only_valid_in=RevisionRange(
                "5814438791fb2d4394b46e5682a96b68cd092803",
                "03739d2b113afe60638069c4e1604dc2ac27380d"))
        binary_map.specify_binary(
            "bin/bro",
            BinaryType.EXECUTABLE,
            only_valid_in=RevisionRange(
                "f9ab24a7aaee93d5932ba212e5e3d32e4306f748",
                "5814438791fb2d4394b46e5682a96b68cd092803"))
        binary_map.specify_binary(
            "tools/bro",
            BinaryType.EXECUTABLE,
            only_valid_in=RevisionRange(
                "e1739826c04a9944672b99b98249dda021bdeb36",
                "378485b097fd7b80a5e404a3cb912f7b18f78cdb"))
        return binary_map[revision]

    def run_tests(self) -> None:
        pass

    def compile(self) -> None:
        """Compile the project."""
        brotli_version_source = local.path(self.source_of_primary)
        brotli_git_path = get_local_project_git_path(self.NAME)
        brotli_version = ShortCommitHash(self.version_of_primary)
        with local.cwd(brotli_git_path):
            configure_revisions = get_all_revisions_between(
                "f9ab24a7aaee93d5932ba212e5e3d32e4306f748",
                "5814438791fb2d4394b46e5682a96b68cd092803", ShortCommitHash)
            simple_make_revisions = get_all_revisions_between(
                "e1739826c04a9944672b99b98249dda021bdeb36",
                "378485b097fd7b80a5e404a3cb912f7b18f78cdb", ShortCommitHash)
        c_compiler = bb.compiler.cc(self)

        if brotli_version in simple_make_revisions:
            with local.cwd(brotli_version_source / "tools"):
                bb.watch(make)("-j", get_number_of_jobs(bb_cfg()))
        elif brotli_version in configure_revisions:
            with local.cwd(brotli_version_source):
                with local.env(CC=str(c_compiler)):
                    bb.watch(local["./configure"])()
                bb.watch(make)("-j", get_number_of_jobs(bb_cfg()))
        else:
            mkdir(brotli_version_source / "out")
            with local.cwd(brotli_version_source / "out"):
                with local.env(CC=str(c_compiler)):
                    bb.watch(local["../configure-cmake"])()
                bb.watch(make)("-j", get_number_of_jobs(bb_cfg()))

        with local.cwd(brotli_version_source):
            verify_binaries(self)

    @classmethod
    def get_cve_product_info(cls) -> tp.List[tp.Tuple[str, str]]:
        return [("google", "brotli")]
Esempio n. 7
0
class Libpng(VProject):
    """
    Picture library.

    (fetched by Git)
    """

    NAME = 'libpng'
    GROUP = 'c_projects'
    DOMAIN = ProjectDomains.FILE_FORMAT

    SOURCE = [
        block_revisions([
            GoodBadSubgraph(["8694cd8bf5f7d0d2739e503218eaf749c6cb7071"],
                            ["0e13545712dc39db5689452ff3299992fc0a8377"],
                            "missing generic libpng.so"),
            GoodBadSubgraph(["9d2ab7b40505c5e94a7783e80217b60f474488fe"],
                            ["b17c75b222942a31394e65c0c1da9fd7ec9f3a4c"],
                            "missing generic libpng.so"),
            GoodBadSubgraph(["0d5805822f8817a17937462a2fd0606ffdad378e"],
                            ["917648ecb92f45537924b3c46a4a811b956c7023"],
                            "build not atomatable"),
            GoodBadSubgraph(["917648ecb92f45537924b3c46a4a811b956c7023"], [
                "9d2ab7b40505c5e94a7783e80217b60f474488fe",
                "6611322a8b29103a160c971819f1c5a031cd9d4f"
            ], "cmake not available"),
            GoodBadSubgraph(["a04b5352310727f20b38e360006feeca94b7201f"],
                            ["0e13545712dc39db5689452ff3299992fc0a8377"],
                            "Not libpng"),
            GoodBadSubgraph(["e209df47c4b821f277504e0cc248d9022b639e55"],
                            ["d61b42c81d9d6f0905039ccc66870b2a27eafdd9"],
                            "Bug in Libpng"),
            GoodBadSubgraph(["8d9e494dfb208c88a9497038977b539310c7fca5"],
                            ["bf15ac7e86f4fc95b6b33831f212c3f13f955623"],
                            "Bug in Libpng"),
            GoodBadSubgraph(["7de02e722f8f6bdb2756e20091c42fa4ffaa89c1"],
                            ["45bb9a62ba343250497c33da2b0bad78376d55b8"],
                            "Bug in Libpng"),
            SingleRevision(
                "79b7e4e621fd611df658ec24a07080708fffe1de", "Bug in Libpng"
            ),
            SingleRevision(
                "67a289ffa924a00fab96a9bd6da8c069441138fa", "Bug in Libpng"
            ),
            GoodBadSubgraph(["b76ab1260d156a390a47f81c0ea6ef0524208b8e"],
                            ["e4f124e3352d63f7162ab7c1360a2db6d54f2ff2"],
                            "Bug in Libpng"),
            GoodBadSubgraph(["5bc90389bffa3cf3d2b8325bfac5c4344a206bc0"],
                            ["c35f888c46986093582f73cafcd7185472748e4b"],
                            "Bug in Libpng"),
            GoodBadSubgraph(["5b79cd52f440a7e1ce418f87b92b526765719c54"],
                            ["c4081f05c88d171cd476d5df78ed4a690296c602"],
                            "Bug in Libpng"),
            GoodBadSubgraph(["9c946e22fcad10c2a44c0380c0909da6732097ce"],
                            ["342c4eab2a0565de456f1f3efcc41b635544160e"],
                            "Bug in Libpng"),
            GoodBadSubgraph(["40afb685704f1a5bf8d9edc0b5c7ec7f25e94b77"],
                            ["619cf868e60807d759639cfb070987ad059fa0c9"],
                            "Bug in Libpng"),
            SingleRevision(
                "7c709f039f7ff3cc92eea03af0660a171ef0673d", "Bug in Libpng"
            ),
            SingleRevision(
                "3fa1df48a1c14d3004733471ce7fbce916750911", "Bug in Libpng"
            ),
            SingleRevision(
                "a1312f7b190df545fb7ec90e23cc4a9b6328af00", "Bug in Libpng"
            ),
            SingleRevision(
                "42369ccd85a48c0802093ecf02444cc4dfc4f1dd", "Bug in Libpng"
            ),
            SingleRevision(
                "d930d36155fe79b277c11d868572769cb4ffb586", "Bug in Libpng"
            ),
            SingleRevision(
                "6e8ba0fab666eb6c90e929988e8fb3439449e7f9", "Bug in Libpng"
            ),
            SingleRevision(
                "ad41b8838a91ab36880716c2264f70ef4651b89f", "Bug in Libpng"
            ),
            GoodBadSubgraph(["d332c67da7818132e462fc44ec28b0b7420bc5b5"],
                            ["1d7f56ab64f397d5841cc277fae7aeaac44ac088"],
                            "Bug in Libpng"),
            SingleRevision(
                "db67cba8d42f5f13a96ce6080a61567f66afd915", "Bug in Libpng"
            ),
            SingleRevision(
                "c9e27d026de520a8646f8f5ee6d20a4080d258b6", "Bug in Libpng"
            ),
            SingleRevision(
                "7b9796539d8d15a61f2aa495fd23fbd5b4a90335", "Bug in Libpng"
            ),
            GoodBadSubgraph(["05a4db1fcd776931bbba0c3472ada94014c3a395"], [
                "403636577395221e63e27b69c5546ae6606f4fa2",
                "2e7c3a6e706e8d3cb54587c2bf8b3b3fdc30ae5a"
            ], "Bug in Libpng"),
            SingleRevision(
                "6cae24c265ea7a3d19a1655b0f7692ada4273290", "Bug in Libpng"
            ),
            SingleRevision(
                "04336ba10ff4da8b69292f6c936c4c0d7bbe67c7", "Bug in Libpng"
            )
        ])(
            PaperConfigSpecificGit(
                project_name="libpng",
                remote="https://github.com/glennrp/libpng.git",
                local="libpng",
                refspec="origin/HEAD",
                limit=None,
                shallow=False
            )
        )
    ]

    CONTAINER = get_base_image(ImageBase.DEBIAN_10
                              ).run('apt', 'install', '-y', 'cmake')

    @staticmethod
    def binaries_for_revision(
        revision: ShortCommitHash
    ) -> tp.List[ProjectBinaryWrapper]:
        binary_map = RevisionBinaryMap(get_local_project_git_path(Libpng.NAME))

        binary_map.specify_binary('build/libpng.so', BinaryType.SHARED_LIBRARY)

        return binary_map[revision]

    def run_tests(self) -> None:
        pass

    def compile(self) -> None:
        """Compile the project."""
        libpng_source = local.path(self.source_of(self.primary_source))

        compiler = bb.compiler.cc(self)
        mkdir(libpng_source / "build")
        with local.cwd(libpng_source / "build"):
            with local.env(CC=str(compiler)):
                bb.watch(cmake)("-G", "Unix Makefiles", "..")

            bb.watch(make)("-j", get_number_of_jobs(bb_cfg()))
        with local.cwd(libpng_source):
            verify_binaries(self)

    @classmethod
    def get_cve_product_info(cls) -> tp.List[tp.Tuple[str, str]]:
        return [("Libpng", "Libpng")]
Esempio n. 8
0
class Gzip(VProject, ReleaseProviderHook):
    """Compression and decompression tool Gzip (fetched by Git)"""

    NAME = 'gzip'
    GROUP = 'c_projects'
    DOMAIN = ProjectDomains.COMPRESSION

    SOURCE = [
        block_revisions([
            # TODO (se-sic/VaRA#537): glibc < 2.28
            # see e.g. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=915151
            RevisionRange("6ef28aeb035af20818578b1a1bc537f797c27029",
                          "203e40cc4558a80998d05eb74b373a51e796ca8b",
                          "Needs glibc < 2.28")
        ])(PaperConfigSpecificGit(project_name="gzip",
                                  remote="https://github.com/vulder/gzip.git",
                                  local="gzip",
                                  refspec="origin/HEAD",
                                  limit=None,
                                  shallow=False)),
        bb.source.GitSubmodule(
            remote="https://github.com/coreutils/gnulib.git",
            local="gzip/gnulib",
            refspec="origin/HEAD",
            limit=None,
            shallow=False,
            version_filter=project_filter_generator("gzip"))
    ]

    CONTAINER = get_base_image(ImageBase.DEBIAN_10).run(
        'apt', 'install', '-y', 'autoconf', 'automake', 'libtool', 'autopoint',
        'gettext', 'texinfo', 'rsync')

    @staticmethod
    def binaries_for_revision(
            revision: ShortCommitHash) -> tp.List[ProjectBinaryWrapper]:
        binary_map = RevisionBinaryMap(get_local_project_git_path(Gzip.NAME))

        binary_map.specify_binary("build/gzip", BinaryType.EXECUTABLE)

        return binary_map[revision]

    def run_tests(self) -> None:
        pass

    def compile(self) -> None:
        """Compile the project."""
        gzip_version_source = local.path(self.source_of_primary)

        # Build binaries in separate dir because executing the binary with path
        # 'gzip' will execute '/usr/bin/gzip' independent of the current working
        # directory.
        mkdir("-p", gzip_version_source / "build")

        self.cflags += [
            "-Wno-error=string-plus-int", "-Wno-error=shift-negative-value",
            "-Wno-string-plus-int", "-Wno-shift-negative-value"
        ]

        with local.cwd(gzip_version_source):
            bb.watch(local["./bootstrap"])()

        c_compiler = bb.compiler.cc(self)
        with local.cwd(gzip_version_source /
                       "build"), local.env(CC=str(c_compiler)):
            bb.watch(local["../configure"])()
            bb.watch(make)("-j", get_number_of_jobs(bb_cfg()))

        with local.cwd(gzip_version_source):
            verify_binaries(self)

    @classmethod
    def get_release_revisions(
            cls, release_type: ReleaseType
    ) -> tp.List[tp.Tuple[FullCommitHash, str]]:
        major_release_regex = "^v[0-9]+\\.[0-9]+$"
        minor_release_regex = "^v[0-9]+\\.[0-9]+(\\.[0-9]+)?$"

        tagged_commits = get_tagged_commits(cls.NAME)
        if release_type == ReleaseType.MAJOR:
            return [(FullCommitHash(h), tag) for h, tag in tagged_commits
                    if re.match(major_release_regex, tag)]
        return [(FullCommitHash(h), tag) for h, tag in tagged_commits
                if re.match(minor_release_regex, tag)]

    @classmethod
    def get_cve_product_info(cls) -> tp.List[tp.Tuple[str, str]]:
        return [("gzip", "gzip"), ("gnu", "gzip")]
Esempio n. 9
0
class Libssh(VProject):
    """
    SSH library.

    (fetched by Git)
    """

    NAME = 'libssh'
    GROUP = 'c_projects'
    DOMAIN = ProjectDomains.PROTOCOL

    SOURCE = [
        block_revisions([
            GoodBadSubgraph(["c65f56aefa50a2e2a78a0e45564526ecc921d74f"],
                            ["0151b6e17041c56813c882a3de6330c82acc8d93"],
                            "Disabled to quickly get this running")
        ])(
            PaperConfigSpecificGit(
                project_name="libssh",
                remote="https://github.com/libssh/libssh-mirror.git",
                local="libssh",
                refspec="origin/HEAD",
                limit=None,
                shallow=False
            )
        )
    ]

    CONTAINER = get_base_image(
        ImageBase.DEBIAN_10
    ).run('apt', 'install', '-y', 'libssl-dev', 'cmake')

    @staticmethod
    def binaries_for_revision(
        revision: ShortCommitHash
    ) -> tp.List[ProjectBinaryWrapper]:
        binary_map = RevisionBinaryMap(get_local_project_git_path(Libssh.NAME))

        binary_map.specify_binary(
            'build/src/libssh.so',
            BinaryType.SHARED_LIBRARY,
            only_valid_in=RevisionRange("c65f56aefa", "aa899f8ec0")
        )

        binary_map.specify_binary(
            'build/lib/libssh.so',
            BinaryType.SHARED_LIBRARY,
            only_valid_in=RevisionRange("aa899f8ec0", "master")
        )

        return binary_map[revision]

    def run_tests(self) -> None:
        pass

    def compile(self) -> None:
        """Compile the project."""
        libssh_source = local.path(self.source_of(self.primary_source))
        libssh_version = ShortCommitHash(self.version_of_primary)
        cmake_revisions = get_all_revisions_between(
            "0151b6e17041c56813c882a3de6330c82acc8d93", "master",
            ShortCommitHash, libssh_source
        )
        if libssh_version in cmake_revisions:
            self.__compile_cmake()
        else:
            self.__compile_make()

    def __compile_cmake(self) -> None:
        libssh_source = local.path(self.source_of(self.primary_source))

        compiler = bb.compiler.cc(self)
        mkdir("-p", libssh_source / "build")
        with local.cwd(libssh_source / "build"):
            with local.env(CC=str(compiler)):
                bb.watch(cmake)("-G", "Unix Makefiles", "..")

            bb.watch(make)("-j", get_number_of_jobs(bb_cfg()))

        with local.cwd(libssh_source):
            verify_binaries(self)

    def __compile_make(self) -> None:
        libssh_source = local.path(self.source_of(self.primary_source))
        libssh_version = ShortCommitHash(self.version_of_primary)
        autoconf_revisions = get_all_revisions_between(
            "5e02c25291d594e01a910fce097a3fc5084fd68f",
            "21e639cc3fd54eb3d59568744c9627beb26e07ed", ShortCommitHash,
            libssh_source
        )
        autogen_revisions = get_all_revisions_between(
            "ca32b0aa146b31d7772f27d16098845e615432aa",
            "ee54acb417c5589a8dc9dab0676f34b3d40a182b", ShortCommitHash,
            libssh_source
        )
        compiler = bb.compiler.cc(self)
        with local.cwd(libssh_source):
            with local.env(CC=str(compiler)):
                if libssh_version in autogen_revisions:
                    bb.watch("./autogen.sh")()
                if libssh_version in autoconf_revisions:
                    bb.watch("autoreconf")()
                configure = bb.watch(local["./configure"])
                configure()
            bb.watch(make)("-j", get_number_of_jobs(bb_cfg()))

            verify_binaries(self)

    @classmethod
    def get_cve_product_info(cls) -> tp.List[tp.Tuple[str, str]]:
        return [("Libssh", "Libssh")]
Esempio n. 10
0
class Xz(VProject):
    """Compression and decompression tool xz (fetched by Git)"""

    NAME = 'xz'
    GROUP = 'c_projects'
    DOMAIN = ProjectDomains.COMPRESSION

    SOURCE = [
        block_revisions([
            GoodBadSubgraph(["cf49f42a6bd40143f54a6b10d6e605599e958c0b"],
                            ["4c7ad179c78f97f68ad548cb40a9dfa6871655ae"],
                            "missing file api/lzma/easy.h"),
            GoodBadSubgraph(["335fe260a81f61ec99ff5940df733b4c50aedb7c"],
                            ["24e0406c0fb7494d2037dec033686faf1bf67068"],
                            "use of undeclared LZMA_THREADS_MAX"),
            RevisionRange("5d018dc03549c1ee4958364712fb0c94e1bf2741",
                          "c324325f9f13cdeb92153c5d00962341ba070ca2",
                          "Initial git import without xz")
        ])(PaperConfigSpecificGit(project_name='xz',
                                  remote="https://github.com/xz-mirror/xz.git",
                                  local="xz",
                                  refspec="origin/HEAD",
                                  limit=None,
                                  shallow=False))
    ]

    CONTAINER = get_base_image(ImageBase.DEBIAN_10).run(
        'apt', 'install', '-y', 'autoconf', 'autopoint', 'automake',
        'autotools-dev', 'libtool', 'pkg-config')

    @staticmethod
    def binaries_for_revision(
            revision: ShortCommitHash) -> tp.List[ProjectBinaryWrapper]:
        binary_map = RevisionBinaryMap(get_local_project_git_path(Xz.NAME))

        binary_map.specify_binary('src/xz/xz',
                                  BinaryType.EXECUTABLE,
                                  only_valid_in=RevisionRange(
                                      "5d018dc035", "3f86532407"))

        binary_map.specify_binary('src/xz/.libs/xz',
                                  BinaryType.EXECUTABLE,
                                  override_entry_point='src/xz/xz',
                                  only_valid_in=RevisionRange(
                                      "880c330938", "master"))

        return binary_map[revision]

    def run_tests(self) -> None:
        pass

    def compile(self) -> None:
        """Compile the project."""
        xz_git_path = get_local_project_git_path(self.NAME)
        xz_version_source = local.path(self.source_of_primary)
        xz_version = self.version_of_primary

        # dynamic linking is off by default until
        # commit f9907503f882a745dce9d84c2968f6c175ba966a
        # (fda4724 is its parent)
        with local.cwd(xz_git_path):
            revisions_wo_dynamic_linking = get_all_revisions_between(
                "5d018dc03549c1ee4958364712fb0c94e1bf2741",
                "fda4724d8114fccfa31c1839c15479f350c2fb4c", ShortCommitHash)

        self.cflags += ["-fPIC"]

        clang = bb.compiler.cc(self)
        with local.cwd(xz_version_source):
            with local.env(CC=str(clang)):
                bb.watch(autoreconf)("--install")
                configure = bb.watch(local["./configure"])

                if xz_version in revisions_wo_dynamic_linking:
                    configure("--enable-dynamic=yes")
                else:
                    configure()

            bb.watch(make)("-j", get_number_of_jobs(bb_cfg()))

            verify_binaries(self)

    @classmethod
    def get_cve_product_info(cls) -> tp.List[tp.Tuple[str, str]]:
        return [("tukaani", "xz")]
Esempio n. 11
0
class Gravity(VProject):
    """Programming language Gravity."""

    NAME = 'gravity'
    GROUP = 'c_projects'
    DOMAIN = ProjectDomains.PROG_LANG

    SOURCE = [
        block_revisions([
            RevisionRange(
                "0b8e0e047fc3d5e18ead3221ad54920f1ad0eedc",
                "8f417752dd14deea64249b5d32b6138ebc877fa9", "nothing to build"
            ),
            GoodBadSubgraph(["e8999a84efbd9c3e739bff7af39500d14e61bfbc"],
                            ["0e918ce0798407dd6c981e1cd26b4ba138d22fab"],
                            "missing -lm"),
            GoodBadSubgraph(["244c5aa91358a5b2472d351e6c7f38ba7da94ef6"],
                            ["371152de2f38534d4da332349d1def83fc66d5bc"],
                            "Visual studio project breaks makefile"),
            GoodBadSubgraph(["112be515b5ef3b67011c7272e5a50ac3a1fcadc4"],
                            ["b9a62dfad41ae06d029493cf4d5757de2a0281b2"],
                            "bug in gravity"),
            SingleRevision(
                "e207f0cc87bf57e9ccb6f0d18ff4fe4d6ef0c096", "bug in gravity"
            ),
            GoodBadSubgraph(["d2a04f92347fb5f2b6fd23bea9b0e12817cd6d8e"],
                            ["e8fbd6a4a2a9618456f1460dc9138b617dc7af4b"],
                            "bug in gravity"),
            GoodBadSubgraph(["968534c5d4f28501b7f34da48cab2c153ae7449b"],
                            ["0caf15328bda90ffb1911077e03b28ea9970208b"],
                            "bug in gravity"),
            GoodBadSubgraph(["e4f95e669a4c5cf2d142d5b0b72a11c117f7092f"],
                            ["09e59da4deff9b35224f4784fae9d0f132be9cea"],
                            "missing -lbsd"),
        ])(
            PaperConfigSpecificGit(
                project_name="gravity",
                remote="https://github.com/marcobambini/gravity.git",
                local="gravity",
                refspec="origin/HEAD",
                limit=None,
                shallow=False
            )
        )
    ]

    CONTAINER = get_base_image(ImageBase.DEBIAN_10
                              ).run('apt', 'install', '-y', 'cmake')

    @staticmethod
    def binaries_for_revision(
        revision: ShortCommitHash
    ) -> tp.List[ProjectBinaryWrapper]:
        binary_map = RevisionBinaryMap(get_local_project_git_path(Gravity.NAME))

        binary_map.specify_binary("gravity", BinaryType.EXECUTABLE)

        return binary_map[revision]

    def run_tests(self) -> None:
        pass

    def compile(self) -> None:
        """Compile the project."""
        gravity_git_path = get_local_project_git_path(self.NAME)
        gravity_version = self.version_of_primary

        # commit 46133fb47d6da1f0dec27ae23db1d633bc72e9e3 introduced
        # cmake as build system
        with local.cwd(gravity_git_path):
            cmake_revisions = get_all_revisions_between(
                "dbb4d61fc2ebb9aca44e8e6bb978efac4a6def87", "master",
                ShortCommitHash
            )

        if gravity_version in cmake_revisions:
            self.__compile_cmake()
        else:
            self.__compile_make()

    def __compile_cmake(self) -> None:
        gravity_version_source = local.path(self.source_of_primary)
        clang = bb.compiler.cc(self)
        with local.cwd(gravity_version_source):
            with local.env(CC=str(clang)):
                bb.watch(cmake)("-G", "Unix Makefiles", ".")
            bb.watch(make)("-j", get_number_of_jobs(bb_cfg()))

            verify_binaries(self)

    def __compile_make(self) -> None:
        gravity_version_source = local.path(self.source_of_primary)
        clang = bb.compiler.cc(self)
        with local.cwd(gravity_version_source):
            with local.env(CC=str(clang)):
                bb.watch(make)("-j", get_number_of_jobs(bb_cfg()))

            verify_binaries(self)

    @classmethod
    def get_cve_product_info(cls) -> tp.List[tp.Tuple[str, str]]:
        return [("creolabs", "gravity")]
Esempio n. 12
0
class Libtiff(VProject):
    """Libtiff is a library for reading and writing Tagged Image File Format
    files."""

    NAME = 'libtiff'
    GROUP = 'c_projects'
    DOMAIN = ProjectDomains.FILE_FORMAT

    SOURCE = [
        block_revisions([
            GoodBadSubgraph(["0ef31e1f62aa7a8b1c488a59c4930775ee0046e4"],
                            ["a63512c436c64ad94b8eff09d6d7faa7e638d45d"],
                            "Bug in Libtiff"),
            GoodBadSubgraph(["88df59e89cfb096085bc5299f087eaceda73f12e"], [
                "901535247413d30d9380ee837ecdb9fb661350c6",
                "5ef6de4c7055a3b426d97d5af1a77484ee92eb30"
            ], "Does not build"),
            GoodBadSubgraph(
                ["6d46b8e4642f372192e94976576b13dcb89970d8"],
                ["88df59e89cfb096085bc5299f087eaceda73f12e"],
                "Does not build because of libtool version discrepancy"),
            GoodBadSubgraph(["5cbfc68f0625d6c29d724b6e57fa7e98017ad325"],
                            ["59e0f5cb3316089eb81064efdc3ba0eac7145fab"],
                            "Bug in Libtiff"),
            SingleRevision("614095e3d06f6ac95fc9bb2e9333cf95c228be1c",
                           "Bug in Libtiff"),
            SingleRevision("a1caf14ce4640eec759a801ea601bd022bdc02d3",
                           "Bug in Libtiff"),
            GoodBadSubgraph(
                ["f7aebc264761adc41142e98e2285700dc51d384e"],
                ["9f3e08cf9409573ffa67e243c8bfbf6263b0fcb5"],
                "Issue on some machines, not sure whos fault it is"),
            GoodBadSubgraph(["97049062b9d1efa7b00d7a13bcf97365b57c937b"],
                            ["66eb5c7cd07fec0647517f418e5fc81c4e26d402"],
                            "Bug in Libtiff"),
            GoodBadSubgraph(["0769c447b7108fe616d855e1ba367ecbb90ba471"],
                            ["40c664948371d60908328f7ccb5982aebda1d04d"],
                            "Error in the Makefile of Libtiff"),
            GoodBadSubgraph(["0730d44a00a34db8659a16833453d231501722a7"],
                            ["5b60852fe65b5908130e809e1011b10afcaf1c9c"],
                            "Bub in Libtiff"),
            GoodBadSubgraph(["145eb81dc87441e400f2bdaf7b873c429ce8c768"],
                            ["0e40776b337855277cf8093cdc9fa1f838642be1"],
                            "Bug in Libtiff"),
            SingleRevision("d7afc8c14f379f1e7dcf91d9c57cb9b2d1f2d926",
                           "Bug in Libtiff"),
            SingleRevision("292c431e5d99464134255e7e2dc8d24fd6f797d5",
                           "Bug in Libtiff"),
            SingleRevision("5b90af247ea3801ce93ec0922b8b81396caa885d",
                           "Bug in Libtiff"),
            SingleRevision("45efaab3950e9aeb4bb6b697e5795613c629826c",
                           "Bug in Libtiff"),
            SingleRevision("394965766478c9fb028b2bc2ca09e92a49a35f14",
                           "Bug in Libtiff"),
            SingleRevision("0e3c0d0550dc5790779bd222844ac736d83e99a5",
                           "Bug in Libtiff"),
            SingleRevision("d4bef27ee8361ee2d8aae6c30c7074d2547ee2f0",
                           "Bug in Libtiff")
        ])(PaperConfigSpecificGit(
            project_name="libtiff",
            remote="https://gitlab.com/libtiff/libtiff.git",
            local="libtiff",
            refspec="origin/HEAD",
            limit=None,
            shallow=False))
    ]

    CONTAINER = get_base_image(ImageBase.DEBIAN_10).run(
        'apt', 'install', '-y', 'autoconf', 'autopoint', 'automake',
        'autotools-dev', 'libtool', 'pkg-config')

    @staticmethod
    def binaries_for_revision(
            revision: ShortCommitHash) -> tp.List[ProjectBinaryWrapper]:
        binary_map = RevisionBinaryMap(get_local_project_git_path(
            Libtiff.NAME))

        binary_map.specify_binary("libtiff/.libs/libtiff.so",
                                  BinaryType.SHARED_LIBRARY)

        return binary_map[revision]

    def run_tests(self) -> None:
        pass

    def compile(self) -> None:
        """Compile the project."""
        libtiff_version_source = local.path(self.source_of(
            self.primary_source))

        c_compiler = bb.compiler.cc(self)
        with local.cwd(libtiff_version_source):
            with local.env(CC=str(c_compiler)):
                bb.watch(local["./autogen.sh"])()
                configure = bb.watch(local["./configure"])
                configure()
            bb.watch(make)("-j", get_number_of_jobs(bb_cfg()))

            verify_binaries(self)

    @classmethod
    def get_cve_product_info(cls) -> tp.List[tp.Tuple[str, str]]:
        return [("Libtiff", "Libtiff")]