mirror of
https://github.com/ovh/debian-cis.git
synced 2025-07-16 13:52:17 +02:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
c75244e3b2 | |||
de295b3a77 | |||
693487c3a5 | |||
670c8c62f5 | |||
0eb2e2ffde | |||
d6c334182e | |||
2188577fc9 | |||
0f59f73297 | |||
f888ce0d39 |
2
.github/workflows/pre-release.yml
vendored
2
.github/workflows/pre-release.yml
vendored
@ -34,7 +34,7 @@ jobs:
|
|||||||
# GENERATE CHANGELOG CORRESPONDING TO COMMIT BETWEEN HEAD AND COMPUTED LAST TAG
|
# GENERATE CHANGELOG CORRESPONDING TO COMMIT BETWEEN HEAD AND COMPUTED LAST TAG
|
||||||
- name: Generate changelog
|
- name: Generate changelog
|
||||||
id: changelog
|
id: changelog
|
||||||
uses: metcalfc/changelog-generator@v4.1.0
|
uses: metcalfc/changelog-generator@v4.2.0
|
||||||
with:
|
with:
|
||||||
myToken: ${{ secrets.GITHUB_TOKEN }}
|
myToken: ${{ secrets.GITHUB_TOKEN }}
|
||||||
head-ref: ${{ github.sha }}
|
head-ref: ${{ github.sha }}
|
||||||
|
@ -10,7 +10,7 @@ jobs:
|
|||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Run the sh-checker
|
- name: Run the sh-checker
|
||||||
uses: luizm/action-sh-checker@v0.7.0
|
uses: luizm/action-sh-checker@v0.8.0
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Optional if sh_checker_comment is false.
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Optional if sh_checker_comment is false.
|
||||||
SHFMT_OPTS: -l -i 4 -w # Optional: pass arguments to shfmt.
|
SHFMT_OPTS: -l -i 4 -w # Optional: pass arguments to shfmt.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# :lock: CIS Debian 10/11 Hardening
|
# :lock: CIS Debian 10/11/12 Hardening
|
||||||
|
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
|
@ -15,20 +15,18 @@ set -u # One variable unset, it's over
|
|||||||
# shellcheck disable=2034
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
# shellcheck disable=2034
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Check that any password that may exist in /etc/shadow is yescrypt (or SHA512 for debian 10) hashed and salted"
|
DESCRIPTION="Check that the algorithm declared in PAM for password changes is sha512 (or yescrypt for Debian 11+)"
|
||||||
|
|
||||||
CONF_FILE="/etc/pam.d/common-password"
|
CONF_FILE="/etc/pam.d/common-password"
|
||||||
CONF_LINE="^\s*password\s.+\s+pam_unix\.so\s+.*sha512"
|
# CONF_LINE is defined in _set_vars_jit below
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled / audit mode
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
audit() {
|
audit() {
|
||||||
|
_set_vars_jit
|
||||||
# Check conf file for default SHA512 hash
|
# Check conf file for default SHA512 hash
|
||||||
if $SUDO_CMD [ ! -r "$CONF_FILE" ]; then
|
if $SUDO_CMD [ ! -r "$CONF_FILE" ]; then
|
||||||
crit "$CONF_FILE is not readable"
|
crit "$CONF_FILE is not readable"
|
||||||
else
|
else
|
||||||
if [ "$DEB_MAJ_VER" -ge "11" ]; then
|
|
||||||
CONF_LINE="^\s*password\s.+\s+pam_unix\.so\s+.*yescrypt" # https://github.com/ovh/debian-cis/issues/158
|
|
||||||
fi
|
|
||||||
# shellcheck disable=SC2001
|
# shellcheck disable=SC2001
|
||||||
does_pattern_exist_in_file "$CONF_FILE" "$(sed 's/ /[[:space:]]+/g' <<<"$CONF_LINE")"
|
does_pattern_exist_in_file "$CONF_FILE" "$(sed 's/ /[[:space:]]+/g' <<<"$CONF_LINE")"
|
||||||
if [ "$FNRET" = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
@ -41,6 +39,7 @@ audit() {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
|
_set_vars_jit
|
||||||
if $SUDO_CMD [ ! -r "$CONF_FILE" ]; then
|
if $SUDO_CMD [ ! -r "$CONF_FILE" ]; then
|
||||||
crit "$CONF_FILE is not readable"
|
crit "$CONF_FILE is not readable"
|
||||||
else
|
else
|
||||||
@ -64,6 +63,18 @@ check_config() {
|
|||||||
:
|
:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# As we use DEB_MAJ_VER, which is set by constants.sh, itself sourced by main.sh below,
|
||||||
|
# We need to call this in the subs called by main.sh when it is sourced, otherwise it would
|
||||||
|
# either be too soon (DEB_MAJ_VER not defined) or too late (test has already been run)
|
||||||
|
_set_vars_jit() {
|
||||||
|
if [ "$DEB_MAJ_VER" -ge "11" ]; then
|
||||||
|
CONF_LINE="^\s*password\s.+\s+pam_unix\.so\s+.*(sha512|yescrypt)" # https://github.com/ovh/debian-cis/issues/158
|
||||||
|
else
|
||||||
|
CONF_LINE="^\s*password\s.+\s+pam_unix\.so\s+.*sha512"
|
||||||
|
fi
|
||||||
|
unset -f _set_vars_jit
|
||||||
|
}
|
||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
|
@ -1,98 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# run-shellcheck
|
|
||||||
#
|
|
||||||
# Legacy CIS Debian Hardening
|
|
||||||
#
|
|
||||||
|
|
||||||
#
|
|
||||||
# 99.5.2.8 Check UsePrivilegeSeparation set to sandbox.
|
|
||||||
#
|
|
||||||
|
|
||||||
set -e # One error, it's over
|
|
||||||
set -u # One variable unset, it's over
|
|
||||||
|
|
||||||
# shellcheck disable=2034
|
|
||||||
HARDENING_LEVEL=2
|
|
||||||
# shellcheck disable=2034
|
|
||||||
DESCRIPTION="Check UsePrivilegeSeparation set to sandbox."
|
|
||||||
|
|
||||||
PACKAGE='openssh-server'
|
|
||||||
OPTIONS='UsePrivilegeSeparation=sandbox'
|
|
||||||
FILE='/etc/ssh/sshd_config'
|
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled / audit mode
|
|
||||||
audit() {
|
|
||||||
is_pkg_installed "$PACKAGE"
|
|
||||||
if [ "$FNRET" != 0 ]; then
|
|
||||||
ok "$PACKAGE is not installed!"
|
|
||||||
else
|
|
||||||
ok "$PACKAGE is installed"
|
|
||||||
for SSH_OPTION in $OPTIONS; do
|
|
||||||
SSH_PARAM=$(echo "$SSH_OPTION" | cut -d= -f 1)
|
|
||||||
SSH_VALUE=$(echo "$SSH_OPTION" | cut -d= -f 2)
|
|
||||||
PATTERN="^${SSH_PARAM}[[:space:]]*$SSH_VALUE"
|
|
||||||
does_pattern_exist_in_file_nocase "$FILE" "$PATTERN"
|
|
||||||
if [ "$FNRET" = 0 ]; then
|
|
||||||
ok "$PATTERN is present in $FILE"
|
|
||||||
else
|
|
||||||
crit "$PATTERN is not present in $FILE"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
|
||||||
apply() {
|
|
||||||
is_pkg_installed "$PACKAGE"
|
|
||||||
if [ "$FNRET" = 0 ]; then
|
|
||||||
ok "$PACKAGE is installed"
|
|
||||||
else
|
|
||||||
crit "$PACKAGE is absent, installing it"
|
|
||||||
apt_install "$PACKAGE"
|
|
||||||
fi
|
|
||||||
for SSH_OPTION in $OPTIONS; do
|
|
||||||
SSH_PARAM=$(echo "$SSH_OPTION" | cut -d= -f 1)
|
|
||||||
SSH_VALUE=$(echo "$SSH_OPTION" | cut -d= -f 2)
|
|
||||||
PATTERN="^${SSH_PARAM}[[:space:]]*$SSH_VALUE"
|
|
||||||
does_pattern_exist_in_file_nocase "$FILE" "$PATTERN"
|
|
||||||
if [ "$FNRET" = 0 ]; then
|
|
||||||
ok "$PATTERN is present in $FILE"
|
|
||||||
else
|
|
||||||
warn "$PATTERN is not present in $FILE, adding it"
|
|
||||||
does_pattern_exist_in_file_nocase "$FILE" "^${SSH_PARAM}"
|
|
||||||
if [ "$FNRET" != 0 ]; then
|
|
||||||
add_end_of_file "$FILE" "$SSH_PARAM $SSH_VALUE"
|
|
||||||
else
|
|
||||||
info "Parameter $SSH_PARAM is present but with the wrong value -- Fixing"
|
|
||||||
replace_in_file "$FILE" "^${SSH_PARAM}[[:space:]]*.*" "$SSH_PARAM $SSH_VALUE"
|
|
||||||
fi
|
|
||||||
/etc/init.d/ssh reload >/dev/null 2>&1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# This function will check config parameters required
|
|
||||||
check_config() {
|
|
||||||
:
|
|
||||||
}
|
|
||||||
|
|
||||||
# Source Root Dir Parameter
|
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
|
||||||
# shellcheck source=../../debian/default
|
|
||||||
. /etc/default/cis-hardening
|
|
||||||
fi
|
|
||||||
if [ -z "$CIS_LIB_DIR" ]; then
|
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
|
||||||
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
|
||||||
exit 128
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
|
||||||
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
|
||||||
# shellcheck source=../../lib/main.sh
|
|
||||||
. "${CIS_LIB_DIR}"/main.sh
|
|
||||||
else
|
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_LIB_DIR in /etc/default/cis-hardening"
|
|
||||||
exit 128
|
|
||||||
fi
|
|
@ -6,7 +6,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
# 99.5.4.5.1 Check that any password that will be created will be SHA512 hashed and salted
|
# 99.5.4.5.1 Check that any password that will be created will use sha512crypt (or yescrypt for Debian 11+)
|
||||||
#
|
#
|
||||||
|
|
||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
@ -15,31 +15,33 @@ set -u # One variable unset, it's over
|
|||||||
# shellcheck disable=2034
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
# shellcheck disable=2034
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Check that any password that will be created will be SHA512 hashed and salted"
|
DESCRIPTION="Check that any password that will be created will use sha512crypt (or yescrypt for Debian 11+)"
|
||||||
|
|
||||||
CONF_FILE="/etc/login.defs"
|
CONF_FILE="/etc/login.defs"
|
||||||
CONF_LINE="ENCRYPT_METHOD SHA512"
|
# CONF_LINE and CONF_LINE_REGEX are defined in _set_vars_jit below
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled / audit mode
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
audit() {
|
audit() {
|
||||||
|
_set_vars_jit
|
||||||
# Check conf file for default SHA512 hash
|
# Check conf file for default SHA512 hash
|
||||||
if $SUDO_CMD [ ! -r "$CONF_FILE" ]; then
|
if $SUDO_CMD [ ! -r "$CONF_FILE" ]; then
|
||||||
crit "$CONF_FILE is not readable"
|
crit "$CONF_FILE is not readable"
|
||||||
else
|
else
|
||||||
does_pattern_exist_in_file "$CONF_FILE" "^ *${CONF_LINE/ /[[:space:]]+}"
|
does_pattern_exist_in_file "$CONF_FILE" "^ *${CONF_LINE_REGEX/ /[[:space:]]+}"
|
||||||
if [ "$FNRET" = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$CONF_LINE is present in $CONF_FILE"
|
ok "$CONF_LINE_REGEX is present in $CONF_FILE"
|
||||||
else
|
else
|
||||||
crit "$CONF_LINE is not present in $CONF_FILE"
|
crit "$CONF_LINE_REGEX is not present in $CONF_FILE"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
does_pattern_exist_in_file "$CONF_FILE" "^ *${CONF_LINE/ /[[:space:]]+}"
|
_set_vars_jit
|
||||||
|
does_pattern_exist_in_file "$CONF_FILE" "^ *${CONF_LINE_REGEX/ /[[:space:]]+}"
|
||||||
if [ "$FNRET" = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$CONF_LINE is present in $CONF_FILE"
|
ok "$CONF_LINE_REGEX is present in $CONF_FILE"
|
||||||
else
|
else
|
||||||
warn "$CONF_LINE is not present in $CONF_FILE, adding it"
|
warn "$CONF_LINE is not present in $CONF_FILE, adding it"
|
||||||
does_pattern_exist_in_file "$CONF_FILE" "^$(echo "$CONF_LINE" | cut -d ' ' -f1)"
|
does_pattern_exist_in_file "$CONF_FILE" "^$(echo "$CONF_LINE" | cut -d ' ' -f1)"
|
||||||
@ -57,6 +59,20 @@ check_config() {
|
|||||||
:
|
:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# As we use DEB_MAJ_VER, which is set by constants.sh, itself sourced by main.sh below,
|
||||||
|
# We need to call this in the subs called by main.sh when it is sourced, otherwise it would
|
||||||
|
# either be too soon (DEB_MAJ_VER not defined) or too late (test has already been run)
|
||||||
|
_set_vars_jit() {
|
||||||
|
if [ "$DEB_MAJ_VER" -ge "11" ]; then
|
||||||
|
CONF_LINE_REGEX="ENCRYPT_METHOD (SHA512|yescrypt|YESCRYPT)"
|
||||||
|
CONF_LINE="ENCRYPT_METHOD YESCRYPT"
|
||||||
|
else
|
||||||
|
CONF_LINE_REGEX="ENCRYPT_METHOD SHA512"
|
||||||
|
CONF_LINE="ENCRYPT_METHOD SHA512"
|
||||||
|
fi
|
||||||
|
unset -f _set_vars_jit
|
||||||
|
}
|
||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
if [ -r /etc/default/cis-hardening ]; then
|
if [ -r /etc/default/cis-hardening ]; then
|
||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
#
|
#
|
||||||
# 99.5.4.5.2 Check that any password that may exist in /etc/shadow is SHA512 hashed and salted
|
# 99.5.4.5.2 Check that passwords in /etc/shadow are sha512crypt (or yescrypt for Debian 11+) hashed and salted
|
||||||
#
|
#
|
||||||
|
|
||||||
set -e # One error, it's over
|
set -e # One error, it's over
|
||||||
@ -15,7 +15,7 @@ set -u # One variable unset, it's over
|
|||||||
# shellcheck disable=2034
|
# shellcheck disable=2034
|
||||||
HARDENING_LEVEL=2
|
HARDENING_LEVEL=2
|
||||||
# shellcheck disable=2034
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Check that any password that may exist in /etc/shadow is SHA512 hashed and salted"
|
DESCRIPTION="Check that passwords in /etc/shadow are sha512crypt (or yescrypt for Debian 11+) hashed and salted"
|
||||||
FILE="/etc/shadow"
|
FILE="/etc/shadow"
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled / audit mode
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
@ -36,13 +36,21 @@ audit() {
|
|||||||
elif [[ $passwd =~ ^!.*$ ]]; then
|
elif [[ $passwd =~ ^!.*$ ]]; then
|
||||||
pw_found+="$user "
|
pw_found+="$user "
|
||||||
ok "User $user has a disabled password."
|
ok "User $user has a disabled password."
|
||||||
# Check password against $6$<salt>$<encrypted>, see `man 3 crypt`
|
# yescrypt: Check password against $y$<salt>$<base64>
|
||||||
|
elif [ "$DEB_MAJ_VER" -ge "11" ] && [[ $passwd =~ ^\$y\$[./A-Za-z0-9]+\$[./A-Za-z0-9]{,86}\$[./A-Za-z0-9]{43} ]]; then
|
||||||
|
pw_found+="$user "
|
||||||
|
ok "User $user has suitable yescrypt hashed password."
|
||||||
|
# sha512: Check password against $6$<salt>$<base64>, see `man 3 crypt`
|
||||||
elif [[ $passwd =~ ^\$6(\$rounds=[0-9]+)?\$[a-zA-Z0-9./]{2,16}\$[a-zA-Z0-9./]{86}$ ]]; then
|
elif [[ $passwd =~ ^\$6(\$rounds=[0-9]+)?\$[a-zA-Z0-9./]{2,16}\$[a-zA-Z0-9./]{86}$ ]]; then
|
||||||
pw_found+="$user "
|
pw_found+="$user "
|
||||||
ok "User $user has suitable SHA512 hashed password."
|
ok "User $user has suitable sha512crypt hashed password."
|
||||||
else
|
else
|
||||||
pw_found+="$user "
|
pw_found+="$user "
|
||||||
crit "User $user has a password that is not SHA512 hashed."
|
if [ "$DEB_MAJ_VER" -ge "11" ]; then
|
||||||
|
crit "User $user has a password that is not sha512crypt nor yescrypt hashed."
|
||||||
|
else
|
||||||
|
crit "User $user has a password that is not sha512crypt hashed."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [[ -z "$users_reviewed" ]]; then
|
if [[ -z "$users_reviewed" ]]; then
|
||||||
|
17
debian/changelog
vendored
17
debian/changelog
vendored
@ -1,3 +1,20 @@
|
|||||||
|
cis-hardening (4.1-3) unstable; urgency=medium
|
||||||
|
|
||||||
|
* Adapt all scripts to yescrypt (#216)
|
||||||
|
* build(deps): bump metcalfc/changelog-generator from 4.1.0 to 4.2.0 (#214)
|
||||||
|
* fix: clean obsolete check 99.5.4.5.1, now handled by 5.3.4 (#215)
|
||||||
|
* enh: remove ssh system sandbox check (#213)
|
||||||
|
* build(deps): bump luizm/action-sh-checker from 0.7.0 to 0.8.0 (#210)
|
||||||
|
* feat: advertise Debian 12 compatibility in readme
|
||||||
|
|
||||||
|
-- Thibault Dewailly <thibault.dewailly@ovhcloud.com> Tue, 28 Nov 2023 10:33:04 +0000
|
||||||
|
|
||||||
|
cis-hardening (4.1-2) unstable; urgency=medium
|
||||||
|
|
||||||
|
* fix: root_dir is still /opt/cis-hardening for the moment (#208)
|
||||||
|
|
||||||
|
-- Thibault Dewailly <thibault.dewailly@ovhcloud.com> Mon, 02 Oct 2023 13:14:58 +0000
|
||||||
|
|
||||||
cis-hardening (4.1-1) unstable; urgency=medium
|
cis-hardening (4.1-1) unstable; urgency=medium
|
||||||
|
|
||||||
* fix: debian12 functional test pass is now mandatory (#207)
|
* fix: debian12 functional test pass is now mandatory (#207)
|
||||||
|
8
debian/default
vendored
8
debian/default
vendored
@ -1,7 +1,7 @@
|
|||||||
# # Default file for CIS Debian hardening scripts
|
# # Default file for CIS Debian hardening scripts
|
||||||
|
|
||||||
# Define here root directory for CIS debian hardening scripts
|
# Define here root directory for CIS debian hardening scripts
|
||||||
CIS_LIB_DIR='/opt/debian-cis/lib'
|
CIS_LIB_DIR='/opt/cis-hardening/lib'
|
||||||
CIS_CHECKS_DIR="/opt/debian-cis/bin/hardening"
|
CIS_CHECKS_DIR="/opt/cis-hardening/bin/hardening"
|
||||||
CIS_CONF_DIR='/opt/debian-cis/etc'
|
CIS_CONF_DIR='/opt/cis-hardening/etc'
|
||||||
CIS_TMP_DIR='/opt/debian-cis/tmp'
|
CIS_TMP_DIR='/opt/cis-hardening/tmp'
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
test_audit() {
|
test_audit() {
|
||||||
describe Running on blank host
|
describe Running on blank host
|
||||||
register_test retvalshouldbe 0
|
register_test retvalshouldbe 0
|
||||||
register_test contain REGEX "[ OK ] .*(sha512|yescrypt) is present in /etc/pam.d/common-password"
|
register_test contain "is present in /etc/pam.d/common-password"
|
||||||
# shellcheck disable=2154
|
# shellcheck disable=2154
|
||||||
run blank "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
|
run blank "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
|
||||||
}
|
}
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
# shellcheck shell=bash
|
|
||||||
# run-shellcheck
|
|
||||||
test_audit() {
|
|
||||||
describe Running on blank host
|
|
||||||
register_test retvalshouldbe 1
|
|
||||||
register_test contain "openssh-server is installed"
|
|
||||||
# shellcheck disable=2154
|
|
||||||
run blank "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
|
|
||||||
|
|
||||||
describe Correcting situation
|
|
||||||
# `apply` performs a service reload after each change in the config file
|
|
||||||
# the service needs to be started for the reload to succeed
|
|
||||||
service ssh start
|
|
||||||
# if the audit script provides "apply" option, enable and run it
|
|
||||||
sed -i 's/audit/enabled/' "${CIS_CONF_DIR}/conf.d/${script}.cfg"
|
|
||||||
"${CIS_CHECKS_DIR}/${script}.sh" || true
|
|
||||||
|
|
||||||
describe Checking resolved state
|
|
||||||
register_test retvalshouldbe 0
|
|
||||||
register_test contain "[ OK ] ^UsePrivilegeSeparation[[:space:]]*sandbox is present in /etc/ssh/sshd_config"
|
|
||||||
run resolved "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
|
|
||||||
}
|
|
@ -3,7 +3,7 @@
|
|||||||
test_audit() {
|
test_audit() {
|
||||||
describe Running on blank host
|
describe Running on blank host
|
||||||
register_test retvalshouldbe 0
|
register_test retvalshouldbe 0
|
||||||
register_test contain "ENCRYPT_METHOD SHA512 is present in /etc/login.defs"
|
register_test contain "is present in /etc/login.defs"
|
||||||
# shellcheck disable=2154
|
# shellcheck disable=2154
|
||||||
run blank "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
|
run blank "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ test_audit() {
|
|||||||
describe Line as comment
|
describe Line as comment
|
||||||
sed -i 's/\(ENCRYPT_METHOD SHA512\)/# \1/' /etc/login.defs
|
sed -i 's/\(ENCRYPT_METHOD SHA512\)/# \1/' /etc/login.defs
|
||||||
register_test retvalshouldbe 1
|
register_test retvalshouldbe 1
|
||||||
register_test contain "SHA512 is not present"
|
register_test contain "is not present in /etc/login.defs"
|
||||||
run commented "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
|
run commented "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
|
||||||
|
|
||||||
rm /etc/login.defs
|
rm /etc/login.defs
|
||||||
@ -24,7 +24,7 @@ test_audit() {
|
|||||||
sed -ir 's/ENCRYPT_METHOD[[:space:]]\+SHA512/ENCRYPT_METHOD MD5/' /etc/login.defs
|
sed -ir 's/ENCRYPT_METHOD[[:space:]]\+SHA512/ENCRYPT_METHOD MD5/' /etc/login.defs
|
||||||
describe Fail: wrong hash function configuration
|
describe Fail: wrong hash function configuration
|
||||||
register_test retvalshouldbe 1
|
register_test retvalshouldbe 1
|
||||||
register_test contain "SHA512 is not present"
|
register_test contain "is not present in /etc/login.defs"
|
||||||
run wrongconf "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
|
run wrongconf "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
|
||||||
|
|
||||||
describe Correcting situation
|
describe Correcting situation
|
||||||
|
@ -12,7 +12,7 @@ test_audit() {
|
|||||||
sed -i 's/secaudit:!/secaudit:mypassword/' /etc/shadow
|
sed -i 's/secaudit:!/secaudit:mypassword/' /etc/shadow
|
||||||
describe Fail: Found unsecure password
|
describe Fail: Found unsecure password
|
||||||
register_test retvalshouldbe 1
|
register_test retvalshouldbe 1
|
||||||
register_test contain "User secaudit has a password that is not SHA512 hashed"
|
register_test contain "User secaudit has a password that is not"
|
||||||
run unsecpasswd "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
|
run unsecpasswd "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
|
||||||
|
|
||||||
sed -i 's/secaudit:mypassword/secaudit:!!/' /etc/shadow
|
sed -i 's/secaudit:mypassword/secaudit:!!/' /etc/shadow
|
||||||
@ -27,7 +27,7 @@ secaudit:mypassword
|
|||||||
EOF
|
EOF
|
||||||
describe Pass: Found properly hashed password
|
describe Pass: Found properly hashed password
|
||||||
register_test retvalshouldbe 0
|
register_test retvalshouldbe 0
|
||||||
register_test contain "User secaudit has suitable SHA512 hashed password"
|
register_test contain "User secaudit has suitable"
|
||||||
run sha512pass "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
|
run sha512pass "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
|
||||||
|
|
||||||
chpasswd -c SHA512 -s 1000 <<EOF
|
chpasswd -c SHA512 -s 1000 <<EOF
|
||||||
@ -35,6 +35,6 @@ secaudit:mypassword
|
|||||||
EOF
|
EOF
|
||||||
describe Pass: Found properly hashed password with custom round number
|
describe Pass: Found properly hashed password with custom round number
|
||||||
register_test retvalshouldbe 0
|
register_test retvalshouldbe 0
|
||||||
register_test contain "User secaudit has suitable SHA512 hashed password"
|
register_test contain "User secaudit has suitable"
|
||||||
run sha512pass "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
|
run sha512pass "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
|
||||||
}
|
}
|
||||||
|
@ -140,6 +140,11 @@ _run() {
|
|||||||
echo $? >"$outdir/$usecase_name.retval"
|
echo $? >"$outdir/$usecase_name.retval"
|
||||||
ret=$(<"$outdir"/"$usecase_name".retval)
|
ret=$(<"$outdir"/"$usecase_name".retval)
|
||||||
get_stdout
|
get_stdout
|
||||||
|
if [ -s "$outdir/${usecase_name}_err.log" ]; then
|
||||||
|
echo ">>> stderr follows"
|
||||||
|
cat "$outdir/${usecase_name}_err.log"
|
||||||
|
echo "<<< end of stderr"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Load assertion functions for functionnal tests
|
# Load assertion functions for functionnal tests
|
||||||
|
Reference in New Issue
Block a user