Skip to content

Commit

Permalink
update the summary and add newline before and after the pacakge result
Browse files Browse the repository at this point in the history
  • Loading branch information
hogo6002 committed Nov 20, 2024
1 parent b65c682 commit ba60c71
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 8 deletions.
35 changes: 28 additions & 7 deletions cmd/osv-scanner/__snapshots__/main_test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2589,7 +2589,9 @@ Scanned <rootdir>/fixtures/maven-transitive/pom.xml file and found 3 packages

[TestRun_OCIImage/Alpine_3.10_image_tar_with_3.18_version_file - 1]
Scanning image ../../internal/image/fixtures/test-alpine.tar
Total 1 packages affected by 2 vulnerabilities (1 Critical, 1 High, 0 Medium, 0 Low, 0 Unknown) from 1 ecosystems, 2 have fixes available
Total 1 packages affected by 2 vulnerabilities (1 Critical, 1 High, 0 Medium, 0 Low, 0 Unknown) from 1 ecosystems.
2 vulnerabilities have fixes available

Alpine:v3.18
+----------------------------------------------------------+
| Source:docker:../../internal/image/fixtures/test-alpine. |
Expand All @@ -2599,6 +2601,7 @@ Alpine:v3.18
+---------+-------------------+---------------+------------+
| zlib | 1.2.11-r1 | Fix Available | 2 |
+---------+-------------------+---------------+------------+

For the most comprehensive scan results, we recommend using the HTML output: `osv-scanner --format html --output results.html`.
You can also view the full vulnerability list in your terminal with: `osv-scanner --format vertical`

Expand All @@ -2620,7 +2623,9 @@ failed to load image ./fixtures/oci-image/no-file-here.tar: open ./fixtures/oci-

[TestRun_OCIImage/scanning_node_modules_using_npm_with_no_packages - 1]
Scanning image ../../internal/image/fixtures/test-node_modules-npm-empty.tar
Total 1 packages affected by 4 vulnerabilities (0 Critical, 0 High, 4 Medium, 0 Low, 0 Unknown) from 1 ecosystems, 4 have fixes available
Total 1 packages affected by 4 vulnerabilities (0 Critical, 0 High, 4 Medium, 0 Low, 0 Unknown) from 1 ecosystems.
4 vulnerabilities have fixes available

Alpine:v3.19
+----------------------------------------------------------+
| Source:docker:../../internal/image/fixtures/test-node_mo |
Expand All @@ -2630,6 +2635,7 @@ Alpine:v3.19
+---------+-------------------+---------------+------------+
| busybox | 1.36.1-r15 | Fix Available | 4 |
+---------+-------------------+---------------+------------+

For the most comprehensive scan results, we recommend using the HTML output: `osv-scanner --format html --output results.html`.
You can also view the full vulnerability list in your terminal with: `osv-scanner --format vertical`

Expand All @@ -2641,7 +2647,9 @@ You can also view the full vulnerability list in your terminal with: `osv-scanne

[TestRun_OCIImage/scanning_node_modules_using_npm_with_some_packages - 1]
Scanning image ../../internal/image/fixtures/test-node_modules-npm-full.tar
Total 3 packages affected by 6 vulnerabilities (2 Critical, 0 High, 4 Medium, 0 Low, 0 Unknown) from 2 ecosystems, 5 have fixes available
Total 3 packages affected by 6 vulnerabilities (2 Critical, 0 High, 4 Medium, 0 Low, 0 Unknown) from 2 ecosystems.
5 vulnerabilities have fixes available

npm
+--------------------------------------------------------------+
| Source:docker:../../internal/image/fixtures/test-node_module |
Expand All @@ -2661,6 +2669,7 @@ Alpine:v3.19
+---------+-------------------+---------------+------------+
| busybox | 1.36.1-r15 | Fix Available | 4 |
+---------+-------------------+---------------+------------+

For the most comprehensive scan results, we recommend using the HTML output: `osv-scanner --format html --output results.html`.
You can also view the full vulnerability list in your terminal with: `osv-scanner --format vertical`

Expand All @@ -2672,7 +2681,9 @@ You can also view the full vulnerability list in your terminal with: `osv-scanne

[TestRun_OCIImage/scanning_node_modules_using_pnpm_with_no_packages - 1]
Scanning image ../../internal/image/fixtures/test-node_modules-pnpm-empty.tar
Total 1 packages affected by 4 vulnerabilities (0 Critical, 0 High, 4 Medium, 0 Low, 0 Unknown) from 1 ecosystems, 4 have fixes available
Total 1 packages affected by 4 vulnerabilities (0 Critical, 0 High, 4 Medium, 0 Low, 0 Unknown) from 1 ecosystems.
4 vulnerabilities have fixes available

Alpine:v3.19
+----------------------------------------------------------+
| Source:docker:../../internal/image/fixtures/test-node_mo |
Expand All @@ -2682,6 +2693,7 @@ Alpine:v3.19
+---------+-------------------+---------------+------------+
| busybox | 1.36.1-r15 | Fix Available | 4 |
+---------+-------------------+---------------+------------+

For the most comprehensive scan results, we recommend using the HTML output: `osv-scanner --format html --output results.html`.
You can also view the full vulnerability list in your terminal with: `osv-scanner --format vertical`

Expand All @@ -2693,7 +2705,9 @@ You can also view the full vulnerability list in your terminal with: `osv-scanne

[TestRun_OCIImage/scanning_node_modules_using_pnpm_with_some_packages - 1]
Scanning image ../../internal/image/fixtures/test-node_modules-pnpm-full.tar
Total 1 packages affected by 4 vulnerabilities (0 Critical, 0 High, 4 Medium, 0 Low, 0 Unknown) from 1 ecosystems, 4 have fixes available
Total 1 packages affected by 4 vulnerabilities (0 Critical, 0 High, 4 Medium, 0 Low, 0 Unknown) from 1 ecosystems.
4 vulnerabilities have fixes available

Alpine:v3.19
+----------------------------------------------------------+
| Source:docker:../../internal/image/fixtures/test-node_mo |
Expand All @@ -2703,6 +2717,7 @@ Alpine:v3.19
+---------+-------------------+---------------+------------+
| busybox | 1.36.1-r15 | Fix Available | 4 |
+---------+-------------------+---------------+------------+

For the most comprehensive scan results, we recommend using the HTML output: `osv-scanner --format html --output results.html`.
You can also view the full vulnerability list in your terminal with: `osv-scanner --format vertical`

Expand All @@ -2714,7 +2729,9 @@ You can also view the full vulnerability list in your terminal with: `osv-scanne

[TestRun_OCIImage/scanning_node_modules_using_yarn_with_no_packages - 1]
Scanning image ../../internal/image/fixtures/test-node_modules-yarn-empty.tar
Total 1 packages affected by 4 vulnerabilities (0 Critical, 0 High, 4 Medium, 0 Low, 0 Unknown) from 1 ecosystems, 4 have fixes available
Total 1 packages affected by 4 vulnerabilities (0 Critical, 0 High, 4 Medium, 0 Low, 0 Unknown) from 1 ecosystems.
4 vulnerabilities have fixes available

Alpine:v3.19
+----------------------------------------------------------+
| Source:docker:../../internal/image/fixtures/test-node_mo |
Expand All @@ -2724,6 +2741,7 @@ Alpine:v3.19
+---------+-------------------+---------------+------------+
| busybox | 1.36.1-r15 | Fix Available | 4 |
+---------+-------------------+---------------+------------+

For the most comprehensive scan results, we recommend using the HTML output: `osv-scanner --format html --output results.html`.
You can also view the full vulnerability list in your terminal with: `osv-scanner --format vertical`

Expand All @@ -2735,7 +2753,9 @@ You can also view the full vulnerability list in your terminal with: `osv-scanne

[TestRun_OCIImage/scanning_node_modules_using_yarn_with_some_packages - 1]
Scanning image ../../internal/image/fixtures/test-node_modules-yarn-full.tar
Total 1 packages affected by 4 vulnerabilities (0 Critical, 0 High, 4 Medium, 0 Low, 0 Unknown) from 1 ecosystems, 4 have fixes available
Total 1 packages affected by 4 vulnerabilities (0 Critical, 0 High, 4 Medium, 0 Low, 0 Unknown) from 1 ecosystems.
4 vulnerabilities have fixes available

Alpine:v3.19
+----------------------------------------------------------+
| Source:docker:../../internal/image/fixtures/test-node_mo |
Expand All @@ -2745,6 +2765,7 @@ Alpine:v3.19
+---------+-------------------+---------------+------------+
| busybox | 1.36.1-r15 | Fix Available | 4 |
+---------+-------------------+---------------+------------+

For the most comprehensive scan results, we recommend using the HTML output: `osv-scanner --format html --output results.html`.
You can also view the full vulnerability list in your terminal with: `osv-scanner --format vertical`

Expand Down
7 changes: 6 additions & 1 deletion internal/output/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ func tableBuilder(outputTable table.Writer, vulnResult *models.VulnerabilityResu

func printContainerScanningResult(result Result, outputWriter io.Writer, terminalWidth int) {
summary := fmt.Sprintf(
"Total %[1]d packages affected by %[2]d vulnerabilities (%[3]d Critical, %[4]d High, %[5]d Medium, %[6]d Low, %[7]d Unknown) from %[8]d ecosystems, %[9]d have fixes available",
"Total %[1]d packages affected by %[2]d vulnerabilities (%[3]d Critical, %[4]d High, %[5]d Medium, %[6]d Low, %[7]d Unknown) from %[8]d ecosystems.\n"+
"%[9]d vulnerabilities have fixes available",
result.PackageTypeCount.Called,
result.VulnTypeCount.All,
result.VulnCount.SeverityCount.Critical,
Expand All @@ -104,6 +105,8 @@ func printContainerScanningResult(result Result, outputWriter io.Writer, termina
result.VulnCount.FixableCount.Fixed,
)
fmt.Fprintln(outputWriter, summary)
// Add a newline
fmt.Fprintln(outputWriter)

for _, ecosystem := range result.Ecosystems {
fmt.Fprintln(outputWriter, ecosystem.Name)
Expand Down Expand Up @@ -131,6 +134,8 @@ func printContainerScanningResult(result Result, outputWriter io.Writer, termina
outputTable.Render()
}
}
// Add a newline
fmt.Fprintln(outputWriter)

const promptMessage = "For the most comprehensive scan results, we recommend using the HTML output: " +
"`osv-scanner --format html --output results.html`.\n" +
Expand Down

0 comments on commit ba60c71

Please sign in to comment.