Commit 55e40205 authored by Romain Courteaud's avatar Romain Courteaud

black

parent d43fcee8
......@@ -671,7 +671,10 @@ class WebBot:
result_dict["ssl_certificate"] = []
for ip_, domain_list_ in server_ip_dict.items():
query = reportSslCertificate(
self._db, ip=ip_, port=443, hostname=domain_list_,
self._db,
ip=ip_,
port=443,
hostname=domain_list_,
)
for ssl_certificate in query.dicts().iterator():
result_dict["ssl_certificate"].append(
......
......@@ -31,7 +31,11 @@ TIMEOUT = 2
def reportSslCertificate(db, ip=None, port=None, hostname=None):
query = (
db.SslChange.select(db.SslChange)
.group_by(db.SslChange.ip, db.SslChange.port, db.SslChange.hostname,)
.group_by(
db.SslChange.ip,
db.SslChange.port,
db.SslChange.hostname,
)
.having(db.SslChange.status_id == fn.MAX(db.SslChange.status_id))
)
......@@ -122,7 +126,16 @@ def hasValidSSLCertificate(db, ip, port, hostname, status_id, timeout=TIMEOUT):
# pyOpenSSL is one way to fix this
# https://stackoverflow.com/a/52298575
logSslCertificate(
db, ip, port, hostname, None, None, None, None, None, status_id,
db,
ip,
port,
hostname,
None,
None,
None,
None,
None,
status_id,
)
return False
except:
......
......@@ -492,8 +492,14 @@ class SurykatkaBotTestCase(unittest.TestCase):
)
mock_request.return_value.headers = {"Etag": "foobar"}
mock_query.side_effect = [
[MockAnswerA("1.2.3.4"), MockAnswerA("1.2.3.5"),],
[MockAnswerA("1.2.3.4"), MockAnswerA("1.2.3.5"),],
[
MockAnswerA("1.2.3.4"),
MockAnswerA("1.2.3.5"),
],
[
MockAnswerA("1.2.3.4"),
MockAnswerA("1.2.3.5"),
],
[MockAnswerMX("")],
[MockAnswerTXT("")],
[MockAnswerPTR(domain)],
......
......@@ -364,8 +364,7 @@ class SurykatkaSslTestCase(unittest.TestCase):
) as mock_socket, mock.patch(
"surykatka.ssl.ssl.create_default_context"
) as mock_create_context:
mock_create_context.return_value.wrap_socket.return_value.getpeercert.side_effect = (
[
mock_create_context.return_value.wrap_socket.return_value.getpeercert.side_effect = [
b"",
{
"notBefore": "Jan 27 04:33:22 2020 GMT",
......@@ -373,9 +372,7 @@ class SurykatkaSslTestCase(unittest.TestCase):
"subject": [[("commonName", "foo")]],
"issuer": [[("commonName", "bar")]],
},
]
* 2
)
] * 2
result = hasValidSSLCertificate(
self.db, ip, port, hostname, status_id
)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment