From 1e3cd6f669514453750c1f5982a4b815214d64ec Mon Sep 17 00:00:00 2001 From: Brenton Cleeland Date: Wed, 28 Feb 2024 08:05:31 +1100 Subject: [PATCH] fix: return the check result from SSL certificate tests to include them in the JSON results. Fixes #28. --- ready/checks/ssl.py | 9 +++++---- ready/ready.py | 2 +- setup.cfg | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ready/checks/ssl.py b/ready/checks/ssl.py index 75fc1f8..d1ca40d 100644 --- a/ready/checks/ssl.py +++ b/ready/checks/ssl.py @@ -59,21 +59,22 @@ def get_ssl_expiry(domain, ipv6=False): def check_ssl_certificate_should_be_trusted(responses, **kwargs): try: response = request(f'https://{kwargs["domain"]}', verify=True) - result( + return result( True, f"SSL certificate should be trusted", "ssl_trusted", **kwargs, ) except: - result(False, f"SSL certificate should be trusted", "ssl_trusted", **kwargs) + return result(False, f"SSL certificate should be trusted", "ssl_trusted", **kwargs) # Check: SSL expiry should be less than one year def check_ssl_expiry_should_be_less_than_one_year(responses, **kwargs): ssl_expiry = get_ssl_expiry(kwargs["domain_with_no_path"], ipv6=kwargs["is_ipv6"]) ssl_expiry_days = (ssl_expiry - date.today()).days if ssl_expiry else None - result( + + return result( ssl_expiry_days and ssl_expiry_days < 366, f"SSL expiry should be less than one year ({ssl_expiry_days} days)", "ssl_expiry_max", @@ -86,7 +87,7 @@ def check_ssl_expiry_should_be_greater_than_five_days(responses, **kwargs): ssl_expiry = get_ssl_expiry(kwargs["domain_with_no_path"], ipv6=kwargs["is_ipv6"]) ssl_expiry_days = (ssl_expiry - date.today()).days if ssl_expiry else None - result( + return result( ssl_expiry_days and ssl_expiry_days > 5, f"SSL expiry should be greater than five days ({ssl_expiry_days} days)", "ssl_expiry_min", diff --git a/ready/ready.py b/ready/ready.py index 16a86bc..40227b0 100644 --- a/ready/ready.py +++ b/ready/ready.py @@ -7,7 +7,7 @@ from importlib import resources from . import checks as checks_module -VERSION = "1.2.5" +VERSION = "1.2.6" from ready.checks.bad_response import ( check_bad_response_cloudflare, diff --git a/setup.cfg b/setup.cfg index 6949568..0d142c1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = ready-check -version = 1.2.5 +version = 1.2.6 author = Brenton Cleeland author_email = brenton@brntn.me description = A developer-friendly web scanning tool