Skip to content

fix(system): sanitize desktop notifications and comply with XDG standards - #77

Merged
JacksonFergusonDev merged 2 commits into
mainfrom
fix/system-notifications-and-xdg
Aug 22, 2026
Merged

fix(system): sanitize desktop notifications and comply with XDG standards#77
JacksonFergusonDev merged 2 commits into
mainfrom
fix/system-notifications-and-xdg

Conversation

@JacksonFergusonDev

Copy link
Copy Markdown
Owner

Summary

This PR resolves desktop notification injection vulnerabilities and implements full XDG base directory specification compliance (P1/P2):

  1. AppleScript Notification Sanitization: MacOSStrategy.notify now passes title and message as discrete argv elements to osascript using an on run argv handler instead of inline string interpolation. This prevents AppleScript injection and syntax errors caused by double quotes, special characters, or shell symbols.
  2. XDG Base Directory Compliance: Updated CONFIG_DIR in constants.py to respect $XDG_CONFIG_HOME (falling back to ~/.config/git-pulsar).
  3. Elimination of Import-Time Side-Effects: Removed top-level STATE_DIR.mkdir(parents=True, exist_ok=True) from constants.py. Directory creation is now performed safely on-demand before file writes (LOG_FILE, PID_FILE, REGISTRY_FILE, and maintenance state files).
  4. Documentation: Updated README.md to document $XDG_CONFIG_HOME in cascading config.

Changes

  • src/git_pulsar/system.py: Refactored MacOSStrategy.notify to use on run argv with osascript.
  • src/git_pulsar/constants.py: Added _XDG_CONFIG resolution for CONFIG_DIR; removed top-level mkdir.
  • src/git_pulsar/daemon.py: Added on-demand parent directory creation in setup_logging, main, and run_maintenance.
  • src/git_pulsar/cli.py: Added on-demand parent directory creation in setup_repo.
  • README.md: Updated configuration section to reference $XDG_CONFIG_HOME.
  • tests/test_system.py: Added tests verifying MacOSStrategy.notify uses argv, LinuxStrategy.notify uses notify-send, and CONFIG_DIR respects $XDG_CONFIG_HOME.

Verification

  • uv run pytest --cov passed (99 tests, 65.7% coverage).
  • bash scripts/test_distributed.sh passed.
  • uv run ruff check ., uv run ruff format --check ., and uv run mypy . passed cleanly.

…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
@JacksonFergusonDev
JacksonFergusonDev merged commit 17dff87 into main Aug 22, 2026
7 checks passed
@JacksonFergusonDev
JacksonFergusonDev deleted the fix/system-notifications-and-xdg branch August 22, 2026 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant