testsAndMisc/linux_configuration/tests/lib/security_pacman.sh
Krzysztof kuhy Rudnicki 08aac8d7d1 Flatten i3-configuration and misc/testsAndMisc-bash
i3 config was filed under periodic_background, which it never was. It is
now linux_configuration/i3/ (config + installer) and
linux_configuration/i3blocks/ (the status scripts), both at depth 2.

misc/testsAndMisc-bash/ was a directory named after the repo it already
lived in, so its contents moved up to misc/. Its stray .gitignore came
along, keeping the media rules working from the new location; its
.vscode/tasks.json did not, because it invoked Bash/transcribe.sh, a path
this repo dropped long ago.

Most of this commit is the references the previous flatten missed. Its
regex skipped anything with a variable prefix, which left 16 files --
including check_and_enable_services.sh and install_core_system.sh, the
orchestrators -- still naming $CONFIG_DIR/scripts/periodic_background/...
It had also rewritten three i3 paths into scripts/i3blocks/, a directory
that has never existed; the i3blocks suites caught that by failing.

13 more symlinks broke on the i3 move. Repointed, and cpu_monitor/volume/
disk were run again to confirm the bar still reports.

Depth 139 -> 104. Roughly 47 of the remainder sit in digital_wellbeing
and hosts, still deferred. The rest encode real structure -- a C project,
Python package directories, artgate's routes/styles, systemd unit dirs --
so flattening them further would destroy information rather than
taxonomy.

Verified: 1798 tests at 100%, both i3blocks suites pass, the shell
coverage gate is clean, and the relocated media rules still ignore what
they should while test_fw.srt stays tracked.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PJrqKERAo5QUeEHWS5Asgp
2026-08-23 19:02:18 +02:00

74 lines
2.5 KiB
Bash
Executable File

#!/bin/bash
# Security hardening tests: pacman wrapper and its policy files.
# Sourced by test_security_hardening.sh; inherits its strict mode,
# colors, counters (PASS/FAIL/SKIP), LIVE_SECTION and test_result().
sec_tests_pacman_wrapper() {
# ==================================================================
# PACMAN WRAPPER TESTS
# ==================================================================
echo "--- PACMAN WRAPPER ---"
# Test 12: pacman wrapper is installed
if [[ -L /usr/bin/pacman ]] && [[ -f /usr/bin/pacman.orig ]]; then
test_result "pacman wrapper installed" "pass"
else
if [[ ! -L /usr/bin/pacman ]]; then
test_result "pacman wrapper installed" "fail" "/usr/bin/pacman is not a symlink"
else
test_result "pacman wrapper installed" "fail" "/usr/bin/pacman.orig not found"
fi
fi
live_section 0 # repository checks from here on
# Test 13: google-chrome is blocked
blocked_file="$REPO_DIR/periodic_background/digital_wellbeing/pacman/pacman_blocked_keywords.txt"
if [[ -f "$blocked_file" ]]; then
if grep -qi "google-chrome" "$blocked_file"; then
test_result "google-chrome in blocked list" "pass"
else
test_result "google-chrome in blocked list" "fail" "Not found in $blocked_file"
fi
else
test_result "google-chrome in blocked list" "skip" "Blocked keywords file not found"
fi
# Test 14: chromium is blocked
if [[ -f "$blocked_file" ]]; then
if grep -qi "^chromium$" "$blocked_file"; then
test_result "chromium in blocked list" "pass"
else
test_result "chromium in blocked list" "fail" "Not found in $blocked_file"
fi
else
test_result "chromium in blocked list" "skip" "Blocked keywords file not found"
fi
# Test 15: Policy integrity file exists
# Lives under /var on the configured host, so it is a live check despite
# sitting among the repository ones.
live_section 1
if [[ -f /var/lib/pacman-wrapper/policy.sha256 ]]; then
test_result "Pacman policy integrity file exists" "pass"
else
test_result "Pacman policy integrity file exists" "fail" "Not found"
fi
live_section 0
# Test 16: LeechBlock auto-install function exists in wrapper
wrapper_file="$REPO_DIR/periodic_background/digital_wellbeing/pacman/pacman_wrapper.sh"
if [[ -f "$wrapper_file" ]]; then
if grep -q "auto_install_leechblock" "$wrapper_file"; then
test_result "LeechBlock auto-install function exists" "pass"
else
test_result "LeechBlock auto-install function exists" "fail" "Function not found"
fi
else
test_result "LeechBlock auto-install function exists" "skip" "Wrapper file not found"
fi
echo ""
}