)]}'
{"/PATCHSET_LEVEL":[{"author":{"_account_id":5314,"name":"Brian Rosmaita","email":"rosmaita.fossdev@gmail.com","username":"brian-rosmaita"},"change_message_id":"0067355da1bad3d231a80f5143a40828e368e288","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":1,"id":"436cbd5e_9bac4422","updated":"2026-11-20 14:23:27.000000000","message":"Also, Eric pointed out that if shlex is only guaranteed for POSIX compatible shells, we may not be able to use this strategy.  So, we need feedback from driver maintainers.","commit_id":"bf11e475abf10025342a987cb196d281783ddca1"},{"author":{"_account_id":5314,"name":"Brian Rosmaita","email":"rosmaita.fossdev@gmail.com","username":"brian-rosmaita"},"change_message_id":"1fd35c2f9bc782c265286d3ab0948aadc1dc4ab5","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":1,"id":"700209f8_b2ffb1ca","updated":"2026-11-20 14:51:04.000000000","message":"Thanks for the analysis, Alexander.  The more I look at this, I think it\u0027s a mistake to think that we can have a generic ssh injection sanitizer, and instead, we need to go in the direction Eric took on https://review.opendev.org/c/openstack/cinder/+/1015478 which is to only let through a string that is acceptable for the context, where the context is known by the caller constructing the call (and then use shlex to join the command safely).\n\nSo, to follow Alexander\u0027s point, we\u0027ll need to go to each driver to make sure that they\u0027re not quoting strings that will then be re-quoted by shlex and lead to something that won\u0027t execute properly.  One of the examples was a hostname, and that shouldn\u0027t have any \u0027;\u0027 in it, whether backslashed properly or not.  So the point would be to check the hostname being constructed to add to the command (at the point where it\u0027s added) against some kind of allowlist or allow regex.  Same thing for other components of any command that will be passed to ssh.","commit_id":"bf11e475abf10025342a987cb196d281783ddca1"},{"author":{"_account_id":5314,"name":"Brian Rosmaita","email":"rosmaita.fossdev@gmail.com","username":"brian-rosmaita"},"change_message_id":"d343d207e4666786f5ca58f3bba1d3fa45817f7a","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":1,"id":"ae0094e3_990dec62","updated":"2026-11-20 13:56:33.000000000","message":"This looks promising.  My question is should we move use of shlex to the sanitizer utility, or just remove the utility completely and tell drivers to use shlex themselves?  I am inclined toward the latter, because the idea behind the sanitizer was to have the sanitization all in one place so that we\u0027d only fix bugs in one place.  But that still means that there\u0027s a driver responsibility to actually use the sanitizer.  So if we switch to shlex, then that solves the \"fix in one place\" issue, and we\u0027re in the same position with respect to the drivers actually preventing ssh injection.","commit_id":"bf11e475abf10025342a987cb196d281783ddca1"},{"author":{"_account_id":34860,"name":"Amit Uniyal","email":"auniyal@redhat.com","username":"auniyal"},"change_message_id":"8771b1b44cf52cfc682086222ebcebeedc6b2346","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":1,"id":"afd6521d_dd4a01ed","updated":"2026-11-20 14:30:53.000000000","message":"will it be possible to add these test here\nregression tests - https://review.opendev.org/c/openstack/cinder/+/1014983/comment/4ac8f150_8262e9fa/","commit_id":"bf11e475abf10025342a987cb196d281783ddca1"}],"cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py":[{"author":{"_account_id":35075,"name":"Alexander Deiter","email":"adeiter@infinidat.com","username":"adeiter"},"change_message_id":"be5bc91bce2934a9e0d23c70a62c68456a8a0fe8","unresolved":true,"context_lines":[{"line_number":4012,"context_line":""},{"line_number":4013,"context_line":"    def _run_ssh(self, cmd_list, check_exit_code\u003dTrue, attempts\u003d1):"},{"line_number":4014,"context_line":"        cinder_utils.check_ssh_injection(cmd_list)"},{"line_number":4015,"context_line":"        command \u003d shlex.join(cmd_list)"},{"line_number":4016,"context_line":"        if not self.sshpool:"},{"line_number":4017,"context_line":"            try:"},{"line_number":4018,"context_line":"                self.sshpool \u003d self._set_up_sshpool(self.active_ip)"}],"source_content_type":"text/x-python","patch_set":1,"id":"e41ac76f_6c45580f","line":4015,"updated":"2026-11-20 14:22:38.000000000","message":"Thank you for working on this. Using the standard library for shell quoting looks like a useful direction.\n\nI have a compatibility concern about replacing the join operation without also updating the command producers. Some existing callers already include shell quoting in individual list elements, whereas shlex.join() expects raw argument values.\n\nFor example, StorwizeSSH.mkvdiskhostmap() currently constructs its arguments using:\n\n    [\u0027svctask\u0027, \u0027mkvdiskhostmap\u0027, \u0027-host\u0027, \u0027\"%s\"\u0027 % host,\n     \u0027-scsi\u0027, lun, \u0027\"%s\"\u0027 % vdisk]\n\nFor host\u003d\u0027host1\u0027, vdisk\u003d\u0027volume1\u0027 and lun\u003d\u00270\u0027, the command changes from:\n\n    svctask mkvdiskhostmap -host \"host1\" -scsi 0 \"volume1\"\n\nto:\n\n    svctask mkvdiskhostmap -host \u0027\"host1\"\u0027 -scsi 0 \u0027\"volume1\"\u0027\n\nWith POSIX shell parsing, the original command passes host1 and volume1 as argument values. The new command preserves the double-quote characters as part of those values: \u0027\"host1\"\u0027 and \u0027\"volume1\"\u0027.\n\nThis can be demonstrated without executing any command:\n\n    import shlex\n\n    cmd \u003d [\n        \u0027svctask\u0027, \u0027mkvdiskhostmap\u0027,\n        \u0027-host\u0027, \u0027\"host1\"\u0027,\n        \u0027-scsi\u0027, \u00270\u0027,\n        \u0027\"volume1\"\u0027,\n    ]\n\n    shlex.split(\u0027 \u0027.join(cmd))\n    # [\u0027svctask\u0027, \u0027mkvdiskhostmap\u0027, \u0027-host\u0027,\n    #  \u0027host1\u0027, \u0027-scsi\u0027, \u00270\u0027, \u0027volume1\u0027]\n\n    shlex.split(shlex.join(cmd))\n    # [\u0027svctask\u0027, \u0027mkvdiskhostmap\u0027, \u0027-host\u0027,\n    #  \u0027\"host1\"\u0027, \u0027-scsi\u0027, \u00270\u0027, \u0027\"volume1\"\u0027]\n\nThis affects ordinary names as well as names containing spaces. Depending on how the remote CLI parses the command, the changed quoting could cause object lookup or command syntax failures.\n\nSimilar explicit quoting is used by other Storwize operations, including mkhost() and mkvdisk(), and by the Inspur InStorage command helpers.\n\nCould we please audit and update these callers to pass raw argument values, with quoting applied once at the SSH command construction boundary? A generic removal of surrounding quotes would be difficult to make reliable because it cannot distinguish existing shell syntax from intentional quote characters in data.\n\nIt would also be helpful to add regression tests that exercise a real command helper through the modified _run_ssh() method and inspect the command passed to the mocked SSH transport. Some existing Storwize fake drivers override _run_ssh(), so those tests bypass the command construction changed here.\n\nSuggested coverage would include:\n\n* Existing create-host, create-volume and host-mapping commands.\n* Preservation of argument values containing spaces, quotes or backslashes, where supported by the CLI.\n* Shell metacharacters remaining argument data rather than introducing additional commands.\n\nThe existing check_ssh_injection() calls also remain in this patch and reject some raw values before shlex.join() can quote them. This should be considered together with the caller changes and Brian\u0027s comment about the future of that utility.\n\nFinally, Python documents shlex quoting for POSIX-compatible shells. Since the patch also changes commands sent to switch CLIs, confirmation from the affected driver maintainers or relevant backend CI would be valuable.\n\nI have verified the argument transformation above locally, but have not tested the resulting commands against the storage systems or switches.\n\nThank you!","commit_id":"bf11e475abf10025342a987cb196d281783ddca1"},{"author":{"_account_id":36538,"name":"Harsh Ailani","display_name":"Harsh Ailani","email":"harsh.ailani@ibm.com","username":"harshailani"},"change_message_id":"37719a06906fc829eee6a0a5b5e0376bb2f6ab20","unresolved":true,"context_lines":[{"line_number":4012,"context_line":""},{"line_number":4013,"context_line":"    def _run_ssh(self, cmd_list, check_exit_code\u003dTrue, attempts\u003d1):"},{"line_number":4014,"context_line":"        cinder_utils.check_ssh_injection(cmd_list)"},{"line_number":4015,"context_line":"        command \u003d shlex.join(cmd_list)"},{"line_number":4016,"context_line":"        if not self.sshpool:"},{"line_number":4017,"context_line":"            try:"},{"line_number":4018,"context_line":"                self.sshpool \u003d self._set_up_sshpool(self.active_ip)"}],"source_content_type":"text/x-python","patch_set":1,"id":"eb431ded_42ddf9b7","line":4015,"in_reply_to":"e41ac76f_6c45580f","updated":"2026-11-20 15:15:52.000000000","message":"I tested shlex module on the IBM Storage backend from my host -\n\nResult analysis\n----------------\nNormal argument - \u0027 \u0027.join() - Success\nNormal argument -  shlex.join() - Success\n\nArgument containing spaces - \u0027 \u0027.join() - CMMVC5804E\nArgument containing spaces - shlex.join() - No error\n\n\nTest Explanation:\n-------------------\n\nNormal argument -\nBoth methods produce:\nsvcinfo lsmdiskgrp -filtervalue name\u003dmdiskgrp0Both return the expected mdiskgrp0 information.\nThis confirms that normal Storwize CLI commands remain unaffected.\n\nArgument containing spaces -\nWith the original implementation: \u0027 \u0027.join(cmd_list)\nThe resulting command is: svcinfo lsmdiskgrp -filtervalue name\u003dmdiskgrp0 something\n\nThe FlashSystem interprets \"something\" as an additional argument and returns:\nCMMVC5804E The action failed because an object that was specified in the command does not exist.\n\nWith shlex.join(): shlex.join(cmd_list)\nThe resulting command is: svcinfo lsmdiskgrp -filtervalue \u0027name\u003dmdiskgrp0 something\u0027\n\nThe FlashSystem accepts the command without an error.\n\nThis confirms that the remote SSH command-processing path correctly handles the quoting generated by shlex.join().","commit_id":"bf11e475abf10025342a987cb196d281783ddca1"}]}
