Skip to content
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

SLES15 use dropin configuration for issue banner #10605

Conversation

teacup-on-rockingchair
Copy link
Contributor

@teacup-on-rockingchair teacup-on-rockingchair commented May 21, 2023

Description:

  • Use drop-in configuration for /etc/issue in case of SLES15 platform

Rationale:

  • For sle15 platform make sure to use drop-in configuration for remediation of /etc/issue banner
  • /etc/issue file is symlink in SLES15 and is managed by the issue-generator service, so additional logic added, to make sure issue-generator service is installed and running.
  • For SLE15 check (group)ownership of drop-in files /etc/issue.d/* instead of symlink /etc/issue

@teacup-on-rockingchair teacup-on-rockingchair added Ansible Ansible remediation update. Bash Bash remediation update. SLES SUSE Linux Enterprise Server product related. labels May 21, 2023
@github-actions
Copy link

Start a new ephemeral environment with changes proposed in this pull request:

rhel8 (from CTF) Environment (using Fedora as testing environment)
Open in Gitpod

Fedora Testing Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

@teacup-on-rockingchair teacup-on-rockingchair marked this pull request as draft May 21, 2023 21:56
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Used by openshift-ci bot. label May 21, 2023
@github-actions
Copy link

github-actions bot commented May 21, 2023

This datastream diff is auto generated by the check Compare DS/Generate Diff

Click here to see the full diff
bash remediation for rule 'xccdf_org.ssgproject.content_rule_banner_etc_issue' differs.
--- xccdf_org.ssgproject.content_rule_banner_etc_issue
+++ xccdf_org.ssgproject.content_rule_banner_etc_issue
@@ -17,7 +17,6 @@
 # 4 - Remove any leftover backslash. (From any parethesis in the banner, for example).
 login_banner_text=$(echo "$login_banner_text" | sed 's/\\//g')
 formatted=$(echo "$login_banner_text" | fold -sw 80)
-
 cat <<EOF >/etc/issue
 $formatted
 EOF

ansible remediation for rule 'xccdf_org.ssgproject.content_rule_banner_etc_issue' differs.
--- xccdf_org.ssgproject.content_rule_banner_etc_issue
+++ xccdf_org.ssgproject.content_rule_banner_etc_issue
@@ -4,7 +4,7 @@
   tags:
     - always
 
-- name: Modify the System Login Banner - ensure correct banner
+- name: Modify the System Login Banner - Ensure Correct Banner
   copy:
     dest: /etc/issue
     content: '{{ login_banner_text | regex_replace("^\^(.*)\$$", "\1") | regex_replace("^\((.*\.)\|.*\)$",

@teacup-on-rockingchair teacup-on-rockingchair marked this pull request as ready for review May 21, 2023 23:36
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Used by openshift-ci bot. label May 21, 2023
@@ -5,7 +5,26 @@
# disruption = medium
{{{ ansible_instantiate_variables("login_banner_text") }}}

- name: "{{{ rule_title }}} - ensure correct banner"
{{% if product not in ['sle15'] %}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove some empty lines left by Jinja2 in the resulting file:
https://jinja.palletsprojects.com/en/3.0.x/templates/#whitespace-control

Also valid for other files in this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@teacup-on-rockingchair , do you have plans to work on this? This is actually only an aesthetic issue to avoid some extra empty lines in the resulting file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for some reason missed the message long time ago and the PR was displayed in the list as review required, so I thought you don't have time for it :)

Anyways modified those macros fromm {{% %}} to {{%- -%}}, but am a bit confused since I can see extra new lines , after build, on my local setup only in the bash files. Could it be because I am using ninja build or something else. I could not find anything in my environment that should cause the ssg build procedure to consider trimming default behaviour.

@marcusburghardt marcusburghardt added this to the 0.1.68 milestone May 25, 2023
@marcusburghardt marcusburghardt self-assigned this May 25, 2023
@jan-cerny jan-cerny modified the milestones: 0.1.68, 0.1.69 May 29, 2023
Copy link
Member

@marcusburghardt marcusburghardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@marcusburghardt marcusburghardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, some new erros appeared now in CI tests. I need to check them.

@teacup-on-rockingchair
Copy link
Contributor Author

Actually, some new erros appeared now in CI tests. I need to check them.

Indeed it turned out I stripped too much lines broke the shell remediation and also templates in the file_owner/groupowner rules, so 900f57a should fix that

@openshift-merge-robot openshift-merge-robot added the needs-rebase Used by openshift-ci bot. label Jun 23, 2023
For sle15 platform make sure to use drop-in configuration for remediation of /etc/issue banner
/etc/issue file is symlink in SLES15 and is managed by the issue-generator service, so additional logic added,
to make sure issue-generator service is installed and running.
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Used by openshift-ci bot. label Jun 25, 2023
@codeclimate
Copy link

codeclimate bot commented Jun 26, 2023

Code Climate has analyzed commit 7b82d62 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 52.8% (0.0% change).

View more on Code Climate.

@marcusburghardt
Copy link
Member

/packit test

@marcusburghardt marcusburghardt merged commit 2cf241a into ComplianceAsCode:master Jul 11, 2023
31 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ansible Ansible remediation update. Bash Bash remediation update. SLES SUSE Linux Enterprise Server product related.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants