Skip to content

Commit 0d6cbac

Browse files
authored
CM-30564 - Print report URLs at the end of the table instead of the column (#207)
* CM-30564-Change report table printer * CM-30564-Change report table printer * CM-30564-fix
1 parent df11e47 commit 0d6cbac

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

cycode/cli/printers/tables/sca_table_printer.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,6 @@ def _enrich_table_with_values(table: Table, detection: Detection) -> None:
160160
table.set(CVE_COLUMNS, detection_details.get('vulnerability_id'))
161161
table.set(LICENSE_COLUMN, detection_details.get('license'))
162162

163-
@staticmethod
164-
def _print_report_urls(local_scan_results: List['LocalScanResult']) -> None:
165-
report_urls = [scan_result.report_url for scan_result in local_scan_results if scan_result.report_url]
166-
if not report_urls:
167-
return
168-
169-
click.echo('Report URLs:')
170-
for report_url in report_urls:
171-
click.echo(f'- {report_url}')
172-
173163
@staticmethod
174164
def _print_summary_issues(detections_count: int, title: str) -> None:
175165
click.echo(f'⛔ Found {detections_count} issues of type: {click.style(title, bold=True)}')

cycode/cli/printers/tables/table_printer.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
VIOLATION_LENGTH_COLUMN = column_builder.build(name='Violation Length')
2626
VIOLATION_COLUMN = column_builder.build(name='Violation')
2727
SCAN_ID_COLUMN = column_builder.build(name='Scan ID')
28-
REPORT_URL_COLUMN = column_builder.build(name='Report URL')
2928

3029
COLUMN_WIDTHS_CONFIG: ColumnWidthsConfig = {
3130
SECRET_SCAN_TYPE: {
@@ -59,13 +58,12 @@ def _print_results(self, local_scan_results: List['LocalScanResult']) -> None:
5958

6059
for local_scan_result in local_scan_results:
6160
for document_detections in local_scan_result.document_detections:
62-
report_url = local_scan_result.report_url if local_scan_result.report_url else 'N/A'
6361
for detection in document_detections.detections:
64-
table.set(REPORT_URL_COLUMN, report_url)
6562
table.set(SCAN_ID_COLUMN, local_scan_result.scan_id)
6663
self._enrich_table_with_values(table, detection, document_detections.document)
6764

6865
self._print_table(table)
66+
self._print_report_urls(local_scan_results)
6967

7068
def _get_table(self) -> Table:
7169
table = Table()
@@ -85,9 +83,6 @@ def _get_table(self) -> Table:
8583
table.add(VIOLATION_LENGTH_COLUMN)
8684
table.add(VIOLATION_COLUMN)
8785

88-
if self.context.obj.get('report'):
89-
table.add(REPORT_URL_COLUMN)
90-
9186
return table
9287

9388
def _enrich_table_with_values(self, table: Table, detection: Detection, document: Document) -> None:

cycode/cli/printers/tables/table_printer_base.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,13 @@ def _print_results(self, local_scan_results: List['LocalScanResult']) -> None:
5656
def _print_table(table: 'Table') -> None:
5757
if table.get_rows():
5858
click.echo(table.get_table().draw())
59+
60+
@staticmethod
61+
def _print_report_urls(local_scan_results: List['LocalScanResult']) -> None:
62+
report_urls = [scan_result.report_url for scan_result in local_scan_results if scan_result.report_url]
63+
if not report_urls:
64+
return
65+
66+
click.echo('Report URLs:')
67+
for report_url in report_urls:
68+
click.echo(f'- {report_url}')

0 commit comments

Comments
 (0)