Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
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
isgphys
python
Commits
63961535
Commit
63961535
authored
2 years ago
by
Sven Mäder
Browse files
Options
Downloads
Patches
Plain Diff
Remove vuln check, moved to monitoring role
parent
c37dcaf1
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
bin/xymon-vulnerabilities.py
+0
-93
0 additions, 93 deletions
bin/xymon-vulnerabilities.py
with
0 additions
and
93 deletions
bin/xymon-vulnerabilities.py
deleted
100755 → 0
+
0
−
93
View file @
c37dcaf1
#!/usr/bin/env python3
import
os
import
sys
import
re
import
argparse
import
traceback
from
pathlib
import
Path
try
:
import
lib_path
import
lib
except
:
pass
finally
:
import
pyxymon
as
pymon
CHECK_NAME
=
'
vuln
'
CHECK_VERSION
=
2
LIFETIME
=
30
rgx
=
{}
cpu_vulnerabilities_base
=
'
/sys/devices/system/cpu/vulnerabilities/
'
cpu_vulnerabilities
=
[
'
l1tf
'
,
'
mds
'
,
'
meltdown
'
,
'
spec_store_bypass
'
,
'
spectre_v1
'
,
'
spectre_v2
'
]
def
yellow
(
xymon
):
if
xymon
.
color
!=
pymon
.
STATUS_CRITICAL
:
xymon
.
color
=
pymon
.
STATUS_WARNING
def
red
(
xymon
):
xymon
.
color
=
pymon
.
STATUS_CRITICAL
def
run_check
(
xymon
,
args
):
title
=
'
CPU
'
content
=
[]
for
vuln
in
cpu_vulnerabilities
:
icon
=
'
&green
'
vuln_file
=
Path
(
''
.
join
([
cpu_vulnerabilities_base
,
vuln
]))
if
vuln_file
.
is_file
():
with
open
(
str
(
vuln_file
))
as
f
:
lines
=
'
<br>
'
.
join
(
f
.
readlines
()).
rstrip
()
if
lines
.
startswith
(
'
Vulnerable
'
):
icon
=
'
&red
'
if
vuln
in
rgx
and
rgx
[
vuln
].
match
(
lines
):
lines
+=
''
.
join
([
'
(ignore:
"'
,
args
[
vuln
],
'"
)
'
])
else
:
red
(
xymon
)
else
:
lines
=
'
Kernel needs update and host reboot
'
icon
=
'
&yellow
'
yellow
(
xymon
)
content
.
append
(
''
.
join
([
icon
,
'
'
,
vuln
,
'
:
'
,
lines
]))
xymon
.
section
(
title
,
'
<br>
'
.
join
(
content
))
def
main
():
parser
=
argparse
.
ArgumentParser
()
for
name
in
cpu_vulnerabilities
:
parser
.
add_argument
(
''
.
join
([
'
--
'
,
name
]),
dest
=
name
,
type
=
str
,
help
=
'
'
.
join
([
name
,
'
vulnerable but green if regex matches
'
]))
args
=
vars
(
parser
.
parse_args
())
for
key
,
value
in
args
.
items
():
if
args
[
key
]:
rgx
[
key
]
=
re
.
compile
(
value
)
"""
Run xymon check
"""
xymon
=
pymon
.
XymonClient
(
CHECK_NAME
)
check_script
=
os
.
path
.
basename
(
__file__
)
# The default criticity is set to 'pymon.STATUS_OK'
xymon
.
lifetime
=
LIFETIME
xymon
.
title
(
'
Vulnerabilities
'
)
try
:
run_check
(
xymon
,
args
)
except
Exception
as
e
:
xymon
.
color
=
pymon
.
STATUS_WARNING
xymon
.
section
(
'
Exception
'
,
e
)
traceback
.
print_exc
()
xymon
.
footer
(
check_script
,
CHECK_VERSION
)
xymon
.
send
()
if
__name__
==
'
__main__
'
:
main
()
sys
.
exit
(
0
)
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