Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cycode/cli/printers/text_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ def print_report_urls(self, report_urls: list[str], aggregation_report_url: str
single_url = report_urls[0] if len(report_urls) == 1 else None
single_url = aggregation_report_url or single_url
if single_url:
self.console.print(f'[b]Report URL:[/] {single_url}')
self.console.print(f'[b]Report URL:[/] {single_url}', soft_wrap=True)
return

# If there are multiple report URLs, print them all
self.console.print('[b]Report URLs:[/]')
for report_url in report_urls:
self.console.print(f'- {report_url}')
self.console.print(f'- {report_url}', soft_wrap=True)
27 changes: 27 additions & 0 deletions tests/cli/printers/test_text_printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,30 @@ def test_malicious_package_prints_the_advisory_and_the_removal_instruction(

assert 'Advisory: MAL-2024-1234' in result
assert 'Remediation: Remove this package from your dependencies.' in result


_LONG_REPORT_URL = 'https://app.eu.cycode.com/cli-logs-aggregation/01234567-89ab-cdef-0123-456789abcdef'


@pytest.fixture
def narrow_printer(output: io.StringIO) -> TextPrinter:
ctx = MagicMock()
ctx.obj = {'scan_type': 'sast', 'show_secret': False}
ctx.info_name = 'path'
return TextPrinter(ctx, Console(file=output, width=80), Console(stderr=True))


def test_report_url_is_not_wrapped_on_a_narrow_console(narrow_printer: TextPrinter, output: io.StringIO) -> None:
narrow_printer.print_report_urls([], aggregation_report_url=_LONG_REPORT_URL)

assert output.getvalue().splitlines() == [f'Report URL: {_LONG_REPORT_URL}']


def test_multiple_report_urls_are_not_wrapped_on_a_narrow_console(
narrow_printer: TextPrinter, output: io.StringIO
) -> None:
report_urls = [_LONG_REPORT_URL, _LONG_REPORT_URL.replace('abcdef', 'fedcba')]

narrow_printer.print_report_urls(report_urls)

assert output.getvalue().splitlines() == ['Report URLs:', *(f'- {url}' for url in report_urls)]
Loading