-
Notifications
You must be signed in to change notification settings - Fork 813
Add template for zIPL boot entry option #5908
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
Merged
vojtapolasek
merged 18 commits into
ComplianceAsCode:master
from
yuumasato:zipl_bootloader_template
Jul 13, 2020
Merged
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
f37e40e
Kickstart zipl_bls_entries_option template
yuumasato f54c3c9
zipl_bls_entries_option: check opts after install
yuumasato 5b66eff
zipl_bls_entries_option: Add Ansible and Bash
yuumasato fd2d807
Enable zIPL in argument rules
yuumasato 08db1a1
zipl_audit_backlog_limit_argument: Fix OCIL typo
yuumasato 7795063
zipl_slub_debug_argument: Fix description
yuumasato 6a3f2f6
Add CCEs to zIPL argument rules
yuumasato a7c3313
Select zipl BLS option rules in OSPP Profile
yuumasato be070d5
Extend Profile resolution to undo rule refinements
yuumasato 2ea270b
Undo rule refinements done to zIPL rules
yuumasato 90d62ba
Update stable test for OSPP Profile
yuumasato b5d5b0f
zipl_bls_entries_option: Add test scenarios
yuumasato 3b52ab4
zipl_bls_entries_option: Remove hardcoded values
yuumasato 68bff71
Improve conditional check for the grubby command
yuumasato 79c60bb
zipl_bls_entries_option: Fix sed in test scenario
yuumasato d513177
Extend scenarios platform and allow remediation
yuumasato 2e84172
Update comment in OVAL zipl_bls_entries_option
yuumasato 9bd0afb
zipl_bls_entries_option: Supress grep error messages
yuumasato 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
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
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
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
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
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
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,48 @@ | ||
| # platform = Red Hat Enterprise Linux 8 | ||
| # reboot = true | ||
| # strategy = configure | ||
| # complexity = medium | ||
| # disruption = low | ||
|
|
||
| - name: "Ensure BLS boot entries options contain {{{ ARG_NAME_VALUE }}}" | ||
| block: | ||
| - name: "Check if any boot entry misses {{{ ARG_NAME_VALUE }}}" | ||
| find: | ||
| paths: "/boot/loader/entries/" | ||
| contains: "^options .*{{{ ARG_NAME_VALUE }}}.*$" | ||
| patterns: "*.conf" | ||
| register: entries_options | ||
|
|
||
| - name: "Update boot entries options" | ||
| command: grubby --update-kernel=ALL --args="{{{ ARG_NAME_VALUE }}}" | ||
| when: entries_options is defined and entries_options.examined != entries_options.matched | ||
| # The conditional above assumes that only *.conf files are present in /boot/loader/entries | ||
| # Then, the number of conf files is the same as examined files | ||
|
|
||
| - name: "Check if /etc/kernel/cmdline exists" | ||
| stat: | ||
| path: /etc/kernel/cmdline | ||
| register: cmdline_stat | ||
|
|
||
| - name: "Check if /etc/kernel/cmdline contains {{{ ARG_NAME_VALUE }}}" | ||
| find: | ||
| paths: "/etc/kernel/" | ||
| patterns: "cmdline" | ||
| contains: "^.*{{{ ARG_NAME_VALUE }}}.*$" | ||
| register: cmdline_find | ||
|
|
||
| - name: "Add /etc/kernel/cmdline contains {{{ ARG_NAME_VALUE }}}" | ||
| lineinfile: | ||
| create: yes | ||
| path: "/etc/kernel/cmdline" | ||
| line: '{{{ ARG_NAME_VALUE }}}' | ||
| when: cmdline_stat is defined and not cmdline_stat.stat.exists | ||
|
|
||
| - name: "Append /etc/kernel/cmdline contains {{{ ARG_NAME_VALUE }}}" | ||
| lineinfile: | ||
| path: "/etc/kernel/cmdline" | ||
| backrefs: yes | ||
| regexp: "^(.*)$" | ||
| line: '\1 {{{ ARG_NAME_VALUE }}}' | ||
| when: cmdline_stat is defined and cmdline_stat.stat.exists and cmdline_find is defined and cmdline_find.matched == 0 | ||
|
|
||
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,12 @@ | ||
| # platform = Red Hat Enterprise Linux 8 | ||
|
|
||
| # Correct BLS option using grubby, which is a thin wrapper around BLS operations | ||
| grubby --update-kernel=ALL --args="{{{ ARG_NAME_VALUE }}}" | ||
|
|
||
| # Ensure new kernels and boot entries retain the boot option | ||
| if [ ! -f /etc/kernel/cmdline ]; then | ||
| echo "{{{ ARG_NAME_VALUE }}}" >> /etc/kernel/cmdline | ||
| elif ! grep -q '^(.*\s)?{{{ ARG_NAME_VALUE }}}(\s.*)?$' /etc/kernel/cmdline; then | ||
| echo " audit=1" >> /etc/kernel/cmdline | ||
|
yuumasato marked this conversation as resolved.
Outdated
|
||
| sed -Ei 's/^(.*)$/\1 audit=1/' /etc/kernel/cmdline | ||
|
yuumasato marked this conversation as resolved.
Outdated
yuumasato marked this conversation as resolved.
Outdated
|
||
| 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <def-group> | ||
| <definition class="compliance" id="{{{ _RULE_ID }}}" version="1"> | ||
| <metadata> | ||
| <title>Ensure that BLS-compatible boot loader is configured to run Linux operating system with argument {{{ ARG_NAME_VALUE }}}</title> | ||
| {{{- oval_affected(products) }}} | ||
| <description>Ensure {{{ ARG_NAME_VALUE }}} option is configured in the 'options' line in /boot/loader/entries/*.conf.</description> | ||
| </metadata> | ||
| <criteria operator="AND"> | ||
| <criterion test_ref="test_bls_{{{ SANITIZED_ARG_NAME }}}_options" | ||
| comment="Check if {{{ ARG_NAME_VALUE }}} is present in the 'options' line in /boot/loader/entries/*" /> | ||
|
yuumasato marked this conversation as resolved.
Outdated
|
||
| <criterion test_ref="test_kernel_update_{{{ SANITIZED_ARG_NAME }}}_option" | ||
| comment="Make sure that newly installed kernels will retain {{{ ARG_NAME_VALUE }}} option" /> | ||
| </criteria> | ||
| </definition> | ||
|
|
||
| <ind:textfilecontent54_test id="test_bls_{{{ SANITIZED_ARG_NAME }}}_options" | ||
| comment="check for kernel option {{{ ARG_NAME_VALUE }}} for all snippets in /boot/loader/entries" | ||
| check="all" check_existence="all_exist" version="1"> | ||
| <ind:object object_ref="object_bls_{{{ SANITIZED_ARG_NAME }}}_options" /> | ||
| <ind:state state_ref="state_bls_{{{ SANITIZED_ARG_NAME }}}_option" /> | ||
| </ind:textfilecontent54_test> | ||
|
|
||
| <ind:textfilecontent54_object id="object_bls_{{{ SANITIZED_ARG_NAME }}}_options" | ||
| version="1"> | ||
| <ind:filepath operation="pattern match">^/boot/loader/entries/.*\.conf$</ind:filepath> | ||
| <ind:pattern operation="pattern match">^options (.*)$</ind:pattern> | ||
| <ind:instance datatype="int" operation="greater than or equal">1</ind:instance> | ||
| </ind:textfilecontent54_object> | ||
|
|
||
| <ind:textfilecontent54_test id="test_kernel_update_{{{ SANITIZED_ARG_NAME }}}_option" | ||
| comment="Check for option {{{ ARG_NAME_VALUE }}} in /etc/kernel/cmdline" | ||
| check="all" check_existence="all_exist" version="1"> | ||
| <ind:object object_ref="object_kernel_update_{{{ SANITIZED_ARG_NAME }}}_option" /> | ||
| <ind:state state_ref="state_bls_{{{ SANITIZED_ARG_NAME }}}_option" /> | ||
| </ind:textfilecontent54_test> | ||
| <ind:textfilecontent54_object id="object_kernel_update_{{{ SANITIZED_ARG_NAME }}}_option" | ||
| version="1"> | ||
| <ind:filepath>/etc/kernel/cmdline</ind:filepath> | ||
| <ind:pattern operation="pattern match">^(.*)$</ind:pattern> | ||
| <ind:instance datatype="int" operation="greater than or equal">1</ind:instance> | ||
| </ind:textfilecontent54_object> | ||
|
|
||
| <ind:textfilecontent54_state id="state_bls_{{{ SANITIZED_ARG_NAME }}}_option" | ||
| version="1"> | ||
| <ind:subexpression datatype="string" operation="pattern match">^(?:.*\s)?{{{ ESCAPED_ARG_NAME_VALUE }}}(?:\s.*)?$</ind:subexpression> | ||
| </ind:textfilecontent54_state> | ||
| </def-group> | ||
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.