Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aa5305f

Browse files
committed
add tests_passwd
1 parent 50a9326 commit aa5305f

File tree

4 files changed

+97
-50
lines changed

4 files changed

+97
-50
lines changed

.DS_Store

6 KB
Binary file not shown.

default.prf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ plugin=software
148148
plugin=system-integrity
149149
plugin=systemd
150150
plugin=users
151-
plugin=get_passwd
151+
plugin=tests_passwd
152152

153153
#################################################################################
154154
#
@@ -448,4 +448,4 @@ compliance-standards=cis,hipaa,iso27001,pci-dss
448448

449449

450450

451-
#EOF
451+
#EOF

plugin_get_passwd_phase2

Lines changed: 0 additions & 48 deletions
This file was deleted.

plugin_tests_passwd_phase2

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/bin/sh
2+
3+
# -------------------------- CUT THIS SECTION ---------------------------
4+
# This is a template to create a customized plugin
5+
#
6+
# Each plugin should at least have several variables defined with the
7+
# prefix PLUGIN_* (see below)
8+
#
9+
# If you want to learn what functions you can use, check include/functions
10+
#
11+
# -------------------------- CUT THIS SECTION ---------------------------
12+
13+
#########################################################################
14+
#
15+
# * DO NOT REMOVE *
16+
#-----------------------------------------------------
17+
18+
# PLUGIN_CATEGORY=PASS
19+
# PLUGIN_DESC=A test for check if there is password hashes stored in /etc/passwd
20+
# PLUGIN_NAME=tests_passwd
21+
# PLUGIN_REQUIRED_TESTS=
22+
#-----------------------------------------------------
23+
#
24+
#########################################################################
25+
check_password_hashes() {
26+
IFS=$'\n'
27+
passwd_content=$(${AWKBINARY} '{print $0}' /etc/passwd)
28+
LogText "Test:obtain /etc/passwd file content"
29+
for each_passwd in ${passwd_content};
30+
do
31+
IFS=':'
32+
arr=($each_passwd)
33+
if [ "${arr[1]}" != "x" ];then
34+
IFS=$'\n'
35+
Report "sensetive_passwd_hashes[]=$each_passwd"
36+
fi
37+
done
38+
}
39+
#########################################################################
40+
#
41+
# Add custom section to screen output
42+
InsertSection "PASS"
43+
#
44+
#################################################################################
45+
#
46+
# Test : PASS-0001
47+
# Description : We show some lines on the screen
48+
49+
# Register our first custom test
50+
# We consider it to be a lightweight test (no heavy IO, or long searches), no network connection needed
51+
Register --test-no PASS-0001 --weight L --network NO --description "A test for check if there is password hashess stored in /etc/passwd"
52+
if [ ${SKIPTEST} -eq 0 ]; then
53+
# The Display function makes it easy to show something on screen, with colors.
54+
# --indent defines amount of spaces
55+
# --text text to be displayed on screen
56+
# --result text at end of line
57+
# --color color of result text
58+
Display --indent 2 --text "- Checking if there is a password hashes on /etc/passwd file" --result OK --color GREEN
59+
check_password_hashes;
60+
fi
61+
#
62+
#################################################################################
63+
#
64+
65+
# First check if OPENSSLBINARY is known as a prerequisite for this test.
66+
if [ ! -z "${OPENSSLBINARY}" ]; then PREQS_MET="YES"; else PREQS_MET="NO"; fi
67+
Register --test-no CUST-0001 --preqs-met ${PREQS_MET} --weight M --network NO --description "Description of custom test"
68+
if [ ${SKIPTEST} -eq 0 ]; then
69+
FOUNDPROBLEM=0
70+
DIR="/my/path"
71+
LogText "Test: we are going to check if we can find a particular directory (${DIR})"
72+
# Check if a directory exists
73+
if [ -d ${DIR} ]; then
74+
LogText "Result: log entry for easier debugging or additional information"
75+
else
76+
FOUNDPROBLEM=1
77+
LogText "Result: directory ${DIR} was not found!"
78+
ReportWarning "${TEST_NO}" "This is a test warning line" "${DIR}" "text:Create directory ${DIR}"
79+
fi
80+
81+
if [ ${FOUNDPROBLEM} -eq 0 ]; then
82+
Display --indent 2 --text "- Checking if everything is OK..." --result OK --color GREEN
83+
else
84+
Display --indent 2 --text "- Checking if everything is OK..." --result WARNING --color RED
85+
ReportSuggestion ${TEST_NO} "This is a suggestion"
86+
fi
87+
fi
88+
#
89+
#################################################################################
90+
#
91+
92+
# Wait for keypress (unless --quick is being used)
93+
WaitForKeyPress
94+
95+
#EOF

0 commit comments

Comments
 (0)