diff --git a/features/cli/vulnerability_list.feature b/features/cli/vulnerability_list.feature index 4400367e88..64ce0c0a85 100644 --- a/features/cli/vulnerability_list.feature +++ b/features/cli/vulnerability_list.feature @@ -24,12 +24,6 @@ Feature: CLI vulnerability list command And I remove colors from output Then I will see the following on stdout: """ - Vulnerabilities with applied fixes: - 13 applied via Ubuntu Security (2 high, 6 medium, 5 low) - - Vulnerabilities with fixes available: - 10 vulnerabilities found (3 high, 4 medium, 2 low, 1 negligible) - Common vulnerabilities and exposures (CVE): VULNERABILITY PRIORITY FIX AVAILABLE FROM AFFECTED INSTALLED PACKAGES CVE-2021-44730 high esm-infra snapd @@ -42,20 +36,17 @@ Feature: CLI vulnerability list command CVE-2021-46848 low esm-infra libtasn1-6 CVE-2023-24626 low esm-infra screen CVE-2018-1000654 negligible esm-infra libtasn1-6 - """ - When I run `pro vulnerability list --all --data-file=/tmp/security_issues_xenial --manifest-file=/tmp/manifest` as non-root - And I remove colors from output - Then I will see the following on stdout: - """ + Vulnerabilities with applied fixes: 13 applied via Ubuntu Security (2 high, 6 medium, 5 low) Vulnerabilities with fixes available: 10 vulnerabilities found (3 high, 4 medium, 2 low, 1 negligible) - - Vulnerabilities with no fixes available: - 10 unfixable vulnerabilities found (8 medium, 2 low) - + """ + When I run `pro vulnerability list --all --data-file=/tmp/security_issues_xenial --manifest-file=/tmp/manifest` as non-root + And I remove colors from output + Then I will see the following on stdout: + """ Common vulnerabilities and exposures (CVE): VULNERABILITY PRIORITY FIX AVAILABLE FROM AFFECTED INSTALLED PACKAGES CVE-2021-44730 high esm-infra snapd @@ -69,7 +60,6 @@ Feature: CLI vulnerability list command CVE-2021-4120 medium esm-infra snapd CVE-2022-28948 medium no-fix snapd CVE-2023-1523 medium esm-infra snapd - CVE-2023-48795 medium no-fix snapd CVE-2024-1724 medium no-fix snapd CVE-2024-29068 medium no-fix snapd CVE-2024-29069 medium no-fix snapd @@ -78,40 +68,42 @@ Feature: CLI vulnerability list command CVE-2023-24626 low esm-infra screen CVE-2024-5138 low no-fix snapd CVE-2018-1000654 negligible esm-infra libtasn1-6 + + Vulnerabilities with applied fixes: + 13 applied via Ubuntu Security (2 high, 6 medium, 5 low) + + Vulnerabilities with fixes available: + 10 vulnerabilities found (3 high, 4 medium, 2 low, 1 negligible) + + Vulnerabilities with no fixes available: + 9 unfixable vulnerabilities found (7 medium, 2 low) """ When I run `pro vulnerability list --unfixable --data-file=/tmp/security_issues_xenial --manifest-file=/tmp/manifest` as non-root And I remove colors from output Then I will see the following on stdout: """ - Vulnerabilities with applied fixes: - 13 applied via Ubuntu Security (2 high, 6 medium, 5 low) - - Vulnerabilities with no fixes available: - 10 unfixable vulnerabilities found (8 medium, 2 low) - Common vulnerabilities and exposures (CVE): VULNERABILITY PRIORITY FIX AVAILABLE FROM AFFECTED INSTALLED PACKAGES CVE-2019-11840 medium no-fix snapd CVE-2021-24031 medium no-fix libzstd1 CVE-2021-24032 medium no-fix libzstd1 CVE-2022-28948 medium no-fix snapd - CVE-2023-48795 medium no-fix snapd CVE-2024-1724 medium no-fix snapd CVE-2024-29068 medium no-fix snapd CVE-2024-29069 medium no-fix snapd CVE-2017-3204 low no-fix snapd CVE-2024-5138 low no-fix snapd + + Vulnerabilities with applied fixes: + 13 applied via Ubuntu Security (2 high, 6 medium, 5 low) + + Vulnerabilities with no fixes available: + 9 unfixable vulnerabilities found (7 medium, 2 low) """ When I run `pro vulnerability list --usns --data-file=/tmp/security_issues_xenial --manifest-file=/tmp/manifest` as non-root And I remove colors from output Then I will see the following on stdout: """ - Vulnerabilities with applied fixes: - 1 applied via Ubuntu Security - - Vulnerabilities with fixes available: - 5 vulnerabilities found - Ubuntu Security Notices (USN): VULNERABILITY FIX AVAILABLE FROM AFFECTED INSTALLED PACKAGES USN-5292-3 esm-infra snapd @@ -119,6 +111,12 @@ Feature: CLI vulnerability list command USN-5593-1 esm-infra libzstd1 USN-5707-1 esm-infra libtasn1-6 USN-5720-1 esm-infra libzstd1 + + Vulnerabilities with applied fixes: + 1 applied via Ubuntu Security + + Vulnerabilities with fixes available: + 5 vulnerabilities found """ When I create the file `/tmp/manifest` with the following: """ diff --git a/uaclient/cli/vulnerability/list.py b/uaclient/cli/vulnerability/list.py index ef8cd2b34f..7a0f43910b 100644 --- a/uaclient/cli/vulnerability/list.py +++ b/uaclient/cli/vulnerability/list.py @@ -327,8 +327,11 @@ def _list_cves( ) if cve_vulnerabilities_result.cves: + print(messages.CLI_VULNERABILITY_LIST_CVE_HEADER) + print(_create_cve_table(cve_vulnerabilities_result.cves)) print( - _create_list_header( + "\n" + + _create_list_header( vulnerabilities=cve_vulnerabilities_result.cves, applied_fixes_count=applied_fixes_count, show_usns=False, @@ -336,13 +339,12 @@ def _list_cves( show_unfixable=show_unfixable, ) ) - print(messages.CLI_VULNERABILITY_LIST_CVE_HEADER) - print(_create_cve_table(cve_vulnerabilities_result.cves)) else: - print(_create_already_fixed_cves_count(applied_fixes_count)) print( messages.CLI_VULNERABILITY_LIST_NOT_AFFECTED.format(issue="CVEs") + + "\n" ) + print(_create_already_fixed_cves_count(applied_fixes_count)) def _list_usns( @@ -365,8 +367,11 @@ def _list_usns( ) if usn_vulnerabilities_result.usns: + print(messages.CLI_VULNERABILITY_LIST_USN_HEADER) + print(_create_usn_table(usn_vulnerabilities_result.usns)) print( - _create_list_header( + "\n" + + _create_list_header( vulnerabilities=usn_vulnerabilities_result.usns, applied_fixes_count=applied_fixes_count, show_usns=True, @@ -374,13 +379,12 @@ def _list_usns( show_unfixable=show_unfixable, ) ) - print(messages.CLI_VULNERABILITY_LIST_USN_HEADER) - print(_create_usn_table(usn_vulnerabilities_result.usns)) else: - print(_create_already_fixed_usns_count(applied_fixes_count)) print( messages.CLI_VULNERABILITY_LIST_NOT_AFFECTED.format(issue="USNs") + + "\n" ) + print(_create_already_fixed_usns_count(applied_fixes_count)) @vuln_util.assert_data_cache_updated("pro vulnerability list")