arthepsy / ssh-audit

SSH server auditing (banner, key exchange, encryption, mac, compression, compatibility, security, etc)
MIT License
2.96k stars 269 forks source link

feature: exit with non-zero exit code #16

Open maticmeznar opened 7 years ago

maticmeznar commented 7 years ago

Since ssh-audit can used in a script, it would be nice if ssh-audit would exit with exit code of 2 if there are 1 or more recommendations. I'd be fine with this requiring an optional command argument.

arthepsy commented 7 years ago

Currently this tool has pretty standard behavior - exits with 0 on success and with 1 if something failed (connection, data, etc). I don't think it is wise to change exit code to < 0 if everything was run fine, therefore I would opt for the option to control this behavior, as You suggested.

I'd like to have a bit more of Your thoughts on this. For example:

See where I'm getting with this? A bit more careful planning must be done before implementing this feature.

maticmeznar commented 7 years ago

Thank you for the reply @arthepsy

My hypothetical use case would be to use ssh-audit as part of continuous auditing of all SSH servers using Sensu or Nagios checks. In Nagios compatible checks, exit code 0 means PASS, 1=WARN, 2=CRITICAL,3=CHECKERROR. This is the primary reason behind wanting exit code 2.

there can be situation, when there are no recommendations, but this specific software has known vulnerabilities or exploits (reported in security section). What exit code to use then?

Exit code 2. I think running ssh-agent in my proposed mode should only return 2 if there are security issues or a severe case of misconfiguration that could lead to problems, regardless of SSH server version. If upgrading SSH server is the only way to fix them, then upgrade is what should be done to silence the alarm (get exit code 0).

Basically, exit code 0 should mean "based on all information available to ssh-audit, this SSH server version and configuration are secure".

egberts commented 2 years ago

Once possibility is to define an environment variable detailing the error code further.