safety
safety copied to clipboard
README Feature: Error codes for check
I would love to see a short section about the error codes of check
.
Black (under Command line options) does that and it helped me a lot:
--check Don't write the files back, just return the
status. Return code 0 means nothing would
change. Return code 1 means some files would be
reformatted. Return code 123 means there was an
internal error.
I found this in safety/cli.py
(line 90) to be very helpful:
sys.exit(-1 if vulns else 0)
Actually it seems -1
is the only exit code ever returned (besides 0
). It would be really useful for me to differentiate between a technical failure and "vulnerabilities being found".
I use safety check --bare
in a cronjob and I want my cronjob to fail loudly if safety could not run, but just report the vulnerabilities if run successfully. A flag like --exit-0-even-if-vulnerabilities-found
or something would also fit my needs.
@wadevries
Actually, you are right.
It would further improve safety
, especially when run in CI jobs. That's exactly my use case as well.
Hi @normoes and @wadevries, the latest Safety version added support for standard error codes. You can find the code and its meaning in the README: https://github.com/pyupio/safety#using-safety-with-a-ci-service