Add nixos-rebuild audit rule#1508
Conversation
21f6ca9 to
56c6079
Compare
|
Tested the PR on lenovo-x1-carbon-gen10 machine . However the failed nixos-rebuild attempts are not captured quite well according to the original requirement https://jira.tii.ae/browse/SSRCSP-6933 |
|
I was curious to see if that write-watch is able to log also direct write to write-watch was able to see that write into nix store, grafana logged: |
If I manage to edit a symbolic link pointing to file in /nix/store |
a638f84 to
56ce742
Compare
I added a "Store Watcher" service to monitor the nix store - https://github.com/everton-dematos/ghaf/blob/pr_logging_nixos_rebuild/modules/common/services/storewatcher.nix It is a bit tricky to monitor failed What I did with this "Store Watcher" is to monitor the modifications at the nix store location and trigger a message if a transfer is taking too long. I added cycles of "checking", as in some cases, the transfer of a specific package may take a while, either because the package is large in size or due to network issues. The number of cycles of waiting and the time for each cycle can be personalized by parameters. Testing:
Performance:
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds an optional audit rule for monitoring /nix/store write operations during nixos-rebuild operations, and introduces a new store watcher service to detect interrupted nixos-rebuild sessions.
- Adds
ghaf.security.audit.enableVerboseRebuildoption (default: false) to enable verbose audit logging of/nix/storemodifications - Introduces
ghaf.services.storeWatcherservice with configurable timers to monitor and lognixos-rebuildcopy sessions - Adds audit rule that logs write operations to
/nix/storewith keynixos_rebuild_store
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| modules/common/services/storewatcher.nix | New service that watches /nix/store using inotify and logs copy session lifecycle events |
| modules/common/services/default.nix | Adds the new storewatcher module to service imports |
| modules/common/security/audit/rules/host.nix | Adds conditional audit rule for monitoring /nix/store write operations |
| modules/common/security/audit/default.nix | Adds enableVerboseRebuild boolean option to control the new audit rule |
Signed-off-by: Everton de Matos <everton.dematos@tii.ae>
Signed-off-by: Everton de Matos <everton.dematos@tii.ae>
56ce742 to
7c47717
Compare




Description of Changes
https://jira.tii.ae/browse/SSRCSP-7333
ghaf.security.audit.enableVerboseRebuildoption./nix/storewrite-watch rule keyednixos_rebuild_store.ghaf-host.Type of Change
Related Issues / Tickets
Checklist
make-checksand it passesTesting Instructions
Applicable Targets
aarch64aarch64x86_64x86_64x86_64Installation Method
nixos-rebuild ... switchTest Steps To Verify:
auditoption to true: https://github.com/everton-dematos/ghaf/blob/pr_logging_nixos_rebuild/modules/reference/profiles/mvp-user-trial.nix#L107enableVerboseRebuildto true at https://github.com/everton-dematos/ghaf/blob/pr_logging_nixos_rebuild/modules/common/security/audit/default.nix#L107 by adding the following line:ghaf.security.audit.enableVerboseRebuild = true;descriptionat any file). This step is important, as it will trigger the audit rule atghaf-host.nixos-rebuild.6.1
{machine="<machine_id>"} |~ "PATH" |~ "/nix/store/"6.2
{machine="<machine_id>"} |= "nixos_rebuild_store"