-
-
Notifications
You must be signed in to change notification settings - Fork 0
fix: harden self-update security and error handling #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Use mktemp for secure temporary file creation - Add robust version extraction with format validation - Save and restore IFS variable properly - Validate backup creation success before proceeding - Add comprehensive error handling for mv and chmod operations - Implement automatic backup restoration on failure - Download from tagged version instead of main branch Co-authored-by: prettyleaf <81024464+prettyleaf@users.noreply.github.com>
Co-authored-by: prettyleaf <81024464+prettyleaf@users.noreply.github.com>
prettyleaf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs a check to delete old backup files. if backup is older than 1 day = delete
- Check for existing backup file at start of self_update - Calculate backup file age using stat command (supports both Linux and BSD) - Delete backup if older than 86400 seconds (1 day) - Log cleanup action for audit trail Co-authored-by: prettyleaf <81024464+prettyleaf@users.noreply.github.com>
- Extract timestamp retrieval into separate variable - Use explicit calculation for one_day_seconds (24 * 60 * 60) Co-authored-by: prettyleaf <81024464+prettyleaf@users.noreply.github.com>
Added automatic cleanup of backup files older than 1 day in commit 796ac4c. The cleanup runs at the start of
|
- Validate backup_timestamp is non-empty and numeric - Prevents arithmetic errors if stat command fails - Silently skips cleanup if timestamp cannot be determined Co-authored-by: prettyleaf <81024464+prettyleaf@users.noreply.github.com>
Addresses security vulnerabilities and error handling gaps in the self-update mechanism identified during code review.
Security hardening:
mktempfor temporary files (prevents symlink attacks)v${version}) instead of main branchError handling improvements:
Code quality:
Backup management:
Example of the improved error handling:
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.