pyupio/safety

safety check is done successfully but exit code is 255

ctfer-Stao opened this issue · 4 comments

  • safety version:version 1.10.3
  • Python version:3.9.6
  • Operating System:mac

Description

I use safety to check dependence.It print success result but exit code is 255
my shell command is safety check

What I Did

 ~  safety check
+==============================================================================+
| |
| /$$$$$$ /$$ |
| /$$__ $$ | $$ |
| /$$$$$$$ /$$$$$$ | $$ _//$$$$$$ /$$$$$$ /$$ /$$ |
| /$$_____/ |
___ $$| $$$$ /$$__ $$|_ $$/ | $$ | $$ |
| | $$$$$$ /$$$$$$$| $$
/ | $$$$$$$$ | $$ | $$ | $$ |
| ____ $$ /$$__ $$| $$ | $$/ | $$ /$$| $$ | $$ |
| /$$$$$$$/| $$$$$$$| $$ | $$$$$$$ | $$$$/| $$$$$$$ |
| |_/ _/|/ _
/ _/ ___ $$ |
| /$$ | $$ |
| | $$$$$$/ |
| by pyup.io ______/ |
| |
+==============================================================================+
| REPORT |
| checked 81 packages, using free DB (updated once a month) |
+============================+===========+==========================+==========+
| package | installed | affected | ID |
+============================+===========+==========================+==========+
| lxml | 4.5.0 | <4.6.2 | 39194 |
| lxml | 4.5.0 | <4.6.3 | 40072 |
| lxml | 4.5.0 | <4.6.5 | 43366 |
| aiohttp | 3.7.4.pos | <3.8.0 | 42692 |
+==============================================================================+
✘  ~  echo $?
255

Hi @ctfer-Stao thanks for reporting this, we are working in a full and standard support of exit codes, this probably is happening because the line below, -1 isn't a good exit code and it is falling back to 255 exit code.

sys.exit(-1 if vulns else 0)

@ctfer-Stao I just had this error too, a bad workaround is too add an OR condition to the bash command:

safety check --full-report || true

This way the error message will show completely since the exit error is ignored. In my case there was a urllib3 and numpy vulnerability that I've added to ignore (specific case where it's a famous service locked dependency).

Might be good for debug, but remember to remove later, || true it's just too flexible, and when the bug is corrected we can forget there as it is.

New Safety version 2.0 supports better exit code handling; please use the last beta version 2.0b5