fix(system): sanitize desktop notifications and comply with XDG standards - #77
Merged
Merged
Conversation
…ards - Pass title and message arguments to osascript via argv on macOS to eliminate AppleScript injection and escaping failures - Respect $XDG_CONFIG_HOME for CONFIG_DIR with fallback to ~/.config/git-pulsar - Remove import-time STATE_DIR.mkdir() side effects from constants.py - Ensure runtime parent directories are created on-demand before file writes - Update README documentation for XDG_CONFIG_HOME support - Add regression tests covering argv notifications, XDG_CONFIG_HOME reloading, and notify-send
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR resolves desktop notification injection vulnerabilities and implements full XDG base directory specification compliance (P1/P2):
MacOSStrategy.notifynow passestitleandmessageas discreteargvelements toosascriptusing anon run argvhandler instead of inline string interpolation. This prevents AppleScript injection and syntax errors caused by double quotes, special characters, or shell symbols.CONFIG_DIRinconstants.pyto respect$XDG_CONFIG_HOME(falling back to~/.config/git-pulsar).STATE_DIR.mkdir(parents=True, exist_ok=True)fromconstants.py. Directory creation is now performed safely on-demand before file writes (LOG_FILE,PID_FILE,REGISTRY_FILE, and maintenance state files).README.mdto document$XDG_CONFIG_HOMEin cascading config.Changes
src/git_pulsar/system.py: RefactoredMacOSStrategy.notifyto useon run argvwithosascript.src/git_pulsar/constants.py: Added_XDG_CONFIGresolution forCONFIG_DIR; removed top-levelmkdir.src/git_pulsar/daemon.py: Added on-demand parent directory creation insetup_logging,main, andrun_maintenance.src/git_pulsar/cli.py: Added on-demand parent directory creation insetup_repo.README.md: Updated configuration section to reference$XDG_CONFIG_HOME.tests/test_system.py: Added tests verifyingMacOSStrategy.notifyusesargv,LinuxStrategy.notifyusesnotify-send, andCONFIG_DIRrespects$XDG_CONFIG_HOME.Verification
uv run pytest --covpassed (99 tests, 65.7% coverage).bash scripts/test_distributed.shpassed.uv run ruff check .,uv run ruff format --check ., anduv run mypy .passed cleanly.