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
e5e0512b
Commit
e5e0512b
authored
Dec 01, 2021
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add warning section to report various wrong configuration
parent
bb6fb890
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
6 deletions
+26
-6
src/surykatka/bot.py
src/surykatka/bot.py
+23
-5
src/surykatka/cli.py
src/surykatka/cli.py
+1
-1
tests/test_bot.py
tests/test_bot.py
+2
-0
No files found.
src/surykatka/bot.py
View file @
e5e0512b
...
...
@@ -67,7 +67,11 @@ def rfc822(date):
def
filterWarningStatus
(
status_dict
,
interval
,
not_critical_url_list
,
warning_period_duration
status_dict
,
interval
,
not_critical_url_list
,
warning_period_duration
,
keep_warning
=
True
,
):
now
=
datetime
.
datetime
.
utcnow
()
if
interval
<
60
:
...
...
@@ -82,6 +86,9 @@ def filterWarningStatus(
if
not
status_dict
[
"bot_status"
]:
del
status_dict
[
"bot_status"
]
if
(
not
status_dict
[
"warning"
])
or
(
not
keep_warning
):
del
status_dict
[
"warning"
]
for
i
in
range
(
len
(
status_dict
[
"whois"
])
-
1
,
-
1
,
-
1
):
expiration_date
=
status_dict
[
"whois"
][
i
][
"expiration_date"
]
if
(
expiration_date
is
None
)
or
(
...
...
@@ -484,6 +491,7 @@ class WebBot:
)
server_ip_dict
=
{}
result_dict
[
"dns_query"
]
=
[]
result_dict
[
"warning"
]
=
[]
for
dns_change
in
query
.
dicts
().
iterator
():
if
dns_change
[
"domain"
]
not
in
checked_domain_dict
:
...
...
@@ -713,22 +721,31 @@ class WebBot:
def
run
(
self
,
mode
):
status_dict
=
None
if
mode
not
in
[
"crawl"
,
"pack"
,
"status"
,
"warning"
]:
if
mode
not
in
[
"crawl"
,
"pack"
,
"status"
,
"warning"
,
"error"
]:
raise
NotImplementedError
(
"Unexpected mode: %s"
%
mode
)
if
self
.
config
[
"SQLITE"
]
==
":memory:"
:
# Crawl/report are mandatory when using memory
if
mode
==
"warning"
:
mode
=
"wallwarning"
elif
mode
==
"error"
:
mode
=
"wallerror"
else
:
mode
=
"all"
self
.
initDB
()
try
:
if
mode
in
[
"crawl"
,
"wallwarning"
,
"all"
]:
if
mode
in
[
"crawl"
,
"wallwarning"
,
"
wallerror"
,
"
all"
]:
self
.
crawl
()
if
mode
in
[
"status"
,
"all"
,
"wallwarning"
,
"warning"
]:
if
mode
in
[
"status"
,
"all"
,
"wallwarning"
,
"warning"
,
"wallerror"
,
"error"
,
]:
status_dict
=
self
.
status
()
if
mode
==
"pack"
:
self
.
pack
()
...
...
@@ -739,12 +756,13 @@ class WebBot:
self
.
closeDB
()
if
status_dict
is
not
None
:
if
mode
in
(
"wallwarning"
,
"warning"
):
if
mode
in
(
"wallwarning"
,
"warning"
,
"wallerror"
,
"error"
):
filterWarningStatus
(
status_dict
,
int
(
self
.
config
.
get
(
"INTERVAL"
)),
self
.
calculateNotCriticalUrlList
(),
float
(
self
.
config
[
"WARNING_PERIOD"
]),
keep_warning
=
(
"warning"
in
mode
),
)
if
self
.
config
[
"FORMAT"
]
==
"json"
:
status_output
=
json
.
dumps
(
status_dict
)
...
...
src/surykatka/cli.py
View file @
e5e0512b
...
...
@@ -29,7 +29,7 @@ from .bot import create_bot
help
=
"The bot operation mode to run."
,
show_default
=
True
,
default
=
"status"
,
type
=
click
.
Choice
([
"crawl"
,
"pack"
,
"status"
,
"warning"
]),
type
=
click
.
Choice
([
"crawl"
,
"pack"
,
"status"
,
"warning"
,
"error"
]),
)
@
click
.
option
(
"--sqlite"
,
"-s"
,
help
=
"The path of the sqlite DB. (default: :memory:)"
...
...
tests/test_bot.py
View file @
e5e0512b
...
...
@@ -974,6 +974,7 @@ class SurykatkaBotStatusTestCase(unittest.TestCase):
"tcp_server"
:
[],
"ssl_certificate"
:
[],
"http_query"
:
[],
"warning"
:
[],
}
def
test_status_sqliteMaxVariableNumber
(
self
):
...
...
@@ -1009,6 +1010,7 @@ class SurykatkaBotStatusTestCase(unittest.TestCase):
assert
len
(
result
[
"tcp_server"
])
==
0
assert
len
(
result
[
"ssl_certificate"
])
==
0
assert
len
(
result
[
"http_query"
])
==
0
assert
len
(
result
[
"warning"
])
==
0
# +1 for example.org
assert
len
(
result
[
"missing_data"
])
==
more_than_sqlite_max
*
2
+
1
...
...
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