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
0
Merge Requests
0
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
Romain Courteaud
surykatka
Commits
fe0adc9f
Commit
fe0adc9f
authored
Feb 12, 2021
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Status: report missing expected data
parent
2eaeb1f3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
12 deletions
+43
-12
src/surykatka/bot.py
src/surykatka/bot.py
+28
-3
tests/test_bot.py
tests/test_bot.py
+15
-9
No files found.
src/surykatka/bot.py
View file @
fe0adc9f
...
...
@@ -33,6 +33,7 @@ import json
import
email.utils
from
collections
import
OrderedDict
from
.ssl
import
hasValidSSLCertificate
,
reportSslCertificate
import
datetime
__version__
=
"0.5.0"
...
...
@@ -163,15 +164,18 @@ class WebBot:
# Report the bot status
result_dict
[
"bot_status"
]
=
[]
try
:
status
=
reportStatus
(
self
.
_db
).
get
()
bot_
status
=
reportStatus
(
self
.
_db
).
get
()
except
self
.
_db
.
Status
.
DoesNotExist
:
pass
result_dict
[
"bot_status"
].
append
(
{
"text"
:
""
,
"date"
:
rfc822
(
datetime
.
datetime
.
utcnow
())}
)
else
:
result_dict
[
"bot_status"
].
append
(
{
"text"
:
status
.
text
,
"date"
:
rfc822
(
status
.
timestamp
)}
{
"text"
:
bot_status
.
text
,
"date"
:
rfc822
(
bot_
status
.
timestamp
)}
)
# Report the list of DNS server status
checked_resolver_ip_dict
=
{}
query
=
reportNetwork
(
self
.
_db
,
port
=
"53"
,
...
...
@@ -181,6 +185,7 @@ class WebBot:
resolver_ip_list
=
[]
result_dict
[
"dns_server"
]
=
[]
for
network_change
in
query
.
dicts
().
iterator
():
checked_resolver_ip_dict
[
network_change
[
"ip"
]]
=
True
if
network_change
[
"state"
]
==
"open"
:
resolver_ip_list
.
append
(
network_change
[
"ip"
])
result_dict
[
"dns_server"
].
append
(
...
...
@@ -192,6 +197,7 @@ class WebBot:
)
domain_list
=
self
.
calculateFullDomainList
()
checked_domain_dict
=
{}
# Report list of DNS query
query
=
reportDnsQuery
(
self
.
_db
,
...
...
@@ -202,6 +208,7 @@ class WebBot:
server_ip_dict
=
{}
result_dict
[
"dns_query"
]
=
[]
for
dns_change
in
query
.
dicts
().
iterator
():
checked_domain_dict
[
dns_change
[
"domain"
]]
=
True
result_dict
[
"dns_query"
].
append
(
{
"domain"
:
dns_change
[
"domain"
],
...
...
@@ -219,6 +226,24 @@ class WebBot:
if
dns_change
[
"domain"
]
not
in
server_ip_dict
[
server_ip
]:
server_ip_dict
[
server_ip
].
append
(
dns_change
[
"domain"
])
result_dict
[
"missing_data"
]
=
[]
for
resolver_ip
in
self
.
config
[
"NAMESERVER"
].
split
():
if
resolver_ip
not
in
checked_resolver_ip_dict
:
result_dict
[
"missing_data"
].
append
(
{
"text"
:
resolver_ip
,
"date"
:
result_dict
[
"bot_status"
][
0
][
"date"
],
}
)
for
domain
in
domain_list
:
if
domain
not
in
checked_domain_dict
:
result_dict
[
"missing_data"
].
append
(
{
"text"
:
domain
,
"date"
:
result_dict
[
"bot_status"
][
0
][
"date"
],
}
)
# Report the list of CDN status
query
=
reportNetwork
(
self
.
_db
,
...
...
tests/test_bot.py
View file @
fe0adc9f
...
...
@@ -561,10 +561,15 @@ class SurykatkaBotStatusTestCase(unittest.TestCase):
checkSslChange
(
bot
,
[])
checkHttpCodeChange
(
bot
,
[])
assert
len
(
result
[
"bot_status"
])
==
1
assert
result
[
"bot_status"
][
0
][
"text"
]
==
""
assert
result
==
{
"bot_status"
:
[
],
"bot_status"
:
result
[
"bot_status"
],
"dns_server"
:
[],
"dns_query"
:
[],
"missing_data"
:
[
{
"text"
:
resolver_ip
,
"date"
:
result
[
"bot_status"
][
0
][
"date"
]}
],
"http_server"
:
[],
"ssl_certificate"
:
[],
"http_query"
:
[],
...
...
@@ -595,14 +600,15 @@ class SurykatkaBotStatusTestCase(unittest.TestCase):
bot
.
initDB
()
result
=
bot
.
status
()
assert
result
==
{
"bot_status"
:
[],
"dns_server"
:
[],
"dns_query"
:
[],
"http_server"
:
[],
"ssl_certificate"
:
[],
"http_query"
:
[],
}
assert
len
(
result
[
"bot_status"
])
==
1
assert
result
[
"bot_status"
][
0
][
"text"
]
==
""
assert
len
(
result
[
"dns_server"
])
==
0
assert
len
(
result
[
"dns_query"
])
==
0
assert
len
(
result
[
"http_server"
])
==
0
assert
len
(
result
[
"ssl_certificate"
])
==
0
assert
len
(
result
[
"http_query"
])
==
0
# +1 for example.org
assert
len
(
result
[
"missing_data"
])
==
more_than_sqlite_max
*
2
+
1
def
suite
():
...
...
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