Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
UserConfig
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jiří Kalvoda
UserConfig
Commits
6f794bc5
Commit
6f794bc5
authored
1 month ago
by
Jiří Kalvoda
Browse files
Options
Downloads
Patches
Plain Diff
security_check
parent
e51424d2
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
security/security_check.py
+56
-0
56 additions, 0 deletions
security/security_check.py
with
56 additions
and
0 deletions
security/security_check.py
0 → 100755
+
56
−
0
View file @
6f794bc5
#!/bin/env python3
import
subprocess
import
re
import
datetime
td
=
datetime
.
timedelta
VERDICT_WRONG
=
2
VERDICT_WARN
=
1
VERDICT_GOOD
=
0
inf
=
float
(
'
inf
'
)
def
format_timedelta
(
td
:
datetime
.
timedelta
)
->
str
:
seconds
=
int
(
td
.
total_seconds
())
days
=
seconds
//
86400
# 1 day = 86400 seconds
hours
=
seconds
//
3600
# 1 hour = 3600 seconds
minutes
=
seconds
//
60
# 1 minute = 60 seconds
if
days
>
3
:
return
f
"
{
days
}
days
"
if
hours
>
3
:
return
f
"
{
hours
}
hours
"
if
minutes
>
5
:
return
f
"
{
minutes
}
minute
"
return
f
"
{
seconds
}
second
"
def
run
(
*
args
):
p
=
subprocess
.
run
(
args
,
check
=
True
,
stdout
=
subprocess
.
PIPE
)
return
p
.
stdout
.
decode
()
def
verdict
(
val
,
verdict
=
VERDICT_WRONG
,
good
=
None
,
warn
=
None
,
format
=
str
):
global
total_verdict
if
warn
:
if
warn
[
0
]
<=
val
<=
warn
[
1
]:
verdict
=
VERDICT_WARN
if
good
:
if
good
[
0
]
<=
val
<=
good
[
1
]:
verdict
=
VERDICT_GOOD
total_verdict
=
max
(
total_verdict
,
verdict
)
return
f
"
\033
[1;
{
{
VERDICT_GOOD
:
32
,
VERDICT_WARN
:
33
,
VERDICT_WRONG
:
31
}
[
verdict
]
}
m
{
format
(
val
)
}
\033
[0m
"
#print(df('/', ssh=['ssh', 'root@radeu1.meteopress.cz']))
#print(df('/', ssh=['ssh', 'root@radeu1.meteopress.cz'], inodes=True))
total_verdict
=
0
print
(
"
NETWORK
"
)
print
(
"
========
"
)
nft_data
=
run
(
"
nft
"
,
"
list
"
,
"
ruleset
"
)
print
(
f
"
NFT length:
{
verdict
(
len
(
nft_data
),
good
=
(
100
,
inf
))
}
"
)
print
(
"
USERS
"
)
print
(
"
=====
"
)
with
open
(
"
/etc/shaddow
"
)
nft_data
=
run
(
"
nft
"
,
"
list
"
,
"
ruleset
"
)
print
(
f
"
NFT length:
{
verdict
(
len
(
nft_data
),
good
=
(
100
,
inf
))
}
"
)
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