Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
surykatka
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
surykatka
Commits
55e40205
Commit
55e40205
authored
Mar 01, 2022
by
Romain Courteaud
🐙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
black
parent
d43fcee8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
17 deletions
+36
-17
src/surykatka/bot.py
src/surykatka/bot.py
+4
-1
src/surykatka/ssl.py
src/surykatka/ssl.py
+15
-2
tests/test_bot.py
tests/test_bot.py
+8
-2
tests/test_ssl.py
tests/test_ssl.py
+9
-12
No files found.
src/surykatka/bot.py
View file @
55e40205
...
...
@@ -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
(
...
...
src/surykatka/ssl.py
View file @
55e40205
...
...
@@ -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
:
...
...
tests/test_bot.py
View file @
55e40205
...
...
@@ -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
)],
...
...
tests/test_ssl.py
View file @
55e40205
...
...
@@ -364,18 +364,15 @@ 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
=
(
[
b""
,
{
"notBefore"
:
"Jan 27 04:33:22 2020 GMT"
,
"notAfter"
:
"Jan 27 04:33:22 2020 GMT"
,
"subject"
:
[[(
"commonName"
,
"foo"
)]],
"issuer"
:
[[(
"commonName"
,
"bar"
)]],
},
]
*
2
)
mock_create_context
.
return_value
.
wrap_socket
.
return_value
.
getpeercert
.
side_effect
=
[
b""
,
{
"notBefore"
:
"Jan 27 04:33:22 2020 GMT"
,
"notAfter"
:
"Jan 27 04:33:22 2020 GMT"
,
"subject"
:
[[(
"commonName"
,
"foo"
)]],
"issuer"
:
[[(
"commonName"
,
"bar"
)]],
},
]
*
2
result
=
hasValidSSLCertificate
(
self
.
db
,
ip
,
port
,
hostname
,
status_id
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment