Skip to content

Conversation

@sergiomb2
Copy link
Contributor

Add a reference to related issue - preferably in the git commit message
Fixes: #1639

Add release note. See https://rpm-software-management.github.io/mock/Release-Notes-New-Entry
or let us know to add label no-release-notes if you think the change does
not deserve a release note.

  • make mock --scrub=all correctly back up build directory
  • Use 'mv' instead of 'cp' for backing up builds

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the backup logic by moving it from backend.py to buildroot.py and changing the operation from copy (cp) to move (mv). This is a good refactoring as the logic is now closer to where the buildroot is actually deleted. However, I've found a critical security vulnerability related to command injection when moving the RPM files. The way the mv command is constructed is unsafe and could allow for arbitrary code execution if a filename contains special shell characters. I've provided a suggestion to fix this using Python's shutil module, which is the safer and more idiomatic approach. I also found a minor style issue where a multi-line string is used for a comment inside a method, which should be a regular hash-prefixed comment. Please address the critical security issue.

@sergiomb2 sergiomb2 force-pushed the back_up_on_scrub branch 2 times, most recently from 57d76c8 to 2f02a9d Compare November 26, 2025 02:40
Copy link
Member

@xsuchy xsuchy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Can you add release entry as described in https://rpm-software-management.github.io/mock/Release-Notes-New-Entry please?

@sergiomb2
Copy link
Contributor Author

Done. Let me know if I can improve anything else.
Thank you

@sergiomb2
Copy link
Contributor Author

I found a bug "shutil.Error: Destination path '/var/lib/mock/backup/fedora-43-x86_64/javapackages-compat-6.4.1-5.fc43.noarch.rpm' already exists"
I will try fix it soon

@sergiomb2 sergiomb2 force-pushed the back_up_on_scrub branch 2 times, most recently from daf4800 to 3089847 Compare November 28, 2025 00:45
@praiskup
Copy link
Member

Can you please rebase on top of main? Thank you.

@sergiomb2
Copy link
Contributor Author

Lint Python issues / python-lint-job (pull_request)Failing after 46s

I'm working on another solution

@sergiomb2 sergiomb2 force-pushed the back_up_on_scrub branch 2 times, most recently from 2f9cdbf to 3879063 Compare December 16, 2025 00:49
@praiskup
Copy link
Member

/packit test

Copy link
Member

@praiskup praiskup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay. Otherwise looks good, thank you for the fix.

…buildroot. Fixes issue rpm-software-management#1639.

The backup process now uses `mv` semantics instead of `cp`, avoiding file duplication,
preserving timestamps, and improving performance. Gemini Code Assist flagged the
use of `util.run` as unsafe, so it was replaced with `os.replace` to safely overwrite
existing files.

Improve logs and comments in backup_build_results for clarity.
@sergiomb2 sergiomb2 requested review from praiskup and xsuchy February 1, 2026 17:32
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.

mock --scrub=all doesn’t back up builds

3 participants