Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(output): display base image info on HTML and table outputs #1513

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

hogo6002
Copy link
Contributor

@hogo6002 hogo6002 commented Jan 21, 2025

Resolves #1410

Adds detailed base image and layer data for HTML output: https://hogo6002.github.io/mvp/
Screenshot 2025-01-21 at 2 29 36 PM
Screenshot 2025-01-21 at 2 30 05 PM

Adds layer tracing for table output:
Screenshot 2025-01-21 at 1 51 28 PM

@hogo6002 hogo6002 requested a review from another-rex January 21, 2025 03:26
@codecov-commenter
Copy link

codecov-commenter commented Jan 21, 2025

Codecov Report

Attention: Patch coverage is 88.72180% with 15 lines in your changes missing coverage. Please review.

Project coverage is 69.00%. Comparing base (5d8e9c7) to head (baccc3c).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
internal/output/output_result.go 89.34% 11 Missing and 2 partials ⚠️
internal/output/html.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1513      +/-   ##
==========================================
- Coverage   69.00%   69.00%   -0.01%     
==========================================
  Files         197      197              
  Lines       18796    18863      +67     
==========================================
+ Hits        12971    13017      +46     
- Misses       5123     5143      +20     
- Partials      702      703       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hogo6002 hogo6002 changed the title feat(output): display base image info on HTML output feat(output): display base image info on HTML and table outputs Jan 21, 2025
if strings.HasPrefix(packageSource.Source.Path, "usr/lib/") {
skipSource := false
for _, annotation := range packageSource.ExperimentalAnnotations {
if annotation == extractor.InsideOSPackage {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: You can use labelled for loops here to break the continue the outer loop:
https://go.dev/ref/spec#Continue_statements

@@ -496,6 +614,14 @@ func getFilteredVulnReasons(vulns []VulnResult) string {
return strings.Join(reasons, ", ")
}

func getBaseImageNames(baseImageInfo BaseImageGroupInfo) string {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Should this be getBaseImageName since we are only getting the first name?

@@ -247,6 +367,12 @@ func processSource(packageSource models.PackageSource) SourceResult {
sourceResult.PackageTypeCount.Hidden += 1
}
}

packages := make([]PackageResult, 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can preallocate the array with the size of the packageMap

Suggested change
packages := make([]PackageResult, 0)
packages := make([]PackageResult, 0, len(packageMap))

<div class="layer-command-container">
<p><span class="package-detail-title">Layer introduced in:&nbsp;</span></p>
<div class="tooltip">
<p># {{ $index }} layer</p>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the " layer" text seems a bit redundant. Also, I still think it's not much value to users to dedicate a whole row to a "# layer" text that gives a diff ID when hovered over.

How about something like this instead?

image

Also changed the "In base image: True: image") to just "In base image: image" to make it a bit more concise.

Copy link
Collaborator

@oliverchang oliverchang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with some small suggestions from a UI perspective.

I'll let @another-rex handle the code review side of things :)

{{ $commandDetail := index $commandSet 1 }}
{{ $diffID := .LayerMetadata.DiffID }}
{{ $longCommand := false }}
{{ if gt (len $command) 109 }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 109? can you leave a comment?

{{ if gt .Count.AnalysisCount.Regular 0 }}
{{ $hasVuln = true }}
{{ end }}
<div title="{{ $diffID }}" class="layer-entry {{ if $hasVuln }}clickable clickable-layer{{ end }}" {{ if $hasVuln }}onclick="quickFilterByLayer('{{ $diffID }}', {{ $command }})"{{ end }}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to have a better visual representation that you can click on a layer to filter by it?

e.g. something that pops up (a tooltip?) that says "Click to filter vulnerabilities to ones introduced by this layer"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhance container scanning results with base image and comprehensive layer data
4 participants