Conversation
| 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'); | ||
| } |
There was a problem hiding this comment.
Why not just
| 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'; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Then just call enter_cmd, ignore failures and let the test continue. No need to do all those error handling branches then
There was a problem hiding this comment.
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.
8532621 to
34ceadc
Compare
Martchus
left a comment
There was a problem hiding this comment.
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'); |
There was a problem hiding this comment.
To be able to merge this it would be good to tidy up, e.g.:
| 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"); |
There was a problem hiding this comment.
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).
| } | ||
|
|
||
| sub test_flags ($self) { | ||
| #do not abort the run |
There was a problem hiding this comment.
This comment is useless without further explanation so I'd just remove it.
| use testapi; | ||
|
|
||
| # Summary: Run and Verify workers' confinement | ||
| # First stage runs openrations on worker VM |
There was a problem hiding this comment.
| # First stage runs openrations on worker VM | |
| # First stage runs operations on the SUT |
| sub run ($self) { | ||
| # select_console 'root-console'; | ||
| send_key('ctrl-alt-f3'); | ||
| record_info('VM-level', 'exercise API commands inside Vm'); |
There was a problem hiding this comment.
| record_info('VM-level', 'exercise API commands inside Vm'); | |
| record_info('VM-level', 'exercise API commands inside VM'); |
| # First stage runs openrations on worker VM | ||
| # - Read the shadow password file | ||
| # - Read sudoers configuration | ||
| # - exposes secrets passed at boot | ||
| # - various operations |
There was a problem hiding this comment.
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).
| # - exposes secrets passed at boot | ||
| # - various operations | ||
| # | ||
| # Second stage runs Host-level operations |
There was a problem hiding this comment.
| # Second stage runs Host-level operations | |
| # Second stage runs host-level operations |
| # 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? |
There was a problem hiding this comment.
These should also be bullet points.
| # 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 |
There was a problem hiding this comment.
| # 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 |
34ceadc to
c962a1e
Compare
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>
c962a1e to
560f760
Compare


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