示例#1
0
def fixture_package_not_matched(mock_apt_cache, mock_apt_origin_no_match):
    mock_apt_cache['mypackage'].origins = [mock_apt_origin_no_match]

    package = Package(mock_apt_cache)

    package.by_name('mypackage')

    return package
示例#2
0
def fixture_package_no_origin(mock_apt_cache):
    mock_apt_cache['mypackage'].origins = []

    package = Package(mock_apt_cache)

    package.by_name('mypackage')

    return package
示例#3
0
    def test_encoded_filename(self, mock_apt_cache):
        """
        Ensure that we can locate urlencoded filenames in apt cache
        """
        package = Package(mock_apt_cache)

        package.by_filename(
            '/var/cache/apt/archive/encodedpackage_3%3a6.03+dfsg-14.1+deb9u1_amd64.deb'
        )

        assert package.name == 'encodedpackage'
        assert package.version == '3:6.03+dfsg-14.1+deb9u1'
        assert package.arch == 'amd64'
示例#4
0
文件: cli.py 项目: shaunrs/aptsign
def process_package(config, filename, cache):
    logging.debug("Package Filename: %s", filename)

    pkg = Package(cache)

    # Allow PackageNotFound to bubble up
    # dpkg should not continue if we are unable to verify the package
    pkg.by_filename(filename)

    logging.debug("Package name: %s", pkg)

    # Generate the filters from configuration file
    filters = Filters()
    for _, repo in config['repositories'].items():
        filters.new(repo['filter'], repo['app'])

    # Pass the package through the filter list, get a list of matching filters
    # We now have a list of filters which tell us what to do
    package_filter = filters.is_match(pkg)

    # If there was no match found, ignore this package
    if not package_filter:
        logging.info("No filter found, skipping signature checks..")
        return

    logging.info("Matched filter: \"%s\"", package_filter)
    logging.info("Validating signatures for %s using '%s'", pkg,
                 package_filter.app)

    command = "{} {}".format(package_filter.app, pkg.filename)

    logging.debug("Passing to command '%s'", command)

    try:
        output = subprocess.check_output(command.split(),
                                         stderr=subprocess.STDOUT)
    except subprocess.CalledProcessError as error:
        logging.error("ERROR: Signature verification check FAILED")
        logging.error(error.output)

        sys.exit(error.returncode)
    else:
        logging.info(output)
示例#5
0
def fixture_package(mock_apt_cache):
    package = Package(mock_apt_cache)

    package.by_name('mypackage')

    return package
示例#6
0
    def test_invalid_package_by_filename(self, mock_apt_cache):
        package = Package(mock_apt_cache)

        with pytest.raises(PackageNotFound):
            package.by_filename("mypackage_1.2.1_amd64.deb")
示例#7
0
    def test_invalid_package_by_name(self, mock_apt_cache):
        package = Package(mock_apt_cache)

        with pytest.raises(PackageNotFound):
            package.by_name("other-package")
示例#8
0
    def test_by_filename(self, mock_apt_cache):
        package = Package(mock_apt_cache)

        package.by_filename('/var/cache/apt/archive/mypackage_1.0.1_amd64.deb')

        self.assert_package(package)
示例#9
0
    def test_by_name(self, mock_apt_cache):
        package = Package(mock_apt_cache)

        package.by_name('mypackage')

        self.assert_package(package)