mirror of
https://github.com/ovh/debian-cis.git
synced 2025-07-16 05:42:17 +02:00
Compare commits
50 Commits
v3.8-1
...
dev/thibau
Author | SHA1 | Date | |
---|---|---|---|
00e0a875c2 | |||
38bf8c4bc0 | |||
68f2c640b1 | |||
7fa2d5f516 | |||
679df5b9cf | |||
9a225c6157 | |||
6079b16611 | |||
f7cdf438d4 | |||
43fc23ee40 | |||
3bd4078e70 | |||
a45aa40ce4 | |||
730ab47437 | |||
5313799193 | |||
73616af4eb | |||
c391723fe5 | |||
71019a5512 | |||
fb4df82fc4 | |||
c75244e3b2 | |||
de295b3a77 | |||
693487c3a5 | |||
670c8c62f5 | |||
0eb2e2ffde | |||
d6c334182e | |||
2188577fc9 | |||
0f59f73297 | |||
f888ce0d39 | |||
f6aa306127 | |||
ceea343ad9 | |||
2e53dfb573 | |||
08aff5d3fc | |||
32886d3a3d | |||
5370ec2ef6 | |||
9d3fb18e6b | |||
6e79fcd00a | |||
27edec6d5f | |||
f2cc14c383 | |||
46377fc255 | |||
a468b29036 | |||
db9ff8a7fd | |||
6135c3d0e5 | |||
a6ad528087 | |||
bc98bedf73 | |||
873ef8827d | |||
bd27cd0dae | |||
f28ffc244c | |||
19ce790a27 | |||
47cf86237b | |||
ccd9c1a7aa | |||
04457e7df2 | |||
05521d5961 |
2
.github/workflows/compile-manual.yml
vendored
2
.github/workflows/compile-manual.yml
vendored
@ -7,7 +7,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Produce debian man
|
- name: Produce debian man
|
||||||
run: 'docker run --rm --volume "`pwd`:/data" --user `id -u`:`id -g` pandoc/latex:2.6 MANUAL.md -s -t man > debian/cis-hardening.8'
|
run: 'docker run --rm --volume "`pwd`:/data" --user `id -u`:`id -g` pandoc/latex:2.6 MANUAL.md -s -t man > debian/cis-hardening.8'
|
||||||
- uses: EndBug/add-and-commit@v9
|
- uses: EndBug/add-and-commit@v9
|
||||||
|
18
.github/workflows/functionnal-tests.yml
vendored
18
.github/workflows/functionnal-tests.yml
vendored
@ -4,24 +4,24 @@ on:
|
|||||||
- pull_request
|
- pull_request
|
||||||
- push
|
- push
|
||||||
jobs:
|
jobs:
|
||||||
functionnal-tests-docker-debian9:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout repo
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
- name: Run the tests debian9
|
|
||||||
run: ./tests/docker_build_and_run_tests.sh debian9
|
|
||||||
functionnal-tests-docker-debian10:
|
functionnal-tests-docker-debian10:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Run the tests debian10
|
- name: Run the tests debian10
|
||||||
run: ./tests/docker_build_and_run_tests.sh debian10
|
run: ./tests/docker_build_and_run_tests.sh debian10
|
||||||
functionnal-tests-docker-debian11:
|
functionnal-tests-docker-debian11:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Run the tests debian11
|
- name: Run the tests debian11
|
||||||
run: ./tests/docker_build_and_run_tests.sh debian11
|
run: ./tests/docker_build_and_run_tests.sh debian11
|
||||||
|
functionnal-tests-docker-debian12:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Run the tests debian12
|
||||||
|
run: ./tests/docker_build_and_run_tests.sh debian12
|
||||||
|
6
.github/workflows/pre-release.yml
vendored
6
.github/workflows/pre-release.yml
vendored
@ -11,7 +11,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
# CHECKOUT CODE
|
# CHECKOUT CODE
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
# BUILD THE .DEB PACKAGE
|
# BUILD THE .DEB PACKAGE
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
@ -21,7 +21,7 @@ jobs:
|
|||||||
find ../ -name "*.deb" -exec mv {} cis-hardening.deb \;
|
find ../ -name "*.deb" -exec mv {} cis-hardening.deb \;
|
||||||
# DELETE THE TAG NAMED LATEST AND THE CORRESPONDING RELEASE
|
# DELETE THE TAG NAMED LATEST AND THE CORRESPONDING RELEASE
|
||||||
- name: Delete the tag latest and the release latest
|
- name: Delete the tag latest and the release latest
|
||||||
uses: dev-drprasad/delete-tag-and-release@v0.2.1
|
uses: dev-drprasad/delete-tag-and-release@v1.1
|
||||||
with:
|
with:
|
||||||
delete_release: true
|
delete_release: true
|
||||||
tag_name: latest
|
tag_name: latest
|
||||||
@ -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.3.1
|
||||||
with:
|
with:
|
||||||
myToken: ${{ secrets.GITHUB_TOKEN }}
|
myToken: ${{ secrets.GITHUB_TOKEN }}
|
||||||
head-ref: ${{ github.sha }}
|
head-ref: ${{ github.sha }}
|
||||||
|
@ -8,9 +8,9 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Run the sh-checker
|
- name: Run the sh-checker
|
||||||
uses: luizm/action-sh-checker@v0.5.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.
|
||||||
@ -24,6 +24,6 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
- name: Run shellcheck
|
- name: Run shellcheck
|
||||||
run: ./shellcheck/docker_build_and_run_shellcheck.sh
|
run: ./shellcheck/docker_build_and_run_shellcheck.sh
|
||||||
|
4
.github/workflows/tagged-release.yml
vendored
4
.github/workflows/tagged-release.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
|||||||
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
|
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
|
||||||
# CHECKOUT CODE
|
# CHECKOUT CODE
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ steps.vars.outputs.tag }}
|
ref: ${{ steps.vars.outputs.tag }}
|
||||||
# GENERATE CHANGELOG CORRESPONDING TO ENTRY IN DEBIAN/CHANGELOG
|
# GENERATE CHANGELOG CORRESPONDING TO ENTRY IN DEBIAN/CHANGELOG
|
||||||
@ -33,7 +33,7 @@ jobs:
|
|||||||
find ../ -name "*.deb" -exec mv {} cis-hardening.deb \;
|
find ../ -name "*.deb" -exec mv {} cis-hardening.deb \;
|
||||||
# DELETE THE TAG NAMED LATEST AND THE CORRESPONDING RELEASE
|
# DELETE THE TAG NAMED LATEST AND THE CORRESPONDING RELEASE
|
||||||
- name: Delete the tag latest and the release latest
|
- name: Delete the tag latest and the release latest
|
||||||
uses: dev-drprasad/delete-tag-and-release@v0.2.1
|
uses: dev-drprasad/delete-tag-and-release@v1.1
|
||||||
with:
|
with:
|
||||||
delete_release: true
|
delete_release: true
|
||||||
tag_name: latest
|
tag_name: latest
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
# NAME
|
# NAME
|
||||||
|
|
||||||
cis-hardening - CIS Debian 9/10 Hardening
|
cis-hardening - CIS Debian 10/11/12 Hardening
|
||||||
|
|
||||||
# SYNOPSIS
|
# SYNOPSIS
|
||||||
|
|
||||||
@ -12,7 +12,7 @@ cis-hardening - CIS Debian 9/10 Hardening
|
|||||||
|
|
||||||
# DESCRIPTION
|
# DESCRIPTION
|
||||||
|
|
||||||
Modular Debian 9/10 security hardening scripts based on the CIS (https://www.cisecurity.org) recommendations.
|
Modular Debian 10/11/12 security hardening scripts based on the CIS (https://www.cisecurity.org) recommendations.
|
||||||
|
|
||||||
We use it at OVHcloud (https://www.ovhcloud.com) to harden our PCI-DSS infrastructure.
|
We use it at OVHcloud (https://www.ovhcloud.com) to harden our PCI-DSS infrastructure.
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ will create a timestamped backup in this directory.
|
|||||||
|
|
||||||
# COPYRIGHT
|
# COPYRIGHT
|
||||||
|
|
||||||
Copyright 2020 OVHcloud
|
Copyright 2023 OVHcloud
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
35
README.md
35
README.md
@ -1,7 +1,4 @@
|
|||||||
# :lock: CIS Debian 9/10 Hardening
|
# :lock: CIS Debian 10/11/12 Hardening
|
||||||
|
|
||||||
:tada: **News**: this project is back in the game and is from now on maintained. Be free to use and to
|
|
||||||
report issues if you find any!
|
|
||||||
|
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
@ -16,9 +13,12 @@ report issues if you find any!
|
|||||||

|

|
||||||
---
|
---
|
||||||
|
|
||||||
Modular Debian 9/10 security hardening scripts based on [cisecurity.org](https://www.cisecurity.org)
|
Modular Debian 10/11/12 security hardening scripts based on [cisecurity.org](https://www.cisecurity.org)
|
||||||
recommendations. We use it at [OVHcloud](https://www.ovhcloud.com) to harden our PCI-DSS infrastructure.
|
recommendations. We use it at [OVHcloud](https://www.ovhcloud.com) to harden our PCI-DSS infrastructure.
|
||||||
|
|
||||||
|
NB : Although Debian 12 CIS Hardening guide is still in development, we do use this set of scripts
|
||||||
|
in production at OVHcloud on Debian 12 Operating Systems.
|
||||||
|
|
||||||
```console
|
```console
|
||||||
$ bin/hardening.sh --audit-all
|
$ bin/hardening.sh --audit-all
|
||||||
[...]
|
[...]
|
||||||
@ -43,9 +43,11 @@ hardening [INFO] Treating /opt/cis-hardening/bin/hardening/6.2.19_check_duplicat
|
|||||||
```console
|
```console
|
||||||
$ git clone https://github.com/ovh/debian-cis.git && cd debian-cis
|
$ git clone https://github.com/ovh/debian-cis.git && cd debian-cis
|
||||||
$ cp debian/default /etc/default/cis-hardening
|
$ cp debian/default /etc/default/cis-hardening
|
||||||
$ sed -i "s#CIS_ROOT_DIR=.*#CIS_ROOT_DIR='$(pwd)'#" /etc/default/cis-hardening
|
$ sed -i "s#CIS_LIB_DIR=.*#CIS_LIB_DIR='$(pwd)'/lib#" /etc/default/cis-hardening
|
||||||
$ bin/hardening/1.1.1.1_disable_freevxfs.sh --audit-all
|
$ sed -i "s#CIS_CHECKS_DIR=.*#CIS_CHECKS_DIR='$(pwd)'/bin/hardening#" /etc/default/cis-hardening
|
||||||
hardening [INFO] Treating /opt/cis-hardening/bin/hardening/1.1.1.1_disable_freevxfs.sh
|
$ sed -i "s#CIS_CONF_DIR=.*#CIS_CONF_DIR='$(pwd)'/etc#" /etc/default/cis-hardening
|
||||||
|
$ sed -i "s#CIS_TMP_DIR=.*#CIS_TMP_DIR='$(pwd)'/tmp#" /etc/default/cis-hardening
|
||||||
|
$ ./bin/hardening/1.1.1.1_disable_freevxfs.sh --audit
|
||||||
1.1.1.1_disable_freevxfs [INFO] Working on 1.1.1.1_disable_freevxfs
|
1.1.1.1_disable_freevxfs [INFO] Working on 1.1.1.1_disable_freevxfs
|
||||||
1.1.1.1_disable_freevxfs [INFO] [DESCRIPTION] Disable mounting of freevxfs filesystems.
|
1.1.1.1_disable_freevxfs [INFO] [DESCRIPTION] Disable mounting of freevxfs filesystems.
|
||||||
1.1.1.1_disable_freevxfs [INFO] Checking Configuration
|
1.1.1.1_disable_freevxfs [INFO] Checking Configuration
|
||||||
@ -172,7 +174,7 @@ Functional tests are available. They are to be run in a Docker environment.
|
|||||||
$ ./tests/docker_build_and_run_tests.sh <target> [name of test script...]
|
$ ./tests/docker_build_and_run_tests.sh <target> [name of test script...]
|
||||||
```
|
```
|
||||||
|
|
||||||
With `target` being like `debian9` or `debian10`.
|
With `target` being like `debian10` or `debian11`.
|
||||||
|
|
||||||
Running without script arguments will run all tests in `./tests/hardening/` directory.
|
Running without script arguments will run all tests in `./tests/hardening/` directory.
|
||||||
Or you can specify one or several test script to be run.
|
Or you can specify one or several test script to be run.
|
||||||
@ -244,6 +246,20 @@ built a secure environment. While we use it at OVHcloud to harden our PCI-DSS co
|
|||||||
infrastructure, we can not guarantee that it will work for you. It will not
|
infrastructure, we can not guarantee that it will work for you. It will not
|
||||||
magically secure any random host.
|
magically secure any random host.
|
||||||
|
|
||||||
|
A word about numbering, implementation and sustainability over time of this repository:
|
||||||
|
This project is born with the Debian 7 distribution in 2016. Over time, CIS Benchmark PDF
|
||||||
|
has evolved, changing it's numbering, deleting obsolete checks.
|
||||||
|
In order to keep retro-compatiblity with the last maintained Debian, the numbering
|
||||||
|
has not been changed along with the PDF, because the configuration scripts are named after it.
|
||||||
|
Changing the numbering might break automation for admins using it for years, and handling
|
||||||
|
this issue without breaking anything would require a huge refactoring.
|
||||||
|
As a consequence, please do not worry about numbering, the checks are there,
|
||||||
|
but the numbering accross PDFs might differ.
|
||||||
|
Please also note that all the check inside CIS Benchmark PDF might not be implemented
|
||||||
|
in this set of scripts.
|
||||||
|
We did choose the most relevant to us at OVHcloud, do not hesitate to make a
|
||||||
|
Pull Request in order to add the missing script you might find relevant for you.
|
||||||
|
|
||||||
Additionally, quoting the License:
|
Additionally, quoting the License:
|
||||||
|
|
||||||
> THIS SOFTWARE IS PROVIDED BY OVH SAS AND CONTRIBUTORS ``AS IS'' AND ANY
|
> THIS SOFTWARE IS PROVIDED BY OVH SAS AND CONTRIBUTORS ``AS IS'' AND ANY
|
||||||
@ -257,6 +273,7 @@ Additionally, quoting the License:
|
|||||||
> (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
> (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
> SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
> SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
|
||||||
## :satellite: Reference
|
## :satellite: Reference
|
||||||
|
|
||||||
- **Center for Internet Security**: https://www.cisecurity.org/
|
- **Center for Internet Security**: https://www.cisecurity.org/
|
||||||
|
@ -192,7 +192,7 @@ while [[ $# -gt 0 ]]; do
|
|||||||
done
|
done
|
||||||
|
|
||||||
# if no RUN_MODE was passed, usage and quit
|
# if no RUN_MODE was passed, usage and quit
|
||||||
if [ "$AUDIT" -eq 0 ] && [ "$AUDIT_ALL" -eq 0 ] && [ "$AUDIT_ALL_ENABLE_PASSED" -eq 0 ] && [ "$APPLY" -eq 0 ] && [ "$CREATE_CONFIG" -eq 0 ]; then
|
if [ "$AUDIT" -eq 0 ] && [ "$AUDIT_ALL" -eq 0 ] && [ "$AUDIT_ALL_ENABLE_PASSED" -eq 0 ] && [ "$APPLY" -eq 0 ] && [ "$CREATE_CONFIG" -eq 0 ] && [ "$SET_HARDENING_LEVEL" -eq 0 ]; then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -201,21 +201,21 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../debian/default
|
# shellcheck source=../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ] || [ -z "${CIS_CONF_DIR}" ] || [ -z "${CIS_CHECKS_DIR}" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR, CIS_CONF_DIR, CIS_CHECKS_DIR variables, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# shellcheck source=../etc/hardening.cfg
|
# shellcheck source=../etc/hardening.cfg
|
||||||
[ -r "$CIS_ROOT_DIR"/etc/hardening.cfg ] && . "$CIS_ROOT_DIR"/etc/hardening.cfg
|
[ -r "${CIS_CONF_DIR}"/hardening.cfg ] && . "${CIS_CONF_DIR}"/hardening.cfg
|
||||||
if [ "$ASK_LOGLEVEL" ]; then LOGLEVEL=$ASK_LOGLEVEL; fi
|
if [ "$ASK_LOGLEVEL" ]; then LOGLEVEL=$ASK_LOGLEVEL; fi
|
||||||
# shellcheck source=../lib/common.sh
|
# shellcheck source=../lib/common.sh
|
||||||
[ -r "$CIS_ROOT_DIR"/lib/common.sh ] && . "$CIS_ROOT_DIR"/lib/common.sh
|
[ -r "${CIS_LIB_DIR}"/common.sh ] && . "${CIS_LIB_DIR}"/common.sh
|
||||||
# shellcheck source=../lib/utils.sh
|
# shellcheck source=../lib/utils.sh
|
||||||
[ -r "$CIS_ROOT_DIR"/lib/utils.sh ] && . "$CIS_ROOT_DIR"/lib/utils.sh
|
[ -r "${CIS_LIB_DIR}"/utils.sh ] && . "${CIS_LIB_DIR}"/utils.sh
|
||||||
# shellcheck source=../lib/constants.sh
|
# shellcheck source=../lib/constants.sh
|
||||||
[ -r "$CIS_ROOT_DIR"/lib/constants.sh ] && . "$CIS_ROOT_DIR"/lib/constants.sh
|
[ -r "${CIS_LIB_DIR}"/constants.sh ] && . "${CIS_LIB_DIR}"/constants.sh
|
||||||
|
|
||||||
# If we're on a unsupported platform and there is no flag --allow-unsupported-distribution
|
# If we're on a unsupported platform and there is no flag --allow-unsupported-distribution
|
||||||
# print warning, otherwise quit
|
# print warning, otherwise quit
|
||||||
@ -257,7 +257,7 @@ fi
|
|||||||
# If --allow-service-list is specified, don't run anything, just list the supported services
|
# If --allow-service-list is specified, don't run anything, just list the supported services
|
||||||
if [ "$ALLOW_SERVICE_LIST" = 1 ]; then
|
if [ "$ALLOW_SERVICE_LIST" = 1 ]; then
|
||||||
declare -a HARDENING_EXCEPTIONS_LIST
|
declare -a HARDENING_EXCEPTIONS_LIST
|
||||||
for SCRIPT in $(find "$CIS_ROOT_DIR"/bin/hardening/ -name "*.sh" | sort -V); do
|
for SCRIPT in $(find "${CIS_CHECKS_DIR}"/ -name "*.sh" | sort -V); do
|
||||||
template=$(grep "^HARDENING_EXCEPTION=" "$SCRIPT" | cut -d= -f2)
|
template=$(grep "^HARDENING_EXCEPTION=" "$SCRIPT" | cut -d= -f2)
|
||||||
[ -n "$template" ] && HARDENING_EXCEPTIONS_LIST[${#HARDENING_EXCEPTIONS_LIST[@]}]="$template"
|
[ -n "$template" ] && HARDENING_EXCEPTIONS_LIST[${#HARDENING_EXCEPTIONS_LIST[@]}]="$template"
|
||||||
done
|
done
|
||||||
@ -272,7 +272,7 @@ if [ -n "$SET_HARDENING_LEVEL" ] && [ "$SET_HARDENING_LEVEL" != 0 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for SCRIPT in $(find "$CIS_ROOT_DIR"/bin/hardening/ -name "*.sh" | sort -V); do
|
for SCRIPT in $(find "${CIS_CHECKS_DIR}"/ -name "*.sh" | sort -V); do
|
||||||
SCRIPT_BASENAME=$(basename "$SCRIPT" .sh)
|
SCRIPT_BASENAME=$(basename "$SCRIPT" .sh)
|
||||||
script_level=$(grep "^HARDENING_LEVEL=" "$SCRIPT" | cut -d= -f2)
|
script_level=$(grep "^HARDENING_LEVEL=" "$SCRIPT" | cut -d= -f2)
|
||||||
if [ -z "$script_level" ]; then
|
if [ -z "$script_level" ]; then
|
||||||
@ -281,7 +281,7 @@ if [ -n "$SET_HARDENING_LEVEL" ] && [ "$SET_HARDENING_LEVEL" != 0 ]; then
|
|||||||
fi
|
fi
|
||||||
wantedstatus=disabled
|
wantedstatus=disabled
|
||||||
[ "$script_level" -le "$SET_HARDENING_LEVEL" ] && wantedstatus=enabled
|
[ "$script_level" -le "$SET_HARDENING_LEVEL" ] && wantedstatus=enabled
|
||||||
sed -i -re "s/^status=.+/status=$wantedstatus/" "$CIS_ROOT_DIR/etc/conf.d/$SCRIPT_BASENAME.cfg"
|
sed -i -re "s/^status=.+/status=$wantedstatus/" "${CIS_CONF_DIR}/conf.d/$SCRIPT_BASENAME.cfg"
|
||||||
done
|
done
|
||||||
echo "Configuration modified to enable scripts for hardening level at or below $SET_HARDENING_LEVEL"
|
echo "Configuration modified to enable scripts for hardening level at or below $SET_HARDENING_LEVEL"
|
||||||
exit 0
|
exit 0
|
||||||
@ -293,13 +293,13 @@ if [ "$CREATE_CONFIG" = 1 ] && [ "$EUID" -ne 0 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Parse every scripts and execute them in the required mode
|
# Parse every scripts and execute them in the required mode
|
||||||
for SCRIPT in $(find "$CIS_ROOT_DIR"/bin/hardening/ -name "*.sh" | sort -V); do
|
for SCRIPT in $(find "${CIS_CHECKS_DIR}"/ -name "*.sh" | sort -V); do
|
||||||
if [ "${#TEST_LIST[@]}" -gt 0 ]; then
|
if [ "${#TEST_LIST[@]}" -gt 0 ]; then
|
||||||
# --only X has been specified at least once, is this script in my list ?
|
# --only X has been specified at least once, is this script in my list ?
|
||||||
SCRIPT_PREFIX=$(grep -Eo '^[0-9.]+' <<<"$(basename "$SCRIPT")")
|
SCRIPT_PREFIX=$(grep -Eo '^[0-9.]+' <<<"$(basename "$SCRIPT")")
|
||||||
# shellcheck disable=SC2001
|
# shellcheck disable=SC2001
|
||||||
SCRIPT_PREFIX_RE=$(sed -e 's/\./\\./g' <<<"$SCRIPT_PREFIX")
|
SCRIPT_PREFIX_RE=$(sed -e 's/\./\\./g' <<<"$SCRIPT_PREFIX")
|
||||||
if ! grep -qwE "(^| )$SCRIPT_PREFIX_RE" <<<"${TEST_LIST[@]}"; then
|
if ! grep -qE "(^|[[:space:]])$SCRIPT_PREFIX_RE([[:space:]]|$)" <<<"${TEST_LIST[@]}"; then
|
||||||
# not in the list
|
# not in the list
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@ -307,19 +307,19 @@ for SCRIPT in $(find "$CIS_ROOT_DIR"/bin/hardening/ -name "*.sh" | sort -V); do
|
|||||||
|
|
||||||
info "Treating $SCRIPT"
|
info "Treating $SCRIPT"
|
||||||
if [ "$CREATE_CONFIG" = 1 ]; then
|
if [ "$CREATE_CONFIG" = 1 ]; then
|
||||||
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --create-config-files-only"
|
debug "$SCRIPT --create-config-files-only"
|
||||||
LOGLEVEL=$LOGLEVEL "$SCRIPT" --create-config-files-only "$BATCH_MODE"
|
LOGLEVEL=$LOGLEVEL "$SCRIPT" --create-config-files-only "$BATCH_MODE"
|
||||||
elif [ "$AUDIT" = 1 ]; then
|
elif [ "$AUDIT" = 1 ]; then
|
||||||
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit $SUDO_MODE $BATCH_MODE"
|
debug "$SCRIPT --audit $SUDO_MODE $BATCH_MODE"
|
||||||
LOGLEVEL=$LOGLEVEL "$SCRIPT" --audit "$SUDO_MODE" "$BATCH_MODE"
|
LOGLEVEL=$LOGLEVEL "$SCRIPT" --audit "$SUDO_MODE" "$BATCH_MODE"
|
||||||
elif [ "$AUDIT_ALL" = 1 ]; then
|
elif [ "$AUDIT_ALL" = 1 ]; then
|
||||||
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit-all $SUDO_MODE $BATCH_MODE"
|
debug "$SCRIPT --audit-all $SUDO_MODE $BATCH_MODE"
|
||||||
LOGLEVEL=$LOGLEVEL "$SCRIPT" --audit-all "$SUDO_MODE" "$BATCH_MODE"
|
LOGLEVEL=$LOGLEVEL "$SCRIPT" --audit-all "$SUDO_MODE" "$BATCH_MODE"
|
||||||
elif [ "$AUDIT_ALL_ENABLE_PASSED" = 1 ]; then
|
elif [ "$AUDIT_ALL_ENABLE_PASSED" = 1 ]; then
|
||||||
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT --audit-all $SUDO_MODE $BATCH_MODE"
|
debug "$SCRIPT --audit-all $SUDO_MODE $BATCH_MODE"
|
||||||
LOGLEVEL=$LOGLEVEL "$SCRIPT" --audit-all "$SUDO_MODE" "$BATCH_MODE"
|
LOGLEVEL=$LOGLEVEL "$SCRIPT" --audit-all "$SUDO_MODE" "$BATCH_MODE"
|
||||||
elif [ "$APPLY" = 1 ]; then
|
elif [ "$APPLY" = 1 ]; then
|
||||||
debug "$CIS_ROOT_DIR/bin/hardening/$SCRIPT"
|
debug "$SCRIPT"
|
||||||
LOGLEVEL=$LOGLEVEL "$SCRIPT"
|
LOGLEVEL=$LOGLEVEL "$SCRIPT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -332,8 +332,8 @@ for SCRIPT in $(find "$CIS_ROOT_DIR"/bin/hardening/ -name "*.sh" | sort -V); do
|
|||||||
PASSED_CHECKS=$((PASSED_CHECKS + 1))
|
PASSED_CHECKS=$((PASSED_CHECKS + 1))
|
||||||
if [ "$AUDIT_ALL_ENABLE_PASSED" = 1 ]; then
|
if [ "$AUDIT_ALL_ENABLE_PASSED" = 1 ]; then
|
||||||
SCRIPT_BASENAME=$(basename "$SCRIPT" .sh)
|
SCRIPT_BASENAME=$(basename "$SCRIPT" .sh)
|
||||||
sed -i -re 's/^status=.+/status=enabled/' "$CIS_ROOT_DIR/etc/conf.d/$SCRIPT_BASENAME.cfg"
|
sed -i -re 's/^status=.+/status=enabled/' "${CIS_CONF_DIR}/conf.d/$SCRIPT_BASENAME.cfg"
|
||||||
info "Status set to enabled in $CIS_ROOT_DIR/etc/conf.d/$SCRIPT_BASENAME.cfg"
|
info "Status set to enabled in ${CIS_CONF_DIR}/conf.d/$SCRIPT_BASENAME.cfg"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
1)
|
1)
|
||||||
|
@ -60,17 +60,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -60,17 +60,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -60,17 +60,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -60,17 +60,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -60,17 +60,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -60,17 +60,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -53,17 +53,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
76
bin/hardening/1.1.1.8_disable_cramfs.sh
Executable file
76
bin/hardening/1.1.1.8_disable_cramfs.sh
Executable file
@ -0,0 +1,76 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
|
#
|
||||||
|
# CIS Debian Hardening
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 1.1.1.1 Ensure Mounting of cramfs filesystems is disabled (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
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="Disable mounting of cramfs filesystems."
|
||||||
|
|
||||||
|
KERNEL_OPTION="CONFIG_CRAMFS"
|
||||||
|
MODULE_NAME="cramfs"
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit() {
|
||||||
|
if [ "$IS_CONTAINER" -eq 1 ]; then
|
||||||
|
# In an unprivileged container, the kernel modules are host dependent, so you should consider enforcing it
|
||||||
|
ok "Container detected, consider host enforcing or disable this check!"
|
||||||
|
else
|
||||||
|
is_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_NAME"
|
||||||
|
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
||||||
|
crit "$MODULE_NAME is enabled!"
|
||||||
|
else
|
||||||
|
ok "$MODULE_NAME is disabled"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply() {
|
||||||
|
if [ "$IS_CONTAINER" -eq 1 ]; then
|
||||||
|
# In an unprivileged container, the kernel modules are host dependent, so you should consider enforcing it
|
||||||
|
ok "Container detected, consider host enforcing!"
|
||||||
|
else
|
||||||
|
is_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_NAME"
|
||||||
|
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
||||||
|
warn "I cannot fix $MODULE_NAME, recompile your kernel or blacklist module $MODULE_NAME (/etc/modprobe.d/blacklist.conf : +install $MODULE_NAME /bin/true)"
|
||||||
|
else
|
||||||
|
ok "$MODULE_NAME is disabled"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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
|
@ -76,17 +76,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
92
bin/hardening/1.1.11.1_var_log_noexec.sh
Executable file
92
bin/hardening/1.1.11.1_var_log_noexec.sh
Executable file
@ -0,0 +1,92 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
|
#
|
||||||
|
# CIS Debian Hardening
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 1.1.11.1 Ensure noexec option set on /var/log partition (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # One error, it's over
|
||||||
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
|
DESCRIPTION="/var/log partition with noexec option."
|
||||||
|
|
||||||
|
# Quick factoring as many script use the same logic
|
||||||
|
PARTITION="/var/log"
|
||||||
|
OPTION="noexec"
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit() {
|
||||||
|
info "Verifying that $PARTITION is a partition"
|
||||||
|
FNRET=0
|
||||||
|
is_a_partition "$PARTITION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
crit "$PARTITION is not a partition"
|
||||||
|
FNRET=2
|
||||||
|
else
|
||||||
|
ok "$PARTITION is a partition"
|
||||||
|
has_mount_option "$PARTITION" "$OPTION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
crit "$PARTITION has no option $OPTION in fstab!"
|
||||||
|
FNRET=1
|
||||||
|
else
|
||||||
|
ok "$PARTITION has $OPTION in fstab"
|
||||||
|
has_mounted_option "$PARTITION" "$OPTION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
warn "$PARTITION is not mounted with $OPTION at runtime"
|
||||||
|
FNRET=3
|
||||||
|
else
|
||||||
|
ok "$PARTITION mounted with $OPTION"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply() {
|
||||||
|
if [ "$FNRET" = 0 ]; then
|
||||||
|
ok "$PARTITION is correctly set"
|
||||||
|
elif [ "$FNRET" = 2 ]; then
|
||||||
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
|
elif [ "$FNRET" = 1 ]; then
|
||||||
|
info "Adding $OPTION to fstab"
|
||||||
|
add_option_to_fstab "$PARTITION" "$OPTION"
|
||||||
|
info "Remounting $PARTITION from fstab"
|
||||||
|
remount_partition "$PARTITION"
|
||||||
|
elif [ "$FNRET" = 3 ]; then
|
||||||
|
info "Remounting $PARTITION from fstab"
|
||||||
|
remount_partition "$PARTITION"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will check config parameters required
|
||||||
|
check_config() {
|
||||||
|
# No param for this script
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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
|
92
bin/hardening/1.1.11.2_var_log_nosuid.sh
Executable file
92
bin/hardening/1.1.11.2_var_log_nosuid.sh
Executable file
@ -0,0 +1,92 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
|
#
|
||||||
|
# CIS Debian Hardening
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 1.1.11.2 Ensure nosuid option set on /var/log partition (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
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="/var/log partition with nosuid option."
|
||||||
|
|
||||||
|
# Quick factoring as many script use the same logic
|
||||||
|
PARTITION="/var/log"
|
||||||
|
OPTION="nosuid"
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit() {
|
||||||
|
info "Verifying that $PARTITION is a partition"
|
||||||
|
FNRET=0
|
||||||
|
is_a_partition "$PARTITION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
crit "$PARTITION is not a partition"
|
||||||
|
FNRET=2
|
||||||
|
else
|
||||||
|
ok "$PARTITION is a partition"
|
||||||
|
has_mount_option "$PARTITION" "$OPTION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
crit "$PARTITION has no option $OPTION in fstab!"
|
||||||
|
FNRET=1
|
||||||
|
else
|
||||||
|
ok "$PARTITION has $OPTION in fstab"
|
||||||
|
has_mounted_option "$PARTITION" "$OPTION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
warn "$PARTITION is not mounted with $OPTION at runtime"
|
||||||
|
FNRET=3
|
||||||
|
else
|
||||||
|
ok "$PARTITION mounted with $OPTION"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply() {
|
||||||
|
if [ "$FNRET" = 0 ]; then
|
||||||
|
ok "$PARTITION is correctly set"
|
||||||
|
elif [ "$FNRET" = 2 ]; then
|
||||||
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
|
elif [ "$FNRET" = 1 ]; then
|
||||||
|
info "Adding $OPTION to fstab"
|
||||||
|
add_option_to_fstab "$PARTITION" "$OPTION"
|
||||||
|
info "Remounting $PARTITION from fstab"
|
||||||
|
remount_partition "$PARTITION"
|
||||||
|
elif [ "$FNRET" = 3 ]; then
|
||||||
|
info "Remounting $PARTITION from fstab"
|
||||||
|
remount_partition "$PARTITION"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will check config parameters required
|
||||||
|
check_config() {
|
||||||
|
# No param for this script
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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
|
92
bin/hardening/1.1.11.3_var_log_nodev.sh
Executable file
92
bin/hardening/1.1.11.3_var_log_nodev.sh
Executable file
@ -0,0 +1,92 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
|
#
|
||||||
|
# CIS Debian Hardening
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 1.1.11.3 ensure nodev option set on /var/log partition (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
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="/var/log partition with nodev option."
|
||||||
|
|
||||||
|
# Quick factoring as many script use the same logic
|
||||||
|
PARTITION="/var/log"
|
||||||
|
OPTION="nodev"
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit() {
|
||||||
|
info "Verifying that $PARTITION is a partition"
|
||||||
|
FNRET=0
|
||||||
|
is_a_partition "$PARTITION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
crit "$PARTITION is not a partition"
|
||||||
|
FNRET=2
|
||||||
|
else
|
||||||
|
ok "$PARTITION is a partition"
|
||||||
|
has_mount_option "$PARTITION" "$OPTION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
crit "$PARTITION has no option $OPTION in fstab!"
|
||||||
|
FNRET=1
|
||||||
|
else
|
||||||
|
ok "$PARTITION has $OPTION in fstab"
|
||||||
|
has_mounted_option "$PARTITION" "$OPTION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
warn "$PARTITION is not mounted with $OPTION at runtime"
|
||||||
|
FNRET=3
|
||||||
|
else
|
||||||
|
ok "$PARTITION mounted with $OPTION"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply() {
|
||||||
|
if [ "$FNRET" = 0 ]; then
|
||||||
|
ok "$PARTITION is correctly set"
|
||||||
|
elif [ "$FNRET" = 2 ]; then
|
||||||
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
|
elif [ "$FNRET" = 1 ]; then
|
||||||
|
info "Adding $OPTION to fstab"
|
||||||
|
add_option_to_fstab "$PARTITION" "$OPTION"
|
||||||
|
info "Remounting $PARTITION from fstab"
|
||||||
|
remount_partition "$PARTITION"
|
||||||
|
elif [ "$FNRET" = 3 ]; then
|
||||||
|
info "Remounting $PARTITION from fstab"
|
||||||
|
remount_partition "$PARTITION"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will check config parameters required
|
||||||
|
check_config() {
|
||||||
|
# No param for this script
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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
|
@ -63,17 +63,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
92
bin/hardening/1.1.12.1_var_log_audit_noexec.sh
Executable file
92
bin/hardening/1.1.12.1_var_log_audit_noexec.sh
Executable file
@ -0,0 +1,92 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
|
#
|
||||||
|
# CIS Debian Hardening
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 1.1.12.1 Ensure noexec option set on /var/log/audit partition (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # One error, it's over
|
||||||
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
|
DESCRIPTION="/var/log/audit partition with noexec option."
|
||||||
|
|
||||||
|
# Quick factoring as many script use the same logic
|
||||||
|
PARTITION="/var/log/audit"
|
||||||
|
OPTION="noexec"
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit() {
|
||||||
|
info "Verifying that $PARTITION is a partition"
|
||||||
|
FNRET=0
|
||||||
|
is_a_partition "$PARTITION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
crit "$PARTITION is not a partition"
|
||||||
|
FNRET=2
|
||||||
|
else
|
||||||
|
ok "$PARTITION is a partition"
|
||||||
|
has_mount_option "$PARTITION" "$OPTION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
crit "$PARTITION has no option $OPTION in fstab!"
|
||||||
|
FNRET=1
|
||||||
|
else
|
||||||
|
ok "$PARTITION has $OPTION in fstab"
|
||||||
|
has_mounted_option "$PARTITION" "$OPTION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
warn "$PARTITION is not mounted with $OPTION at runtime"
|
||||||
|
FNRET=3
|
||||||
|
else
|
||||||
|
ok "$PARTITION mounted with $OPTION"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply() {
|
||||||
|
if [ "$FNRET" = 0 ]; then
|
||||||
|
ok "$PARTITION is correctly set"
|
||||||
|
elif [ "$FNRET" = 2 ]; then
|
||||||
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
|
elif [ "$FNRET" = 1 ]; then
|
||||||
|
info "Adding $OPTION to fstab"
|
||||||
|
add_option_to_fstab "$PARTITION" "$OPTION"
|
||||||
|
info "Remounting $PARTITION from fstab"
|
||||||
|
remount_partition "$PARTITION"
|
||||||
|
elif [ "$FNRET" = 3 ]; then
|
||||||
|
info "Remounting $PARTITION from fstab"
|
||||||
|
remount_partition "$PARTITION"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will check config parameters required
|
||||||
|
check_config() {
|
||||||
|
# No param for this script
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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
|
92
bin/hardening/1.1.12.2_var_log_audit_nosuid.sh
Executable file
92
bin/hardening/1.1.12.2_var_log_audit_nosuid.sh
Executable file
@ -0,0 +1,92 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
|
#
|
||||||
|
# CIS Debian Hardening
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 1.1.12.2 Ensure nosuid option set on /var/log/audit partition (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
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="/var/log/audit partition with nosuid option."
|
||||||
|
|
||||||
|
# Quick factoring as many script use the same logic
|
||||||
|
PARTITION="/var/log/audit"
|
||||||
|
OPTION="nosuid"
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit() {
|
||||||
|
info "Verifying that $PARTITION is a partition"
|
||||||
|
FNRET=0
|
||||||
|
is_a_partition "$PARTITION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
crit "$PARTITION is not a partition"
|
||||||
|
FNRET=2
|
||||||
|
else
|
||||||
|
ok "$PARTITION is a partition"
|
||||||
|
has_mount_option "$PARTITION" "$OPTION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
crit "$PARTITION has no option $OPTION in fstab!"
|
||||||
|
FNRET=1
|
||||||
|
else
|
||||||
|
ok "$PARTITION has $OPTION in fstab"
|
||||||
|
has_mounted_option "$PARTITION" "$OPTION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
warn "$PARTITION is not mounted with $OPTION at runtime"
|
||||||
|
FNRET=3
|
||||||
|
else
|
||||||
|
ok "$PARTITION mounted with $OPTION"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply() {
|
||||||
|
if [ "$FNRET" = 0 ]; then
|
||||||
|
ok "$PARTITION is correctly set"
|
||||||
|
elif [ "$FNRET" = 2 ]; then
|
||||||
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
|
elif [ "$FNRET" = 1 ]; then
|
||||||
|
info "Adding $OPTION to fstab"
|
||||||
|
add_option_to_fstab "$PARTITION" "$OPTION"
|
||||||
|
info "Remounting $PARTITION from fstab"
|
||||||
|
remount_partition "$PARTITION"
|
||||||
|
elif [ "$FNRET" = 3 ]; then
|
||||||
|
info "Remounting $PARTITION from fstab"
|
||||||
|
remount_partition "$PARTITION"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will check config parameters required
|
||||||
|
check_config() {
|
||||||
|
# No param for this script
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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
|
92
bin/hardening/1.1.12.3_var_log_audit_nodev.sh
Executable file
92
bin/hardening/1.1.12.3_var_log_audit_nodev.sh
Executable file
@ -0,0 +1,92 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
|
#
|
||||||
|
# CIS Debian Hardening
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 1.1.12.3 Ensure nodev option set on /var/log/audit partition (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
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="/var/log/audit partition with nodev option."
|
||||||
|
|
||||||
|
# Quick factoring as many script use the same logic
|
||||||
|
PARTITION="/var/log/audit"
|
||||||
|
OPTION="nodev"
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit() {
|
||||||
|
info "Verifying that $PARTITION is a partition"
|
||||||
|
FNRET=0
|
||||||
|
is_a_partition "$PARTITION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
crit "$PARTITION is not a partition"
|
||||||
|
FNRET=2
|
||||||
|
else
|
||||||
|
ok "$PARTITION is a partition"
|
||||||
|
has_mount_option "$PARTITION" "$OPTION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
crit "$PARTITION has no option $OPTION in fstab!"
|
||||||
|
FNRET=1
|
||||||
|
else
|
||||||
|
ok "$PARTITION has $OPTION in fstab"
|
||||||
|
has_mounted_option "$PARTITION" "$OPTION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
warn "$PARTITION is not mounted with $OPTION at runtime"
|
||||||
|
FNRET=3
|
||||||
|
else
|
||||||
|
ok "$PARTITION mounted with $OPTION"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply() {
|
||||||
|
if [ "$FNRET" = 0 ]; then
|
||||||
|
ok "$PARTITION is correctly set"
|
||||||
|
elif [ "$FNRET" = 2 ]; then
|
||||||
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
|
elif [ "$FNRET" = 1 ]; then
|
||||||
|
info "Adding $OPTION to fstab"
|
||||||
|
add_option_to_fstab "$PARTITION" "$OPTION"
|
||||||
|
info "Remounting $PARTITION from fstab"
|
||||||
|
remount_partition "$PARTITION"
|
||||||
|
elif [ "$FNRET" = 3 ]; then
|
||||||
|
info "Remounting $PARTITION from fstab"
|
||||||
|
remount_partition "$PARTITION"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will check config parameters required
|
||||||
|
check_config() {
|
||||||
|
# No param for this script
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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
|
@ -63,17 +63,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -63,17 +63,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
92
bin/hardening/1.1.14.1_home_nosuid.sh
Executable file
92
bin/hardening/1.1.14.1_home_nosuid.sh
Executable file
@ -0,0 +1,92 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
|
#
|
||||||
|
# CIS Debian Hardening
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 1.1.14.1 Ensure nosuid option set on /home partition (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
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="/home partition with nosuid option."
|
||||||
|
|
||||||
|
# Quick factoring as many script use the same logic
|
||||||
|
PARTITION="/home"
|
||||||
|
OPTION="nosuid"
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit() {
|
||||||
|
info "Verifying that $PARTITION is a partition"
|
||||||
|
FNRET=0
|
||||||
|
is_a_partition "$PARTITION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
crit "$PARTITION is not a partition"
|
||||||
|
FNRET=2
|
||||||
|
else
|
||||||
|
ok "$PARTITION is a partition"
|
||||||
|
has_mount_option "$PARTITION" "$OPTION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
crit "$PARTITION has no option $OPTION in fstab!"
|
||||||
|
FNRET=1
|
||||||
|
else
|
||||||
|
ok "$PARTITION has $OPTION in fstab"
|
||||||
|
has_mounted_option "$PARTITION" "$OPTION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
warn "$PARTITION is not mounted with $OPTION at runtime"
|
||||||
|
FNRET=3
|
||||||
|
else
|
||||||
|
ok "$PARTITION mounted with $OPTION"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply() {
|
||||||
|
if [ "$FNRET" = 0 ]; then
|
||||||
|
ok "$PARTITION is correctly set"
|
||||||
|
elif [ "$FNRET" = 2 ]; then
|
||||||
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
|
elif [ "$FNRET" = 1 ]; then
|
||||||
|
info "Adding $OPTION to fstab"
|
||||||
|
add_option_to_fstab "$PARTITION" "$OPTION"
|
||||||
|
info "Remounting $PARTITION from fstab"
|
||||||
|
remount_partition "$PARTITION"
|
||||||
|
elif [ "$FNRET" = 3 ]; then
|
||||||
|
info "Remounting $PARTITION from fstab"
|
||||||
|
remount_partition "$PARTITION"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will check config parameters required
|
||||||
|
check_config() {
|
||||||
|
# No param for this script
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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
|
@ -76,17 +76,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -81,17 +81,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -81,17 +81,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -81,17 +81,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -64,17 +64,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -64,17 +64,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -64,17 +64,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -81,17 +81,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -52,17 +52,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -62,17 +62,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -63,17 +63,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -76,17 +76,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -76,17 +76,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -76,17 +76,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
92
bin/hardening/1.1.6.1_var_nodev.sh
Executable file
92
bin/hardening/1.1.6.1_var_nodev.sh
Executable file
@ -0,0 +1,92 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
|
#
|
||||||
|
# CIS Debian Hardening
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 1.1.6.1 Ensure nodev option set for /var Partition (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
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="/var partition with nodev option."
|
||||||
|
|
||||||
|
# Quick factoring as many script use the same logic
|
||||||
|
PARTITION="/var"
|
||||||
|
OPTION="nodev"
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit() {
|
||||||
|
info "Verifying that $PARTITION is a partition"
|
||||||
|
FNRET=0
|
||||||
|
is_a_partition "$PARTITION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
crit "$PARTITION is not a partition"
|
||||||
|
FNRET=2
|
||||||
|
else
|
||||||
|
ok "$PARTITION is a partition"
|
||||||
|
has_mount_option "$PARTITION" "$OPTION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
crit "$PARTITION has no option $OPTION in fstab!"
|
||||||
|
FNRET=1
|
||||||
|
else
|
||||||
|
ok "$PARTITION has $OPTION in fstab"
|
||||||
|
has_mounted_option "$PARTITION" "$OPTION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
warn "$PARTITION is not mounted with $OPTION at runtime"
|
||||||
|
FNRET=3
|
||||||
|
else
|
||||||
|
ok "$PARTITION mounted with $OPTION"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply() {
|
||||||
|
if [ "$FNRET" = 0 ]; then
|
||||||
|
ok "$PARTITION is correctly set"
|
||||||
|
elif [ "$FNRET" = 2 ]; then
|
||||||
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
|
elif [ "$FNRET" = 1 ]; then
|
||||||
|
info "Adding $OPTION to fstab"
|
||||||
|
add_option_to_fstab "$PARTITION" "$OPTION"
|
||||||
|
info "Remounting $PARTITION from fstab"
|
||||||
|
remount_partition "$PARTITION"
|
||||||
|
elif [ "$FNRET" = 3 ]; then
|
||||||
|
info "Remounting $PARTITION from fstab"
|
||||||
|
remount_partition "$PARTITION"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will check config parameters required
|
||||||
|
check_config() {
|
||||||
|
# No param for this script
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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
|
92
bin/hardening/1.1.6.2_var_nosuid.sh
Executable file
92
bin/hardening/1.1.6.2_var_nosuid.sh
Executable file
@ -0,0 +1,92 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
|
#
|
||||||
|
# CIS Debian Hardening
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 1.1.6.2 Ensure nosuid option set for /var Partition (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
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="/var partition with nosuid option."
|
||||||
|
|
||||||
|
# Quick factoring as many script use the same logic
|
||||||
|
PARTITION="/var"
|
||||||
|
OPTION="nosuid"
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit() {
|
||||||
|
info "Verifying that $PARTITION is a partition"
|
||||||
|
FNRET=0
|
||||||
|
is_a_partition "$PARTITION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
crit "$PARTITION is not a partition"
|
||||||
|
FNRET=2
|
||||||
|
else
|
||||||
|
ok "$PARTITION is a partition"
|
||||||
|
has_mount_option "$PARTITION" "$OPTION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
crit "$PARTITION has no option $OPTION in fstab!"
|
||||||
|
FNRET=1
|
||||||
|
else
|
||||||
|
ok "$PARTITION has $OPTION in fstab"
|
||||||
|
has_mounted_option "$PARTITION" "$OPTION"
|
||||||
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
|
warn "$PARTITION is not mounted with $OPTION at runtime"
|
||||||
|
FNRET=3
|
||||||
|
else
|
||||||
|
ok "$PARTITION mounted with $OPTION"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply() {
|
||||||
|
if [ "$FNRET" = 0 ]; then
|
||||||
|
ok "$PARTITION is correctly set"
|
||||||
|
elif [ "$FNRET" = 2 ]; then
|
||||||
|
crit "$PARTITION is not a partition, correct this by yourself, I cannot help you here"
|
||||||
|
elif [ "$FNRET" = 1 ]; then
|
||||||
|
info "Adding $OPTION to fstab"
|
||||||
|
add_option_to_fstab "$PARTITION" "$OPTION"
|
||||||
|
info "Remounting $PARTITION from fstab"
|
||||||
|
remount_partition "$PARTITION"
|
||||||
|
elif [ "$FNRET" = 3 ]; then
|
||||||
|
info "Remounting $PARTITION from fstab"
|
||||||
|
remount_partition "$PARTITION"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will check config parameters required
|
||||||
|
check_config() {
|
||||||
|
# No param for this script
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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
|
@ -65,17 +65,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -65,17 +65,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -76,17 +76,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -76,17 +76,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -50,17 +50,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -64,17 +64,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -64,17 +64,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -53,17 +53,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -68,17 +68,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -91,17 +91,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -71,17 +71,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -50,17 +50,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -81,17 +81,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -55,17 +55,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
69
bin/hardening/1.6.3.1_disable_apport.sh
Executable file
69
bin/hardening/1.6.3.1_disable_apport.sh
Executable file
@ -0,0 +1,69 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
|
#
|
||||||
|
# CIS Debian Hardening
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 1.6.3.1 Ensure apport is disabled (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
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="Disable apport to avoid confidential data leaks."
|
||||||
|
|
||||||
|
PACKAGE='apport'
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit() {
|
||||||
|
is_pkg_installed "$PACKAGE"
|
||||||
|
if [ "$FNRET" = 0 ]; then
|
||||||
|
crit "$PACKAGE is installed!"
|
||||||
|
else
|
||||||
|
ok "$PACKAGE is absent"
|
||||||
|
fi
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply() {
|
||||||
|
is_pkg_installed "$PACKAGE"
|
||||||
|
if [ "$FNRET" = 0 ]; then
|
||||||
|
crit "$PACKAGE is installed, purging it"
|
||||||
|
apt-get purge "$PACKAGE" -y
|
||||||
|
apt-get autoremove
|
||||||
|
else
|
||||||
|
ok "$PACKAGE is absent"
|
||||||
|
fi
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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
|
@ -54,17 +54,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -87,17 +87,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
71
bin/hardening/1.6.5_restrict_ptrace_scope.sh
Executable file
71
bin/hardening/1.6.5_restrict_ptrace_scope.sh
Executable file
@ -0,0 +1,71 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
|
#
|
||||||
|
# CIS Debian Hardening
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 1.6.2 Ensure ptrace_scope is restricted
|
||||||
|
#
|
||||||
|
|
||||||
|
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="Ensure ptrace_scope is restricted."
|
||||||
|
|
||||||
|
SYSCTL_PARAM='kernel.yama.ptrace_scope'
|
||||||
|
SYSCTL_EXP_RESULT=2
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit() {
|
||||||
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
|
if [ "$FNRET" != 0 ]; then
|
||||||
|
crit "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT"
|
||||||
|
elif [ "$FNRET" = 255 ]; then
|
||||||
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
|
else
|
||||||
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply() {
|
||||||
|
has_sysctl_param_expected_result "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
|
if [ "$FNRET" != 0 ]; then
|
||||||
|
warn "$SYSCTL_PARAM was not set to $SYSCTL_EXP_RESULT -- Fixing"
|
||||||
|
set_sysctl_param "$SYSCTL_PARAM" "$SYSCTL_EXP_RESULT"
|
||||||
|
elif [ "$FNRET" = 255 ]; then
|
||||||
|
warn "$SYSCTL_PARAM does not exist -- Typo?"
|
||||||
|
else
|
||||||
|
ok "$SYSCTL_PARAM correctly set to $SYSCTL_EXP_RESULT"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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
|
@ -54,17 +54,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -118,17 +118,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -75,17 +75,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -89,17 +89,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -51,17 +51,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -51,17 +51,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -51,17 +51,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -76,17 +76,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -76,17 +76,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -76,17 +76,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -37,17 +37,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -53,17 +53,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -51,17 +51,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -55,17 +55,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -17,7 +17,7 @@ HARDENING_LEVEL=3
|
|||||||
# shellcheck disable=2034
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure time synchronization is in use"
|
DESCRIPTION="Ensure time synchronization is in use"
|
||||||
|
|
||||||
PACKAGES="ntp chrony"
|
PACKAGES="systemd-timesyncd ntp chrony"
|
||||||
|
|
||||||
# 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() {
|
||||||
@ -49,17 +49,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -44,17 +44,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -52,17 +52,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -83,17 +83,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -58,17 +58,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -58,17 +58,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -71,17 +71,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -19,7 +19,7 @@ DESCRIPTION="Ensure HTTP-proxy is not enabled."
|
|||||||
# shellcheck disable=2034
|
# shellcheck disable=2034
|
||||||
HARDENING_EXCEPTION=http
|
HARDENING_EXCEPTION=http
|
||||||
|
|
||||||
PACKAGES='squid3 squid'
|
PACKAGES='squid3 squid tinyproxy'
|
||||||
|
|
||||||
# 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() {
|
||||||
@ -57,17 +57,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -57,17 +57,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -23,7 +23,7 @@ HARDENING_EXCEPTION=mail
|
|||||||
audit() {
|
audit() {
|
||||||
is_pkg_installed net-tools
|
is_pkg_installed net-tools
|
||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "netsat not installed, cannot execute check"
|
warn "netstat not installed, cannot execute check"
|
||||||
exit 2
|
exit 2
|
||||||
else
|
else
|
||||||
info "Checking netport ports opened"
|
info "Checking netport ports opened"
|
||||||
@ -47,7 +47,7 @@ audit() {
|
|||||||
apply() {
|
apply() {
|
||||||
is_pkg_installed net-tools
|
is_pkg_installed net-tools
|
||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "netsat not installed, cannot execute check"
|
warn "netstat not installed, cannot execute check"
|
||||||
exit 2
|
exit 2
|
||||||
else
|
else
|
||||||
info "Checking netport ports opened"
|
info "Checking netport ports opened"
|
||||||
@ -77,17 +77,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -68,17 +68,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -17,7 +17,7 @@ HARDENING_LEVEL=3
|
|||||||
# shellcheck disable=2034
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable NIS Server."
|
DESCRIPTION="Disable NIS Server."
|
||||||
|
|
||||||
PACKAGES='nis'
|
PACKAGES='nis ypserv'
|
||||||
|
|
||||||
# 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() {
|
||||||
@ -55,17 +55,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
73
bin/hardening/2.2.18_disable_tftp.sh
Executable file
73
bin/hardening/2.2.18_disable_tftp.sh
Executable file
@ -0,0 +1,73 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# run-shellcheck
|
||||||
|
#
|
||||||
|
# CIS Debian Hardening
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# 2.2.18 Ensure TFTP server is not enabled (Scored)
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e # One error, it's over
|
||||||
|
set -u # One variable unset, it's over
|
||||||
|
|
||||||
|
# shellcheck disable=2034
|
||||||
|
HARDENING_LEVEL=3
|
||||||
|
# shellcheck disable=2034
|
||||||
|
DESCRIPTION="Ensure Trivial File Transfer Protocol server is not enabled."
|
||||||
|
# shellcheck disable=2034
|
||||||
|
HARDENING_EXCEPTION=tftp
|
||||||
|
|
||||||
|
PACKAGES='tftpd tftpd-hpa'
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled / audit mode
|
||||||
|
audit() {
|
||||||
|
for PACKAGE in $PACKAGES; do
|
||||||
|
is_pkg_installed "$PACKAGE"
|
||||||
|
if [ "$FNRET" = 0 ]; then
|
||||||
|
crit "$PACKAGE is installed!"
|
||||||
|
else
|
||||||
|
ok "$PACKAGE is absent"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# This function will be called if the script status is on enabled mode
|
||||||
|
apply() {
|
||||||
|
for PACKAGE in $PACKAGES; do
|
||||||
|
is_pkg_installed "$PACKAGE"
|
||||||
|
if [ "$FNRET" = 0 ]; then
|
||||||
|
crit "$PACKAGE is installed, purging it"
|
||||||
|
apt-get purge "$PACKAGE" -y
|
||||||
|
apt-get autoremove -y
|
||||||
|
else
|
||||||
|
ok "$PACKAGE is absent"
|
||||||
|
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
|
@ -58,17 +58,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -55,17 +55,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -57,17 +57,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -57,17 +57,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -57,17 +57,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -57,17 +57,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -19,7 +19,7 @@ DESCRIPTION="Ensure Domain Name System (dns) server is not enabled."
|
|||||||
# shellcheck disable=2034
|
# shellcheck disable=2034
|
||||||
HARDENING_EXCEPTION=dns
|
HARDENING_EXCEPTION=dns
|
||||||
|
|
||||||
PACKAGES='bind9 unbound'
|
PACKAGES='bind9 unbound dnsmasq'
|
||||||
|
|
||||||
# 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() {
|
||||||
@ -57,17 +57,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -58,17 +58,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -17,29 +17,32 @@ HARDENING_LEVEL=3
|
|||||||
# shellcheck disable=2034
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Ensure that Network Information Service is not installed. Recommended alternative : LDAP."
|
DESCRIPTION="Ensure that Network Information Service is not installed. Recommended alternative : LDAP."
|
||||||
|
|
||||||
PACKAGE='nis'
|
PACKAGES='nis ypbind-mt'
|
||||||
|
|
||||||
# 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() {
|
||||||
is_pkg_installed "$PACKAGE"
|
for PACKAGE in $PACKAGES; do
|
||||||
if [ "$FNRET" = 0 ]; then
|
is_pkg_installed "$PACKAGE"
|
||||||
crit "$PACKAGE is installed!"
|
if [ "$FNRET" = 0 ]; then
|
||||||
else
|
crit "$PACKAGE is installed!"
|
||||||
ok "$PACKAGE is absent"
|
else
|
||||||
fi
|
ok "$PACKAGE is absent"
|
||||||
:
|
fi
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# 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() {
|
||||||
is_pkg_installed "$PACKAGE"
|
for PACKAGE in $PACKAGES; do
|
||||||
if [ "$FNRET" = 0 ]; then
|
is_pkg_installed "$PACKAGE"
|
||||||
crit "$PACKAGE is installed, purging it"
|
if [ "$FNRET" = 0 ]; then
|
||||||
apt-get purge "$PACKAGE" -y
|
crit "$PACKAGE is installed, purging it"
|
||||||
apt-get autoremove -y
|
apt-get purge "$PACKAGE" -y
|
||||||
else
|
apt-get autoremove -y
|
||||||
ok "$PACKAGE is absent"
|
else
|
||||||
fi
|
ok "$PACKAGE is absent"
|
||||||
|
fi
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will check config parameters required
|
# This function will check config parameters required
|
||||||
@ -52,17 +55,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -56,17 +56,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -55,17 +55,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
@ -55,17 +55,17 @@ if [ -r /etc/default/cis-hardening ]; then
|
|||||||
# shellcheck source=../../debian/default
|
# shellcheck source=../../debian/default
|
||||||
. /etc/default/cis-hardening
|
. /etc/default/cis-hardening
|
||||||
fi
|
fi
|
||||||
if [ -z "$CIS_ROOT_DIR" ]; then
|
if [ -z "$CIS_LIB_DIR" ]; then
|
||||||
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
echo "There is no /etc/default/cis-hardening file nor cis-hardening directory in current environment."
|
||||||
echo "Cannot source CIS_ROOT_DIR variable, aborting."
|
echo "Cannot source CIS_LIB_DIR variable, aborting."
|
||||||
exit 128
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
# Main function, will call the proper functions given the configuration (audit, enabled, disabled)
|
||||||
if [ -r "$CIS_ROOT_DIR"/lib/main.sh ]; then
|
if [ -r "${CIS_LIB_DIR}"/main.sh ]; then
|
||||||
# shellcheck source=../../lib/main.sh
|
# shellcheck source=../../lib/main.sh
|
||||||
. "$CIS_ROOT_DIR"/lib/main.sh
|
. "${CIS_LIB_DIR}"/main.sh
|
||||||
else
|
else
|
||||||
echo "Cannot find main.sh, have you correctly defined your root directory? Current value is $CIS_ROOT_DIR in /etc/default/cis-hardening"
|
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
|
exit 128
|
||||||
fi
|
fi
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user