Bug 1283101

Summary: pyrpkg.Commands.commit() does not quote commit message
Product: [Fedora] Fedora EPEL Reporter: Miroslav Suchý <msuchy>
Component: rpkgAssignee: Dennis Gilmore <dennis>
Status: CLOSED WORKSFORME QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: urgent Docs Contact:
Priority: high    
Version: epel7CC: dennis, onosek, pbabinca, s
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-01-15 23:05:12 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Miroslav Suchý 2015-11-18 09:36:51 UTC
Description of problem:
It seems that Commands.commit() message pass the message to system unquoted.
I can only imagine what will happen if you pass as message ";rm -rf /"...

This is what  I get when I pass "Importing of forestdb":

Traceback (most recent call last):
  File "/usr/share/copr/dist_git/srpm_import.py", line 91, in actual_do_git_srpm_import
    commands.commit(message)
  File "/usr/lib/python2.7/site-packages/pyrpkg/__init__.py", line 1282, in commit
    self._run_command(cmd, cwd=self.path)
  File "/usr/lib/python2.7/site-packages/pyrpkg/__init__.py", line 903, in _run_command
    % (' '.join(cmd), proc.returncode, error))
rpkgError: Command git commit -m Import of forestdb 0.0.0-1013.gee2791a.el7.centos -a returned code 1 with error:


Version-Release number of selected component (if applicable):
pyrpkg-1.35-2.el7.noarch

How reproducible:
always

Steps to Reproduce:

from pyrpkg import Commands
commands = Commands(path=repo_dir,
                        lookaside="",
                        lookasidehash="md5",
                        lookaside_cgi="",
                        gitbaseurl=git_base_url,
                        anongiturl="",
                        branchre="",
                        kojiconfig="",
                        build_client="")
upload_files = commands.import_srpm(src_filepath)
commands.upload(upload_files, replace=True)
commands.commit("This will fail")

Comment 1 Ondřej Nosek 2021-01-15 23:05:12 UTC
Hi,

I found this relic still opened during ticket exploration and I found some time for looking at it.
I didn't look at the code at a time when the ticket was opened. In the current code, I don't see an issue - maybe it was fixed in a past during continuous development.

The 'commit' command is executed via python's subprocess.Popen(). It has implicitly 'shell=False' parameter set and doesn't require quoting. I tested a modified command with a potential side effect. Command looked like:
['git', 'commit', '-m', 'safsd; touch /src/fedpkg/nnn;', '-a']
After the execution, no extra file was created and the whole argument was used as a commit message.

Comment 2 Miroslav Suchý 2021-01-18 12:41:57 UTC
I do confirm that it works now.