Skip to content

Commit

Permalink
Switch to libyui
Browse files Browse the repository at this point in the history
  • Loading branch information
paolostivanin committed Oct 21, 2024
1 parent bf68740 commit 53b950e
Show file tree
Hide file tree
Showing 14 changed files with 161 additions and 20 deletions.
20 changes: 20 additions & 0 deletions lib/security/config.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# openssl fips test
#
# Copyright SUSE LLC
# SPDX-License-Identifier: FSFAP
# Summary: Stronger password to be used with CC/FIPS.
#
# Maintainer: QE Security <[email protected]>

package security::config;

use strict;
use warnings;

use base 'Exporter';

our @EXPORT = qw(strong_password);

our $strong_password = "not-so-s3cr3t_BUT_VERY_STRONG.";

1;
8 changes: 6 additions & 2 deletions lib/security_boot_utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ use grub_utils qw(grub_test);
use utils;
use testapi;
use Utils::Architectures;
use security::config;
use version_utils 'is_sle';

our @EXPORT = qw(
boot_has_no_video
Expand All @@ -27,7 +29,8 @@ sub boot_has_no_video {
my $is_encrypted = check_var('FULL_LVM_ENCRYPT', '1') || check_var('ENCRYPT', '1');
my $is_qr = check_var('FLAVOR', 'Online-QR') || check_var('FLAVOR', 'Full-QR');
my $is_arch = is_aarch64() || is_s390x();
return ($is_encrypted && $is_qr && $is_arch);
my $is_aarch_sle15sp6 = is_aarch64 && is_sle('=15-SP6');
return (($is_encrypted && $is_qr && $is_arch) || ($is_encrypted && $is_aarch_sle15sp6));
}

sub boot_encrypt_no_video {
Expand All @@ -37,7 +40,8 @@ sub boot_encrypt_no_video {
# used, for example, by aarch64 on 15-SP5 QR (https://progress.opensuse.org/issues/156655)
assert_screen 'encrypted-disk-no-video';
wait_serial("Please enter passphrase for disk.*");
type_string_slow("$testapi::password");
my $password = check_var('SYSTEM_ROLE', 'Common_Criteria') ? $security::config::strong_password : $testapi::password;
type_string_slow("$password");
send_key 'ret';
wait_still_screen 15;
$self->wait_boot_past_bootloader;
Expand Down
10 changes: 6 additions & 4 deletions lib/utils.pm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use Storable qw(dclone);
use Getopt::Long qw(GetOptionsFromString);
use File::Basename;
use XML::LibXML;
use security::config;

our @EXPORT = qw(
generate_results
Expand Down Expand Up @@ -202,12 +203,13 @@ C<$testapi::password> will be used as password.

sub unlock_zvm_disk {
my ($console) = @_;
my $password = check_var('SYSTEM_ROLE', 'Common_Criteria') ? $security::config::strong_password : $testapi::password;
eval { $console->expect_3270(output_delim => 'Please enter passphrase', timeout => 30) };
if ($@) {
diag 'No passphrase asked, continuing';
}
else {
$console->sequence_3270("String(\"$testapi::password\")", "ENTER");
$console->sequence_3270("String(\"$password\")", "ENTER");
diag 'Passphrase entered';
}

Expand Down Expand Up @@ -338,11 +340,11 @@ C<$check_typed_password> will default to C<0>.
sub unlock_if_encrypted {
my (%args) = @_;
$args{check_typed_password} //= 0;
my $password = check_var('SYSTEM_ROLE', 'Common_Criteria') ? $security::config::strong_password : $testapi::password;

return unless get_var("ENCRYPT");

if (get_var('S390_ZKVM')) {
my $password = $testapi::password;
select_console('svirt');

# enter passphrase twice (before grub and after grub) if full disk is encrypted
Expand All @@ -365,13 +367,13 @@ sub unlock_if_encrypted {
}
else {
assert_screen("encrypted-disk-password-prompt", 200);
type_password; # enter PW at boot
type_password $password;
save_screenshot;
if ($args{check_typed_password}) {
unless (check_screen "encrypted_disk-typed_password", 30) {
record_info("Invalid password", "Not all password characters were typed successfully, retyping");
send_key "backspace" for (0 .. 9);
type_password;
type_password $password;
assert_screen "encrypted_disk-typed_password";
}
}
Expand Down
27 changes: 27 additions & 0 deletions schedule/security/create_hdd_cc_libyui/aarch64/cc_maint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: create_hdd_common_criteria
vars:
PATTERNS: 'default,-enhanced_base'
YUI_REST_API: 1
schedule:
access_beta: []
add_on_product:
- installation/add_on_product/add_maintenance_repos
additional_products: []
system_role:
- installation/system_role/select_common_criteria_role
- installation/common_criteria_configuration/common_criteria_configuration
security: []
software:
- installation/select_patterns
grub: []
first_login:
- security/boot_disk
system_preparation:
- console/hostname
- console/system_prepare
- console/force_scheduled_tasks
- security/cc/ensure_crypto_checks_enabled
- shutdown/grub_set_bootargs
- shutdown/cleanup_before_shutdown
- shutdown/shutdown
5 changes: 1 addition & 4 deletions schedule/security/create_hdd_cc_libyui/s390x/cc_beta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ schedule:
system_role:
- installation/system_role/select_common_criteria_role
- installation/common_criteria_configuration/common_criteria_configuration
suggested_partitioning:
- installation/partitioning/new_partitioning_gpt
grub:
- installation/handle_reboot
security: []
first_login:
- installation/boot_encrypt
- installation/first_boot
Expand Down
29 changes: 29 additions & 0 deletions schedule/security/create_hdd_cc_libyui/s390x/cc_maint_fde.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: create_hdd_common_criteria
vars:
PATTERNS: 'default,-enhanced_base'
YUI_REST_API: 1
schedule:
access_beta: []
extension_module_selection:
- installation/module_registration/register_extensions_and_modules
add_on_product:
- installation/add_on_product/add_maintenance_repos
system_role:
- installation/system_role/select_common_criteria_role
- installation/common_criteria_configuration/common_criteria_configuration
software:
- installation/select_patterns
security: []
first_login:
- installation/boot_encrypt
- installation/first_boot
system_preparation:
- console/hostname
- console/system_prepare
- console/force_scheduled_tasks
- security/cc/ensure_crypto_checks_enabled
- shutdown/grub_set_bootargs
- shutdown/cleanup_before_shutdown
- shutdown/shutdown
- shutdown/svirt_upload_assets
26 changes: 26 additions & 0 deletions schedule/security/create_hdd_cc_libyui/s390x/cc_maint_no_fde.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
name: create_hdd_common_criteria
vars:
PATTERNS: 'default,-enhanced_base'
YUI_REST_API: 1
schedule:
access_beta: []
extension_module_selection:
- installation/module_registration/register_extensions_and_modules
add_on_product:
- installation/add_on_product/add_maintenance_repos
system_role:
- installation/system_role/select_common_criteria_role
- installation/common_criteria_configuration/common_criteria_configuration
software:
- installation/select_patterns
security: []
system_preparation:
- console/hostname
- console/system_prepare
- console/force_scheduled_tasks
- security/cc/ensure_crypto_checks_enabled
- shutdown/grub_set_bootargs
- shutdown/cleanup_before_shutdown
- shutdown/shutdown
- shutdown/svirt_upload_assets
28 changes: 28 additions & 0 deletions schedule/security/create_hdd_cc_libyui/x86_64/cc_maint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: create_hdd_common_criteria
vars:
PATTERNS: 'default,-enhanced_base'
YUI_REST_API: 1
schedule:
access_beta: []
add_on_product:
- installation/add_on_product/add_maintenance_repos
additional_products: []
product_selection:
- installation/product_selection/install_SLES
system_role:
- installation/system_role/select_common_criteria_role
- installation/common_criteria_configuration/common_criteria_configuration
software:
- installation/select_patterns
grub: []
first_login:
- security/boot_disk
system_preparation:
- console/hostname
- console/system_prepare
- console/force_scheduled_tasks
- security/cc/ensure_crypto_checks_enabled
- shutdown/grub_set_bootargs
- shutdown/cleanup_before_shutdown
- shutdown/shutdown
2 changes: 2 additions & 0 deletions schedule/yast/sle/flows/default_sle15sp4_aarch64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ grub:
- installation/grub_test
first_login:
- installation/first_boot
system_preparation: []
system_validation: []
2 changes: 2 additions & 0 deletions schedule/yast/sle/flows/default_sle15sp4_s390x_kvm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ reboot:
- installation/handle_reboot
first_login:
- installation/first_boot
system_preparation: []
system_validation: []
4 changes: 2 additions & 2 deletions tests/console/cryptsetup.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ use testapi;
use serial_terminal 'select_serial_terminal';
use utils 'zypper_call';
use version_utils qw(is_sle);
use security::config;

sub run {
# Strengthen password to avoid password quality check failed on Tumbleweed
my $cryptpasswd = $testapi::password . '_on-a-sunny-D4Y';
my $cryptpasswd = $security::config::strong_password;
select_serial_terminal;

# Update related packages including latest systemd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ use parent 'y2_installbase';
use strict;
use testapi;
use warnings;
use security::config;

sub run {
my $common_criteria_configuration = $testapi::distri->get_common_criteria_configuration();
if (check_var('ENCRYPT', '1')) {
$common_criteria_configuration->configure_encryption($testapi::password);
$common_criteria_configuration->configure_encryption($security::config::strong_password);
$common_criteria_configuration->go_forward();
$common_criteria_configuration->get_weak_password_warning->press_yes();
} else {
$common_criteria_configuration->go_forward();
}
Expand Down
11 changes: 7 additions & 4 deletions tests/installation/logs_from_installation_system.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ sub run {

# on a CC enabled system, root ssh login is disabled by default, but we need it enabled
if (check_var('SYSTEM_ROLE', 'Common_Criteria') && is_sle && is_s390x) {
my $vg_name = "vg-system";
my $lv_name = "lv-root";
my $crypt_name = "encrypted_disk";
my $stor_inst = "/var/log/YaST2/storage-inst/*committed.yml";
my $root_hd = get_var('ENCRYPT') ? "/dev/$vg_name/$lv_name " : script_output("cat $stor_inst | grep -B4 'mount_point: \"/\"' | grep name | awk -F \\\" '{print \$2}'");
my $is_encrypted = check_var('ENCRYPT', '1') || check_var('FULL_LVM_ENCRYPT', '1');
my $root_hd = script_output("cat $stor_inst | grep -B4 'mount_point: \"/\"' | grep name | awk -F \\\" '{print \$2}'");
if ($is_encrypted) {
$root_hd = "/dev/mapper/" . script_output("dmsetup ls | grep root | awk '{print \$1}'");
}

assert_script_run("mount $root_hd /mnt");
assert_script_run("sed -i -e 's/PermitRootLogin no/PermitRootLogin yes/g' /mnt/etc/ssh/sshd_config");
assert_script_run("sed -i -e 's/PermitRootLogin prohibit-password/PermitRootLogin yes/g' /mnt/etc/ssh/sshd_config.d/51-permit-root-login.conf") if is_sle('>=15-SP6');
assert_script_run('umount /mnt');
}

Expand Down
5 changes: 3 additions & 2 deletions tests/installation/partitioning.pm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use testapi;
use version_utils qw(is_leap is_storage_ng is_sle is_tumbleweed);
use partition_setup qw(%partition_roles is_storage_ng_newui);
use utils 'type_string_slow';
use security::config;

sub handle_common_criteria {
if (is_sle '<=15-SP5') {
Expand All @@ -26,9 +27,9 @@ sub handle_common_criteria {
wait_still_screen;
assert_screen 'Common-Criteria-Disk-Encryption-Passphrase';
send_key 'alt-e';
type_password;
type_password $security::config::strong_password;
send_key 'alt-v';
type_password;
type_password $security::config::strong_password;
send_key 'alt-n';
wait_still_screen;
send_key 'alt-y'; # to confirm "the password too simple" dialog
Expand Down

0 comments on commit 53b950e

Please sign in to comment.