コード例 #1
0
 def setup_method(self):
     assert inpath("ar"), "Required tool 'ar' not found"
     download_file(TMUX_DEB, os.path.join(self.tempdir, "test.deb"))
     shutil.copyfile(
         os.path.join(self.tempdir, "test.deb"),
         os.path.join(self.tempdir, "test.ipk"),
     )
コード例 #2
0
    def test_version_in_package(self, url, package_name, product, version):
        """ Helper function to get a file (presumed to be a real copy
        of a library, probably from a Linux distribution) and run a
        scan on it.  Any test using this should likely be listed as a
        long test."""
        # get file
        tempfile = os.path.join(self.package_test_dir, package_name)
        download_file(url + package_name, tempfile)
        # new scanner for the new test.
        self.scanner = Scanner(cvedb=self.cvedb, should_extract=True)
        # run the tests
        self.scanner.recursive_scan(tempfile)

        # make sure we found the expected product/version
        # list of all the products
        products = [cve_data.product for cve_data in self.scanner.all_cves]
        # Make sure the product is in the results
        assert product in products

        product_versions = []
        for cve_data in self.scanner.all_cves:
            if cve_data.product == product:
                product_versions.append(cve_data.version)

        assert version in product_versions
コード例 #3
0
ファイル: test_scanner.py プロジェクト: mmg1/cve-bin-tool
    def test_version_in_package(self, url, package_name, module, version):
        """ Helper function to get a file (presumed to be a real copy
        of a library, probably from a Linux distribution) and run a
        scan on it.  Any test using this should likely be listed as a
        long test."""
        # get file
        tempfile = os.path.join(self.package_test_dir, package_name)
        download_file(url + package_name, tempfile)
        # new scanner for the new test.
        self.scanner = Scanner(cvedb=self.cvedb, should_extract=True)
        # run the tests
        self.scanner.recursive_scan(tempfile)

        # make sure we found the expected package/version
        assert module in self.scanner.all_cves
        assert version in self.scanner.all_cves[module]
コード例 #4
0
    def _file_test(self, url, filename, package, version):
        """ Helper function to get a file (presumed to be a real copy
        of a library, probably from a Linux distribution) and run a
        scan on it.  Any test using this should likely be listed as a
        long test."""
        # get file
        tempfile = os.path.join(self.tempdir, filename)
        download_file(url + filename, tempfile)
        # new scanner for the new test.
        self.scanner = Scanner(cvedb=self.cvedb)
        # run the tests
        cves = self.scanner.extract_and_scan(tempfile)

        # make sure we found the expected package/version
        assert package in cves
        assert version in cves[package]
コード例 #5
0
 def setup_class(cls):
     super(TestExtractFileRpm, cls).setup_class()
     download_file(CURL_7_20_0_URL, os.path.join(cls.tempdir, "test.rpm"))
コード例 #6
0
 def setup_class(cls):
     super().setup_class()
     download_file(CURL_7_20_0_URL, path.join(cls.tempdir, "test.rpm"))