Repository navigation
feat: add SELinux status detection - #3
Conversation
Signed-off-by: Gabriel Pereira do Carmo <gabrielcarmobr14@gmail.com>
39d6763 to
09b0ebb
Compare
Signed-off-by: Gabriel Pereira do Carmo <gabrielcarmobr14@gmail.com>
vitormattos
left a comment
There was a problem hiding this comment.
Thanks for the update!
Could you add a few tests for getSELinuxStatus() when PHP has open_basedir enabled?
open_basedir limits which directories PHP can access. We need to make sure the method handles these cases correctly:
-
File inside an allowed directory: Create a temporary directory with
sys/fs/selinux/enforcecontaining1. Setopen_basedirto allow this directory. The method should returnSELINUX_ENFORCING. -
File outside the allowed directories: Create the same file containing
1, but setopen_basedirto allow only a different directory. The method should returnSELINUX_UNKNOWNwithout PHP warnings. It should not returnSELINUX_UNAVAILABLE, because PHP cannot check whether the file exists. -
File does not exist: Set
open_basedirto allow a temporary directory where the SELinux status file does not exist. The method should returnSELINUX_UNAVAILABLE.
Please create the test files before enabling the restrictions. Run the restricted tests in separate PHP processes so that open_basedir does not affect other tests. PHPUnit supports this with #[RunInSeparateProcess].
Could you add these tests and run them with the current implementation first? I expect the first two cases to fail.
After confirming the failures, please fix the method and run the tests again to verify the results.
Thanks!
Signed-off-by: Gabriel Pereira do Carmo <gabrielcarmobr14@gmail.com>
|
Hi! Thanks for the feedback! I've added the three requested tests covering I ran the tests before applying the fix and confirmed that the first two cases failed, as expected. After updating the implementation, all tests passed successfully (12 tests, 36 assertions). The changes have been pushed and are ready for review. Thanks again! |
vitormattos
left a comment
There was a problem hiding this comment.
Follow-up review of the latest changes. See the inline comment for two additional path-handling regression scenarios.
Signed-off-by: Gabriel Pereira do Carmo <gabrielcarmobr14@gmail.com>
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
|
Hi @GabrielPdoCarmo, Thank you for contributing SELinux status detection to whatosami, especially for addressing the We also appreciate your contributions to LibreSign's PHPUnit tests and developer documentation. Thank you for helping improve different parts of the LibreSign ecosystem! We'd love to hear about your experience contributing. Was anything unclear or unnecessarily difficult? What could we improve? You can share your feedback through our short, optional survey: You're always welcome to contribute again and join our community: https://t.me/LibreSign Thanks again for your contributions! |
Pull Request Description
This PR adds SELinux status detection to the
OperatingSystemclass.Changes include:
getSELinuxStatus()using filesystem information without privileged commands.enforcing,permissive,unavailable, andunknown.Related Issue
Issue Number: #2
Closes #2
Pull Request Type
Pull request checklist
Testing
Run the unit tests using:
composer test:unitResults:
PHP version: 8.3.35
PHPUnit version: 11.2.7