Repository navigation
test: cover harden_sysctl / harden_attack_surface invariants - #29
Merged
Merged
Conversation
Both functions write system files and call systemctl/sudo, so the new tests extract their bodies and assert structurally instead of executing them. Pins regressions that were real bugs: - core network profile values (rp_filter, syncookies, source_route, accept_redirects, rfc1337, log_martians) - user.max_user_namespaces=0 stays gated on container detection - sysctl metrics count uses '|| true' on the grep -cE line, not a duplicated '|| echo 0' fallback that yields '00' - SSH crypto directives split on the first space, not '=' - sshd_config.d drop-ins are backed up before edits - login.defs ENCRYPT_METHOD is never downgraded - squashfs is blacklisted conditionally and stays out of the static array - attack_surface and apt_https are reachable via --step
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the coverage gap on the two hardening functions added in PR #25/#27/#28.
Neither function is directly executable in the test harness (they write /etc files and call systemctl/sudo), so the tests extract each function body and assert structurally. Each assertion pins a behaviour that was a real bug:
Negative controls: reintroducing the '=' split, the duplicated echo fallback, or removing the snap/squashfs triage each flip the corresponding assertion. Verified in-memory (no source mutation).