mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-10 18:07:06 +01:00
The last unit over the cap is now github.com/kuhyx/digital-wellbeing, cloned at ~/digital-wellbeing, and `--warn` is gone from the directory-depth-cap hook. `check_directory_depth.sh --all` exits 0 with zero violations, down from 46 at the start of the session. That was the point of the campaign. History was filtered across all three paths the unit has lived at (63 commits); the current path alone holds 2. The six suites that test this code lived in linux_configuration/tests/ rather than beside it, so they were filtered separately (24 commits) and merged in as a second root. A path filter of the unit alone would have left them here, testing code that had left the repo -- and their names would still have been in shell-tests.yml's hardcoded arrays, failing CI on missing files. linux_configuration/lib/common.sh is vendored into vendor/ rather than trimmed to the four functions actually used: set_actual_user_vars calls two of the others, so a trim breaks silently. It is in vendor/ and not lib/ because test_music_parallelism.sh copies the unit's own lib/ into a scratch worktree while stubbing the shared lib; in one directory the real common.sh overwrote the stub, and the suite silently measured the wrong library. Running the callers caught what shellcheck and grep both missed: check_and_enable_services.sh died with "DW_REPO: unbound variable" because the definition sat below its first use. It now runs clean and reports ok for every extracted-unit check. Two long-standing live defects fixed as a consequence. The pacman-wrapper drift manifest embeds ABSOLUTE paths and had named deleted scripts/ paths since the flatten, so the check reported a permanent false "stale or tampered"; it now verifies, with unchanged hashes proving the extracted bytes are identical. And the last two stale live references are gone: 8 -> 0. The two pre-commit excludes for setup_midnight_shutdown.sh are dropped rather than moved. lsattr shows nothing in the unit is chattr +i any more, and the fixer hooks leave the file alone when allowed to run. Removing 80 shell files also shrank the jscpd denominator enough that the virtualenv/tqdm clones inside the GENERATED .ci-mirror-venv/ tipped the repo to 2.09% and blocked this commit, which adds no duplication. That directory is the same vendored third-party shell the ignore list already excludes as .venv/, just under another name; jscpd walks the working tree rather than the index, so being untracked did not spare it. Excluded by name: 1.74%. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PJrqKERAo5QUeEHWS5Asgp
132 lines
4.6 KiB
Bash
Executable File
132 lines
4.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# Security hardening tests: compulsive-opening block + screen locker.
|
|
# Sourced by test_security_hardening.sh; inherits its strict mode,
|
|
# colors, counters (PASS/FAIL/SKIP), LIVE_SECTION and test_result().
|
|
|
|
sec_tests_compulsive_block() {
|
|
# ==================================================================
|
|
# COMPULSIVE BLOCK TESTS
|
|
# ==================================================================
|
|
echo "--- COMPULSIVE OPENING BLOCK ---"
|
|
|
|
compulsive_dir="$DW_REPO"
|
|
compulsive_file="$compulsive_dir/block_compulsive_opening.sh"
|
|
|
|
# The blocker was split into lib/cco_*.sh under the 250-line cap, so these
|
|
# two checks search the entry script AND its libs. Grepping the entry
|
|
# script alone made them report "not found" for code that had simply moved
|
|
# one file over — a false failure that says nothing about the feature.
|
|
# Searching the set keeps the assertion about the FEATURE existing, which
|
|
# is what it was always for, and survives the next split too.
|
|
compulsive_sources=("$compulsive_file")
|
|
for compulsive_lib in "$compulsive_dir"/lib/cco_*.sh; do
|
|
[[ -f "$compulsive_lib" ]] && compulsive_sources+=("$compulsive_lib")
|
|
done
|
|
|
|
# Test 17: Auto-close timer configuration exists
|
|
if [[ -f "$compulsive_file" ]]; then
|
|
if grep -qs "AUTO_CLOSE_TIMEOUT_MINUTES" "${compulsive_sources[@]}"; then
|
|
test_result "Auto-close timer configuration exists" "pass"
|
|
else
|
|
test_result "Auto-close timer configuration exists" "fail" "Variable not found"
|
|
fi
|
|
else
|
|
test_result "Auto-close timer configuration exists" "skip" "Script not found"
|
|
fi
|
|
|
|
# Test 18: launch_with_timer function exists
|
|
if [[ -f "$compulsive_file" ]]; then
|
|
if grep -qs "launch_with_timer" "${compulsive_sources[@]}"; then
|
|
test_result "launch_with_timer function exists" "pass"
|
|
else
|
|
test_result "launch_with_timer function exists" "fail" "Function not found"
|
|
fi
|
|
else
|
|
test_result "launch_with_timer function exists" "skip" "Script not found"
|
|
fi
|
|
|
|
# Test 19: Compulsive block wrappers installed
|
|
wrappers_ok=true
|
|
for app in beeper signal-desktop discord; do
|
|
if [[ -f "/usr/bin/$app" ]]; then
|
|
if grep -q "block-compulsive-opening" "/usr/bin/$app" 2>/dev/null; then
|
|
: # OK
|
|
else
|
|
wrappers_ok=false
|
|
fi
|
|
fi
|
|
done
|
|
if [[ "$wrappers_ok" == true ]]; then
|
|
test_result "Compulsive block wrappers installed" "pass"
|
|
else
|
|
test_result "Compulsive block wrappers installed" "fail" "Some wrappers missing or incorrect"
|
|
fi
|
|
|
|
echo ""
|
|
|
|
}
|
|
|
|
sec_tests_screen_locker() {
|
|
# ==================================================================
|
|
# SCREEN LOCKER TESTS
|
|
# ==================================================================
|
|
echo "--- SCREEN LOCKER ---"
|
|
|
|
screen_locker="$HOME/testsAndMisc/python_pkg/screen_locker/screen_lock.py"
|
|
|
|
# Test 20: Screen locker exists
|
|
if [[ -f "$screen_locker" ]]; then
|
|
test_result "Screen locker script exists" "pass"
|
|
else
|
|
test_result "Screen locker script exists" "skip" "Not found at expected location"
|
|
fi
|
|
|
|
# Test 21: Running option removed
|
|
if [[ -f "$screen_locker" ]]; then
|
|
# Check that there's no "Running" button in ask_workout_type
|
|
if grep -A 20 "def ask_workout_type" "$screen_locker" | grep -q '"Running"'; then
|
|
test_result "Running workout option removed" "fail" "Still present in ask_workout_type"
|
|
else
|
|
test_result "Running workout option removed" "pass"
|
|
fi
|
|
else
|
|
test_result "Running workout option removed" "skip" "Script not found"
|
|
fi
|
|
|
|
# Test 22: Table tennis minimum sets validation
|
|
if [[ -f "$screen_locker" ]]; then
|
|
if grep -q "MIN_TABLE_TENNIS_SETS" "$screen_locker"; then
|
|
test_result "Table tennis minimum sets validation exists" "pass"
|
|
else
|
|
test_result "Table tennis minimum sets validation exists" "fail" "Constant not found"
|
|
fi
|
|
else
|
|
test_result "Table tennis minimum sets validation exists" "skip" "Script not found"
|
|
fi
|
|
|
|
# Test 23: Table tennis verification question
|
|
if [[ -f "$screen_locker" ]]; then
|
|
if grep -q "ask_table_tennis_verification" "$screen_locker"; then
|
|
test_result "Table tennis verification question exists" "pass"
|
|
else
|
|
test_result "Table tennis verification question exists" "fail" "Function not found"
|
|
fi
|
|
else
|
|
test_result "Table tennis verification question exists" "skip" "Script not found"
|
|
fi
|
|
|
|
# Test 24: 60 second submit delay for table tennis
|
|
if [[ -f "$screen_locker" ]]; then
|
|
if grep -q "TABLE_TENNIS_SUBMIT_DELAY = 60" "$screen_locker"; then
|
|
test_result "Table tennis 60-second submit delay" "pass"
|
|
else
|
|
test_result "Table tennis 60-second submit delay" "fail" "Constant not set to 60"
|
|
fi
|
|
else
|
|
test_result "Table tennis 60-second submit delay" "skip" "Script not found"
|
|
fi
|
|
|
|
echo ""
|
|
|
|
}
|