Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow check to ignore packages #2408

Merged
merged 7 commits into from
Jun 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2408.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``pipenv check`` now may take multiple of the additional argument ``--ignore`` which takes a parameter ``cve_id`` for the purpose of ignoring specific CVEs.
15 changes: 13 additions & 2 deletions pipenv/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,19 +694,30 @@ def run(command, args, three=None, python=False):
default=False,
help="Given a code path, show potentially unused dependencies.",
)
@option(
'--ignore',
'-i',
multiple=True,
help="Ignore specified vulnerability during safety checks."
)
@argument('args', nargs=-1)
def check(
three=None,
python=False,
system=False,
unused=False,
style=False,
ignore=None,
args=None,
):
from .core import do_check

do_check(
three=three, python=python, system=system, unused=unused, args=args
three=three,
python=python,
system=system,
unused=unused,
ignore=ignore,
args=args
)


Expand Down
19 changes: 12 additions & 7 deletions pipenv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ def do_lock(
u'{0} {1} {2}'.format(
crayons.normal('Locking'),
crayons.red('[{0}]'.format(settings['log_string'])),
crayons.normal('dependencies'),
crayons.normal('dependencies...'),
),
err=True,
)
Expand Down Expand Up @@ -1845,7 +1845,7 @@ def do_install(
error, traceback = None, None
click.echo(
crayons.normal(
u'Requirements file provided! Importing into Pipfile...¦',
u'Requirements file provided! Importing into Pipfile...',
bold=True,
),
err=True,
Expand Down Expand Up @@ -1952,7 +1952,7 @@ def do_install(
except KeyError:
pass
# Install all dependencies, if none was provided.
# This basically ensures that we have a pipfile and lockfile, then it locks and
# This basically ensures that we have a pipfile and lockfile, then it locks and
# installs from the lockfile
if package_name is False:
# Update project settings with pre preference.
Expand All @@ -1972,7 +1972,7 @@ def do_install(
pypi_mirror=pypi_mirror,
)

# This is for if the user passed in dependencies, then we want to maek sure we
# This is for if the user passed in dependencies, then we want to maek sure we
else:
for package_name in package_names:
click.echo(
Expand Down Expand Up @@ -2338,7 +2338,7 @@ def do_run(command, args, three=None, python=False):
do_run_posix(script, command=command)


def do_check(three=None, python=False, system=False, unused=False, args=None):
def do_check(three=None, python=False, system=False, unused=False, ignore=None, args=None):
if not system:
# Ensure that virtualenv is available.
ensure_project(three=three, python=python, validate=False, warn=False)
Expand Down Expand Up @@ -2409,9 +2409,14 @@ def do_check(three=None, python=False, system=False, unused=False, args=None):
python = which('python')
else:
python = system_which('python')
if ignore:
ignored = '--ignore {0}'.format('--ignore '.join(ignore))
click.echo(crayons.normal('Notice: Ignoring CVE(s) {0}'.format(crayons.yellow(', '.join(ignore)))), err=True)
else:
ignored = ''
c = delegator.run(
'"{0}" {1} check --json --key=1ab8d58f-5122e025-83674263-bc1e79e0'.format(
python, escape_grouped_arguments(path)
'"{0}" {1} check --json --key=1ab8d58f-5122e025-83674263-bc1e79e0 {2}'.format(
python, escape_grouped_arguments(path), ignored
)
)
try:
Expand Down
9 changes: 8 additions & 1 deletion tests/integration/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,14 @@ def test_pipenv_graph_reverse(PipenvInstance, pypi):
def test_pipenv_check(PipenvInstance, pypi):
with PipenvInstance(pypi=pypi) as p:
p.pipenv('install requests==1.0.0')
assert 'requests' in p.pipenv('check').out
c = p.pipenv('check')
assert c.return_code != 0
assert 'requests' in c.out
p.pipenv('uninstall requests')
p.pipenv('install six')
c = p.pipenv('check --ignore 35015')
assert c.return_code == 0
assert 'Ignoring' in c.err


@pytest.mark.cli
Expand Down