(ctx: click.Context, name: str)
scan a docker image <NAME>.

    ggshield will try to pull the image if it's not available locally.
scan a docker image <NAME>.
scan a docker image <NAME > .
def docker_name_cmd(ctx: click.Context, name: str) -> int:
    """
    scan a docker image <NAME>.

    ggshield will try to pull the image if it's not available locally.
    """

    with tempfile.TemporaryDirectory(suffix="ggshield") as temporary_dir:
        config = ctx.obj["config"]
        output_handler: OutputHandler = ctx.obj["output_handler"]

        try:
            archive = str(docker_save_to_tmp(name, temporary_dir))

            scan = docker_scan_archive(
                archive=archive,
                client=ctx.obj["client"],
                cache=ctx.obj["cache"],
                verbose=config.verbose,
                matches_ignore=config.matches_ignore,
                all_policies=config.all_policies,
                scan_id=name,
                banlisted_detectors=config.banlisted_detectors,
            )

            return output_handler.process_scan(scan)
        except Exception as error:
            return handle_exception(error, config.verbose)
def docker_name_cmd ( ctx : click . Context , name : str ) -> int : with tempfile . TemporaryDirectory ( suffix = "ggshield" ) as temporary_dir : config = ctx . obj [ "config" ] output_handler : OutputHandler = ctx . obj [ "output_handler" ] try : archive = str ( docker_save_to_tmp ( name , temporary_dir ) ) scan = docker_scan_archive ( archive = archive , client = ctx . obj [ "client" ] , cache = ctx . obj [ "cache" ] , verbose = config . verbose , matches_ignore = config . matches_ignore , all_policies = config . all_policies , scan_id = name , banlisted_detectors = config . banlisted_detectors , ) return output_handler . process_scan ( scan ) except Exception as error : return handle_exception ( error , config . verbose )