How remediation works
Remediation is a three-phase process for each failing rule:- Pre-state capture. Kensa records the current value of every setting it will change.
- Apply fix. The remediation mechanism writes the corrected configuration.
- Post-check. Kensa re-runs the compliance check to verify the fix took effect.
--rollback-on-failure is active, Kensa reverses all changes for that rule using the captured pre-state data.
Remediation mechanisms
All remediations use typed, declarative mechanisms — not arbitrary shell scripts. Each mechanism is idempotent (running it twice produces the same result as running it once). Kensa selects the most durable option available: drop-in files in.d/ directories survive package updates, while direct config edits may be overwritten.
Risk classification
Every remediation step is assigned a risk level based on its mechanism type and target path:| Risk | Scope |
|---|---|
| High | Mechanisms affecting boot, authentication, or mount behavior: GRUB parameters, kernel module disabling, PAM configuration, mount options. Also triggered by high-risk paths: /etc/pam.d/, /etc/fstab, /etc/default/grub, /etc/selinux/config. |
| Medium | Mechanisms that change service or kernel behavior: config file edits, sysctl values, service masking, audit rules, SELinux booleans. |
| Low | Narrow-scope changes: file permissions, package install/remove, cron jobs. |
Snapshot configuration
Therollback section of config/defaults.yml controls pre-state capture:
all(default): Capture pre-state for every remediation step.risk_based: Capture only for steps at or above the risk threshold.none: No snapshots. Faster, but rollback is unavailable.
Rollback workflow
Non-capturable mechanisms
Three mechanism types cannot capture pre-state:command_exec— arbitrary commandsmanual— human-performed stepsgrub_parameter_set/remove— requires regenerating boot config
History and drift detection
Storing results
Add--store to any check command to persist results in the local SQLite database (.kensa/results.db):
Tracking drift
Compare two scan sessions to find regressions and improvements:diff reports four categories: regressions (previously passing rules that now fail), resolved (previously failing rules that now pass), new failures, and new passes.
Database maintenance
defaults.yml): full rollback data is available for 7 days (active window), metadata is retained for 90 days (archive window), then records are pruned.