Skip to content

Explore worker confinement adding dedicate module - #276

Open
d3flex wants to merge 1 commit into
os-autoinst:masterfrom
d3flex:feat/worker_confined_test
Open

d3flex wants to merge 1 commit into
os-autoinst:masterfrom
d3flex:feat/worker_confined_test

Conversation

@d3flex

@d3flex d3flex commented Mar 30, 2026

Copy link
Copy Markdown
Contributor

Provide a set of scripts which explore the confined capabilities of the workers. There are two main approaches: using the test API to read/write from within the SUT and the Host level operations using system().

RFD: os-autoinst/openQA#7127

Issue: https://progress.opensuse.org/issues/194717

@d3flex

d3flex commented Mar 30, 2026

Copy link
Copy Markdown
Contributor Author
  • confined
image
  • unconfined
image

Comment thread tests/openQA/worker_sec_checks.pm Outdated
Comment on lines +25 to +32
script_run 'cat /etc/shadow';
eval { upload_logs '/etc/shadow' };
if ($@) {
record_info('upload-shadows', $@ , result=>'softfail');
}
else {
record_info('upload-shadows', 'uploaded /etc/shadows to WebUI');
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why not just

Suggested change
script_run 'cat /etc/shadow';
eval { upload_logs '/etc/shadow' };
if ($@) {
record_info('upload-shadows', $@ , result=>'softfail');
}
else {
record_info('upload-shadows', 'uploaded /etc/shadows to WebUI');
}
assert_script_run 'cat /etc/shadow';
upload_logs '/etc/shadow';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The module is just informative in most cases.the record_info will tell when the process is interrupted or completed. assert_script_run will make it fail at that point.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Then just call enter_cmd, ignore failures and let the test continue. No need to do all those error handling branches then

@Martchus Martchus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I find it interesting that you've chosen to explore this as an openQA tests. This surely seems like a lot of work just for exploring.

Note that it is not forbidden to use signatures, Mojo::File and other "modern" features/libraries just because it is test code.

Is autodie enabled in test modules? If not you should do error handling after calls like system and open consistently. If autodie is enabled you should avoid explicit error handling consistently.

@d3flex
d3flex force-pushed the feat/worker_confined_test branch 4 times, most recently from 8532621 to 34ceadc Compare April 2, 2026 12:39

@Martchus Martchus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess this is generally useful. If we proceed with the confinement tickets we can also schedule such a test job to test other ways of confinement.

The upfront comments could a bit more concise and should include an example command for how to schedule a job using this test module.

You could also split the run function and the length upfront comment so you end up with e.g. _test_sut_operations and _test_host_operations that both have their individual pod documentation.

system('rmdir /etc/systemd/system/worker-probe.d 2>/dev/null');
}
else {
record_info('ETC-WRITE', 'UNCONFINED: wrote to host /etc/systemd/system/', result=>'fail');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To be able to merge this it would be good to tidy up, e.g.:

Suggested change
record_info('ETC-WRITE', 'UNCONFINED: wrote to host /etc/systemd/system/', result=>'fail');
record_info('ETC-WRITE', 'UNCONFINED: wrote to host /etc/systemd/system/', result => 'fail');

record_info('CACHE-ACCESS', "Cache directory accessible: $cachedir", result => 'softfail');
}
else {
record_info('CACHE-ACCESS', "Cache directory not accessible ($!): $cachedir");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This directory probably has to be accessible - at least read-only. So this should probably be a failure and the record_info above just an info (at least if caching is enabled).

Comment thread tests/openQA/worker_sec_checks.pm Outdated
}

sub test_flags ($self) {
#do not abort the run

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This comment is useless without further explanation so I'd just remove it.

Comment thread tests/openQA/worker_sec_checks.pm Outdated
use testapi;

# Summary: Run and Verify workers' confinement
# First stage runs openrations on worker VM

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
# First stage runs openrations on worker VM
# First stage runs operations on the SUT

Comment thread tests/openQA/worker_sec_checks.pm Outdated
sub run ($self) {
# select_console 'root-console';
send_key('ctrl-alt-f3');
record_info('VM-level', 'exercise API commands inside Vm');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
record_info('VM-level', 'exercise API commands inside Vm');
record_info('VM-level', 'exercise API commands inside VM');

Comment thread tests/openQA/worker_sec_checks.pm Outdated
Comment on lines +6 to +10
# First stage runs openrations on worker VM
# - Read the shadow password file
# - Read sudoers configuration
# - exposes secrets passed at boot
# - various operations

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is the point of this first stage? All of these operations are pretty standard and supposed to be possible. Of course it can't hurt to do a few operations within the VM to see that it basically still works (despite the confinement).

Comment thread tests/openQA/worker_sec_checks.pm Outdated
# - exposes secrets passed at boot
# - various operations
#
# Second stage runs Host-level operations

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
# Second stage runs Host-level operations
# Second stage runs host-level operations

Comment thread tests/openQA/worker_sec_checks.pm Outdated
Comment on lines +15 to +19
# verify the cache directory is readable — ReadWritePaths must include it for the cache service to work
# try to write to the cache directory — should be blocked when ReadOnlyPaths is active
# verify this worker slot cannot read another slot's pool directory
# can we read a sensitive host file from Perl?
# can we read another process /proc/<pid>/environ on the host?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

These should also be bullet points.

Comment thread tests/openQA/worker_sec_checks.pm Outdated
# Second stage runs Host-level operations
# - write to host /etc.
# - write to the worker's own home directory.
# verify the cache directory is readable — ReadWritePaths must include it for the cache service to work

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
# verify the cache directory is readable — ReadWritePaths must include it for the cache service to work
# verify the cache directory is readable — ReadOnlyPaths must include it for the cache service to work

@d3flex
d3flex force-pushed the feat/worker_confined_test branch from 34ceadc to c962a1e Compare April 2, 2026 13:06
Provide a set of scripts which explore the confined capabilities of the workers.
There are two main approaches: using the test API to read/write from within the
SUT and the Host level operations using system().

RFD: os-autoinst/openQA#7127

Issue: https://progress.opensuse.org/issues/194717
Signed-off-by: Ioannis Bonatakis <ybonatakis@suse.com>
@d3flex
d3flex force-pushed the feat/worker_confined_test branch from c962a1e to 560f760 Compare April 6, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants