Skip to content

Commit

Permalink
fix: return the check result from SSL certificate tests to include th…
Browse files Browse the repository at this point in the history
…em in the JSON results. Fixes #28.
  • Loading branch information
sesh committed Feb 27, 2024
1 parent bec2618 commit 1e3cd6f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions ready/checks/ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion ready/ready.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = ready-check
version = 1.2.5
version = 1.2.6
author = Brenton Cleeland
author_email = [email protected]
description = A developer-friendly web scanning tool
Expand Down

0 comments on commit 1e3cd6f

Please sign in to comment.