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

Exit codes #99

Closed
di opened this issue Nov 1, 2021 · 4 comments · Fixed by #102
Closed

Exit codes #99

di opened this issue Nov 1, 2021 · 4 comments · Fixed by #102
Labels
component:cli CLI components

Comments

@di
Copy link
Member

di commented Nov 1, 2021

Right now, pip-audit exits with an exit code of 0 regardless of whether the audit has passed or failed:

$ pip-audit
- Auditing zipp (3.4.1)
Package  Version ID             Fix Versions
-------- ------- -------------- ------------
py       1.9.0   PYSEC-2020-92  1.10.0
Pygments 2.6.1   PYSEC-2021-140 2.7.4
Pygments 2.6.1   PYSEC-2021-141 2.7.4
PyYAML   5.3.1   PYSEC-2021-142 5.4
sqlparse 0.3.1   PYSEC-2021-333 0.4.2
urllib3  1.25.9  PYSEC-2021-108 1.26.5

$ echo $?
0

Ideally, pip-audit would exit with a nonzero exit code if vulnerabilities were found.

@di di added this to the Stable Release milestone Nov 1, 2021
@woodruffw woodruffw added the component:cli CLI components label Nov 1, 2021
@woodruffw
Copy link
Member

Sounds good. We can also make our exit codes slightly semantic (1 for exactly one vuln found, 2 for more than one?) if that's desirable.

@di
Copy link
Member Author

di commented Nov 1, 2021

We can also make our exit codes slightly semantic (1 for exactly one vuln found, 2 for more than one?) if that's desirable.

I think it might eventually make sense to have different nonzero exit codes, although I'm not sure making a distinction between the quantity of vulnerabilities would be useful. For now, let's just support 0 for no vulnerabilities, 1 for one or more vulnerabilities.

We should also think about this in the context of #82 as well.

@irishismyname
Copy link

Can you recommend a way to bypass this for pipeline jobs? Exit code 1 is preventing us from uploading the CycloneDX report as a job artifact in GitLab.

@woodruffw
Copy link
Member

The easiest thing to do is probably to swallow the exit code entirely:

pip-audit ... || exit 0

That should keep your CI from exiting prematurely. Longer term, we could think about making the current exit code behavior optional if it's something multiple users would like 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:cli CLI components
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants