-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
nixos/apparmor: policy activation tristate and policy path support #356796
Conversation
3de6ae1
to
2b7647e
Compare
2b7647e
to
9f7131e
Compare
9f7131e
to
49493c1
Compare
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/apparmor-default-profiles/16780/8 |
49493c1
to
4b3e3c9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you think you could test your options in the nixos test?
Thank you for the feedback! I'll take a look at more explicit nixos tests also testing the new logic. Your points about wording of docs/descriptions is entirely fair. |
4b3e3c9
to
0e37071
Compare
Thank you for the improved nixos test. Do you think you could add a profile in enforce mode for a third tool (say, hexdump) and check that it really gets permission denied/crashes when trying to access files beyond what its profile allows ? That would be a good integration test that apparmor works. |
Alright. I had a go at completely refactoring the apparmor nixos tests.
|
fair point in seeing something crash! Will add a test case for |
0e37071
to
376cf48
Compare
Alright, i managed to add a failing test case for hexdump and a succeeding testcase for hello. |
@getchoo you are missing one relevant detail here: The current assert runs in the The alternative is dropping the apply function and inlining it wherever the actual path is required. I did not do this because the previous module using apply. I also figured it'd break peoples configs less hard if behavior stayed roughly similar (previously, you could query the policy path by using I am willing to change the assert to a module-global assert instead of specifically in the submodule. I did want to confirm though, because your requested changes alone wouldn't work. |
1dcdcfa
to
5e3203b
Compare
5e3203b
to
1b12de4
Compare
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/apparmor-on-nixos-roadmap/57217/1 |
1b12de4
to
1ecda09
Compare
Alright, my new ram arrived, i ran |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for all of your work here!
@ofborg test apparmor |
I am confused, why are ofborg eval and eval-lib-tests failing on gnome circle things? this PR doesn't even touch those... But at least the apparmor nixos test passes, and the new github actions to replace ofborg pass too |
They were probably failing on the base commit at the time that ofborg merged your changes against master to test eval. |
1ecda09
to
8ecddfa
Compare
i fixed merge conflicts (again). |
- nixfmt on apparmor test - move apparmor test to nixos/tests/apparmor directory - expected profile contents are now generated in its own file to make the test file less confusing and hard to maintain - enforce/complain is now being tested via diff of expected against aa-status - path is now tested against diff+file checking symlink target of /etc/static/apparmor.d/<name> - profile is now checked by diff of /etc/static/apparmor.d/<name> against original string added in nix config - test still successfully passes - added test for confined hello to succeed - added test for confined hexdump on denied path to fail
8ecddfa
to
b27f064
Compare
@ofborg test apparmor |
Thank you! |
AppArmor profiles are files written to
/etc/apparmor.d/<name>
. Previously, profiles were defined with a string and written to a store entry, then linked into the etc path. However, this makes little sense if one wants to use profiles that are already files in the nix store, e.g. when using rules fromroddhjav-apparmor-rules
(which is absolutely broken currently, but that is a different topic; PR for that coming eventually). This change in the module exposes an optionsecurity.apparmor.policies.<name>.path
with which a path to a profile can be directly symlinked into the apparmor directory, without first reading and rewriting that file into nix store again. This should boost nixos eval times on systems using prebuilt apparmor rules and makes prebuilding/caching apparmor rulesets via nix possible.AppArmor profiles always fall within a tristate of
enable
,disable
,complain
. It makes no sense to have two boolean options instead of a neat enum config for the tristate. Therefore, i added that tristate, removing the two bools in the process.The apparmor nixos test breaks often. While testing this PR, i noticed the test failing on master/nixos-unstable too. Therefore, i included a fix to the nixos test.
Yes, the two removed bools are a breaking change. However, the path option addition is inert, it does not break definitions of apparmor policies defined via string.
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.