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
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
Show 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
...
@@ -33,6 +33,7 @@ import json
import
email.utils
import
email.utils
from
collections
import
OrderedDict
from
collections
import
OrderedDict
from
.ssl
import
hasValidSSLCertificate
,
reportSslCertificate
from
.ssl
import
hasValidSSLCertificate
,
reportSslCertificate
import
datetime
__version__
=
"0.5.0"
__version__
=
"0.5.0"
...
@@ -163,15 +164,18 @@ class WebBot:
...
@@ -163,15 +164,18 @@ class WebBot:
# Report the bot status
# Report the bot status
result_dict
[
"bot_status"
]
=
[]
result_dict
[
"bot_status"
]
=
[]
try
:
try
:
status
=
reportStatus
(
self
.
_db
).
get
()
bot_
status
=
reportStatus
(
self
.
_db
).
get
()
except
self
.
_db
.
Status
.
DoesNotExist
:
except
self
.
_db
.
Status
.
DoesNotExist
:
pass
result_dict
[
"bot_status"
].
append
(
{
"text"
:
""
,
"date"
:
rfc822
(
datetime
.
datetime
.
utcnow
())}
)
else
:
else
:
result_dict
[
"bot_status"
].
append
(
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
# Report the list of DNS server status
checked_resolver_ip_dict
=
{}
query
=
reportNetwork
(
query
=
reportNetwork
(
self
.
_db
,
self
.
_db
,
port
=
"53"
,
port
=
"53"
,
...
@@ -181,6 +185,7 @@ class WebBot:
...
@@ -181,6 +185,7 @@ class WebBot:
resolver_ip_list
=
[]
resolver_ip_list
=
[]
result_dict
[
"dns_server"
]
=
[]
result_dict
[
"dns_server"
]
=
[]
for
network_change
in
query
.
dicts
().
iterator
():
for
network_change
in
query
.
dicts
().
iterator
():
checked_resolver_ip_dict
[
network_change
[
"ip"
]]
=
True
if
network_change
[
"state"
]
==
"open"
:
if
network_change
[
"state"
]
==
"open"
:
resolver_ip_list
.
append
(
network_change
[
"ip"
])
resolver_ip_list
.
append
(
network_change
[
"ip"
])
result_dict
[
"dns_server"
].
append
(
result_dict
[
"dns_server"
].
append
(
...
@@ -192,6 +197,7 @@ class WebBot:
...
@@ -192,6 +197,7 @@ class WebBot:
)
)
domain_list
=
self
.
calculateFullDomainList
()
domain_list
=
self
.
calculateFullDomainList
()
checked_domain_dict
=
{}
# Report list of DNS query
# Report list of DNS query
query
=
reportDnsQuery
(
query
=
reportDnsQuery
(
self
.
_db
,
self
.
_db
,
...
@@ -202,6 +208,7 @@ class WebBot:
...
@@ -202,6 +208,7 @@ class WebBot:
server_ip_dict
=
{}
server_ip_dict
=
{}
result_dict
[
"dns_query"
]
=
[]
result_dict
[
"dns_query"
]
=
[]
for
dns_change
in
query
.
dicts
().
iterator
():
for
dns_change
in
query
.
dicts
().
iterator
():
checked_domain_dict
[
dns_change
[
"domain"
]]
=
True
result_dict
[
"dns_query"
].
append
(
result_dict
[
"dns_query"
].
append
(
{
{
"domain"
:
dns_change
[
"domain"
],
"domain"
:
dns_change
[
"domain"
],
...
@@ -219,6 +226,24 @@ class WebBot:
...
@@ -219,6 +226,24 @@ class WebBot:
if
dns_change
[
"domain"
]
not
in
server_ip_dict
[
server_ip
]:
if
dns_change
[
"domain"
]
not
in
server_ip_dict
[
server_ip
]:
server_ip_dict
[
server_ip
].
append
(
dns_change
[
"domain"
])
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
# Report the list of CDN status
query
=
reportNetwork
(
query
=
reportNetwork
(
self
.
_db
,
self
.
_db
,
...
...
tests/test_bot.py
View file @
fe0adc9f
...
@@ -561,10 +561,15 @@ class SurykatkaBotStatusTestCase(unittest.TestCase):
...
@@ -561,10 +561,15 @@ class SurykatkaBotStatusTestCase(unittest.TestCase):
checkSslChange
(
bot
,
[])
checkSslChange
(
bot
,
[])
checkHttpCodeChange
(
bot
,
[])
checkHttpCodeChange
(
bot
,
[])
assert
len
(
result
[
"bot_status"
])
==
1
assert
result
[
"bot_status"
][
0
][
"text"
]
==
""
assert
result
==
{
assert
result
==
{
"bot_status"
:
[
],
"bot_status"
:
result
[
"bot_status"
],
"dns_server"
:
[],
"dns_server"
:
[],
"dns_query"
:
[],
"dns_query"
:
[],
"missing_data"
:
[
{
"text"
:
resolver_ip
,
"date"
:
result
[
"bot_status"
][
0
][
"date"
]}
],
"http_server"
:
[],
"http_server"
:
[],
"ssl_certificate"
:
[],
"ssl_certificate"
:
[],
"http_query"
:
[],
"http_query"
:
[],
...
@@ -595,14 +600,15 @@ class SurykatkaBotStatusTestCase(unittest.TestCase):
...
@@ -595,14 +600,15 @@ class SurykatkaBotStatusTestCase(unittest.TestCase):
bot
.
initDB
()
bot
.
initDB
()
result
=
bot
.
status
()
result
=
bot
.
status
()
assert
result
==
{
assert
len
(
result
[
"bot_status"
])
==
1
"bot_status"
:
[],
assert
result
[
"bot_status"
][
0
][
"text"
]
==
""
"dns_server"
:
[],
assert
len
(
result
[
"dns_server"
])
==
0
"dns_query"
:
[],
assert
len
(
result
[
"dns_query"
])
==
0
"http_server"
:
[],
assert
len
(
result
[
"http_server"
])
==
0
"ssl_certificate"
:
[],
assert
len
(
result
[
"ssl_certificate"
])
==
0
"http_query"
:
[],
assert
len
(
result
[
"http_query"
])
==
0
}
# +1 for example.org
assert
len
(
result
[
"missing_data"
])
==
more_than_sqlite_max
*
2
+
1
def
suite
():
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