Skip to content

Commit

Permalink
Fix black formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
yeisonvargasf committed Nov 16, 2022
1 parent bda9a2d commit f89aaee
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions pipenv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2815,7 +2815,8 @@ def do_check(
if not quiet and not project.s.is_quiet():
click.echo(
click.style(
decode_for_output("Checking installed packages for vulnerabilities..."), bold=True
decode_for_output("Checking installed packages for vulnerabilities..."),
bold=True,
)
)
if ignore:
Expand Down Expand Up @@ -2873,15 +2874,17 @@ def do_check(
for cve in ignored:
cmd += cve

os.environ['SAFETY_CUSTOM_INTEGRATION'] = "True"
os.environ["SAFETY_CUSTOM_INTEGRATION"] = "True"
os.environ["SAFETY_SOURCE"] = "pipenv"
os.environ["SAFETY_PURE_YAML"] = "True"

from pipenv.patched.safety.cli import cli

sys.argv = cmd[1:]

if output == 'minimal':
if output == "minimal":
from contextlib import redirect_stderr, redirect_stdout

code = 0

with redirect_stdout(io.StringIO()) as out, redirect_stderr(io.StringIO()) as err:
Expand All @@ -2899,38 +2902,40 @@ def do_check(
raise exceptions.PipenvCmdError(
cmd_list_to_shell(cmd), report, error, exit_code=code
)
meta = json_report.get('report_meta')
vulnerabilities_found = meta.get('vulnerabilities_found')
meta = json_report.get("report_meta")
vulnerabilities_found = meta.get("vulnerabilities_found")

fg = 'green'
message = 'All good!'
db_type = 'commercial' if meta.get('api_key', False) else 'free'
fg = "green"
message = "All good!"
db_type = "commercial" if meta.get("api_key", False) else "free"

if vulnerabilities_found >= 0:
fg = 'red'
message = f'Scan was complete using Safety’s {db_type} vulnerability database.'
fg = "red"
message = (
f"Scan was complete using Safety’s {db_type} vulnerability database."
)

click.echo()
click.secho(f"{vulnerabilities_found} vulnerabilities found.", fg=fg)
click.echo()

vulnerabilities = json_report.get('vulnerabilities', [])
vulnerabilities = json_report.get("vulnerabilities", [])

for vuln in vulnerabilities:
click.echo(
"{}: {} {} open to vulnerability {} ({}). More info: {}".format(
click.style(vuln['vulnerability_id'], bold=True, fg='red'),
click.style(vuln['package_name'], fg="green"),
click.style(vuln['analyzed_version'], fg="yellow", bold=True),
click.style(vuln['vulnerability_id'], bold=True),
click.style(vuln['vulnerable_spec'], fg="yellow", bold=False),
click.style(vuln['more_info_url'], bold=True)
click.style(vuln["vulnerability_id"], bold=True, fg="red"),
click.style(vuln["package_name"], fg="green"),
click.style(vuln["analyzed_version"], fg="yellow", bold=True),
click.style(vuln["vulnerability_id"], bold=True),
click.style(vuln["vulnerable_spec"], fg="yellow", bold=False),
click.style(vuln["more_info_url"], bold=True),
)
)
click.echo(f"{vuln['advisory']}")
click.echo()

click.echo(click.style(message, fg='white', bold=True))
click.echo(click.style(message, fg="white", bold=True))
sys.exit(code)

cli(prog_name="pipenv")
Expand Down

0 comments on commit f89aaee

Please sign in to comment.