-
Notifications
You must be signed in to change notification settings - Fork 717
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
[template]: fixes in file_owner template #13070
base: master
Are you sure you want to change the base?
Conversation
change parameter fileuid of file_owner template to uid_or_name explain its behavior
change the parameter name from filgeuid to uid_or_name additionally, use the -user parameter instead of -uid parameter in find command invocation the -user parameter accepts both uid and user names, where the -uid parameter accepts only uid
establish a new variable which carries information if the parameter is a uid or a user name
decide if to user ID or user name based on the variable declared in the preprocessing function change parameter name from file_uid to uid_or_name
Hi @alanmcanonical. Thanks for your PR. I'm waiting for a ComplianceAsCode member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
296d790
to
3507fcf
Compare
This datastream diff is auto generated by the check Click here to see the full diffbash remediation for rule 'xccdf_org.ssgproject.content_rule_file_owner_systemmap' differs.
--- xccdf_org.ssgproject.content_rule_file_owner_systemmap
+++ xccdf_org.ssgproject.content_rule_file_owner_systemmap
@@ -1,2 +1,2 @@
-find -L /boot/ -maxdepth 1 -type f ! -uid 0 -regextype posix-extended -regex '^.*System\.map.*$' -exec chown -L 0 {} \;
+find -L /boot/ -maxdepth 1 -type f ! -user 0 -regextype posix-extended -regex '^.*System\.map.*$' -exec chown -L 0 {} \;
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_file_owner_systemmap' differs.
--- xccdf_org.ssgproject.content_rule_file_owner_systemmap
+++ xccdf_org.ssgproject.content_rule_file_owner_systemmap
@@ -1,6 +1,6 @@
- name: Find /boot/ file(s) matching ^.*System\.map.*$
- command: find -H /boot/ -maxdepth 1 -type f ! -uid 0 -regextype posix-extended -regex
- "^.*System\.map.*$"
+ command: find -H /boot/ -maxdepth 1 -type f ! -user 0 -regextype posix-extended
+ -regex "^.*System\.map.*$"
register: files_found
changed_when: false
failed_when: false
bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_groupowner_var_log_syslog' differs.
--- xccdf_org.ssgproject.content_rule_file_groupowner_var_log_syslog
+++ xccdf_org.ssgproject.content_rule_file_groupowner_var_log_syslog
@@ -1 +1,8 @@
+# Remediation is applicable only in certain platforms
+if rpm --quiet -q rsyslog; then
+
chgrp 4 /var/log/syslog
+
+else
+ >&2 echo 'Remediation is not applicable, nothing was done'
+fi
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_file_groupowner_var_log_syslog' differs.
--- xccdf_org.ssgproject.content_rule_file_groupowner_var_log_syslog
+++ xccdf_org.ssgproject.content_rule_file_groupowner_var_log_syslog
@@ -1,7 +1,19 @@
+- name: Gather the package facts
+ package_facts:
+ manager: auto
+ tags:
+ - configure_strategy
+ - file_groupowner_var_log_syslog
+ - low_complexity
+ - low_disruption
+ - medium_severity
+ - no_reboot_needed
+
- name: Test for existence /var/log/syslog
stat:
path: /var/log/syslog
register: file_exists
+ when: '"rsyslog" in ansible_facts.packages'
tags:
- configure_strategy
- file_groupowner_var_log_syslog
@@ -14,7 +26,9 @@
file:
path: /var/log/syslog
group: '4'
- when: file_exists.stat is defined and file_exists.stat.exists
+ when:
+ - '"rsyslog" in ansible_facts.packages'
+ - file_exists.stat is defined and file_exists.stat.exists
tags:
- configure_strategy
- file_groupowner_var_log_syslog
Platform has been changed for rule 'xccdf_org.ssgproject.content_rule_file_groupowner_var_log_syslog'
--- xccdf_org.ssgproject.content_rule_file_groupowner_var_log_syslog
+++ xccdf_org.ssgproject.content_rule_file_groupowner_var_log_syslog
@@ -1 +1 @@
-
+oval:ssg-package_rsyslog:def:1
bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_owner_var_log_syslog' differs.
--- xccdf_org.ssgproject.content_rule_file_owner_var_log_syslog
+++ xccdf_org.ssgproject.content_rule_file_owner_var_log_syslog
@@ -1 +1,8 @@
-chown 104 /var/log/syslog
+# Remediation is applicable only in certain platforms
+if rpm --quiet -q rsyslog; then
+
+chown syslog /var/log/syslog
+
+else
+ >&2 echo 'Remediation is not applicable, nothing was done'
+fi
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_file_owner_var_log_syslog' differs.
--- xccdf_org.ssgproject.content_rule_file_owner_var_log_syslog
+++ xccdf_org.ssgproject.content_rule_file_owner_var_log_syslog
@@ -1,7 +1,6 @@
-- name: Test for existence /var/log/syslog
- stat:
- path: /var/log/syslog
- register: file_exists
+- name: Gather the package facts
+ package_facts:
+ manager: auto
tags:
- configure_strategy
- file_owner_var_log_syslog
@@ -10,11 +9,11 @@
- medium_severity
- no_reboot_needed
-- name: Ensure owner 104 on /var/log/syslog
- file:
+- name: Test for existence /var/log/syslog
+ stat:
path: /var/log/syslog
- owner: '104'
- when: file_exists.stat is defined and file_exists.stat.exists
+ register: file_exists
+ when: '"rsyslog" in ansible_facts.packages'
tags:
- configure_strategy
- file_owner_var_log_syslog
@@ -22,3 +21,18 @@
- low_disruption
- medium_severity
- no_reboot_needed
+
+- name: Ensure owner syslog on /var/log/syslog
+ file:
+ path: /var/log/syslog
+ owner: syslog
+ when:
+ - '"rsyslog" in ansible_facts.packages'
+ - file_exists.stat is defined and file_exists.stat.exists
+ tags:
+ - configure_strategy
+ - file_owner_var_log_syslog
+ - low_complexity
+ - low_disruption
+ - medium_severity
+ - no_reboot_needed
Platform has been changed for rule 'xccdf_org.ssgproject.content_rule_file_owner_var_log_syslog'
--- xccdf_org.ssgproject.content_rule_file_owner_var_log_syslog
+++ xccdf_org.ssgproject.content_rule_file_owner_var_log_syslog
@@ -1 +1 @@
-
+oval:ssg-package_rsyslog:def:1
bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_ownership_library_dirs' differs.
--- xccdf_org.ssgproject.content_rule_file_ownership_library_dirs
+++ xccdf_org.ssgproject.content_rule_file_ownership_library_dirs
@@ -1,8 +1,8 @@
-find /lib/ -type f ! -uid 0 -regextype posix-extended -regex '^.*$' -exec chown -L 0 {} \;
+find /lib/ -type f ! -user 0 -regextype posix-extended -regex '^.*$' -exec chown -L 0 {} \;
-find /lib64/ -type f ! -uid 0 -regextype posix-extended -regex '^.*$' -exec chown -L 0 {} \;
+find /lib64/ -type f ! -user 0 -regextype posix-extended -regex '^.*$' -exec chown -L 0 {} \;
-find /usr/lib/ -type f ! -uid 0 -regextype posix-extended -regex '^.*$' -exec chown -L 0 {} \;
+find /usr/lib/ -type f ! -user 0 -regextype posix-extended -regex '^.*$' -exec chown -L 0 {} \;
-find /usr/lib64/ -type f ! -uid 0 -regextype posix-extended -regex '^.*$' -exec chown -L 0 {} \;
+find /usr/lib64/ -type f ! -user 0 -regextype posix-extended -regex '^.*$' -exec chown -L 0 {} \;
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_file_ownership_library_dirs' differs.
--- xccdf_org.ssgproject.content_rule_file_ownership_library_dirs
+++ xccdf_org.ssgproject.content_rule_file_ownership_library_dirs
@@ -1,5 +1,5 @@
- name: Find /lib/ file(s) matching ^.*$ recursively
- command: find -H /lib/ -type f ! -uid 0 -regextype posix-extended -regex "^.*$"
+ command: find -H /lib/ -type f ! -user 0 -regextype posix-extended -regex "^.*$"
register: files_found
changed_when: false
failed_when: false
@@ -40,7 +40,7 @@
- no_reboot_needed
- name: Find /lib64/ file(s) matching ^.*$ recursively
- command: find -H /lib64/ -type f ! -uid 0 -regextype posix-extended -regex "^.*$"
+ command: find -H /lib64/ -type f ! -user 0 -regextype posix-extended -regex "^.*$"
register: files_found
changed_when: false
failed_when: false
@@ -81,7 +81,7 @@
- no_reboot_needed
- name: Find /usr/lib/ file(s) matching ^.*$ recursively
- command: find -H /usr/lib/ -type f ! -uid 0 -regextype posix-extended -regex "^.*$"
+ command: find -H /usr/lib/ -type f ! -user 0 -regextype posix-extended -regex "^.*$"
register: files_found
changed_when: false
failed_when: false
@@ -122,7 +122,7 @@
- no_reboot_needed
- name: Find /usr/lib64/ file(s) matching ^.*$ recursively
- command: find -H /usr/lib64/ -type f ! -uid 0 -regextype posix-extended -regex
+ command: find -H /usr/lib64/ -type f ! -user 0 -regextype posix-extended -regex
"^.*$"
register: files_found
changed_when: false
bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_cron_allow_exists' differs.
--- xccdf_org.ssgproject.content_rule_file_cron_allow_exists
+++ xccdf_org.ssgproject.content_rule_file_cron_allow_exists
@@ -2,7 +2,6 @@
if rpm --quiet -q kernel; then
touch /etc/cron.allow
- chown 0 /etc/cron.allow
chmod 0600 /etc/cron.allow
else
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_file_cron_allow_exists' differs.
--- xccdf_org.ssgproject.content_rule_file_cron_allow_exists
+++ xccdf_org.ssgproject.content_rule_file_cron_allow_exists
@@ -14,7 +14,6 @@
file:
path: /etc/cron.allow
state: touch
- owner: '0'
mode: '0600'
when: '"kernel" in ansible_facts.packages'
tags:
bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_ownership_sshd_private_key' differs.
--- xccdf_org.ssgproject.content_rule_file_ownership_sshd_private_key
+++ xccdf_org.ssgproject.content_rule_file_ownership_sshd_private_key
@@ -1,7 +1,7 @@
# Remediation is applicable only in certain platforms
if rpm --quiet -q kernel; then
-find -L /etc/ssh/ -maxdepth 1 -type f ! -uid 0 -regextype posix-extended -regex '^.*_key$' -exec chown -L 0 {} \;
+find -L /etc/ssh/ -maxdepth 1 -type f ! -user 0 -regextype posix-extended -regex '^.*_key$' -exec chown -L 0 {} \;
else
>&2 echo 'Remediation is not applicable, nothing was done'
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_file_ownership_sshd_private_key' differs.
--- xccdf_org.ssgproject.content_rule_file_ownership_sshd_private_key
+++ xccdf_org.ssgproject.content_rule_file_ownership_sshd_private_key
@@ -11,7 +11,7 @@
- no_reboot_needed
- name: Find /etc/ssh/ file(s) matching ^.*_key$
- command: find -H /etc/ssh/ -maxdepth 1 -type f ! -uid 0 -regextype posix-extended
+ command: find -H /etc/ssh/ -maxdepth 1 -type f ! -user 0 -regextype posix-extended
-regex "^.*_key$"
register: files_found
changed_when: false
bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_ownership_sshd_pub_key' differs.
--- xccdf_org.ssgproject.content_rule_file_ownership_sshd_pub_key
+++ xccdf_org.ssgproject.content_rule_file_ownership_sshd_pub_key
@@ -1,7 +1,7 @@
# Remediation is applicable only in certain platforms
if rpm --quiet -q kernel; then
-find -L /etc/ssh/ -maxdepth 1 -type f ! -uid 0 -regextype posix-extended -regex '^.*\.pub$' -exec chown -L 0 {} \;
+find -L /etc/ssh/ -maxdepth 1 -type f ! -user 0 -regextype posix-extended -regex '^.*\.pub$' -exec chown -L 0 {} \;
else
>&2 echo 'Remediation is not applicable, nothing was done'
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_file_ownership_sshd_pub_key' differs.
--- xccdf_org.ssgproject.content_rule_file_ownership_sshd_pub_key
+++ xccdf_org.ssgproject.content_rule_file_ownership_sshd_pub_key
@@ -11,7 +11,7 @@
- no_reboot_needed
- name: Find /etc/ssh/ file(s) matching ^.*\.pub$
- command: find -H /etc/ssh/ -maxdepth 1 -type f ! -uid 0 -regextype posix-extended
+ command: find -H /etc/ssh/ -maxdepth 1 -type f ! -user 0 -regextype posix-extended
-regex "^.*\.pub$"
register: files_found
changed_when: false
bash remediation for rule 'xccdf_org.ssgproject.content_rule_file_ownership_audit_configuration' differs.
--- xccdf_org.ssgproject.content_rule_file_ownership_audit_configuration
+++ xccdf_org.ssgproject.content_rule_file_ownership_audit_configuration
@@ -1,9 +1,9 @@
# Remediation is applicable only in certain platforms
if rpm --quiet -q audit && rpm --quiet -q kernel; then
-find -L /etc/audit/ -maxdepth 1 -type f ! -uid 0 -regextype posix-extended -regex '^.*audit(\.rules|d\.conf)$' -exec chown -L 0 {} \;
+find -L /etc/audit/ -maxdepth 1 -type f ! -user 0 -regextype posix-extended -regex '^.*audit(\.rules|d\.conf)$' -exec chown -L 0 {} \;
-find -L /etc/audit/rules.d/ -maxdepth 1 -type f ! -uid 0 -regextype posix-extended -regex '^.*\.rules$' -exec chown -L 0 {} \;
+find -L /etc/audit/rules.d/ -maxdepth 1 -type f ! -user 0 -regextype posix-extended -regex '^.*\.rules$' -exec chown -L 0 {} \;
else
>&2 echo 'Remediation is not applicable, nothing was done'
ansible remediation for rule 'xccdf_org.ssgproject.content_rule_file_ownership_audit_configuration' differs.
--- xccdf_org.ssgproject.content_rule_file_ownership_audit_configuration
+++ xccdf_org.ssgproject.content_rule_file_ownership_audit_configuration
@@ -11,7 +11,7 @@
- no_reboot_needed
- name: Find /etc/audit/ file(s) matching ^.*audit(\.rules|d\.conf)$
- command: find -H /etc/audit/ -maxdepth 1 -type f ! -uid 0 -regextype posix-extended
+ command: find -H /etc/audit/ -maxdepth 1 -type f ! -user 0 -regextype posix-extended
-regex "^.*audit(\.rules|d\.conf)$"
register: files_found
changed_when: false
@@ -49,7 +49,7 @@
- no_reboot_needed
- name: Find /etc/audit/rules.d/ file(s) matching ^.*\.rules$
- command: find -H /etc/audit/rules.d/ -maxdepth 1 -type f ! -uid 0 -regextype posix-extended
+ command: find -H /etc/audit/rules.d/ -maxdepth 1 -type f ! -user 0 -regextype posix-extended
-regex "^.*\.rules$"
register: files_found
changed_when: false |
Change in Ansible Please consider using more suitable Ansible module than |
1 similar comment
Change in Ansible Please consider using more suitable Ansible module than |
…plate from fileuid to uid_or_name
c118ea9
to
dc65c70
Compare
Change in Ansible Please consider using more suitable Ansible module than |
Change in Ansible Please consider using more suitable Ansible module than |
Change in Ansible Please consider using more suitable Ansible module than |
The audit pkg issue caused by rule file_ownership_audit_configuration |
Description:
Rationale: