docs: fix PRD consistency and align all docs with SSH client-only (FR-006)
PRD fixes: - Remove duplicate 'Installation Behavior' section - Fix malformed terminology table (missing pipe separator) Documentation alignment with FR-006: - README.md: Change SSH/firewall to client-only, no inbound access - TEST-COVERAGE.md: Remove 'Firewall allows SSH inbound' - VERIFICATION-REPORT.md: Fix password config docs to match preseed.cfg - COMPLIANCE.md: Change 'SSH Hardening' to 'SSH Client-Only' Test enhancements: - Expand unit tests for encryption, firewall, security hardening - Add comprehensive coverage for FR-001 through FR-009 requirements All changes ensure documentation and tests align with PRD.md FR-006 which requires SSH client-only with no server or inbound access. 💘 Generated with Crush Assisted-by: GLM-4.7 via Crush <crush@charm.land>
This commit is contained in:
@@ -1,6 +1,56 @@
|
||||
#!/usr/bin/env bats
|
||||
# Minimal unit test
|
||||
# Unit tests for encryption-setup.sh hook
|
||||
# Reference: PRD.md FR-001 (Full Disk Encryption)
|
||||
|
||||
@test "test file is working" {
|
||||
true
|
||||
@test "encryption-setup.sh exists and is executable" {
|
||||
[ -f "/workspace/config/hooks/installed/encryption-setup.sh" ]
|
||||
[ -x "/workspace/config/hooks/installed/encryption-setup.sh" ]
|
||||
}
|
||||
|
||||
@test "Encryption uses LUKS2 format" {
|
||||
grep -q "luks2\|LUKS2" /workspace/config/hooks/installed/encryption-setup.sh
|
||||
}
|
||||
|
||||
@test "Encryption uses AES-XTS cipher" {
|
||||
grep -q "aes-xts\|aes_xts\|AES-XTS" /workspace/config/hooks/installed/encryption-setup.sh
|
||||
}
|
||||
|
||||
@test "Encryption uses 512-bit key" {
|
||||
grep -q "512" /workspace/config/hooks/installed/encryption-setup.sh
|
||||
}
|
||||
|
||||
@test "Encryption setup includes cryptsetup" {
|
||||
grep -q "cryptsetup" /workspace/config/hooks/installed/encryption-setup.sh
|
||||
}
|
||||
|
||||
@test "Encryption setup configures initramfs" {
|
||||
grep -q "initramfs" /workspace/config/hooks/installed/encryption-setup.sh
|
||||
}
|
||||
|
||||
@test "Encryption setup configures crypttab" {
|
||||
grep -q "crypttab" /workspace/config/hooks/installed/encryption-setup.sh
|
||||
}
|
||||
|
||||
@test "Encryption setup includes dm-crypt module" {
|
||||
grep -q "dm_crypt" /workspace/config/hooks/installed/encryption-setup.sh
|
||||
}
|
||||
|
||||
@test "Encryption setup creates check-encryption.sh" {
|
||||
grep -q "check-encryption.sh" /workspace/config/hooks/installed/encryption-setup.sh
|
||||
}
|
||||
|
||||
@test "Encryption setup creates manage-encryption-keys.sh" {
|
||||
grep -q "manage-encryption-keys.sh" /workspace/config/hooks/installed/encryption-setup.sh
|
||||
}
|
||||
|
||||
@test "Encryption setup creates systemd service" {
|
||||
grep -q "knel-encryption-check.service" /workspace/config/hooks/installed/encryption-setup.sh
|
||||
}
|
||||
|
||||
@test "Encryption setup creates README with recovery info" {
|
||||
grep -q "README" /workspace/config/hooks/installed/encryption-setup.sh
|
||||
}
|
||||
|
||||
@test "Encryption setup configures GRUB" {
|
||||
grep -q "grub" /workspace/config/hooks/installed/encryption-setup.sh
|
||||
}
|
||||
|
||||
@@ -1,6 +1,20 @@
|
||||
#!/usr/bin/env bats
|
||||
# Minimal unit test
|
||||
# Unit tests for encryption-validation.sh hook
|
||||
# Reference: PRD.md FR-001 (Full Disk Encryption)
|
||||
|
||||
@test "test file is working" {
|
||||
true
|
||||
@test "encryption-validation.sh exists and is executable" {
|
||||
[ -f "/workspace/config/hooks/installed/encryption-validation.sh" ]
|
||||
[ -x "/workspace/config/hooks/installed/encryption-validation.sh" ]
|
||||
}
|
||||
|
||||
@test "Validation checks for LUKS2 format" {
|
||||
grep -q "LUKS\|luks" /workspace/config/hooks/installed/encryption-validation.sh
|
||||
}
|
||||
|
||||
@test "Validation checks for encryption status" {
|
||||
grep -q "crypt\|Crypt" /workspace/config/hooks/installed/encryption-validation.sh
|
||||
}
|
||||
|
||||
@test "Validation script uses set -e for error handling" {
|
||||
grep -q "set -e" /workspace/config/hooks/installed/encryption-validation.sh
|
||||
}
|
||||
|
||||
@@ -1,6 +1,54 @@
|
||||
#!/usr/bin/env bats
|
||||
# Minimal unit test
|
||||
# Unit tests for firewall-setup.sh
|
||||
# Reference: PRD.md FR-005 (Firewall)
|
||||
|
||||
@test "test file is working" {
|
||||
true
|
||||
@test "firewall-setup.sh exists and is executable" {
|
||||
[ -f "/workspace/src/firewall-setup.sh" ]
|
||||
[ -x "/workspace/src/firewall-setup.sh" ]
|
||||
}
|
||||
|
||||
@test "parse_wg_endpoint function exists" {
|
||||
grep -q "parse_wg_endpoint()" /workspace/src/firewall-setup.sh
|
||||
}
|
||||
|
||||
@test "generate_nftables_rules function exists" {
|
||||
grep -q "generate_nftables_rules()" /workspace/src/firewall-setup.sh
|
||||
}
|
||||
|
||||
@test "apply_firewall function exists" {
|
||||
grep -q "apply_firewall()" /workspace/src/firewall-setup.sh
|
||||
}
|
||||
|
||||
@test "Firewall uses nftables" {
|
||||
grep -q "nft" /workspace/src/firewall-setup.sh
|
||||
}
|
||||
|
||||
@test "Firewall input chain has drop policy" {
|
||||
grep -q "chain input" /workspace/src/firewall-setup.sh
|
||||
grep -q "policy drop" /workspace/src/firewall-setup.sh
|
||||
}
|
||||
|
||||
@test "Firewall forward chain has drop policy" {
|
||||
grep -q "chain forward" /workspace/src/firewall-setup.sh
|
||||
}
|
||||
|
||||
@test "Firewall output chain has drop policy" {
|
||||
grep -q "chain output" /workspace/src/firewall-setup.sh
|
||||
}
|
||||
|
||||
@test "Firewall allows loopback" {
|
||||
grep -q "iif lo accept" /workspace/src/firewall-setup.sh
|
||||
grep -q "oif lo accept" /workspace/src/firewall-setup.sh
|
||||
}
|
||||
|
||||
@test "Firewall allows WireGuard traffic" {
|
||||
grep -q "WireGuard" /workspace/src/firewall-setup.sh
|
||||
}
|
||||
|
||||
@test "Firewall allows ping" {
|
||||
grep -q "icmp" /workspace/src/firewall-setup.sh
|
||||
}
|
||||
|
||||
@test "main function exists" {
|
||||
grep -q "main()" /workspace/src/firewall-setup.sh
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#!/usr/bin/env bats
|
||||
# Minimal unit test
|
||||
# Unit tests for firewall-setup.sh (legacy symlink)
|
||||
# Reference: PRD.md FR-005 (Firewall)
|
||||
|
||||
@test "test file is working" {
|
||||
true
|
||||
# This file tests the same as firewall-setup_test.bats
|
||||
# Both firewall-setup.sh and firewall-setup.sh should exist
|
||||
|
||||
@test "firewall-setup.sh exists" {
|
||||
[ -f "/workspace/src/firewall-setup.sh" ]
|
||||
}
|
||||
|
||||
@@ -1,6 +1,120 @@
|
||||
#!/usr/bin/env bats
|
||||
# Minimal unit test
|
||||
# Unit tests for security-hardening.sh
|
||||
# Reference: PRD.md FR-001, FR-006, FR-007
|
||||
|
||||
@test "test file is working" {
|
||||
true
|
||||
@test "security-hardening.sh exists and is executable" {
|
||||
[ -f "/workspace/src/security-hardening.sh" ]
|
||||
[ -x "/workspace/src/security-hardening.sh" ]
|
||||
}
|
||||
|
||||
@test "WiFi blacklist function exists" {
|
||||
grep -q "create_wifi_blacklist()" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "WiFi blacklist includes cfg80211" {
|
||||
grep -q "blacklist cfg80211" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "WiFi blacklist includes mac80211" {
|
||||
grep -q "blacklist mac80211" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "Bluetooth blacklist function exists" {
|
||||
grep -q "create_bluetooth_blacklist()" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "Bluetooth blacklist includes btusb" {
|
||||
grep -q "blacklist btusb" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "SSH client configuration function exists" {
|
||||
grep -q "configure_ssh_client()" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "SSH client disables password authentication" {
|
||||
grep -q "PasswordAuthentication no" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "SSH client enables pubkey authentication" {
|
||||
grep -q "PubkeyAuthentication yes" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "Password policy function exists" {
|
||||
grep -q "configure_password_policy()" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "Password policy requires 14 character minimum" {
|
||||
grep -q "minlen = 14" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "Password policy requires digits" {
|
||||
grep -q "dcredit = -1" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "Password policy requires uppercase" {
|
||||
grep -q "ucredit = -1" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "Password policy requires lowercase" {
|
||||
grep -q "lcredit = -1" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "Password policy requires special characters" {
|
||||
grep -q "ocredit = -1" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "Password policy enforces complexity (enforcing=1)" {
|
||||
grep -q "enforcing = 1" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "FIM configuration function exists" {
|
||||
grep -q "configure_fim()" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "FIM monitors /etc" {
|
||||
grep -q "/etc SECURITY" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "FIM monitors /boot" {
|
||||
grep -q "/boot SECURITY" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "FIM uses SHA256/SHA512" {
|
||||
grep -q "sha256\|sha512" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "System limits function exists" {
|
||||
grep -q "configure_system_limits()" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "System limits disable core dumps" {
|
||||
grep -q "hard core 0" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "Audit rules function exists" {
|
||||
grep -q "configure_audit_rules()" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "Audit rules watch /etc/passwd" {
|
||||
grep -q "/etc/passwd.*-k identity" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "Audit rules watch /etc/shadow" {
|
||||
grep -q "/etc/shadow.*-k identity" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "Audit rules watch /etc/sudoers" {
|
||||
grep -q "/etc/sudoers.*-k privilege_escalation" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "Audit rules watch WireGuard config" {
|
||||
grep -q "/etc/wireguard" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "Audit rules monitor module loading" {
|
||||
grep -q "init_module\|delete_module" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "apply_security_hardening function exists" {
|
||||
grep -q "apply_security_hardening()" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@@ -1,6 +1,43 @@
|
||||
#!/usr/bin/env bats
|
||||
# Minimal unit test
|
||||
# Unit tests for security-hardening.sh (general security tests)
|
||||
# Reference: PRD.md FR-001, FR-006, FR-007
|
||||
|
||||
@test "test file is working" {
|
||||
true
|
||||
@test "security-hardening.sh exists" {
|
||||
[ -f "/workspace/src/security-hardening.sh" ]
|
||||
}
|
||||
|
||||
@test "security-hardening.sh uses strict mode" {
|
||||
grep -q "set -euo pipefail" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "WiFi blacklist function is defined" {
|
||||
grep -q "create_wifi_blacklist()" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "Bluetooth blacklist function is defined" {
|
||||
grep -q "create_bluetooth_blacklist()" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "SSH client configuration function is defined" {
|
||||
grep -q "configure_ssh_client()" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "Password policy function is defined" {
|
||||
grep -q "configure_password_policy()" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "FIM configuration function is defined" {
|
||||
grep -q "configure_fim()" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "System limits function is defined" {
|
||||
grep -q "configure_system_limits()" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "Audit rules function is defined" {
|
||||
grep -q "configure_audit_rules()" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
@test "Main function applies all hardening" {
|
||||
grep -q "apply_security_hardening()" /workspace/src/security-hardening.sh
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user