-
-
Notifications
You must be signed in to change notification settings - Fork 88
[releaser] Fix git add to only include release files #552 #553
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
[releaser] Fix git add to only include release files #552 #553
Conversation
The releaser tool was using 'git add .' which dangerously adds all files including potentially private ones. Changed to only add specific files that are modified during the release process (changelog and version files). Fixes openwisp#552
📝 WalkthroughWalkthroughThe release flow now stages only tracked, modified files by replacing Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
Comment |
|
Hi @nemesifier , I've implemented a fix for the security issue you reported. The dangerous |
nemesifier
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.
Looks good, I'll need to test it on a new bugfix release before merging.
|
Thanks @nemesifier! sounds good, let me know if anything comes up during testing. |
3d57403 to
ec48e47
Compare
- Changed from selective file staging to git add -u approach - Stages all modified tracked files for better future compatibility - Maintains security by not adding untracked files - Addresses maintainer feedback for automatic version bumping support
ec48e47 to
ef21fad
Compare
|
Heyy @nemesifier , i have updated my PR as you suggested, please have a look. |
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.
Actionable comments posted: 1
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
openwisp_utils/releaser/release.py
🧰 Additional context used
🪛 Ruff (0.14.10)
openwisp_utils/releaser/release.py
362-362: Starting a process with a partial executable path
(S607)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
- GitHub Check: Python==3.12 | django~=5.1.0
- GitHub Check: Python==3.10 | django~=5.0.0
- GitHub Check: Python==3.11 | django~=5.1.0
- GitHub Check: Python==3.11 | django~=5.2.0
- GitHub Check: Python==3.13 | django~=5.2.0
- GitHub Check: Python==3.13 | django~=5.1.0
- GitHub Check: Python==3.12 | django~=4.2.0
- GitHub Check: Python==3.12 | django~=5.0.0
- GitHub Check: Python==3.12 | django~=5.2.0
- GitHub Check: Python==3.11 | django~=5.0.0
- GitHub Check: Python==3.10 | django~=5.2.0
- GitHub Check: Python==3.10 | django~=5.1.0
- GitHub Check: Python==3.11 | django~=4.2.0
- GitHub Check: Python==3.10 | django~=4.2.0
| print("Adding tracked changes to git...") | ||
| subprocess.run(["git", "add", "-u"], check=True, capture_output=True) |
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.
git add -u still stages all tracked modified files, not just release files.
While git add -u is an improvement over git add ., it stages all tracked modified files in the repository, not just the changelog and version files modified by the release process. If a developer has other tracked files with uncommitted changes, those will be included in the release commit.
To fully address issue #552, explicitly stage only the files modified during the release process. The changelog file is always modified, and the version file(s) should be staged conditionally based on whether bump_version succeeded.
🔎 Recommended fix to stage only release-modified files
- print("Adding tracked changes to git...")
- subprocess.run(["git", "add", "-u"], check=True, capture_output=True)
+ # Stage only the files modified by the release process
+ print("Staging release files (changelog and version files)...")
+ subprocess.run(
+ ["git", "add", changelog_path], check=True, capture_output=True
+ )
+ if was_bumped and config.get("version_file"):
+ subprocess.run(
+ ["git", "add", config["version_file"]], check=True, capture_output=True
+ )Note: You may need to verify the correct key/path for the version file in the config. If there are multiple version files or a different config structure, adjust accordingly.
Additional observation: The PR description mentions "Comments explaining selective staging were added," but no explanatory comments are present in the code changes.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| print("Adding tracked changes to git...") | |
| subprocess.run(["git", "add", "-u"], check=True, capture_output=True) | |
| # Stage only the files modified by the release process | |
| print("Staging release files (changelog and version files)...") | |
| subprocess.run( | |
| ["git", "add", changelog_path], check=True, capture_output=True | |
| ) | |
| if was_bumped and config.get("version_file"): | |
| subprocess.run( | |
| ["git", "add", config["version_file"]], check=True, capture_output=True | |
| ) |
🧰 Tools
🪛 Ruff (0.14.10)
362-362: Starting a process with a partial executable path
(S607)
🤖 Prompt for AI Agents
In openwisp_utils/releaser/release.py around lines 361-362, the code uses "git
add -u" which stages all tracked modified files; change this to explicitly stage
only the changelog file and any version file(s) modified by the release. Modify
the logic to compute the changelog path (always) and, if bump_version succeeded,
determine the version file path(s) from the config and add them too; call
subprocess.run(["git","add", <path>], check=True, capture_output=True) for each
file instead of a single "git add -u". Also add brief comments explaining why we
selectively stage only release-modified files and that version files are added
conditionally when bump_version succeeds.
|
@nemesifier Thanks, excited for more! |
The releaser tool was using 'git add .' which dangerously adds all files including potentially private ones. Changed to only add specific files that are modified during the release process (changelog and version files).
Fixes #552
Checklist
Reference to Existing Issue
Closes #552.
Description of Changes
I noticed the releaser tool had a security issue where it was using
git add .to stage files for commit. This is problematic because it adds every single file in the repository, including things like private config files or temporary files that shouldn't be committed.The fix was straightforward - instead of adding everything, I made it only add the specific files that actually get modified during a release:
I also added some comments to explain why we're being selective about which files to add, and updated the console message to be clearer about what's happening.
The change is in the
openwisp_utils/releaser/release.pyfile around lines 361-370. I tested it by running the code quality checks and making sure the syntax is correct.This should prevent any accidental commits of private files during the release process.
Screenshot
Not applicable since this is a backend code fix.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.