mirror of
https://github.com/ovh/debian-cis.git
synced 2024-11-22 21:47:02 +01:00
fix: catch cidr network in ssh keys (#236)
Co-authored-by: Ismaël Tanguy <ismael.tanguy@ovhcloud.com>
This commit is contained in:
parent
3bd4078e70
commit
43fc23ee40
@ -19,7 +19,7 @@ DESCRIPTION="Check <from> field in ssh authorized keys files for users with logi
|
|||||||
|
|
||||||
# Regex looking for empty, hash starting lines, or 'from="127.127.127,127.127.127" ssh'
|
# Regex looking for empty, hash starting lines, or 'from="127.127.127,127.127.127" ssh'
|
||||||
# shellcheck disable=2089
|
# shellcheck disable=2089
|
||||||
REGEX_FROM_IP="from=(?:'|\")(,?(\d{1,3}(\.\d{1,3}){3}))+(?:'|\")"
|
REGEX_FROM_IP="from=(?:'|\")(,?(\d{1,3}(\.\d{1,3}){3})(\/\d{1,2})?)+(?:'|\")"
|
||||||
REGEX_OK_LINES="(^(#|$)|($REGEX_FROM_IP))"
|
REGEX_OK_LINES="(^(#|$)|($REGEX_FROM_IP))"
|
||||||
AUTHKEYFILE_PATTERN=""
|
AUTHKEYFILE_PATTERN=""
|
||||||
AUTHKEYFILE_PATTERN_DEFAULT=".ssh/authorized_keys .ssh/authorized_keys2"
|
AUTHKEYFILE_PATTERN_DEFAULT=".ssh/authorized_keys .ssh/authorized_keys2"
|
||||||
|
@ -72,11 +72,11 @@ test_audit() {
|
|||||||
run allwdfromip "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
|
run allwdfromip "${CIS_CHECKS_DIR}/${script}.sh" --audit-all
|
||||||
|
|
||||||
# shellcheck disable=2016
|
# shellcheck disable=2016
|
||||||
echo 'ALLOWED_IPS="$ALLOWED_IPS 127.0.0.1,10.2.3.1"' >>"${CIS_CONF_DIR}/conf.d/${script}.cfg"
|
echo 'ALLOWED_IPS="$ALLOWED_IPS 127.0.0.1,10.2.3.1/8"' >>"${CIS_CONF_DIR}/conf.d/${script}.cfg"
|
||||||
{
|
{
|
||||||
echo -n 'from="10.0.1.2",command="echo bla" '
|
echo -n 'from="10.0.1.2",command="echo bla" '
|
||||||
cat /tmp/key1.pub
|
cat /tmp/key1.pub
|
||||||
echo -n 'command="echo bla,from="10.0.1.2,10.2.3.1"" '
|
echo -n 'command="echo bla,from="10.0.1.2,10.2.3.1/8"" '
|
||||||
cat /tmp/key1.pub
|
cat /tmp/key1.pub
|
||||||
} >>/home/secaudit/.ssh/authorized_keys2
|
} >>/home/secaudit/.ssh/authorized_keys2
|
||||||
describe Key with from and command options
|
describe Key with from and command options
|
||||||
|
Loading…
Reference in New Issue
Block a user