1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 19:09:43 +00:00

fix: Enhance uninstall robustness with base64

compatibility and cleanup improvements

- Fix field count
  mismatch and base64 BSD/GNU compatibility
  - Add sensitive data detection and macOS defaults cleanup
  - Improve error handling and add compatibility tests
This commit is contained in:
Tw93
2025-12-25 11:24:12 +08:00
parent 2ecae62d57
commit 952b2eea61
3 changed files with 147 additions and 41 deletions

View File

@@ -204,6 +204,34 @@ else
# Or return error code
true
fi
EOF
[ "$status" -eq 0 ]
}
@test "decode_file_list handles both BSD and GNU base64 formats" {
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc << 'EOF'
set -euo pipefail
source "$PROJECT_ROOT/lib/core/common.sh"
source "$PROJECT_ROOT/lib/uninstall/batch.sh"
# Test data: absolute paths
test_paths="/path/to/file1
/path/to/file2"
# Encode with whatever base64 is available (no flags)
encoded_data=$(printf '%s' "$test_paths" | base64 | tr -d '\n')
# decode_file_list should handle it regardless of BSD (-D) or GNU (-d)
result=$(decode_file_list "$encoded_data" "TestApp")
# Verify result contains expected paths
[[ "$result" == *"/path/to/file1"* ]] || exit 1
[[ "$result" == *"/path/to/file2"* ]] || exit 1
# Verify the function tries both -D and -d by checking it doesn't fail
# This tests the fallback logic in decode_file_list
[[ -n "$result" ]] || exit 1
EOF
[ "$status" -eq 0 ]