import json
import os
import shlex

from anchore_engine.utils import run_check


def run_syft(image):
    proc_env = os.environ.copy()

    syft_env = {
        "SYFT_CHECK_FOR_APP_UPDATE": "0",
        "SYFT_LOG_STRUCTURED": "1",
    }

    proc_env.update(syft_env)

    cmd = "syft -vv -o json oci-dir:{image}".format(image=image)

    stdout, _ = run_check(shlex.split(cmd), env=proc_env)

    return json.loads(stdout)

import json
import os
import shlex

from anchore_engine.utils import run_check


def run_syft(image):
    proc_env = os.environ.copy()

    syft_env = {
        "SYFT_CHECK_FOR_APP_UPDATE": "0",
        "SYFT_LOG_STRUCTURED": "1",
    }

    proc_env.update(syft_env)

    cmd = "syft -vv -o json oci-dir:{image}".format(image=image)

    stdout, _ = run_check(shlex.split(cmd), env=proc_env, log_level="spew")

    return json.loads(stdout)

Make the syft invocation only log the full output at spew level instead of debug.
Make the syft invocation only log the full output at spew level instead
of debug.

The syft json output for very large images can be 100s of MB and
cause the analyzer to be unusable due to the logging itself. This
changes that call to only dump output at "spew" level logging.

Signed-off-by: Zach Hill <9de8c4480303b5335cd2a33eefe814615ba3612a@anchore.com>
