-
-
Notifications
You must be signed in to change notification settings - Fork 20
feat(roles/aide): add aide remediation #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,22 @@ | ||||||||
| - name: 'Playbook linuxfabrik.lfops.rl9_cis' | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i would like to call the playbook for cis differently ( for now, rename this playbook to |
||||||||
| hosts: | ||||||||
| - 'lfops_rl9_cis' | ||||||||
|
|
||||||||
| pre_tasks: | ||||||||
| - ansible.builtin.import_role: | ||||||||
| name: 'shared' | ||||||||
| tasks_from: 'log-start.yml' | ||||||||
| tags: | ||||||||
| - 'always' | ||||||||
|
|
||||||||
|
|
||||||||
| roles: | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please include a newline after
Suggested change
|
||||||||
| - role: 'linuxfabrik.lfops.aide' | ||||||||
|
|
||||||||
|
|
||||||||
| post_tasks: | ||||||||
| - ansible.builtin.import_role: | ||||||||
| name: 'shared' | ||||||||
| tasks_from: 'log-end.yml' | ||||||||
| tags: | ||||||||
| - 'always' | ||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ | |
|
|
||
| - name: 'Deploy /etc/systemd/system/acme-sh.service' | ||
| ansible.builtin.template: | ||
| backup: true | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unrelated changes, undo these |
||
| src: 'etc/systemd/system/acme-sh.service.j2' | ||
| dest: '/etc/systemd/system/acme-sh.service' | ||
| owner: 'root' | ||
|
|
@@ -37,6 +38,7 @@ | |
|
|
||
| - name: 'Deploy /etc/systemd/system/acme-sh.timer' | ||
| ansible.builtin.template: | ||
| backup: true | ||
| src: 'etc/systemd/system/acme-sh.timer.j2' | ||
| dest: '/etc/systemd/system/acme-sh.timer' | ||
| owner: 'root' | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Ansible Role linuxfabrik.lfops.aide | ||
|
|
||
| This role ensures that AIDE is installed, configured, and scheduled for regular filesystem integrity checks. | ||
|
|
||
| * The initial AIDE database is created only if `/var/lib/aide/aide.db.gz` does not already exist. | ||
|
|
||
|
|
||
| ## Tags | ||
|
|
||
| | Tag | What it does | Reload / Restart | | ||
| | --- | ------------ | ---------------- | | ||
| | `aide` | Runs all tasks of the role | - | | ||
| | `aide:configure` | Deploys the `/etc/aide.conf` configuration file | - | | ||
| | `aide:install` | Installs the AIDE package and initializes the AIDE database if it does not exist yet | - | | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this tag |
||
| | `aide:update_db` | Rebuilds the AIDE database; Only runs if called explicitly | - | | ||
| | `aide:state` | Deploys and enables the `aide-check.service` and `aide-check.timer` systemd units | Reloads systemd daemon if unit files changed | | ||
|
|
||
|
|
||
| ## Optional Role Variables | ||
|
|
||
| | Variable | Description | Default Value | | ||
| | -------- | ----------- | ------------- | | ||
| | `aide__check_time_on_calendar` | Specifies at what time of the day the aide check runs. Have a look at [systemd.time(7)](https://www.freedesktop.org/software/systemd/man/systemd.time.html) for the format. | `'05:00:00'` | | ||
| | `aide__include_rules` | List of paths to monitor with their AIDE rule group. | `['/srv CONTENT_EX', '/opt/venv CONTENT']` | | ||
| | `aide__exclude_rules` | List of paths to exclude from monitoring. | `['/srv/app/tmp', '/srv/app/cache']` | | ||
|
Comment on lines
+23
to
+25
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please sort them alphabetically |
||
|
|
||
| Example: | ||
| ```yaml | ||
| # optional | ||
| aide__check_time_on_calendar: '03:00:00' | ||
| aide__include_rules: | ||
| - '/etc CONTENT_EX' # Extended content + file type + access | ||
| - '/srv/app/node_modules CONTENT' # Content + file type | ||
| aide__exclude_rules: | ||
| - '/var/log' | ||
| ``` | ||
|
|
||
|
|
||
| ## License | ||
|
|
||
| [The Unlicense](https://unlicense.org/) | ||
|
|
||
|
|
||
| ## Author Information | ||
|
|
||
| [Linuxfabrik GmbH, Zurich](https://www.linuxfabrik.ch) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| aide__check_time_on_calendar: '05:00:00' #5 AM | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. generally don't add comments that are "user documentation" in the defaults file - comments for the developer are fine. these comments should be contained in the README (either in the table or in the examples section) |
||
|
|
||
| #vars for aide.conf | ||
| aide__include_rules: | ||
| - '/srv CONTENT_EX' # Extended content + file type + access. | ||
| - '/opt/venv CONTENT' # Content + file type. | ||
|
|
||
| aide__exclude_rules: | ||
| - '/srv/app/tmp' | ||
| - '/srv/app/cache' | ||
|
Comment on lines
+4
to
+10
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where do these default values come from? |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| - name: 'aide: init db' | ||
| ansible.builtin.service: | ||
| name: | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. something is missing here ;) |
||
|
|
||
| - name: 'aide: enable aidecheck.service' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. enabling a service shouldn't be a handler (it is also never used) |
||
| ansible.builtin.service: | ||
| name: 'aidecheck.service' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please configure your editor to do the end of file correctly (consistent with our other files)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be |
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,91 @@ | ||||||
| # CIS_Rocky_Linux_9_Benchmark_v2.0.0 | ||||||
| - block: | ||||||
|
|
||||||
| - name: '6.1.1 Ensure AIDE is installed' | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's keep the names unrelated to cis (since this could also be used without any stig, or for a different stig)
Suggested change
|
||||||
| ansible.builtin.package: | ||||||
| name: | ||||||
| - 'aide' | ||||||
| state: 'present' | ||||||
|
|
||||||
| - name: 'Initialize AIDE database' | ||||||
| ansible.builtin.command: 'aide --init --before "database_out=file:/var/lib/aide/aide.db.gz"' | ||||||
| args: | ||||||
| creates: '/var/lib/aide/aide.db.gz' | ||||||
|
|
||||||
| tags: | ||||||
| - 'aide' | ||||||
| - 'aide:install' | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we do not use |
||||||
|
|
||||||
|
|
||||||
| # CIS_Rocky_Linux_9_Benchmark_v2.0.0 | ||||||
| - block: | ||||||
|
|
||||||
| - name: '6.1.3 Ensure cryptographic mechanisms are used to protect the integrity of audit tools' | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do not use CIS names in the task names - the roles should be generic |
||||||
| ansible.builtin.template: | ||||||
| backup: true | ||||||
| src: 'etc/aide.conf.j2' | ||||||
| dest: '/etc/aide.conf' | ||||||
| owner: 'root' | ||||||
| group: 'root' | ||||||
| mode: 0o644 | ||||||
|
|
||||||
| tags: | ||||||
| - 'aide' | ||||||
| - 'aide:configure' | ||||||
|
|
||||||
|
|
||||||
| # CIS_Rocky_Linux_9_Benchmark_v2.0.0 | ||||||
| - block: | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i would move this whole block to the end of the file, for cleaner separation |
||||||
|
|
||||||
| - name: 'Update AIDE database' | ||||||
| ansible.builtin.command: "aide --init --before 'database_out=file:/var/lib/aide/aide.db.gz'" | ||||||
| changed_when: "'AIDE initialized database at' in aide__dbupdate_result.stdout" | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||||||
| register: 'aide__dbupdate_result' | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use the |
||||||
|
|
||||||
| tags: | ||||||
| - 'never' | ||||||
| - 'aide:update_db' | ||||||
|
|
||||||
|
|
||||||
| # 6.1.2 Ensure filesystem integrity is regularly checked | ||||||
| # CIS_Rocky_Linux_9_Benchmark_v2.0.0 | ||||||
| - block: | ||||||
|
|
||||||
| - name: 'Create /etc/systemd/system/aide-check.service' | ||||||
| ansible.builtin.template: | ||||||
| src: 'etc/systemd/system/aide-check.service.j2' | ||||||
| dest: '/etc/systemd/system/aide-check.service' | ||||||
| owner: 'root' | ||||||
| group: 'root' | ||||||
| mode: 0o644 | ||||||
| register: '__aide__service_unit_result' | ||||||
|
|
||||||
| - name: 'Create /etc/systemd/system/aide-check.timer' | ||||||
| ansible.builtin.template: | ||||||
| src: 'etc/systemd/system/aide-check.timer.j2' | ||||||
| dest: '/etc/systemd/system/aide-check.timer' | ||||||
| owner: 'root' | ||||||
| group: 'root' | ||||||
| mode: 0o644 | ||||||
| register: '__aide__timer_unit_result' | ||||||
|
|
||||||
| - name: 'Reload systemd' | ||||||
| ansible.builtin.systemd: | ||||||
| daemon_reload: true | ||||||
| when: | ||||||
| - '__aide__service_unit_result is changed or __aide__timer_unit_result is changed' | ||||||
|
|
||||||
| - name: 'Enable aide-check.service' | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we really need to enable the service? |
||||||
| ansible.builtin.systemd: | ||||||
| name: 'aide-check.service' | ||||||
| enabled: true | ||||||
|
|
||||||
| - name: 'Enable aide-check.timer' | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| ansible.builtin.systemd: | ||||||
| name: 'aide-check.timer' | ||||||
| state: 'started' | ||||||
| enabled: true | ||||||
|
|
||||||
| tags: | ||||||
| - 'aide' | ||||||
| - 'aide:state' | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.