Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ansible_lza_ingest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Digital Preservation
ansible_lza_ingest
Commits
004ecbb7
Commit
004ecbb7
authored
3 years ago
by
Jörg Sachse
Browse files
Options
Downloads
Patches
Plain Diff
feat: add Check_MK Service for Mojolicious vulnerability
parent
14f968d1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
templates/usr/lib/check_mk_agent/plugins/check_subapp_ws_status.sh.j2
+37
-21
37 additions, 21 deletions
...r/lib/check_mk_agent/plugins/check_subapp_ws_status.sh.j2
with
37 additions
and
21 deletions
templates/usr/lib/check_mk_agent/plugins/check_subapp_ws_status.sh.j2
+
37
−
21
View file @
004ecbb7
...
...
@@ -9,11 +9,27 @@ set -e
# The webservice uses the HTTP-Statuscodes 200, 204, 404 and 500.
LOCKFILE
=
"/var/lock/check_subapp_ws_status.lock"
itemname
=
'subapp_ws.run_status'
URL
=
"http://
${
HOSTNAME
}
.{{ vault_subapp_webservice_domain | default('localdomain') }}:{{ vault_subapp_webservice_port }}/heartbeat"
itemname_heartbeat
=
'subapp_ws.run_status'
itemname_mainpage
=
'subapp_ws.info_reveal'
URL_HEARTBEAT
=
"http://
${
HOSTNAME
}
.{{ vault_subapp_webservice_domain | default('localdomain') }}:{{ vault_subapp_webservice_port }}/heartbeat"
URL_MAINPAGE
=
"http://
${
HOSTNAME
}
.{{ vault_subapp_webservice_domain | default('localdomain') }}:{{ vault_subapp_webservice_port }}"
# IMPORTANT: Create lockfile using "flock", NOT "touch"!!! It's atomic and doesn't have to be cleared after the script ran.
output
=
$(
flock
${
LOCKFILE
}
curl
--silent
--location
--head
--max-time
10
--write-out
"%{http_code}
\n
"
"
${
URL
}
"
--output
/dev/null
)
output_heartbeat
=
$(
flock
${
LOCKFILE
}
curl
--silent
--location
--head
--max-time
10
--write-out
"%{http_code}
\n
"
"
${
URL_HEARTBEAT
}
"
--output
/dev/null
)
output_mainpage
=
$(
flock
${
LOCKFILE
}
curl
--silent
--max-time
10
"
${
URL_MAINPAGE
}
"
)
# details: https://git.slub-dresden.de/slub-digitalpreservation/submissionapplications4rosetta/-/issues/117
if
[[
${
output_mainpage
}
=
~
"/mojo/noraptor.png"
]]
;
then
status_mainpage
=
0
perf_values_mainpage
=
"-"
statustext_mainpage
=
"Webservice doesn't reveal any confidential information. Great!"
else
status_mainpage
=
2
perf_values_mainpage
=
"-"
statustext_mainpage
=
"Webservice reveals confidential information via Mojolicious. OH NOES!!! Check deployed version."
fi
echo
"
${
status_mainpage
}
${
itemname_mainpage
}
${
perf_values_mainpage
}
${
statustext_mainpage
}
"
#EXEMPLARY OUTPUT:
# HTTP/1.1 204 No Content
...
...
@@ -24,29 +40,29 @@ output=$( flock ${LOCKFILE} curl --silent --location --head --max-time 10 --writ
# 204 ### <===== HERE'S THE HTTP CODE, THE REST IS DISCARDED TO /dev/null
# https://de.wikipedia.org/wiki/HTTP-Statuscode
if
[[
(
${
output
}
-ge
200
)
&&
(
${
output
}
-le
226
)
]]
;
then
if
[[
(
${
output
_heartbeat
}
-ge
200
)
&&
(
${
output
_heartbeat
}
-le
226
)
]]
;
then
# Webservice should return HTTP 204 "No Content" if heartbeat is alive
status
=
0
perf_values
=
"-"
statustext
=
"WebService is available (HTTP
${
output
}
status code)."
elif
[[
(
${
output
}
-ge
400
)
&&
(
${
output
}
-le
451
)
]]
;
then
status
=
2
perf_values
=
"-"
statustext
=
"WebService is NOT available (Client side error HTTP-
${
output
}
)."
elif
[[
(
${
output
}
-ge
500
)
&&
(
${
output
}
-le
511
)
]]
;
then
status
=
2
perf_values
=
"-"
statustext
=
"WebService is NOT available (Server side error HTTP-
${
output
}
)."
status
_heartbeat
=
0
perf_values
_heartbeat
=
"-"
statustext
_heartbeat
=
"WebService is available (HTTP
${
output
_heartbeat
}
status code)."
elif
[[
(
${
output
_heartbeat
}
-ge
400
)
&&
(
${
output
_heartbeat
}
-le
451
)
]]
;
then
status
_heartbeat
=
2
perf_values
_heartbeat
=
"-"
statustext
_heartbeat
=
"WebService is NOT available (Client side error HTTP-
${
output
_heartbeat
}
)."
elif
[[
(
${
output
_heartbeat
}
-ge
500
)
&&
(
${
output
_heartbeat
}
-le
511
)
]]
;
then
status
_heartbeat
=
2
perf_values
_heartbeat
=
"-"
statustext
_heartbeat
=
"WebService is NOT available (Server side error HTTP-
${
output
_heartbeat
}
)."
else
status
=
3
perf_values
=
"-"
status
_heartbeat
=
3
perf_values
_heartbeat
=
"-"
if
[[
!
"
$(
systemctl status webservice_status_SLUBarchiv.service
)
"
=
~
"enabled"
]]
;
then
statustext
=
"SystemD-Unit for Webservice is DISABLED."
statustext
_heartbeat
=
"SystemD-Unit for Webservice is DISABLED."
elif
[[
$(
systemctl status webservice_status_SLUBarchiv.service |
grep
"Active: inactive (dead)"
)
]]
;
then
statustext
=
"SystemD-Unit for Webservice is STOPPED."
statustext
_heartbeat
=
"SystemD-Unit for Webservice is STOPPED."
else
statustext
=
"Couldn't get WebService status (perhaps timeout occurred)."
statustext
_heartbeat
=
"Couldn't get WebService status (perhaps timeout occurred)."
fi
fi
echo
"
${
status
}
${
itemname
}
${
perf_values
}
${
statustext
}
"
echo
"
${
status
_heartbeat
}
${
itemname
_heartbeat
}
${
perf_values
_heartbeat
}
${
statustext
_heartbeat
}
"
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