1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 16:45:07 +00:00
Commit Graph

1878 Commits

Author SHA1 Message Date
Tw93
3b46b4ade6 fix(ui): use system sleep for inline spinner 2026-03-19 00:40:39 +08:00
Tw93
821a824d81 fix: dedupe cleanup previews by filesystem identity 2026-03-19 00:32:28 +08:00
github-actions[bot]
03db800709 chore: update contributors [skip ci] 2026-03-18 16:28:53 +00:00
Jason Costello
e617ed2e76 Fix: Removed duplicate calls to clean_xcode_tools and clean_code_editors (#593)
* removed duplicate calls to clean_xcode_tools and clean_code_editors

in lib/clean/app_caches.sh clean_user_gui_application() was making calls
to clean_xcode_tools and clean_code_editors.

in lib/clean/dev.sh clean_xcode_tools and clean_code_editors was also
being called, causing the duplication when executing the clean command.

removed the calls from lib/clean/app_caches.sh
clean_user_gui_application since these two calls are developer focused.

* test: cover removed developer app calls

---------

Co-authored-by: Tw93 <hitw93@gmail.com>
2026-03-19 00:25:49 +08:00
Tw93
06d2a3d029 fix: keep tealdeer tldr pages cache 2026-03-19 00:24:54 +08:00
Tw93
88521a14c2 fix: remove jq dependency from optimize command (#588)
Replace jq with bash-native JSON parsing helpers (json_get_value,
json_validate, parse_optimization_items) so that mo optimize no
longer requires jq to be installed.

Closes #588
2026-03-18 17:36:39 +08:00
Tw93
6e1048a70a Revert "fix(ui): unify ICON_LIST dot size with ICON_SOLID"
This reverts commit 112d134829.
2026-03-18 15:24:07 +08:00
github-actions[bot]
dda9ee9c4a chore: update contributors [skip ci] 2026-03-18 07:17:29 +00:00
Tw93
112d134829 fix(ui): unify ICON_LIST dot size with ICON_SOLID
Change ICON_LIST from • (small bullet) to ● (filled circle) so both
checkbox indicators and list bullets render at the same balanced size.
2026-03-18 15:17:03 +08:00
Tw93
49c16a3450 Merge branch 'bugfix/fix-software-update-available-false-positive'
# Conflicts:
#	lib/check/all.sh
#	tests/clean_system_maintenance.bats
2026-03-18 15:05:37 +08:00
Tw93
90949f7fdf test(purge): fix glob quoting in path assertion 2026-03-18 14:55:26 +08:00
Tw93
702f299e78 fix(ui): rename Filter to Search in paginated menu 2026-03-18 14:55:20 +08:00
Tw93
5a2a5d9179 fix(uninstall): detect bundle-id-derived extension leftovers
Scan Application Scripts, Containers and FileProvider directories for
entries that share the app bundle-id prefix (e.g. share extensions,
file-provider extensions) so they are included in uninstall cleanup.
2026-03-18 14:54:59 +08:00
Tw93
fa935548b0 fix(optimize): warn before bluetooth refresh
Show "Bluetooth devices may disconnect briefly during refresh" before
actually restarting bluetoothd, so the user is not surprised by a
momentary disconnect.
2026-03-18 14:50:04 +08:00
Tw93
b8f3a0ecd3 fix(clean): avoid container cache scan stalls
Add a lightweight top-level entry cap to Containers and Group
Containers scanning.  When a cache directory exceeds the threshold,
skip the expensive per-item du/find size scan and take a partial-size
/ "cleaned" output path instead.  Replace find-piped-to-read loops
with pure-bash glob iteration to cut external process overhead.

Closes #586
2026-03-18 14:49:12 +08:00
Tw93
f88b2116ab fix(check): use softwareupdate output for macOS update detection
Replace LastRecommendedUpdatesAvailable defaults check with unified
softwareupdate -l --no-scan parsing.  Add caching layer and teach the
parser to distinguish macOS updates, Background Security Improvements,
Rapid Security Responses, and non-macOS entries so each gets an
accurate title in the output.

Fix reset_softwareupdate_cache() to also reset the in-memory
SOFTWARE_UPDATE_LIST_LOADED flag, and add a regression test.

Closes #585
2026-03-18 14:48:39 +08:00
corevibe555
2d8c938333 trust softwareupdate for macOS status and harden tests 2026-03-18 04:59:33 +01:00
root
e6ee9ec490 fix macOS update false positives 2026-03-18 03:15:39 +01:00
Tw93
25892594b0 fix: show full purge paths during confirmation
Fixes #576
2026-03-17 19:20:32 +08:00
dependabot[bot]
13274154d4 chore(deps): bump actions/download-artifact from 8.0.0 to 8.0.1 (#580)
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 8.0.0 to 8.0.1.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](70fc10c6e5...3e5f45b2cf)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-version: 8.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-17 16:52:06 +08:00
dependabot[bot]
f461ab77f4 chore(deps): bump softprops/action-gh-release from 2.5.0 to 2.6.1 (#579)
Bumps [softprops/action-gh-release](https://github.com/softprops/action-gh-release) from 2.5.0 to 2.6.1.
- [Release notes](https://github.com/softprops/action-gh-release/releases)
- [Changelog](https://github.com/softprops/action-gh-release/blob/master/CHANGELOG.md)
- [Commits](a06a81a03e...153bb8e044)

---
updated-dependencies:
- dependency-name: softprops/action-gh-release
  dependency-version: 2.6.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-17 16:51:51 +08:00
Tw93
6c53906427 fix brew uninstall fallback consistency 2026-03-17 16:39:42 +08:00
Tw93
e1f427c9aa fix: stop cleaning aerial wallpaper assets by default 2026-03-17 16:35:10 +08:00
Tw93
ea4cd9d0e3 fix(tests): prevent permission dialogs during test runs
Add MOLE_TEST_MODE=1 checks to skip AppleScript osascript calls
and sudo operations that trigger system permission dialogs during tests:

- lib/check/all.sh: Skip login items listing
- lib/clean/apps.sh: Skip running app detection
- lib/clean/user.sh: Skip Finder trash operations and sudo test calls
- lib/core/log.sh: Skip sudo status check in debug log
- lib/uninstall/batch.sh: Skip login item removal

Also add MOLE_TEST_MODE=1 export to all test files that load
these modules to ensure consistent test isolation.
2026-03-16 20:43:35 +08:00
Tw93
0cc4862f9c fix(touchid): add Q key support to quit menu
Allow users to press 'q' or 'Q' to quit the Touch ID setup menu,
in addition to ESC key. This fixes the "Invalid key" error when
users press Q as suggested by the prompt.

Fixes #575
2026-03-16 20:19:32 +08:00
Tw93
cfa0a82057 fix: skip incomplete downloads that are actively in use
Before deleting .download/.crdownload/.part files, check lsof to
detect open file handles. Files held by an active browser process
are skipped with a warning instead of being deleted.

Fixes a case where a 12GB IPSW being downloaded in Safari was
removed mid-download because the .download bundle matched the glob.
2026-03-16 07:39:41 +08:00
Tw93
30c1a95731 Harden test mode against auth and uninstall side effects 2026-03-15 12:19:50 +08:00
Tw93
7a0b4cf07e fix: move logs to ~/Library/Logs/mole, add system idle assets cleanup
- Move log files from ~/.config/mole/ to ~/Library/Logs/mole/ per
     macOS convention. Fixes #569.
   - Add safe_sudo_find_delete for /Library/Application Support/
     com.apple.idleassetsd/Customer/ screensaver videos. Closes #570.
   - Update tests to reflect new log file paths.
2026-03-15 11:38:18 +08:00
Tw93
398097162c chore: add pre-commit hook and update review skill to mirror GitHub CI
.githooks/pre-commit runs bash syntax check, shfmt format check,
shellcheck, and go vet against staged files on every commit.
Catches the same issues as check.yml before they reach GitHub.

Also update CONTRIBUTING.md setup instructions to include
`git config core.hooksPath .githooks`.
2026-03-15 09:08:56 +08:00
Tw93
45c98c2ec8 fix: explicitly skip system binary launch agents and harden test isolation
Add hint_is_system_binary() to short-circuit detection for plists that
use /bin/*, /usr/bin/*, /usr/libexec/* etc. as their program path.
These are custom scripts, not app-backed launch agents, so the stale
detection logic does not apply. Previously the function relied on the
absence of AssociatedBundleIdentifiers as an implicit skip, which could
fail on certain macOS plutil edge cases.

Also add teardown() in clean_hints.bats to explicitly remove the
LaunchAgents directory after each test, and add run_with_timeout mock
in the "skips custom shell wrappers" test to prevent mdfind from
influencing results. This eliminates the intermittent failure where
test 70 showed "Review:" in output without "Potential stale login item:".
2026-03-15 08:55:17 +08:00
Tw93
a6931dab5b fix: clean HTTPStorages binarycookies files and Preferences directories on uninstall
Add ~/Library/HTTPStorages/<bundle-id>.binarycookies to targeted uninstall
cleanup. WKWebView creates both a directory and a .binarycookies file under
HTTPStorages; only the directory was previously covered. Affected apps include
cmux (com.cmuxterm.app) and Tuna (com.brnbw.Tuna).

Also add ~/Library/Preferences/<bundle-id> directory detection for apps like
VLC (org.videolan.vlc) that store preferences in a directory rather than a
.plist file.
2026-03-14 23:20:18 +08:00
Tw93
c7f59a4d33 Potential fix for code scanning alert no. 7: Checkout of untrusted code in trusted context
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-03-14 23:08:29 +08:00
Tw93
c1d2e221a2 Potential fix for code scanning alert no. 3: Workflow does not contain permissions
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-03-14 23:07:19 +08:00
Tw93
49ca883dc8 Potential fix for code scanning alert no. 8: Incorrect conversion between integer types
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
2026-03-14 23:02:35 +08:00
Tw93
a61d959d7f Stabilize launch agent hint test 2026-03-14 22:56:31 +08:00
Tw93
2e6553ab2b Protect user launch agents during clean 2026-03-14 22:32:53 +08:00
Tw93
9db5488397 security: validate raw path in moveToTrash before filepath.Abs resolves traversal
filepath.Abs resolves ".." components, so the existing validatePath call
on the resolved path could never catch traversal attempts. Move validation
before Abs to reject raw input with "..", keeping the post-Abs check as
defense-in-depth.
2026-03-14 10:39:33 +08:00
Tw93
ba01cb7f43 test: fix parallel test flakiness and bash 3.2 empty-array expansion
- Fix 'bats_opts[@]: unbound variable' under set -u + bash 3.2: empty
  arrays must use ${arr[@]+"${arr[@]}"} idiom, not "${arr[@]}"
- Split core_performance.bats out of the parallel batch; run it after
  all parallel workers finish so wall-clock timing assertions aren't
  skewed by CPU contention from concurrent bats processes
- Raise MOLE_PERF_GET_INVOKING_USER_LIMIT_MS default 500→2000ms and
  add MOLE_PERF_SECTION_LIMIT_MS (default 2000ms) to give sufficient
  headroom without masking real regressions

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-14 10:16:42 +08:00
Tw93
a7b28faeda chore: auto format code 2026-03-14 01:22:54 +00:00
Tw93
7697acb711 test: speed up bats execution 2026-03-14 09:19:54 +08:00
Tw93
169be1e1f2 fix(timeout): inherit helper state and pass checks 2026-03-14 08:32:11 +08:00
Tw93
0d2f217f28 security: add regression tests for validatePath with special chars
- Add TestValidatePath covering Chinese, emoji, and special characters
- Add TestValidatePathWithChineseAndSpecialChars for filesystem tests
- Fix validatePath to detect .. components without rejecting valid paths

Ensures paths with $, ;, :, emoji, Chinese chars are not rejected
while still blocking path traversal attempts.
2026-03-14 08:26:45 +08:00
Tw93
951e395ab7 security: fix CodeQL command injection and path traversal alerts
- Add validatePath() helper to check path safety before external commands
- Validate paths in delete.go (moveToTrash), scanner.go (mdfind, du),
  and main.go (open command)
- Remove overly restrictive character whitelist that rejected valid
  macOS paths (Chinese, emoji, $, ;, etc.)
- Unify path validation logic across all three files

Fixes CodeQL alerts:
- Command injection in osascript (delete.go)
- Command injection in mdfind/du (scanner.go)
- Path traversal in open command (main.go)
2026-03-14 08:24:08 +08:00
Tw93
f6acfa774c feat(disk): enhance APFS disk usage reporting with Finder integration 2026-03-14 07:48:16 +08:00
Tw93
ea37d3e356 fix(purge): remove 60-char hard cap on path display width (issue #564)
The path column in 'mo purge' selection was capped at 60 characters
regardless of terminal width. On wide terminals (120+ cols) this caused
long project paths like ~/GitHub/Ulama/transformer-project to be
truncated unnecessarily to ~17 visible characters.

Remove the hard 60-char cap and let the available terminal space be the
only upper bound, which is already computed as:
  available_for_path = terminal_width - fixed_overhead

Paths now use as much space as the terminal allows while still keeping
the size and artifact-type columns readable.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-14 07:46:44 +08:00
Tw93
cb2eb1097a fix(analyze): add darwin build tag to all platform-specific files
All files in cmd/analyze/ are macOS-only but several were missing the
//go:build darwin constraint. On Linux (e.g. CodeQL CI), Go compiled
these files without the types defined in main.go (which had the tag),
causing undefined symbol errors for dirEntry, fileEntry, scanResult,
cacheEntry, historyEntry and model.

- Add //go:build darwin to heap.go, cache.go, scanner.go, cleanable.go,
  delete.go, format.go, constants.go and all *_test.go files

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-14 07:46:32 +08:00
Tw93
97d35c03d6 fix(purge): parallelize size calculations to prevent hang (issue #560)
Sequential du calls with 15s timeout each meant N artifacts × 15s of potential
wait when paths are on slow storage (network mounts, Syncthing, large dirs).
Now all du processes are launched concurrently; total time is bounded by the
single longest call (≤ 15s) rather than N × 15s.

fix(protection): protect CoreAudio paths in should_protect_path (issue #553)

Add com.apple.coreaudio*, com.apple.audio.*, and coreaudiod* to the protected
path patterns so deep-clean cannot touch audio subsystem caches, reducing risk
of audio output loss on Intel Macs running macOS Sequoia.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-03-14 00:00:08 +08:00
Tw93
fca8214276 chore: ignore Claude Code workspace files 2026-03-13 13:58:50 +08:00
Tw93
e6850329ae chore: ignore Claude Code local settings 2026-03-13 13:58:50 +08:00
Tw93
643cb8e9ac chore: add Claude Code skills for GitHub operations
Add github-ops skill for automated issue and PR management.
2026-03-13 13:58:50 +08:00