mirror of
https://github.com/ovh/debian-cis.git
synced 2025-07-16 22:02:17 +02:00
Compare commits
130 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 | |||
06525f06f9 | |||
d5c1c63971 | |||
7d93ddeb86 | |||
a35ecab377 | |||
dc952b90df | |||
82a217032d | |||
e478a89bad | |||
371c23cd52 | |||
ea8334d516 | |||
987bb9c975 | |||
3031bb55d1 | |||
66ccc6316a | |||
7a3145d7f1 | |||
5c072668d5 | |||
d1bd1eb2e7 | |||
ad5c71c3ce | |||
33964c0a3d | |||
8320d0eecc | |||
a0d33ab158 | |||
a6a22084e1 | |||
b962155a3c | |||
20bf51f65b | |||
adfe28470a | |||
c94ee10afe | |||
453a72b8c8 | |||
bb03764918 | |||
17d272420a | |||
f1c1517bd2 | |||
1341622335 | |||
c8fcfed248 | |||
97914976c8 | |||
66c8ccf495 | |||
b53bf1795c | |||
1a874b2b35 | |||
7266ec7cb4 | |||
8f855ac159 | |||
ad192c9457 | |||
3d2d97a727 | |||
6e2fb1570c | |||
faf5b155e5 | |||
43887d4165 | |||
499ebf2f9b | |||
afed5a9dce | |||
01c3d1b98c | |||
25e899168f | |||
9a2e3a0e0d | |||
334d743125 | |||
4ed8adf790 | |||
f4328deeb2 | |||
29505255ff | |||
9e6c9a0d8a | |||
1cade2e375 | |||
fc8a2b2561 | |||
cadc25c28c | |||
8c6c9a7571 | |||
dd41988933 | |||
f6c6e6a0a8 | |||
d26ad48416 | |||
d110a2aa19 | |||
cbd81b8ab2 | |||
1c51e4cec4 | |||
f8ac58700d | |||
1c1393c7e3 | |||
c50f200c5c | |||
c0ecc9cd6f | |||
fb5be208ef | |||
b44fb47c3a | |||
84ac4db90f | |||
40fb536d4e | |||
d1b371f410 | |||
6ab1cab3ce | |||
1a7dd5893a | |||
fa111bc0d0 | |||
460843ffb3 | |||
896d277d95 | |||
6ae05f3fa2 | |||
449c695415 | |||
2d6550fb13 | |||
0b6ea0d97e | |||
ec9e2addc2 | |||
ed1baa724e | |||
bd4ddfc398 | |||
5a72d986ea | |||
c51513e083 | |||
6127f2fe67 | |||
6efefa07ac | |||
dce926a536 | |||
0edb837f80 | |||
1c2e171655 | |||
4a652a94c6 |
4
.github/workflows/compile-manual.yml
vendored
4
.github/workflows/compile-manual.yml
vendored
@ -7,10 +7,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@v2
|
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@v6
|
- uses: EndBug/add-and-commit@v9
|
||||||
with:
|
with:
|
||||||
add: 'debian/cis-hardening.8'
|
add: 'debian/cis-hardening.8'
|
||||||
message: 'Regenerate man pages (Github action)'
|
message: 'Regenerate man pages (Github action)'
|
||||||
|
23
.github/workflows/functionnal-tests.yml
vendored
23
.github/workflows/functionnal-tests.yml
vendored
@ -4,17 +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@v2
|
|
||||||
- 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@v2
|
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:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Run the tests 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
|
||||||
|
8
.github/workflows/pre-release.yml
vendored
8
.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@v2
|
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.1.2
|
uses: dev-drprasad/delete-tag-and-release@v1.0.1
|
||||||
with:
|
with:
|
||||||
delete_release: true
|
delete_release: true
|
||||||
tag_name: latest
|
tag_name: latest
|
||||||
@ -29,12 +29,12 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
# GET LATEST VERSION TAG
|
# GET LATEST VERSION TAG
|
||||||
- name: Get latest version tag
|
- name: Get latest version tag
|
||||||
uses: actions-ecosystem/action-get-latest-tag@v1
|
uses: actions-ecosystem/action-get-latest-tag@v1.6.0
|
||||||
id: get-latest-tag
|
id: get-latest-tag
|
||||||
# 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@v0.4.4
|
uses: metcalfc/changelog-generator@v4.2.0
|
||||||
with:
|
with:
|
||||||
myToken: ${{ secrets.GITHUB_TOKEN }}
|
myToken: ${{ secrets.GITHUB_TOKEN }}
|
||||||
head-ref: ${{ github.sha }}
|
head-ref: ${{ github.sha }}
|
||||||
|
15
.github/workflows/shellcheck_and_shellfmt.yml
vendored
15
.github/workflows/shellcheck_and_shellfmt.yml
vendored
@ -4,19 +4,26 @@ on:
|
|||||||
- push
|
- push
|
||||||
- pull_request
|
- pull_request
|
||||||
jobs:
|
jobs:
|
||||||
sh-checker:
|
shellfmt:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v4
|
||||||
- name: Run the sh-checker
|
- name: Run the sh-checker
|
||||||
uses: luizm/action-sh-checker@v0.1.10
|
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.
|
||||||
SHELLCHECK_OPTS: --color=always --shell=bash -x --source-path=SCRIPTDIR # Optional: exclude some shellcheck warnings.
|
|
||||||
SHFMT_OPTS: -l -i 4 -w # Optional: pass arguments to shfmt.
|
SHFMT_OPTS: -l -i 4 -w # Optional: pass arguments to shfmt.
|
||||||
with:
|
with:
|
||||||
|
sh_checker_shellcheck_disable: true
|
||||||
sh_checker_comment: true
|
sh_checker_comment: true
|
||||||
sh_checker_exclude: |
|
sh_checker_exclude: |
|
||||||
src/
|
src/
|
||||||
debian/postrm
|
debian/postrm
|
||||||
|
shellcheck:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Run shellcheck
|
||||||
|
run: ./shellcheck/docker_build_and_run_shellcheck.sh
|
||||||
|
6
.github/workflows/tagged-release.yml
vendored
6
.github/workflows/tagged-release.yml
vendored
@ -7,8 +7,6 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Create Release
|
name: Create Release
|
||||||
# only runs on master
|
|
||||||
if: github.event.base_ref == 'refs/heads/master'
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
# GET VERSION TAG
|
# GET VERSION TAG
|
||||||
@ -17,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@v2
|
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
|
||||||
@ -35,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.1.2
|
uses: dev-drprasad/delete-tag-and-release@v1.0.1
|
||||||
with:
|
with:
|
||||||
delete_release: true
|
delete_release: true
|
||||||
tag_name: latest
|
tag_name: latest
|
||||||
|
15
MANUAL.md
15
MANUAL.md
@ -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.
|
||||||
|
|
||||||
@ -115,11 +115,20 @@ will create a timestamped backup in this directory.
|
|||||||
the -n option instructs sudo not to prompt for a password.
|
the -n option instructs sudo not to prompt for a password.
|
||||||
Finally note that `--sudo` mode only works for audit mode.
|
Finally note that `--sudo` mode only works for audit mode.
|
||||||
|
|
||||||
|
`--set-log-level=level`
|
||||||
|
: This option sets LOGLEVEL, you can choose : info, warning, error, ok, debug.
|
||||||
|
Default value is : info
|
||||||
|
|
||||||
`--batch`
|
`--batch`
|
||||||
: While performing system audit, this option sets LOGLEVEL to 'ok' and
|
: While performing system audit, this option sets LOGLEVEL to 'ok' and
|
||||||
captures all output to print only one line once the check is done, formatted like :
|
captures all output to print only one line once the check is done, formatted like :
|
||||||
OK|KO OK|KO|WARN{subcheck results} [OK|KO|WARN{...}]
|
OK|KO OK|KO|WARN{subcheck results} [OK|KO|WARN{...}]
|
||||||
|
|
||||||
|
`--allow-unsupported-distribution`
|
||||||
|
Must be specified manually in the command line to allow the run on non compatible
|
||||||
|
version or distribution. If you want to mute the warning change the LOGLEVEL
|
||||||
|
in /etc/hardening.cfg
|
||||||
|
|
||||||
|
|
||||||
# AUTHORS
|
# AUTHORS
|
||||||
|
|
||||||
@ -130,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.
|
||||||
|
42
README.md
42
README.md
@ -1,7 +1,4 @@
|
|||||||
# :lock: CIS Debian 9/10 Hardening
|
# :lock: CIS Debian 10/11/12 Hardening
|
||||||
|
|
||||||
:tada: **News**: this projet 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_install_updates.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
|
||||||
@ -117,9 +119,16 @@ to allow a certain kind of services on the machine, such as http, mail, etc.
|
|||||||
Can be specified multiple times to allow multiple services.
|
Can be specified multiple times to allow multiple services.
|
||||||
Use --allow-service-list to get a list of supported services.
|
Use --allow-service-list to get a list of supported services.
|
||||||
|
|
||||||
|
``--set-log-level <level>``: This option sets LOGLEVEL, you can choose : info, warning, error, ok, debug.
|
||||||
|
Default value is : info
|
||||||
|
|
||||||
``--create-config-files-only``: create the config files in etc/conf.d. Must be run as root,
|
``--create-config-files-only``: create the config files in etc/conf.d. Must be run as root,
|
||||||
before running the audit with user secaudit, to have the rights setup well on the conf files.
|
before running the audit with user secaudit, to have the rights setup well on the conf files.
|
||||||
|
|
||||||
|
``--allow-unsupported-distribution``: must be specified manually in the command line to allow
|
||||||
|
the run on non compatible version or distribution. If you want to mute the warning change the
|
||||||
|
LOGLEVEL in /etc/hardening.cfg
|
||||||
|
|
||||||
## :computer: Hacking
|
## :computer: Hacking
|
||||||
|
|
||||||
**Getting the source**
|
**Getting the source**
|
||||||
@ -165,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.
|
||||||
@ -237,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
|
||||||
@ -250,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/
|
||||||
|
140
bin/hardening.sh
140
bin/hardening.sh
@ -26,6 +26,9 @@ ALLOW_SERVICE_LIST=0
|
|||||||
SET_HARDENING_LEVEL=0
|
SET_HARDENING_LEVEL=0
|
||||||
SUDO_MODE=''
|
SUDO_MODE=''
|
||||||
BATCH_MODE=''
|
BATCH_MODE=''
|
||||||
|
SUMMARY_JSON=''
|
||||||
|
ASK_LOGLEVEL=''
|
||||||
|
ALLOW_UNSUPPORTED_DISTRIBUTION=0
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
@ -98,11 +101,24 @@ OPTIONS:
|
|||||||
the '-n' option instructs sudo not to prompt for a password.
|
the '-n' option instructs sudo not to prompt for a password.
|
||||||
Finally note that '--sudo' mode only works for audit mode.
|
Finally note that '--sudo' mode only works for audit mode.
|
||||||
|
|
||||||
|
--set-log-level <level>
|
||||||
|
This option sets LOGLEVEL, you can choose : info, warning, error, ok, debug or silent.
|
||||||
|
Default value is : info
|
||||||
|
|
||||||
|
--summary-json
|
||||||
|
While performing system audit, this option sets LOGLEVEL to silent and
|
||||||
|
only output a json summary at the end
|
||||||
|
|
||||||
--batch
|
--batch
|
||||||
While performing system audit, this option sets LOGLEVEL to 'ok' and
|
While performing system audit, this option sets LOGLEVEL to 'ok' and
|
||||||
captures all output to print only one line once the check is done, formatted like :
|
captures all output to print only one line once the check is done, formatted like :
|
||||||
OK|KO OK|KO|WARN{subcheck results} [OK|KO|WARN{...}]
|
OK|KO OK|KO|WARN{subcheck results} [OK|KO|WARN{...}]
|
||||||
|
|
||||||
|
--allow-unsupported-distribution
|
||||||
|
Must be specified manually in the command line to allow the run on non compatible
|
||||||
|
version or distribution. If you want to mute the warning change the LOGLEVEL
|
||||||
|
in /etc/hardening.cfg
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
@ -143,6 +159,10 @@ while [[ $# -gt 0 ]]; do
|
|||||||
SET_HARDENING_LEVEL="$2"
|
SET_HARDENING_LEVEL="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
--set-log-level)
|
||||||
|
ASK_LOGLEVEL=$2
|
||||||
|
shift
|
||||||
|
;;
|
||||||
--only)
|
--only)
|
||||||
TEST_LIST[${#TEST_LIST[@]}]="$2"
|
TEST_LIST[${#TEST_LIST[@]}]="$2"
|
||||||
shift
|
shift
|
||||||
@ -150,9 +170,16 @@ while [[ $# -gt 0 ]]; do
|
|||||||
--sudo)
|
--sudo)
|
||||||
SUDO_MODE='--sudo'
|
SUDO_MODE='--sudo'
|
||||||
;;
|
;;
|
||||||
|
--summary-json)
|
||||||
|
SUMMARY_JSON='--summary-json'
|
||||||
|
ASK_LOGLEVEL=silent
|
||||||
|
;;
|
||||||
--batch)
|
--batch)
|
||||||
BATCH_MODE='--batch'
|
BATCH_MODE='--batch'
|
||||||
LOGLEVEL=ok
|
ASK_LOGLEVEL=ok
|
||||||
|
;;
|
||||||
|
--allow-unsupported-distribution)
|
||||||
|
ALLOW_UNSUPPORTED_DISTRIBUTION=1
|
||||||
;;
|
;;
|
||||||
-h | --help)
|
-h | --help)
|
||||||
usage
|
usage
|
||||||
@ -174,26 +201,63 @@ 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=../lib/constants.sh
|
|
||||||
[ -r "$CIS_ROOT_DIR"/lib/constants.sh ] && . "$CIS_ROOT_DIR"/lib/constants.sh
|
|
||||||
# shellcheck source=../etc/hardening.cfg
|
|
||||||
[ -r "$CIS_ROOT_DIR"/etc/hardening.cfg ] && . "$CIS_ROOT_DIR"/etc/hardening.cfg
|
|
||||||
# shellcheck source=../lib/common.sh
|
|
||||||
[ -r "$CIS_ROOT_DIR"/lib/common.sh ] && . "$CIS_ROOT_DIR"/lib/common.sh
|
|
||||||
# shellcheck source=../lib/utils.sh
|
|
||||||
[ -r "$CIS_ROOT_DIR"/lib/utils.sh ] && . "$CIS_ROOT_DIR"/lib/utils.sh
|
|
||||||
|
|
||||||
if [ "$BATCH_MODE" ]; then MACHINE_LOG_LEVEL=3; fi
|
# shellcheck source=../etc/hardening.cfg
|
||||||
|
[ -r "${CIS_CONF_DIR}"/hardening.cfg ] && . "${CIS_CONF_DIR}"/hardening.cfg
|
||||||
|
if [ "$ASK_LOGLEVEL" ]; then LOGLEVEL=$ASK_LOGLEVEL; fi
|
||||||
|
# shellcheck source=../lib/common.sh
|
||||||
|
[ -r "${CIS_LIB_DIR}"/common.sh ] && . "${CIS_LIB_DIR}"/common.sh
|
||||||
|
# shellcheck source=../lib/utils.sh
|
||||||
|
[ -r "${CIS_LIB_DIR}"/utils.sh ] && . "${CIS_LIB_DIR}"/utils.sh
|
||||||
|
# shellcheck source=../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
|
||||||
|
# print warning, otherwise quit
|
||||||
|
|
||||||
|
if [ "$DISTRIBUTION" != "debian" ]; then
|
||||||
|
echo "Your distribution has been identified as $DISTRIBUTION which is not debian"
|
||||||
|
if [ "$ALLOW_UNSUPPORTED_DISTRIBUTION" -eq 0 ]; then
|
||||||
|
echo "If you want to run it anyway, you can use the flag --allow-unsupported-distribution"
|
||||||
|
echo "Exiting now"
|
||||||
|
exit 100
|
||||||
|
elif [ "$ALLOW_UNSUPPORTED_DISTRIBUTION" -eq 0 ] && [ "$MACHINE_LOG_LEVEL" -ge 2 ]; then
|
||||||
|
echo "Be aware that the result given by this set of scripts can give you a false feedback of security on unsupported distributions !"
|
||||||
|
echo "You can deactivate this message by setting the LOGLEVEL variable in /etc/hardening.cfg"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [ "$DEB_MAJ_VER" = "sid" ] || [ "$DEB_MAJ_VER" -gt "$HIGHEST_SUPPORTED_DEBIAN_VERSION" ]; then
|
||||||
|
echo "Your debian version is too recent and is not supported yet because there is no official CIS PDF for this version yet."
|
||||||
|
if [ "$ALLOW_UNSUPPORTED_DISTRIBUTION" -eq 0 ]; then
|
||||||
|
echo "If you want to run it anyway, you can use the flag --allow-unsupported-distribution"
|
||||||
|
echo "Exiting now"
|
||||||
|
exit 100
|
||||||
|
elif [ "$ALLOW_UNSUPPORTED_DISTRIBUTION" -eq 0 ] && [ "$MACHINE_LOG_LEVEL" -ge 2 ]; then
|
||||||
|
echo "Be aware that the result given by this set of scripts can give you a false feedback of security on unsupported distributions !"
|
||||||
|
echo "You can deactivate this message by setting the LOGLEVEL variable in /etc/hardening.cfg"
|
||||||
|
fi
|
||||||
|
elif [ "$DEB_MAJ_VER" -lt "$SMALLEST_SUPPORTED_DEBIAN_VERSION" ]; then
|
||||||
|
echo "Your debian version is deprecated and is no more maintained. Please upgrade to a supported version."
|
||||||
|
if [ "$ALLOW_UNSUPPORTED_DISTRIBUTION" -eq 0 ]; then
|
||||||
|
echo "If you want to run it anyway, you can use the flag --allow-unsupported-distribution"
|
||||||
|
echo "Exiting now"
|
||||||
|
exit 100
|
||||||
|
elif [ "$ALLOW_UNSUPPORTED_DISTRIBUTION" -eq 0 ] && [ "$MACHINE_LOG_LEVEL" -ge 2 ]; then
|
||||||
|
echo "Be aware that the result given by this set of scripts can give you a false feedback of security on unsupported distributions, especially on deprecated ones !"
|
||||||
|
echo "You can deactivate this message by setting the LOGLEVEL variable in /etc/hardening.cfg"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
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
|
||||||
@ -208,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
|
||||||
@ -217,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
|
||||||
@ -229,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
|
||||||
@ -243,20 +307,20 @@ 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"
|
||||||
"$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"
|
||||||
"$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"
|
||||||
"$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"
|
||||||
"$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"
|
||||||
"$SCRIPT"
|
LOGLEVEL=$LOGLEVEL "$SCRIPT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SCRIPT_EXITCODE=$?
|
SCRIPT_EXITCODE=$?
|
||||||
@ -268,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)
|
||||||
@ -294,12 +358,24 @@ if [ "$BATCH_MODE" ]; then
|
|||||||
BATCH_SUMMARY+="RUN_CHECKS:${TOTAL_TREATED_CHECKS:-0} "
|
BATCH_SUMMARY+="RUN_CHECKS:${TOTAL_TREATED_CHECKS:-0} "
|
||||||
BATCH_SUMMARY+="TOTAL_CHECKS_AVAIL:${TOTAL_CHECKS:-0}"
|
BATCH_SUMMARY+="TOTAL_CHECKS_AVAIL:${TOTAL_CHECKS:-0}"
|
||||||
if [ "$TOTAL_TREATED_CHECKS" != 0 ]; then
|
if [ "$TOTAL_TREATED_CHECKS" != 0 ]; then
|
||||||
CONFORMITY_PERCENTAGE=$(bc -l <<<"scale=2; ($PASSED_CHECKS/$TOTAL_TREATED_CHECKS) * 100")
|
CONFORMITY_PERCENTAGE=$(div $((PASSED_CHECKS * 100)) $TOTAL_TREATED_CHECKS)
|
||||||
BATCH_SUMMARY+=" CONFORMITY_PERCENTAGE:$(printf "%s" "$CONFORMITY_PERCENTAGE")"
|
BATCH_SUMMARY+=" CONFORMITY_PERCENTAGE:$(printf "%s" "$CONFORMITY_PERCENTAGE")"
|
||||||
else
|
else
|
||||||
BATCH_SUMMARY+=" CONFORMITY_PERCENTAGE:N.A" # No check runned, avoid division by 0
|
BATCH_SUMMARY+=" CONFORMITY_PERCENTAGE:N.A" # No check runned, avoid division by 0
|
||||||
fi
|
fi
|
||||||
becho "$BATCH_SUMMARY"
|
becho "$BATCH_SUMMARY"
|
||||||
|
elif [ "$SUMMARY_JSON" ]; then
|
||||||
|
if [ "$TOTAL_TREATED_CHECKS" != 0 ]; then
|
||||||
|
CONFORMITY_PERCENTAGE=$(div $((PASSED_CHECKS * 100)) $TOTAL_TREATED_CHECKS)
|
||||||
|
else
|
||||||
|
CONFORMITY_PERCENTAGE=0 # No check runned, avoid division by 0
|
||||||
|
fi
|
||||||
|
printf '{'
|
||||||
|
printf '"available_checks": %s, ' "$TOTAL_CHECKS"
|
||||||
|
printf '"run_checks": %s, ' "$TOTAL_TREATED_CHECKS"
|
||||||
|
printf '"passed_checks": %s, ' "$PASSED_CHECKS"
|
||||||
|
printf '"conformity_percentage": %s' "$CONFORMITY_PERCENTAGE"
|
||||||
|
printf '}\n'
|
||||||
else
|
else
|
||||||
printf "%40s\n" "################### SUMMARY ###################"
|
printf "%40s\n" "################### SUMMARY ###################"
|
||||||
printf "%30s %s\n" "Total Available Checks :" "$TOTAL_CHECKS"
|
printf "%30s %s\n" "Total Available Checks :" "$TOTAL_CHECKS"
|
||||||
@ -307,8 +383,8 @@ else
|
|||||||
printf "%30s [ %7s ]\n" "Total Passed Checks :" "$PASSED_CHECKS/$TOTAL_TREATED_CHECKS"
|
printf "%30s [ %7s ]\n" "Total Passed Checks :" "$PASSED_CHECKS/$TOTAL_TREATED_CHECKS"
|
||||||
printf "%30s [ %7s ]\n" "Total Failed Checks :" "$FAILED_CHECKS/$TOTAL_TREATED_CHECKS"
|
printf "%30s [ %7s ]\n" "Total Failed Checks :" "$FAILED_CHECKS/$TOTAL_TREATED_CHECKS"
|
||||||
|
|
||||||
ENABLED_CHECKS_PERCENTAGE=$(bc -l <<<"scale=2; ($TOTAL_TREATED_CHECKS/$TOTAL_CHECKS) * 100")
|
ENABLED_CHECKS_PERCENTAGE=$(div $((TOTAL_TREATED_CHECKS * 100)) $TOTAL_CHECKS)
|
||||||
CONFORMITY_PERCENTAGE=$(bc -l <<<"scale=2; ($PASSED_CHECKS/$TOTAL_TREATED_CHECKS) * 100")
|
CONFORMITY_PERCENTAGE=$(div $((PASSED_CHECKS * 100)) $TOTAL_TREATED_CHECKS)
|
||||||
printf "%30s %s %%\n" "Enabled Checks Percentage :" "$ENABLED_CHECKS_PERCENTAGE"
|
printf "%30s %s %%\n" "Enabled Checks Percentage :" "$ENABLED_CHECKS_PERCENTAGE"
|
||||||
if [ "$TOTAL_TREATED_CHECKS" != 0 ]; then
|
if [ "$TOTAL_TREATED_CHECKS" != 0 ]; then
|
||||||
printf "%30s %s %%\n" "Conformity Percentage :" "$CONFORMITY_PERCENTAGE"
|
printf "%30s %s %%\n" "Conformity Percentage :" "$CONFORMITY_PERCENTAGE"
|
||||||
|
@ -17,28 +17,36 @@ HARDENING_LEVEL=2
|
|||||||
# shellcheck disable=2034
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable mounting of freevxfs filesystems."
|
DESCRIPTION="Disable mounting of freevxfs filesystems."
|
||||||
|
|
||||||
# Note: we check /proc/config.gz to be compliant with both monolithic and modular kernels
|
|
||||||
|
|
||||||
KERNEL_OPTION="CONFIG_VXFS_FS"
|
KERNEL_OPTION="CONFIG_VXFS_FS"
|
||||||
MODULE_NAME="freevxfs"
|
MODULE_NAME="freevxfs"
|
||||||
|
|
||||||
# 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() {
|
||||||
|
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"
|
is_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_NAME"
|
||||||
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
||||||
crit "$KERNEL_OPTION is enabled!"
|
crit "$MODULE_NAME is enabled!"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled"
|
ok "$MODULE_NAME is disabled"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
is_kernel_option_enabled "$KERNEL_OPTION"
|
if [ "$IS_CONTAINER" -eq 1 ]; then
|
||||||
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
# In an unprivileged container, the kernel modules are host dependent, so you should consider enforcing it
|
||||||
warn "I cannot fix $KERNEL_OPTION enabled, recompile your kernel please"
|
ok "Container detected, consider host enforcing!"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled, nothing to do"
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,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
|
||||||
|
@ -17,28 +17,36 @@ HARDENING_LEVEL=2
|
|||||||
# shellcheck disable=2034
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable mounting of jffs2 filesystems."
|
DESCRIPTION="Disable mounting of jffs2 filesystems."
|
||||||
|
|
||||||
# Note: we check /proc/config.gz to be compliant with both monolithic and modular kernels
|
|
||||||
|
|
||||||
KERNEL_OPTION="CONFIG_JFFS2_FS"
|
KERNEL_OPTION="CONFIG_JFFS2_FS"
|
||||||
MODULE_NAME="jffs2"
|
MODULE_NAME="jffs2"
|
||||||
|
|
||||||
# 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_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_NAME"
|
if [ "$IS_CONTAINER" -eq 1 ]; then
|
||||||
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
# In an unprivileged container, the kernel modules are host dependent, so you should consider enforcing it
|
||||||
crit "$KERNEL_OPTION is enabled!"
|
ok "Container detected, consider host enforcing or disable this check!"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled"
|
is_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_NAME" "($MODULE_NAME|install)"
|
||||||
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
is_kernel_option_enabled "$KERNEL_OPTION"
|
if [ "$IS_CONTAINER" -eq 1 ]; then
|
||||||
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
# In an unprivileged container, the kernel modules are host dependent, so you should consider enforcing it
|
||||||
warn "I cannot fix $KERNEL_OPTION enabled, recompile your kernel please"
|
ok "Container detected, consider host enforcing!"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled, nothing to do"
|
is_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_NAME" "($MODULE_NAME|install)"
|
||||||
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,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
|
||||||
|
@ -17,28 +17,36 @@ HARDENING_LEVEL=2
|
|||||||
# shellcheck disable=2034
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable mounting of hfs filesystems."
|
DESCRIPTION="Disable mounting of hfs filesystems."
|
||||||
|
|
||||||
# Note: we check /proc/config.gz to be compliant with both monolithic and modular kernels
|
|
||||||
|
|
||||||
KERNEL_OPTION="CONFIG_HFS_FS"
|
KERNEL_OPTION="CONFIG_HFS_FS"
|
||||||
MODULE_FILE="hfs"
|
MODULE_NAME="hfs"
|
||||||
|
|
||||||
# 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_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_FILE"
|
if [ "$IS_CONTAINER" -eq 1 ]; then
|
||||||
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
# In an unprivileged container, the kernel modules are host dependent, so you should consider enforcing it
|
||||||
crit "$KERNEL_OPTION is enabled!"
|
ok "Container detected, consider host enforcing or disable this check!"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled"
|
is_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_NAME" "($MODULE_NAME|install)"
|
||||||
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
is_kernel_option_enabled "$KERNEL_OPTION"
|
if [ "$IS_CONTAINER" -eq 1 ]; then
|
||||||
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
# In an unprivileged container, the kernel modules are host dependent, so you should consider enforcing it
|
||||||
warn "I cannot fix $KERNEL_OPTION enabled, recompile your kernel please"
|
ok "Container detected, consider host enforcing!"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled, nothing to do"
|
is_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_NAME" "($MODULE_NAME|install)"
|
||||||
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,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
|
||||||
|
@ -17,28 +17,36 @@ HARDENING_LEVEL=2
|
|||||||
# shellcheck disable=2034
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable mounting of hfsplus filesystems."
|
DESCRIPTION="Disable mounting of hfsplus filesystems."
|
||||||
|
|
||||||
# Note: we check /proc/config.gz to be compliant with both monolithic and modular kernels
|
|
||||||
|
|
||||||
KERNEL_OPTION="CONFIG_HFSPLUS_FS"
|
KERNEL_OPTION="CONFIG_HFSPLUS_FS"
|
||||||
MODULE_FILE="hfsplus"
|
MODULE_NAME="hfsplus"
|
||||||
|
|
||||||
# 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_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_FILE"
|
if [ "$IS_CONTAINER" -eq 1 ]; then
|
||||||
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
# In an unprivileged container, the kernel modules are host dependent, so you should consider enforcing it
|
||||||
crit "$KERNEL_OPTION is enabled!"
|
ok "Container detected, consider host enforcing or disable this check!"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled"
|
is_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_NAME" "($MODULE_NAME|install)"
|
||||||
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
is_kernel_option_enabled "$KERNEL_OPTION"
|
if [ "$IS_CONTAINER" -eq 1 ]; then
|
||||||
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
# In an unprivileged container, the kernel modules are host dependent, so you should consider enforcing it
|
||||||
warn "I cannot fix $KERNEL_OPTION enabled, recompile your kernel please"
|
ok "Container detected, consider host enforcing!"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled, nothing to do"
|
is_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_NAME" "($MODULE_NAME|install)"
|
||||||
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,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
|
||||||
|
@ -17,31 +17,37 @@ HARDENING_LEVEL=2
|
|||||||
# shellcheck disable=2034
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable mounting of squashfs filesytems."
|
DESCRIPTION="Disable mounting of squashfs filesytems."
|
||||||
|
|
||||||
# Note: we check /proc/config.gz to be compliant with both monolithic and modular kernels
|
|
||||||
|
|
||||||
KERNEL_OPTION="CONFIG_SQUASHFS"
|
KERNEL_OPTION="CONFIG_SQUASHFS"
|
||||||
MODULE_FILE="squashfs"
|
MODULE_NAME="squashfs"
|
||||||
|
|
||||||
# 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_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_FILE"
|
if [ "$IS_CONTAINER" -eq 1 ]; then
|
||||||
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
# In an unprivileged container, the kernel modules are host dependent, so you should consider enforcing it
|
||||||
crit "$KERNEL_OPTION is enabled!"
|
ok "Container detected, consider host enforcing or disable this check!"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled"
|
is_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_NAME" "($MODULE_NAME|install)"
|
||||||
|
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
|
fi
|
||||||
:
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
is_kernel_option_enabled "$KERNEL_OPTION"
|
if [ "$IS_CONTAINER" -eq 1 ]; then
|
||||||
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
# In an unprivileged container, the kernel modules are host dependent, so you should consider enforcing it
|
||||||
warn "I cannot fix $KERNEL_OPTION enabled, recompile your kernel please"
|
ok "Container detected, consider host enforcing!"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled, nothing to do"
|
is_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_NAME" "($MODULE_NAME|install)"
|
||||||
|
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
|
fi
|
||||||
:
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will check config parameters required
|
# This function will check config parameters required
|
||||||
@ -54,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
|
||||||
|
@ -17,28 +17,36 @@ HARDENING_LEVEL=2
|
|||||||
# shellcheck disable=2034
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable mounting of udf filesystems."
|
DESCRIPTION="Disable mounting of udf filesystems."
|
||||||
|
|
||||||
# Note: we check /proc/config.gz to be compliant with both monolithic and modular kernels
|
|
||||||
|
|
||||||
KERNEL_OPTION="CONFIG_UDF_FS"
|
KERNEL_OPTION="CONFIG_UDF_FS"
|
||||||
MODULE_FILE="udf"
|
MODULE_NAME="udf"
|
||||||
|
|
||||||
# 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_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_FILE"
|
if [ "$IS_CONTAINER" -eq 1 ]; then
|
||||||
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
# In an unprivileged container, the kernel modules are host dependent, so you should consider enforcing it
|
||||||
crit "$KERNEL_OPTION is enabled!"
|
ok "Container detected, consider host enforcing or disable this check!"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled"
|
is_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_NAME" "($MODULE_NAME|install)"
|
||||||
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
is_kernel_option_enabled "$KERNEL_OPTION"
|
if [ "$IS_CONTAINER" -eq 1 ]; then
|
||||||
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
# In an unprivileged container, the kernel modules are host dependent, so you should consider enforcing it
|
||||||
warn "I cannot fix $KERNEL_OPTION enabled, recompile your kernel please"
|
ok "Container detected, consider host enforcing!"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled, nothing to do"
|
is_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_NAME" "($MODULE_NAME|install)"
|
||||||
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,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
|
||||||
|
@ -24,6 +24,7 @@ MODULE_FILE="vfat"
|
|||||||
|
|
||||||
# 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() {
|
||||||
|
# TODO check if uefi enabled if yes check if only boot partition use FAT
|
||||||
is_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_FILE"
|
is_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_FILE"
|
||||||
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
||||||
crit "$KERNEL_OPTION is enabled!"
|
crit "$KERNEL_OPTION is enabled!"
|
||||||
@ -52,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
|
||||||
|
@ -24,7 +24,11 @@ OPTION="nodev"
|
|||||||
# 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() {
|
||||||
info "Verifying that $PARTITION is a partition"
|
info "Verifying that $PARTITION is a partition"
|
||||||
|
if [ -e "$PARTITION" ]; then
|
||||||
PARTITION=$(readlink -e "$PARTITION")
|
PARTITION=$(readlink -e "$PARTITION")
|
||||||
|
else
|
||||||
|
PARTITION="/dev/shm"
|
||||||
|
fi
|
||||||
FNRET=0
|
FNRET=0
|
||||||
is_a_partition "$PARTITION"
|
is_a_partition "$PARTITION"
|
||||||
if [ "$FNRET" -gt 0 ]; then
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
@ -77,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
|
||||||
|
@ -24,7 +24,11 @@ OPTION="nosuid"
|
|||||||
# 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() {
|
||||||
info "Verifying that $PARTITION is a partition"
|
info "Verifying that $PARTITION is a partition"
|
||||||
|
if [ -e "$PARTITION" ]; then
|
||||||
PARTITION=$(readlink -e "$PARTITION")
|
PARTITION=$(readlink -e "$PARTITION")
|
||||||
|
else
|
||||||
|
PARTITION="/dev/shm"
|
||||||
|
fi
|
||||||
FNRET=0
|
FNRET=0
|
||||||
is_a_partition "$PARTITION"
|
is_a_partition "$PARTITION"
|
||||||
if [ "$FNRET" -gt 0 ]; then
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
@ -77,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
|
||||||
|
@ -24,7 +24,11 @@ OPTION="noexec"
|
|||||||
# 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() {
|
||||||
info "Verifying that $PARTITION is a partition"
|
info "Verifying that $PARTITION is a partition"
|
||||||
|
if [ -e "$PARTITION" ]; then
|
||||||
PARTITION=$(readlink -e "$PARTITION")
|
PARTITION=$(readlink -e "$PARTITION")
|
||||||
|
else
|
||||||
|
PARTITION="/dev/shm"
|
||||||
|
fi
|
||||||
FNRET=0
|
FNRET=0
|
||||||
is_a_partition "$PARTITION"
|
is_a_partition "$PARTITION"
|
||||||
if [ "$FNRET" -gt 0 ]; then
|
if [ "$FNRET" -gt 0 ]; then
|
||||||
@ -77,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
|
||||||
|
@ -17,12 +17,32 @@ HARDENING_LEVEL=2
|
|||||||
# shellcheck disable=2034
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Set sticky bit on world writable directories to prevent users from deleting or renaming files that are not owned by them."
|
DESCRIPTION="Set sticky bit on world writable directories to prevent users from deleting or renaming files that are not owned by them."
|
||||||
|
|
||||||
|
EXCEPTIONS=''
|
||||||
|
|
||||||
|
# find emits following error if directory or file disappear during
|
||||||
|
# tree traversal: find: ‘/tmp/xxx’: No such file or directory
|
||||||
|
FIND_IGNORE_NOSUCHFILE_ERR=false
|
||||||
|
|
||||||
# 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() {
|
||||||
info "Checking if setuid is set on world writable Directories"
|
info "Checking if setuid is set on world writable Directories"
|
||||||
FS_NAMES=$(df --local -P | awk '{if (NR!=1) print $6}')
|
if [ -n "$EXCEPTIONS" ]; then
|
||||||
|
# maybe EXCEPTIONS allow us to filter out some FS
|
||||||
|
FS_NAMES=$(df --local -P | awk '{if (NR!=1) print $6}' | grep -vE "$EXCEPTIONS")
|
||||||
|
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set +e
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
RESULT=$($SUDO_CMD find $FS_NAMES -xdev -type d \( -perm -0002 -a ! -perm -1000 \) -print 2>/dev/null)
|
RESULT=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -type d \( -perm -0002 -a ! -perm -1000 \) -regextype 'egrep' ! -regex $EXCEPTIONS -print 2>/dev/null)
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set -e
|
||||||
|
else
|
||||||
|
FS_NAMES=$(df --local -P | awk '{if (NR!=1) print $6}')
|
||||||
|
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set +e
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
RESULT=$($SUDO_CMD find $FS_NAMES -xdev -ignore_readdir_race -type d \( -perm -0002 -a ! -perm -1000 \) -print 2>/dev/null)
|
||||||
|
[ "${FIND_IGNORE_NOSUCHFILE_ERR}" = true ] && set -e
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n "$RESULT" ]; then
|
if [ -n "$RESULT" ]; then
|
||||||
crit "Some world writable directories are not on sticky bit mode!"
|
crit "Some world writable directories are not on sticky bit mode!"
|
||||||
# shellcheck disable=SC2001
|
# shellcheck disable=SC2001
|
||||||
@ -35,9 +55,16 @@ audit() {
|
|||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
RESULT=$(df --local -P | awk '{if (NR!=1) print $6}' | xargs -I '{}' find '{}' -xdev -type d \( -perm -0002 -a ! -perm -1000 \) -print 2>/dev/null)
|
if [ -n "$EXCEPTIONS" ]; then
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
RESULT=$(df --local -P | awk '{if (NR!=1) print $6}' | grep -vE "$EXCEPTIONS" | xargs -I '{}' find '{}' -xdev -ignore_readdir_race -type d \( -perm -0002 -a ! -perm -1000 \) -regextype 'egrep' ! -regex "$EXCEPTIONS" -print 2>/dev/null)
|
||||||
|
else
|
||||||
|
RESULT=$(df --local -P | awk '{if (NR!=1) print $6}' | xargs -I '{}' find '{}' -xdev -ignore_readdir_race -type d \( -perm -0002 -a ! -perm -1000 \) -print 2>/dev/null)
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n "$RESULT" ]; then
|
if [ -n "$RESULT" ]; then
|
||||||
df --local -P | awk '{if (NR!=1) print $6}' | xargs -I '{}' find '{}' -xdev -type d -perm -0002 2>/dev/null | xargs chmod a+t
|
warn "Setting sticky bit on world writable directories"
|
||||||
|
df --local -P | awk '{if (NR!=1) print $6}' | xargs -I '{}' find '{}' -xdev -ignore_readdir_race -type d -perm -0002 2>/dev/null | xargs chmod a+t
|
||||||
else
|
else
|
||||||
ok "All world writable directories have a sticky bit, nothing to apply"
|
ok "All world writable directories have a sticky bit, nothing to apply"
|
||||||
fi
|
fi
|
||||||
@ -54,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
|
||||||
|
@ -20,25 +20,35 @@ DESCRIPTION="Disable USB storage."
|
|||||||
# Note: we check /proc/config.gz to be compliant with both monolithic and modular kernels
|
# Note: we check /proc/config.gz to be compliant with both monolithic and modular kernels
|
||||||
|
|
||||||
KERNEL_OPTION="CONFIG_USB_STORAGE"
|
KERNEL_OPTION="CONFIG_USB_STORAGE"
|
||||||
MODULE_FILE="usb-storage"
|
MODULE_NAME="usb-storage"
|
||||||
|
|
||||||
# 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_kernel_option_enabled "$KERNEL_OPTION" "$MODULE_FILE"
|
if [ "$IS_CONTAINER" -eq 1 ]; then
|
||||||
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
# In an unprivileged container, the kernel modules are host dependent, so you should consider enforcing it
|
||||||
crit "$KERNEL_OPTION is enabled!"
|
ok "Container detected, consider host enforcing or disable this check!"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled"
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
is_kernel_option_enabled "$KERNEL_OPTION"
|
if [ "$IS_CONTAINER" -eq 1 ]; then
|
||||||
if [ "$FNRET" = 0 ]; then # 0 means true in bash, so it IS activated
|
# In an unprivileged container, the kernel modules are host dependent, so you should consider enforcing it
|
||||||
warn "I cannot fix $KERNEL_OPTION enabled, recompile your kernel please"
|
ok "Container detected, consider host enforcing!"
|
||||||
else
|
else
|
||||||
ok "$KERNEL_OPTION is disabled, nothing to do"
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,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
|
||||||
|
@ -23,6 +23,7 @@ FILE='/boot/grub/grub.cfg'
|
|||||||
USER='root'
|
USER='root'
|
||||||
GROUP='root'
|
GROUP='root'
|
||||||
PERMISSIONS='400'
|
PERMISSIONS='400'
|
||||||
|
PERMISSIONSOK='400 600'
|
||||||
|
|
||||||
# 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() {
|
||||||
@ -33,7 +34,7 @@ audit() {
|
|||||||
crit "$FILE ownership was not set to $USER:$GROUP"
|
crit "$FILE ownership was not set to $USER:$GROUP"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
has_file_correct_permissions "$FILE" "$PERMISSIONS"
|
has_file_one_of_permissions "$FILE" "$PERMISSIONSOK"
|
||||||
if [ "$FNRET" = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct permissions"
|
ok "$FILE has correct permissions"
|
||||||
else
|
else
|
||||||
@ -51,7 +52,7 @@ apply() {
|
|||||||
chown "$USER":"$GROUP" "$FILE"
|
chown "$USER":"$GROUP" "$FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
has_file_correct_permissions "$FILE" "$PERMISSIONS"
|
has_file_one_of_permissions "$FILE" "$PERMISSIONSOK"
|
||||||
if [ "$FNRET" = 0 ]; then
|
if [ "$FNRET" = 0 ]; then
|
||||||
ok "$FILE has correct permissions"
|
ok "$FILE has correct permissions"
|
||||||
else
|
else
|
||||||
@ -63,25 +64,25 @@ apply() {
|
|||||||
# This function will check config parameters required
|
# This function will check config parameters required
|
||||||
check_config() {
|
check_config() {
|
||||||
|
|
||||||
is_pkg_installed "grub-pc"
|
is_pkg_installed "grub-common"
|
||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "Grub is not installed, not handling configuration"
|
warn "Grub is not installed, not handling configuration"
|
||||||
exit 128
|
exit 2
|
||||||
fi
|
fi
|
||||||
does_user_exist "$USER"
|
does_user_exist "$USER"
|
||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$USER does not exist"
|
crit "$USER does not exist"
|
||||||
exit 128
|
exit 2
|
||||||
fi
|
fi
|
||||||
does_group_exist "$GROUP"
|
does_group_exist "$GROUP"
|
||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$GROUP does not exist"
|
crit "$GROUP does not exist"
|
||||||
exit 128
|
exit 2
|
||||||
fi
|
fi
|
||||||
does_file_exist "$FILE"
|
does_file_exist "$FILE"
|
||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$FILE does not exist"
|
crit "$FILE does not exist"
|
||||||
exit 128
|
exit 2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,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
|
||||||
|
@ -51,19 +51,18 @@ apply() {
|
|||||||
else
|
else
|
||||||
ok "$PWD_PATTERN is present in $FILE"
|
ok "$PWD_PATTERN is present in $FILE"
|
||||||
fi
|
fi
|
||||||
:
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will check config parameters required
|
# This function will check config parameters required
|
||||||
check_config() {
|
check_config() {
|
||||||
is_pkg_installed "grub-pc"
|
is_pkg_installed "grub-common"
|
||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
warn "grub-pc is not installed, not handling configuration"
|
warn "Grub is not installed, not handling configuration"
|
||||||
exit 128
|
exit 2
|
||||||
fi
|
fi
|
||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$FILE does not exist"
|
crit "$FILE does not exist"
|
||||||
exit 128
|
exit 2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,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
|
||||||
|
@ -38,7 +38,6 @@ apply() {
|
|||||||
else
|
else
|
||||||
ok "$PATTERN is not present in $FILE"
|
ok "$PATTERN is not present in $FILE"
|
||||||
fi
|
fi
|
||||||
:
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will check config parameters required
|
# This function will check config parameters required
|
||||||
@ -51,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
|
||||||
|
@ -35,6 +35,9 @@ nx_supported_and_enabled() {
|
|||||||
|
|
||||||
# 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() {
|
||||||
|
if [ "$IS_CONTAINER" -eq 1 ]; then
|
||||||
|
ok "Container detected, cannot read dmesg!"
|
||||||
|
else
|
||||||
does_pattern_exist_in_dmesg "$PATTERN"
|
does_pattern_exist_in_dmesg "$PATTERN"
|
||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
nx_supported_and_enabled
|
nx_supported_and_enabled
|
||||||
@ -46,10 +49,14 @@ audit() {
|
|||||||
else
|
else
|
||||||
ok "$PATTERN is present in dmesg"
|
ok "$PATTERN is present in dmesg"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
|
if [ "$IS_CONTAINER" -eq 1 ]; then
|
||||||
|
ok "Container detected, cannot read dmesg!"
|
||||||
|
else
|
||||||
does_pattern_exist_in_dmesg "$PATTERN"
|
does_pattern_exist_in_dmesg "$PATTERN"
|
||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
nx_supported_and_enabled
|
nx_supported_and_enabled
|
||||||
@ -61,6 +68,7 @@ apply() {
|
|||||||
else
|
else
|
||||||
ok "$PATTERN is present in dmesg"
|
ok "$PATTERN is present in dmesg"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will check config parameters required
|
# This function will check config parameters required
|
||||||
@ -73,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
|
||||||
|
@ -29,7 +29,7 @@ audit() {
|
|||||||
LIMIT_FILES=""
|
LIMIT_FILES=""
|
||||||
if $SUDO_CMD [ -d "$LIMIT_DIR" ]; then
|
if $SUDO_CMD [ -d "$LIMIT_DIR" ]; then
|
||||||
for file in $($SUDO_CMD ls "$LIMIT_DIR"/*.conf 2>/dev/null); do
|
for file in $($SUDO_CMD ls "$LIMIT_DIR"/*.conf 2>/dev/null); do
|
||||||
LIMIT_FILES="$LIMIT_FILES $LIMIT_DIR/$file"
|
LIMIT_FILES="$LIMIT_FILES $file"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
debug "Files to search $LIMIT_FILE $LIMIT_FILES"
|
debug "Files to search $LIMIT_FILE $LIMIT_FILES"
|
||||||
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -21,15 +21,27 @@ PACKAGES='apparmor apparmor-utils'
|
|||||||
|
|
||||||
# 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() {
|
||||||
|
ERROR=0
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed "$PACKAGE"
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$PACKAGE is absent!"
|
crit "$PACKAGE is absent!"
|
||||||
|
ERROR=1
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is installed"
|
ok "$PACKAGE is installed"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ "$ERROR" = 0 ]; then
|
||||||
|
is_pkg_installed "grub-common"
|
||||||
|
if [ "$FNRET" != 0 ]; then
|
||||||
|
if [ "$IS_CONTAINER" -eq 1 ]; then
|
||||||
|
ok "Grub is not installed in container"
|
||||||
|
else
|
||||||
|
warn "Grub is not installed"
|
||||||
|
exit 128
|
||||||
|
fi
|
||||||
|
else
|
||||||
ERROR=0
|
ERROR=0
|
||||||
RESULT=$($SUDO_CMD grep "^\s*linux" /boot/grub/grub.cfg)
|
RESULT=$($SUDO_CMD grep "^\s*linux" /boot/grub/grub.cfg)
|
||||||
|
|
||||||
@ -48,6 +60,8 @@ audit() {
|
|||||||
ok "$PACKAGES are configured"
|
ok "$PACKAGES are configured"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
@ -62,6 +76,14 @@ apply() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
is_pkg_installed "grub-pc"
|
||||||
|
if [ "$FNRET" != 0 ]; then
|
||||||
|
if [ "$IS_CONTAINER" -eq 1 ]; then
|
||||||
|
ok "Grub is not installed in container"
|
||||||
|
else
|
||||||
|
warn "You should use grub. Install it yourself"
|
||||||
|
fi
|
||||||
|
else
|
||||||
ERROR=0
|
ERROR=0
|
||||||
RESULT=$($SUDO_CMD grep "^\s*linux" /boot/grub/grub.cfg)
|
RESULT=$($SUDO_CMD grep "^\s*linux" /boot/grub/grub.cfg)
|
||||||
|
|
||||||
@ -83,6 +105,7 @@ apply() {
|
|||||||
else
|
else
|
||||||
ok "$PACKAGES are configured"
|
ok "$PACKAGES are configured"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will check config parameters required
|
# This function will check config parameters required
|
||||||
@ -95,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
|
||||||
|
@ -21,15 +21,17 @@ PACKAGES='apparmor apparmor-utils'
|
|||||||
|
|
||||||
# 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() {
|
||||||
|
ERROR=0
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed "$PACKAGE"
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$PACKAGE is absent!"
|
crit "$PACKAGE is absent!"
|
||||||
|
ERROR=1
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is installed"
|
ok "$PACKAGE is installed"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
if [ "$ERROR" = 0 ]; then
|
||||||
RESULT_UNCONFINED=$($SUDO_CMD apparmor_status | grep "^0 processes are unconfined but have a profile defined")
|
RESULT_UNCONFINED=$($SUDO_CMD apparmor_status | grep "^0 processes are unconfined but have a profile defined")
|
||||||
|
|
||||||
if [ -n "$RESULT_UNCONFINED" ]; then
|
if [ -n "$RESULT_UNCONFINED" ]; then
|
||||||
@ -38,6 +40,7 @@ audit() {
|
|||||||
else
|
else
|
||||||
crit "Some processes are unconfined while they have defined profile"
|
crit "Some processes are unconfined while they have defined profile"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
@ -46,6 +49,7 @@ apply() {
|
|||||||
is_pkg_installed "$PACKAGE"
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$PACKAGES is absent!"
|
crit "$PACKAGES is absent!"
|
||||||
|
apt_install "$PACKAGE"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is installed"
|
ok "$PACKAGE is installed"
|
||||||
fi
|
fi
|
||||||
@ -71,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
|
||||||
|
@ -21,17 +21,19 @@ PACKAGES='apparmor apparmor-utils'
|
|||||||
|
|
||||||
# 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() {
|
||||||
|
ERROR=0
|
||||||
for PACKAGE in $PACKAGES; do
|
for PACKAGE in $PACKAGES; do
|
||||||
is_pkg_installed "$PACKAGE"
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$PACKAGE is absent!"
|
crit "$PACKAGE is absent!"
|
||||||
|
ERROR=1
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is installed"
|
ok "$PACKAGE is installed"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
if [ "$ERROR" = 0 ]; then
|
||||||
RESULT_UNCONFINED=$($SUDO_CMD apparmor_status | grep "^0 processes are unconfined but have a profile defined")
|
RESULT_UNCONFINED=$($SUDO_CMD apparmor_status | grep "^0 processes are unconfined but have a profile defined" || true)
|
||||||
RESULT_COMPLAIN=$($SUDO_CMD apparmor_status | grep "^0 profiles are in complain mode.")
|
RESULT_COMPLAIN=$($SUDO_CMD apparmor_status | grep "^0 profiles are in complain mode." || true)
|
||||||
|
|
||||||
if [ -n "$RESULT_UNCONFINED" ]; then
|
if [ -n "$RESULT_UNCONFINED" ]; then
|
||||||
ok "No profiles are unconfined"
|
ok "No profiles are unconfined"
|
||||||
@ -44,6 +46,7 @@ audit() {
|
|||||||
else
|
else
|
||||||
crit "Some processes are in complain mode"
|
crit "Some processes are in complain mode"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
@ -52,13 +55,14 @@ apply() {
|
|||||||
is_pkg_installed "$PACKAGE"
|
is_pkg_installed "$PACKAGE"
|
||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$PACKAGE is absent!"
|
crit "$PACKAGE is absent!"
|
||||||
|
apt_install "$PACKAGE"
|
||||||
else
|
else
|
||||||
ok "$PACKAGE is installed"
|
ok "$PACKAGE is installed"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
RESULT_UNCONFINED=$(apparmor_status | grep "^0 processes are unconfined but have a profile defined")
|
RESULT_UNCONFINED=$(apparmor_status | grep "^0 processes are unconfined but have a profile defined" || true)
|
||||||
RESULT_COMPLAIN=$(apparmor_status | grep "^0 profiles are in complain mode.")
|
RESULT_COMPLAIN=$(apparmor_status | grep "^0 profiles are in complain mode." || true)
|
||||||
|
|
||||||
if [ -n "$RESULT_UNCONFINED" ]; then
|
if [ -n "$RESULT_UNCONFINED" ]; then
|
||||||
ok "No profiles are unconfined"
|
ok "No profiles are unconfined"
|
||||||
@ -85,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
|
||||||
|
@ -21,8 +21,8 @@ SERVICE_NAME="systemd-timesyncd"
|
|||||||
|
|
||||||
# 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_service_enabled "$SERVICE_NAME"
|
status=$(systemctl is-enabled "$SERVICE_NAME")
|
||||||
if [ "$FNRET" = 0 ]; then
|
if [ "$status" = "enabled" ]; then
|
||||||
ok "$SERVICE_NAME is enabled"
|
ok "$SERVICE_NAME is enabled"
|
||||||
else
|
else
|
||||||
crit "$SERVICE_NAME is disabled"
|
crit "$SERVICE_NAME is disabled"
|
||||||
@ -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
|
||||||
|
@ -25,18 +25,12 @@ CONF_FILE='/etc/chrony/chrony.conf'
|
|||||||
|
|
||||||
# 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"
|
|
||||||
if [ "$FNRET" != 0 ]; then
|
|
||||||
crit "$PACKAGE is not installed!"
|
|
||||||
else
|
|
||||||
ok "$PACKAGE is installed, checking configuration"
|
|
||||||
does_pattern_exist_in_file "$CONF_FILE" "$CONF_DEFAULT_PATTERN"
|
does_pattern_exist_in_file "$CONF_FILE" "$CONF_DEFAULT_PATTERN"
|
||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$CONF_DEFAULT_PATTERN not found in $CONF_FILE"
|
crit "$CONF_DEFAULT_PATTERN not found in $CONF_FILE"
|
||||||
else
|
else
|
||||||
ok "$CONF_DEFAULT_PATTERN found in $CONF_FILE"
|
ok "$CONF_DEFAULT_PATTERN found in $CONF_FILE"
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
@ -46,7 +40,11 @@ apply() {
|
|||||||
|
|
||||||
# This function will check config parameters required
|
# This function will check config parameters required
|
||||||
check_config() {
|
check_config() {
|
||||||
:
|
is_pkg_installed "$PACKAGE"
|
||||||
|
if [ "$FNRET" != 0 ]; then
|
||||||
|
warn "$PACKAGE is not installed, not handling configuration"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
@ -54,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
|
||||||
|
@ -20,18 +20,13 @@ DESCRIPTION="Configure Network Time Protocol (ntp). Check restrict parameters an
|
|||||||
HARDENING_EXCEPTION=ntp
|
HARDENING_EXCEPTION=ntp
|
||||||
|
|
||||||
PACKAGE='ntp'
|
PACKAGE='ntp'
|
||||||
NTP_CONF_DEFAULT_PATTERN='^restrict -4 default (kod nomodify notrap nopeer noquery|ignore)'
|
NTP_CONF_DEFAULT_PATTERN='^restrict -4 default (kod nomodify notrap nopeer noquery|kod notrap nomodify nopeer noquery|ignore)'
|
||||||
NTP_CONF_FILE='/etc/ntp.conf'
|
NTP_CONF_FILE='/etc/ntp.conf'
|
||||||
NTP_INIT_PATTERN='RUNASUSER=ntp'
|
NTP_INIT_PATTERN='RUNASUSER=ntp'
|
||||||
NTP_INIT_FILE='/etc/init.d/ntp'
|
NTP_INIT_FILE='/etc/init.d/ntp'
|
||||||
|
|
||||||
# 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"
|
|
||||||
if [ "$FNRET" != 0 ]; then
|
|
||||||
crit "$PACKAGE is not installed!"
|
|
||||||
else
|
|
||||||
ok "$PACKAGE is installed, checking configuration"
|
|
||||||
does_pattern_exist_in_file "$NTP_CONF_FILE" "$NTP_CONF_DEFAULT_PATTERN"
|
does_pattern_exist_in_file "$NTP_CONF_FILE" "$NTP_CONF_DEFAULT_PATTERN"
|
||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
crit "$NTP_CONF_DEFAULT_PATTERN not found in $NTP_CONF_FILE"
|
crit "$NTP_CONF_DEFAULT_PATTERN not found in $NTP_CONF_FILE"
|
||||||
@ -44,7 +39,6 @@ audit() {
|
|||||||
else
|
else
|
||||||
ok "$NTP_INIT_PATTERN found in $NTP_INIT_FILE"
|
ok "$NTP_INIT_PATTERN found in $NTP_INIT_FILE"
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
@ -77,7 +71,11 @@ apply() {
|
|||||||
|
|
||||||
# This function will check config parameters required
|
# This function will check config parameters required
|
||||||
check_config() {
|
check_config() {
|
||||||
:
|
is_pkg_installed "$PACKAGE"
|
||||||
|
if [ "$FNRET" != 0 ]; then
|
||||||
|
warn "$PACKAGE is not installed, not handling configuration"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Source Root Dir Parameter
|
# Source Root Dir Parameter
|
||||||
@ -85,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
|
||||||
|
@ -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
|
||||||
|
@ -21,6 +21,11 @@ HARDENING_EXCEPTION=mail
|
|||||||
|
|
||||||
# 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 net-tools
|
||||||
|
if [ "$FNRET" != 0 ]; then
|
||||||
|
warn "netstat not installed, cannot execute check"
|
||||||
|
exit 2
|
||||||
|
else
|
||||||
info "Checking netport ports opened"
|
info "Checking netport ports opened"
|
||||||
RESULT=$($SUDO_CMD netstat -an | grep LIST | grep ":25[[:space:]]") || :
|
RESULT=$($SUDO_CMD netstat -an | grep LIST | grep ":25[[:space:]]") || :
|
||||||
RESULT=${RESULT:-}
|
RESULT=${RESULT:-}
|
||||||
@ -35,10 +40,16 @@ audit() {
|
|||||||
crit "MTA listens worldwide"
|
crit "MTA listens worldwide"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
|
is_pkg_installed net-tools
|
||||||
|
if [ "$FNRET" != 0 ]; then
|
||||||
|
warn "netstat not installed, cannot execute check"
|
||||||
|
exit 2
|
||||||
|
else
|
||||||
info "Checking netport ports opened"
|
info "Checking netport ports opened"
|
||||||
RESULT=$(netstat -an | grep LIST | grep ":25[[:space:]]") || :
|
RESULT=$(netstat -an | grep LIST | grep ":25[[:space:]]") || :
|
||||||
RESULT=${RESULT:-}
|
RESULT=${RESULT:-}
|
||||||
@ -53,7 +64,7 @@ apply() {
|
|||||||
warn "MTA listens worldwide, correct this considering your MTA"
|
warn "MTA listens worldwide, correct this considering your MTA"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
:
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will check config parameters required
|
# This function will check config parameters required
|
||||||
@ -66,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,14 +17,32 @@ HARDENING_LEVEL=3
|
|||||||
# shellcheck disable=2034
|
# shellcheck disable=2034
|
||||||
DESCRIPTION="Disable NIS Server."
|
DESCRIPTION="Disable NIS Server."
|
||||||
|
|
||||||
|
PACKAGES='nis'
|
||||||
|
|
||||||
# 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() {
|
||||||
:
|
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
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
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
|
# This function will check config parameters required
|
||||||
@ -37,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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -21,29 +21,17 @@ SYSCTL_PARAMS='net.ipv6.conf.all.disable_ipv6=1 net.ipv6.conf.default.disable_ip
|
|||||||
|
|
||||||
# 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() {
|
||||||
does_sysctl_param_exists "net.ipv6"
|
is_ipv6_enabled
|
||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
ok "ipv6 is disabled"
|
ok "ipv6 is disabled"
|
||||||
else
|
else
|
||||||
for SYSCTL_VALUES in $SYSCTL_PARAMS; do
|
crit "ipv6 is enabled"
|
||||||
SYSCTL_PARAM=$(echo "$SYSCTL_VALUES" | cut -d= -f 1)
|
|
||||||
SYSCTL_EXP_RESULT=$(echo "$SYSCTL_VALUES" | cut -d= -f 2)
|
|
||||||
debug "$SYSCTL_PARAM should be set to $SYSCTL_EXP_RESULT"
|
|
||||||
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
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# This function will be called if the script status is on enabled mode
|
# This function will be called if the script status is on enabled mode
|
||||||
apply() {
|
apply() {
|
||||||
does_sysctl_param_exists "net.ipv6"
|
is_ipv6_enabled
|
||||||
if [ "$FNRET" != 0 ]; then
|
if [ "$FNRET" != 0 ]; then
|
||||||
ok "ipv6 is disabled"
|
ok "ipv6 is disabled"
|
||||||
else
|
else
|
||||||
@ -75,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
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user