1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 23:40:09 +00:00
Commit Graph

15 Commits

Author SHA1 Message Date
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
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
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
7d43e669a8 fix(analyze): improve deletion safety and UI clarity
- Update UI status to 'Moving to Trash...' for clarity
- Use os.Lstat instead of os.Stat to correctly handle broken symlinks during deletion checks
2026-01-10 08:51:14 +08:00
Tw93
ebb4f7a1e9 feat(analyze): safer deletion with Trash and two-key confirm
- Change delete confirmation from double-delete to Delete→Enter
- Move files to macOS Trash instead of permanent deletion
- Allow file recovery from Trash if accidentally deleted
- Update UI prompts to show 'Press Enter to confirm'
- Skip Finder-dependent tests in CI environments
- Update SECURITY_AUDIT.md with new safety mechanisms

Closes #288
2026-01-10 07:24:58 +08:00
Tw93
9aa569cbb6 feat: Enhance clean, optimize, analyze, and status commands, and update security audit documentation. 2025-12-31 16:23:31 +08:00
Tw93
d2dc68da90 feat: Enhance app protection with centralized critical component checks, improve UI string width calculation, refine analysis and cleaning logic, and add new tests. 2025-12-22 11:24:04 +08:00
Tw93
e13d92abc0 fix(analyze): clear multi-select on refresh and optimize delete
- Clear multi-selection map on refresh to prevent index mismatch
- Use built-in min function in delete.go
- Improve delete cancellation logic
2025-12-21 22:15:18 +08:00
Sizk
74d05ed9aa feat(analyze): add multi-select for batch file operations (#140)
- Add spacebar to toggle selection on files/directories
- Support batch delete for multiple selected items
- Support batch open (O) and reveal in Finder (F) for selections
- Show selection count and total size in status bar
- Display selection indicator (● selected, ○ unselected)
- Clear selections when navigating directories or switching views

Authored-by: Sizk <sizk@users.noreply.github.com>
2025-12-21 22:15:14 +08:00
Tw93
36a84e5211 Reconstruct the structure of go 2025-12-01 19:26:03 +08:00
Tw93
45c65345ac Significantly optimize the speed and cache of scanning 2025-11-19 11:53:57 +08:00
Tw93
621b4090a9 Continuously optimize go analysis 2025-11-18 22:00:05 +08:00
Tw93
a900d03bef Refactor Go analysis capabilities 2025-11-18 18:23:33 +08:00