-
Notifications
You must be signed in to change notification settings - Fork 818
DRAFT: fix remediations for file_permissions_audit_configuration_stig #15019
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
Draft
macko1
wants to merge
3
commits into
ComplianceAsCode:master
Choose a base branch
from
macko1:fix_file_permissions_audit_configuration_stig
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
...iting/auditd_configure_rules/file_permissions_audit_configuration_stig/ansible/shared.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # platform = multi_platform_rhel | ||
| # reboot = false | ||
| # strategy = configure | ||
| # complexity = low | ||
| # disruption = low | ||
|
|
||
| # Copied and modified from `file_permissions/ansible.yml` template | ||
| # | ||
| # Sets mode 0600 and ownership root:root on all audit config files. | ||
| # Installs an auditd.service dropin to restore 0600 on audit.rules after augenrules | ||
| # rewrites it to 0640 when /etc/audit/rules.d/ content changes (RHEL 8/9 only, not containers). | ||
|
|
||
| - name: Set /etc/audit/audit.rules and /etc/audit/auditd.conf to 0600, owned by root | ||
| ansible.builtin.file: | ||
| path: "{{ item }}" | ||
| mode: '0600' | ||
| owner: root | ||
| group: root | ||
| state: file | ||
| loop: | ||
| - /etc/audit/audit.rules | ||
| - /etc/audit/auditd.conf | ||
| failed_when: false | ||
|
|
||
| - name: Set /etc/audit/rules.d/*.rules files to 0600, owned by root | ||
| ansible.builtin.file: | ||
| path: "{{ item }}" | ||
| mode: '0600' | ||
| owner: root | ||
| group: root | ||
| state: file | ||
| with_fileglob: | ||
| - /etc/audit/rules.d/*.rules | ||
|
|
||
| - name: Install ExecStartPost dropin on auditd.service | ||
| block: | ||
| - name: Create dropin directory /etc/systemd/system/auditd.service.d | ||
| ansible.builtin.file: | ||
| path: /etc/systemd/system/auditd.service.d | ||
| state: directory | ||
| mode: '0755' | ||
|
|
||
| - name: Install /etc/systemd/system/auditd.service.d/permissions.conf | ||
| ansible.builtin.copy: | ||
|
macko1 marked this conversation as resolved.
|
||
| dest: /etc/systemd/system/auditd.service.d/permissions.conf | ||
| content: | | ||
| [Service] | ||
| ExecStartPost=/usr/bin/chmod 0600 /etc/audit/audit.rules | ||
| mode: '0644' | ||
|
|
||
| - name: Restore SELinux context on /etc/systemd/system/auditd.service.d/permissions.conf | ||
| ansible.builtin.command: restorecon /etc/systemd/system/auditd.service.d/permissions.conf | ||
| changed_when: false | ||
|
|
||
| - name: Reload systemd daemon to pick up permissions.conf | ||
| ansible.builtin.systemd: | ||
| daemon_reload: true | ||
|
|
||
| # IMPORTANT: this is necessary to ensure the dropin is loaded and the permissions for /etc/audit/ and /etc/audit/rules.d/ files are set correctly. | ||
| # !!!USE `service` module instead of `systemd` module to avoid | ||
| # "Operation refused" error, see https://access.redhat.com/solutions/2664811 | ||
| - name: Restart auditd.service | ||
| ansible.builtin.service: | ||
| name: auditd.service | ||
| state: restarted | ||
|
|
||
| when: | ||
| - '"audit" in ansible_facts.packages' | ||
| - '"kernel-core" in ansible_facts.packages' | ||
37 changes: 37 additions & 0 deletions
37
.../auditing/auditd_configure_rules/file_permissions_audit_configuration_stig/bash/shared.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # platform = multi_platform_rhel | ||
| # reboot = false | ||
| # strategy = configure | ||
| # complexity = low | ||
| # disruption = low | ||
|
|
||
| # Copied and modified from `file_permissions/bash.template` template | ||
| # | ||
| # Sets mode 0600 and ownership root:root on all audit config files. | ||
| # Installs an auditd.service dropin to restore 0600 on audit.rules after augenrules | ||
| # rewrites it to 0640 when /etc/audit/rules.d/ content changes (RHEL 8/9 only, not containers). | ||
|
|
||
| find /etc/audit/ -maxdepth 1 -type f \ | ||
| -regextype posix-extended -regex '^.*audit(\.rules|d\.conf)$' \ | ||
| -exec chmod 0600 {} \; \ | ||
| -exec chown root:root {} \; | ||
|
|
||
| find /etc/audit/rules.d/ -maxdepth 1 -type f -name '*.rules' \ | ||
| -exec chmod 0600 {} \; \ | ||
| -exec chown root:root {} \; | ||
|
|
||
| if rpm --quiet -q audit && rpm --quiet -q kernel-core; then | ||
|
|
||
| mkdir -p /etc/systemd/system/auditd.service.d | ||
| chmod 0755 /etc/systemd/system/auditd.service.d | ||
|
|
||
| cat > /etc/systemd/system/auditd.service.d/permissions.conf << 'EOF' | ||
| [Service] | ||
| ExecStartPost=/usr/bin/chmod 0600 /etc/audit/audit.rules | ||
| EOF | ||
| chmod 0644 /etc/systemd/system/auditd.service.d/permissions.conf | ||
|
macko1 marked this conversation as resolved.
|
||
| restorecon /etc/systemd/system/auditd.service.d/permissions.conf | ||
|
|
||
| systemctl daemon-reload | ||
| service restart auditd # IMPORTANT: this is necessary to ensure the dropin is loaded and the permissions for /etc/audit/ and /etc/audit/rules.d/ files are set correctly. | ||
|
|
||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.