-
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 1 commit
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
53 changes: 53 additions & 0 deletions
53
...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,53 @@ | ||
| # platform = multi_platform_rhel | ||
| # reboot = false | ||
| # strategy = configure | ||
| # complexity = low | ||
| # disruption = low | ||
|
|
||
| # Copied and modified from `file_permissions/ansible.yml` template | ||
|
|
||
| - name: Ensure audit config files are not more permissive than 0600 | ||
| block: | ||
| - name: Set /etc/audit/audit.rules and /etc/audit/auditd.conf to 0600 | ||
| ansible.builtin.file: | ||
| path: "{{ item }}" | ||
| mode: '0600' | ||
| state: file | ||
| loop: | ||
| - /etc/audit/audit.rules | ||
| - /etc/audit/auditd.conf | ||
| failed_when: false | ||
|
|
||
| - name: Set /etc/audit/rules.d/*.rules files to 0600 | ||
| ansible.builtin.file: | ||
| path: "{{ item }}" | ||
| mode: '0600' | ||
| state: file | ||
| with_fileglob: | ||
| - /etc/audit/rules.d/*.rules | ||
|
|
||
| # augenrules --load hardcodes chmod 0640 on audit.rules on every rewrite of the rules.d files. | ||
| # Install ExecStartPost in auditd.service to restore 0600 after each run. | ||
| # Runs inside the auditd_t SELinux domain which has write access to auditd_etc_t files. | ||
| # On RHEL 8/9, augenrules is called via ExecStartPost in auditd.service directly. | ||
| - 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 - chmod audit.rules to 0600 after augenrules runs | ||
| 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: Reload systemd daemon to pick up permissions.conf | ||
| ansible.builtin.systemd: | ||
| daemon_reload: true | ||
|
|
||
| when: | ||
| - '"audit" in ansible_facts.packages' | ||
| - '"kernel-core" in ansible_facts.packages' | ||
35 changes: 35 additions & 0 deletions
35
.../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,35 @@ | ||
| # platform = multi_platform_rhel | ||
| # reboot = false | ||
| # strategy = configure | ||
| # complexity = low | ||
| # disruption = low | ||
|
|
||
| # Copied and modified from `file_permissions/bash.template` template | ||
|
|
||
| if rpm --quiet -q audit && rpm --quiet -q kernel-core; then | ||
|
|
||
| find /etc/audit/ -maxdepth 1 -type f \ | ||
| -regextype posix-extended -regex '^.*audit(\.rules|d\.conf)$' \ | ||
| -exec chmod 0600 {} \; | ||
|
|
||
| find /etc/audit/rules.d/ -maxdepth 1 -type f -name '*.rules' \ | ||
| -exec chmod 0600 {} \; | ||
|
|
||
| # augenrules --load hardcodes chmod 0640 on audit.rules on every rewrite of the rules.d files. | ||
| # Install ExecStartPost in auditd.service to restore 0600 after each run. | ||
| # Runs inside the auditd_t SELinux domain which has write access to auditd_etc_t files. | ||
| # On RHEL 8/9, augenrules is called via ExecStartPost in auditd.service directly. | ||
| 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.
|
||
|
|
||
| systemctl daemon-reload | ||
|
|
||
| else | ||
| >&2 echo 'Remediation is not applicable, nothing was done' | ||
| fi | ||
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.