Skip to content

Commit 5706e6f

Browse files
committed
reporting: fix incorrect converting of list based commands
The reporting module handled conversion between shell command representations for the text and json reports incorrectly. The list of strings representation was converted without preserving the argument separation correctly which results in malformed commands in the text report. This patch utilizes the built-in shlex Python library for the conversion which preserves the argument separation by wrapping arguments in quotes when necessary. Jira: RHEL-156521
1 parent 2f210e7 commit 5706e6f

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

leapp/reporting/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import datetime
2-
import json
32
import hashlib
3+
import json
44
import logging
55
import os
6+
import shlex
67
import six
78

89
from leapp.compat import string_types
910
# NOTE(pstodulk): the format_list is imported to provide the function
1011
# also in this library. Its use is not planned here however.
1112
from leapp.libraries.stdlib import format_list
1213
from leapp.libraries.stdlib.api import produce
13-
from leapp.models import fields, Model, ErrorModel
14+
from leapp.models import ErrorModel, Model, fields
1415
from leapp.topics import ReportTopic
1516
from leapp.utils.deprecation import deprecated
1617

@@ -282,7 +283,7 @@ def __repr__(self):
282283
# NOTE(ivasilev) As the message can contain non-ascii characters let's deal with it properly.
283284
# As per python practices repr has to return an encoded string
284285
return "[{}] {}".format(self._value['type'],
285-
' '.join([_guarantee_encoded_str(c) for c in self._value['context']]))
286+
shlex.join([_guarantee_encoded_str(c) for c in self._value['context']]))
286287

287288

288289
class RemediationHint(BaseRemediation):

0 commit comments

Comments
 (0)