Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
envsetup
Manage
Activity
Members
Plan
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mediaserver
envsetup
Commits
9124eeb0
Commit
9124eeb0
authored
4 years ago
by
Stéphane Diemer
Browse files
Options
Downloads
Patches
Plain Diff
Fixed fail2ban test when no jails are configured | refs
#33101
parent
61be8f6d
No related branches found
Branches containing commit
Tags
mediaserver-9.4.0
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/scripts/test_fail2ban.py
+13
-1
13 additions, 1 deletion
tests/scripts/test_fail2ban.py
with
13 additions
and
1 deletion
tests/scripts/test_fail2ban.py
+
13
−
1
View file @
9124eeb0
...
@@ -93,7 +93,14 @@ def get_jails() -> list:
...
@@ -93,7 +93,14 @@ def get_jails() -> list:
_
,
output
=
exec_cmd
(
_
,
output
=
exec_cmd
(
"
fail2ban-client status | grep
'
Jail list
'"
,
log_output
=
False
"
fail2ban-client status | grep
'
Jail list
'"
,
log_output
=
False
)
)
jails
=
output
.
split
(
"
:
"
)[
1
].
strip
().
replace
(
"
"
,
""
).
split
(
"
,
"
)
if
"
:
"
not
in
output
:
return
list
()
jails_str
=
output
.
split
(
"
:
"
)[
1
].
strip
().
replace
(
"
"
,
""
).
strip
(
"
,
"
)
if
not
jails_str
:
return
list
()
jails
=
jails_str
.
split
(
"
,
"
)
return
jails
return
jails
...
@@ -111,6 +118,9 @@ def check_jail_banned(name: str) -> int:
...
@@ -111,6 +118,9 @@ def check_jail_banned(name: str) -> int:
"
fail2ban-client status {} | grep
'
Currently banned
'"
.
format
(
name
),
"
fail2ban-client status {} | grep
'
Currently banned
'"
.
format
(
name
),
log_output
=
False
,
log_output
=
False
,
)
)
if
"
:
"
not
in
output
:
return
0
banned
=
output
.
split
(
"
:
"
)[
1
].
strip
()
banned
=
output
.
split
(
"
:
"
)[
1
].
strip
()
if
banned
:
if
banned
:
...
@@ -146,6 +156,8 @@ def main():
...
@@ -146,6 +156,8 @@ def main():
banned
=
check_jail_banned
(
jail
)
banned
=
check_jail_banned
(
jail
)
if
banned
>
0
:
if
banned
>
0
:
lg
.
info
(
"
there is {} banned host in {} jail
"
.
format
(
banned
,
jail
))
lg
.
info
(
"
there is {} banned host in {} jail
"
.
format
(
banned
,
jail
))
else
:
lg
.
info
(
"
no banned host in {} jail
"
.
format
(
jail
))
if
errors
:
if
errors
:
exit
(
1
)
exit
(
1
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment