Skip to content

Commit d4e0152

Browse files
morsa4406MarshalX
andauthored
CM-23952 - Failed to print table result for License Compliance (#120)
* CM-23952 [SCA] [Cycode-cli] failed to print table result for License Compliance * CM-23952 [SCA] [Cycode-cli] failed to print table result for License Compliance * code refactoring --------- Co-authored-by: Ilya Siamionau <ilya.siamionau@cycode.com>
1 parent 39356bd commit d4e0152

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

cycode/cli/printers/table_printer.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,13 @@ def _print_table_detections(
119119
def set_table_width(headers: List[str], text_table: Texttable) -> None:
120120
header_width_size_cols = []
121121
for header in headers:
122-
header_width_size_cols.append(len(header))
123-
122+
header_len = len(header)
123+
if header == CVE_COLUMN:
124+
header_width_size_cols.append(header_len * 5)
125+
elif header == UPGRADE_COLUMN:
126+
header_width_size_cols.append(header_len * 2)
127+
else:
128+
header_width_size_cols.append(header_len)
124129
text_table.set_cols_width(header_width_size_cols)
125130

126131
@staticmethod
@@ -133,8 +138,7 @@ def _get_common_detection_fields(self, detection: Detection) -> List[str]:
133138
detection.detection_details.get('ecosystem'),
134139
detection.detection_details.get('package_name'),
135140
detection.detection_details.get('is_direct_dependency_str'),
136-
detection.detection_details.get('is_dev_dependency_str'),
137-
detection.detection_details.get('vulnerability_id')
141+
detection.detection_details.get('is_dev_dependency_str')
138142
]
139143

140144
if self._is_git_repository():
@@ -147,7 +151,11 @@ def _is_git_repository(self) -> bool:
147151

148152
def _get_upgrade_package_vulnerability(self, detection: Detection) -> List[str]:
149153
alert = detection.detection_details.get('alert')
150-
row = [detection.detection_details.get('advisory_severity')] + self._get_common_detection_fields(detection)
154+
row = [
155+
detection.detection_details.get('advisory_severity'),
156+
*self._get_common_detection_fields(detection),
157+
detection.detection_details.get('vulnerability_id')
158+
]
151159

152160
upgrade = ''
153161
if alert.get("first_patched_version"):

0 commit comments

Comments
 (0)