コード例 #1
0
def main(arguments):
    try:
        locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
    except locale.Error:
        pass
    output = Outputs(arguments.output, arguments.maxsize, arguments.sha256)

    logger.log(PROGRESS, "Loading artifacts ...")

    platform = get_operating_system()
    collector = Collector(platform)

    artifacts_registry = get_artifacts_registry(arguments.library,
                                                arguments.directory)

    include_artifacts = resolve_artifact_groups(artifacts_registry,
                                                arguments.include)
    exclude_artifacts = resolve_artifact_groups(artifacts_registry,
                                                arguments.exclude)

    for artifact_definition, artifact_source in get_artifacts_to_collect(
            artifacts_registry, include_artifacts, exclude_artifacts, platform,
            arguments.include
            or (arguments.directory and not arguments.library)):
        collector.register_source(artifact_definition, artifact_source)

    collector.collect(output)
コード例 #2
0
def test_unsupported_source(path_artifact, caplog):
    collector = Collector(get_operating_system())

    collector.register_source(path_artifact, path_artifact.sources[0])

    log = caplog.records[0]
    assert log.levelname == "WARNING"
    assert log.message == "Cannot process source for 'PathArtifact' because type 'PATH' is not supported"
コード例 #3
0
def test_collector(command_echo, passwords_file, outputs, fake_partitions):
    collector = Collector(get_operating_system())

    collector.register_source(command_echo, command_echo.sources[0])
    collector.register_source(passwords_file, passwords_file.sources[0])
    collector.collect(outputs)

    assert outputs.add_collected_file.call_count == 1
    assert outputs.add_collected_command.call_count == 1