-
Notifications
You must be signed in to change notification settings - Fork 821
SLE fixes for sshd distributed config for approved macs and ciphers rules #15021
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
Open
teacup-on-rockingchair
wants to merge
8
commits into
ComplianceAsCode:master
Choose a base branch
from
teacup-on-rockingchair:sshd_approved_mac_ciphers_distributed_config_support
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.
+570
−62
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b2d0ce0
Add support for SSH distributed config in sshd_use_approved_ciphers rule
teacup-on-rockingchair c62c09d
Add support for SSH distributed config in sshd_use_approved_ciphers_o…
teacup-on-rockingchair 6bd658e
Add support for SSH distributed config in sshd_use_approved_macs
teacup-on-rockingchair b620879
Add support for SSH distributed config in sshd_use_approved_macs_orde…
teacup-on-rockingchair 41c65a0
Upgrade SLE15 test docker to support ssh distributed config
teacup-on-rockingchair 953d7c3
Fix definition of defalt main sshd config file for sle16
teacup-on-rockingchair a9ead0e
Improve oval checks for sshd_use_approved_macs_ordered_stig and sshd_…
teacup-on-rockingchair afd5252
Add more tests to cover possible bad configuration with multple lines…
teacup-on-rockingchair 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
13 changes: 13 additions & 0 deletions
13
...es/ssh/ssh_server/sshd_use_approved_ciphers/tests/correct_reduced_list_config_dir.pass.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,13 @@ | ||
| #!/bin/bash | ||
| {{% if sshd_distributed_config == "false" %}} | ||
| # platform = Not Applicable | ||
| {{% else %}} | ||
| # platform = multi_platform_sle | ||
| {{% endif %}} | ||
|
|
||
| source include.sh | ||
| {{% if product in [ 'sle16', 'slmicro6' ] %}} | ||
| touch "{{{ sshd_main_config_file }}}" | ||
| {{% endif %}} | ||
|
|
||
| echo 'Ciphers aes128-ctr,aes192-ctr' >> "{{{ sshd_config_dir }}}/00-test.conf" |
12 changes: 12 additions & 0 deletions
12
.../services/ssh/ssh_server/sshd_use_approved_ciphers/tests/correct_value_config_dir.pass.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,12 @@ | ||
| #!/bin/bash | ||
| {{% if sshd_distributed_config == "false" %}} | ||
| # platform = Not Applicable | ||
| {{% else %}} | ||
| # platform = multi_platform_sle | ||
| {{% endif %}} | ||
|
|
||
| source include.sh | ||
| {{% if product in [ 'sle16', 'slmicro6' ] %}} | ||
| touch "{{{ sshd_main_config_file }}}" | ||
| {{% endif %}} | ||
| echo 'Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc,rijndael-cbc@lysator.liu.se' >> "{{{ sshd_config_dir }}}/00-test.conf" |
14 changes: 14 additions & 0 deletions
14
...rvices/ssh/ssh_server/sshd_use_approved_ciphers/tests/correct_variable_config_dir.pass.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,14 @@ | ||
| #!/bin/bash | ||
| {{% if sshd_distributed_config == "false" %}} | ||
| # platform = Not Applicable | ||
| {{% else %}} | ||
| # platform = multi_platform_sle | ||
| {{% endif %}} | ||
| # variables = sshd_approved_ciphers=ijkl158,sits,wwq-98,kl24 | ||
|
|
||
| source include.sh | ||
| {{% if product in [ 'sle16', 'slmicro6' ] %}} | ||
| touch "{{{ sshd_main_config_file }}}" | ||
| {{% endif %}} | ||
|
|
||
| echo 'Ciphers ijkl158,sits,wwq-98,kl24' >> "{{{ sshd_config_dir }}}/00-test.conf" |
15 changes: 15 additions & 0 deletions
15
linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers/tests/include.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,15 @@ | ||
| #!/bin/bash | ||
|
|
||
| declare -a SSHD_PATHS=({{{ sshd_main_config_file }}}) | ||
| {{% if product in [ 'sle16', 'slmicro6' ] %}} | ||
| SSHD_PATHS+=({{{ sshd_config_dir }}}/*) | ||
| {{% endif %}} | ||
| # clean up configurations | ||
| sed -i '/^Ciphers.*/d' "${SSHD_PATHS[@]}" | ||
|
|
||
| # restore to defaults for sle16 and slmicro6 | ||
| {{% if product in [ 'sle16', 'slmicro6' ] %}} | ||
| if [ -e "{{{ sshd_main_config_file }}}" ] ; then | ||
| rm "{{{ sshd_main_config_file }}}" | ||
| fi | ||
| {{% endif %}} |
13 changes: 13 additions & 0 deletions
13
...de/services/ssh/ssh_server/sshd_use_approved_ciphers/tests/wrong_value_conifg_dir.fail.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,13 @@ | ||
| #!/bin/bash | ||
| {{% if sshd_distributed_config == "false" %}} | ||
| # platform = Not Applicable | ||
| {{% else %}} | ||
| # platform = multi_platform_sle | ||
| {{% endif %}} | ||
|
|
||
| source include.sh | ||
| {{% if product in [ 'sle16', 'slmicro6' ] %}} | ||
| touch "{{{ sshd_main_config_file }}}" | ||
| {{% endif %}} | ||
| echo 'Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc,rijndael-cbc@lysator.liu.se' >> {{{ sshd_main_config_file }}} | ||
| echo 'Ciphers weak-cipher' >> "{{{ sshd_config_dir }}}/00-test.conf" |
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
5 changes: 5 additions & 0 deletions
5
linux_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_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
95 changes: 77 additions & 18 deletions
95
...x_os/guide/services/ssh/ssh_server/sshd_use_approved_ciphers_ordered_stig/oval/shared.xml
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 |
|---|---|---|
| @@ -1,36 +1,95 @@ | ||
| {{%- set sshd_main_config = sshd_main_config_file -%}} | ||
| {{%- set sshd_drop_in_dir = sshd_config_dir -%}} | ||
| {{% set sufix_conf="(\s.*)?" %}} | ||
| {{% set prefix_conf="^\s*Ciphers\s*" %}} | ||
| {{% set ciphers=["aes256-ctr","aes192-ctr","aes128-ctr"] %}} | ||
| {{% set ciphers_regex=prefix_conf ~ "(?=[\w-])" "(\\b" ~ ciphers|join("\\b,?)?(\\b") ~ ")?" ~ sufix_conf ~ "[\\s]*(?:#.*)?$" %}} | ||
| <def-group> | ||
| <definition class="compliance" id="sshd_use_approved_ciphers_ordered_stig" version="1"> | ||
| <definition class="compliance" id="{{{ rule_id }}}" version="1"> | ||
| {{{ oval_metadata("Limit the ciphers to those which are FIPS-approved.", rule_title=rule_title) }}} | ||
| <criteria comment="SSH is configured correctly or is not installed" | ||
| operator="OR"> | ||
| <criteria comment="sshd is configured correctly or is not installed" operator="OR"> | ||
| <criteria comment="sshd is not installed" operator="AND"> | ||
| <extend_definition comment="sshd is not required or requirement is unset" | ||
| definition_ref="sshd_not_required_or_unset" /> | ||
| <extend_definition comment="rpm package openssh-server removed" | ||
| definition_ref="package_openssh-server_removed" /> | ||
| definition_ref="sshd_not_required_or_unset" /> | ||
| <extend_definition comment="package openssh-server removed" | ||
| definition_ref="package_openssh-server_removed" /> | ||
| </criteria> | ||
|
|
||
| <criteria comment="sshd is installed and configured" operator="AND"> | ||
| <extend_definition comment="sshd is required or requirement is unset" | ||
| definition_ref="sshd_required_or_unset" /> | ||
| <extend_definition comment="rpm package openssh-server installed" | ||
| definition_ref="package_openssh-server_installed" /> | ||
| <criterion comment="Check the Ciphers list in /etc/ssh/sshd_config" | ||
| test_ref="test_sshd_use_approved_ciphers_ordered_stig" /> | ||
| definition_ref="sshd_required_or_unset" /> | ||
| <extend_definition comment="package openssh-server installed" | ||
| definition_ref="package_openssh-server_installed" /> | ||
| <criteria comment="sshd is configured correctly" operator="AND"> | ||
| <criteria comment="the configuration is correct if it exists" operator="AND"> | ||
| {{% if product in [ 'sle16', 'slmicro6' ] %}} | ||
| <criterion comment="test if SSH main configuration {{{ sshd_main_config }}} exists for {{{ rule_id }}}" | ||
| test_ref="test_{{{ rule_id }}}_config_file_exists"/> | ||
| {{% endif %}} | ||
| <criterion comment="Check the ciphers in {{{ sshd_main_config }}} if any" | ||
| test_ref="test_{{{ rule_id }}}" /> | ||
| {{%- if sshd_distributed_config == "true" %}} | ||
| <criterion comment="Check the ciphers in {{{ sshd_drop_in_dir }}} if any" | ||
| test_ref="test_{{{ rule_id }}}_config_dir" /> | ||
| {{%- endif %}} | ||
| </criteria> | ||
| <criterion comment="the configuration exists" test_ref="test_ciphers_present_{{{ rule_id }}}" /> | ||
| </criteria> | ||
| </criteria> | ||
|
|
||
| </criteria> | ||
| </definition> | ||
|
|
||
| <ind:textfilecontent54_test check="all" check_existence="all_exist" | ||
| comment="tests the value of Ciphers setting in the /etc/ssh/sshd_config file" | ||
| id="test_sshd_use_approved_ciphers_ordered_stig" version="1"> | ||
| <ind:object object_ref="obj_sshd_use_approved_ciphers_ordered_stig" /> | ||
| {{% if product in [ 'sle16', 'slmicro6' ] %}} | ||
| {{{ oval_config_file_exists_test(sshd_main_config, rule_id=rule_id) }}} | ||
| {{{ oval_config_file_exists_object(sshd_main_config, rule_id=rule_id) }}} | ||
| {{% endif %}} | ||
| <ind:textfilecontent54_test check="all" check_existence="any_exist" | ||
| comment="tests the value of ciphers setting in the {{{ sshd_main_config }}} file" | ||
| id="test_{{{ rule_id }}}" version="1"> | ||
| <ind:object object_ref="obj_{{{ rule_id }}}" /> | ||
| <ind:state state_ref="state_{{{ rule_id }}}" /> | ||
| </ind:textfilecontent54_test> | ||
|
|
||
| <ind:textfilecontent54_object id="obj_sshd_use_approved_ciphers_ordered_stig" version="1"> | ||
| <ind:textfilecontent54_state id="state_{{{ rule_id }}}" version="1"> | ||
| <ind:text operation="pattern match">{{{ ciphers_regex }}}</ind:text> | ||
| </ind:textfilecontent54_state> | ||
|
|
||
| <ind:textfilecontent54_object id="obj_{{{ rule_id }}}" version="1"> | ||
| <ind:filepath>{{{ sshd_main_config }}}</ind:filepath> | ||
| <ind:pattern operation="pattern match">^[\s]*(?i)Ciphers(?-i)[\s]+(?=[\w]+)(aes256-ctr(?=[\w,]+|$),?)?(aes192-ctr(?=[\w,]+|$),?)?(aes128-ctr)?[\s]*(?:#.*)?$</ind:pattern> | ||
| <ind:instance datatype="int">1</ind:instance> | ||
| <ind:pattern operation="pattern match">{{{ prefix_conf }}}.*</ind:pattern> | ||
| <ind:instance datatype="int" operation="greater than or equal" >1</ind:instance> | ||
| </ind:textfilecontent54_object> | ||
|
|
||
| {{%- if sshd_distributed_config == "true" %}} | ||
| <ind:textfilecontent54_test check="all" check_existence="any_exist" | ||
| comment="tests the value of ciphers setting in the {{{ sshd_drop_in_dir }}} file" | ||
| id="test_{{{ rule_id }}}_config_dir" version="1"> | ||
| <ind:object object_ref="obj_{{{ rule_id }}}_config_dir" /> | ||
| <ind:state state_ref="state_{{{ rule_id }}}" /> | ||
| </ind:textfilecontent54_test> | ||
|
|
||
| <ind:textfilecontent54_object id="obj_{{{ rule_id }}}_config_dir" version="1"> | ||
| <ind:path>{{{ sshd_drop_in_dir }}}</ind:path> | ||
| <ind:filename operation="pattern match">.*\.conf$</ind:filename> | ||
| <ind:pattern operation="pattern match">{{{ prefix_conf }}}.*</ind:pattern> | ||
| <ind:instance datatype="int" operation="greater than or equal" >1</ind:instance> | ||
| </ind:textfilecontent54_object> | ||
| {{%- endif %}} | ||
|
|
||
| <ind:textfilecontent54_object comment="All confs collection" id="obj_collection_obj_{{{ rule_id }}}" version="1"> | ||
| <set> | ||
| <object_reference>obj_{{{ rule_id }}}</object_reference> | ||
| {{% if sshd_distributed_config == "true" %}} | ||
| <object_reference>obj_{{{ rule_id }}}_config_dir</object_reference> | ||
| {{% endif %}} | ||
| </set> | ||
| </ind:textfilecontent54_object> | ||
|
|
||
| <ind:textfilecontent54_test id="test_ciphers_present_{{{ rule_id }}}" version="1" | ||
| check="all" check_existence="at_least_one_exists" | ||
| comment="Verify that the value of ciphers is present"> | ||
| <ind:object object_ref="obj_collection_obj_{{{ rule_id }}}" /> | ||
| </ind:textfilecontent54_test> | ||
|
|
||
| </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
5 changes: 5 additions & 0 deletions
5
.../ssh_server/sshd_use_approved_ciphers_ordered_stig/tests/correct_value_config_dir.pass.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,5 @@ | ||
| #!/bin/bash | ||
|
|
||
| source common.sh | ||
|
|
||
| echo "Ciphers $sshd_approved_ciphers" >> "{{{ sshd_config_dir }}}/00-test.conf" |
5 changes: 5 additions & 0 deletions
5
...sh/ssh_server/sshd_use_approved_ciphers_ordered_stig/tests/wrong_value_config_dir.fail.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,5 @@ | ||
| #!/bin/bash | ||
|
|
||
| source common.sh | ||
|
|
||
| echo "Ciphers $sshd_approved_ciphers,weak-cipher" >> "{{{ sshd_config_dir }}}/00-test.conf" |
6 changes: 6 additions & 0 deletions
6
...ver/sshd_use_approved_ciphers_ordered_stig/tests/wrong_value_multiple_configs_dir.fail.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,6 @@ | ||
| #!/bin/bash | ||
| # platform = multi_platform_sle | ||
| source common.sh | ||
|
|
||
| echo "Ciphers $sshd_approved_ciphers" >> "{{{ sshd_config_dir }}}/00-test.conf" | ||
| echo "Ciphers weak-cipher" >> "{{{ sshd_config_dir }}}/01-test.conf" |
Oops, something went wrong.
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.