Skip to content

feat : vuln summary command#738

Open
Sypher845 wants to merge 3 commits intogoharbor:mainfrom
Sypher845:feat/vuln-summary-command
Open

feat : vuln summary command#738
Sypher845 wants to merge 3 commits intogoharbor:mainfrom
Sypher845:feat/vuln-summary-command

Conversation

@Sypher845
Copy link
Contributor

@Sypher845 Sypher845 commented Mar 11, 2026

Kooha-2026-03-12-01-02-33

Note : This is the first PR for the issue #723

Description

The PR adds the new harbor vuln summary command. A new command that displays an overview of vulnerability data from Harbor's Security Hub.

  • Severity distribution bar chart (Critical, High, Medium, Low, None, Unknown)
  • Total artifact and scan counts with not-scanned breakdown
  • Optional --with-dangerous-artifact flag to show top 5 most vulnerable artifacts
  • Optional --with-dangerous-cve flag to show top 5 most dangerous CVEs

Type of Change

Please select the relevant type.

  • Bug fix
  • New feature
  • Refactor
  • Documentation update
  • Chore / maintenance

Signed-off-by: Sypher845 <suyashpatil845@gmail.com>
Signed-off-by: Sypher845 <suyashpatil845@gmail.com>
Signed-off-by: Sypher845 <suyashpatil845@gmail.com>
@Sypher845 Sypher845 changed the title Feat/vuln summary command Feat : vuln summary command Mar 11, 2026
@codecov
Copy link

codecov bot commented Mar 11, 2026

Codecov Report

❌ Patch coverage is 2.04082% with 144 lines in your changes missing coverage. Please review.
✅ Project coverage is 7.40%. Comparing base (60ad0bd) to head (fea5a6e).
⚠️ Report is 111 commits behind head on main.

Files with missing lines Patch % Lines
pkg/views/vulnerability/summary/view.go 0.00% 93 Missing ⚠️
cmd/harbor/root/vulnerability/summary.go 0.00% 29 Missing ⚠️
cmd/harbor/root/vulnerability/cmd.go 0.00% 11 Missing ⚠️
pkg/api/vulnerability_handler.go 0.00% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             main    #738      +/-   ##
=========================================
- Coverage   10.99%   7.40%   -3.59%     
=========================================
  Files         173     265      +92     
  Lines        8671   13168    +4497     
=========================================
+ Hits          953     975      +22     
- Misses       7612   12084    +4472     
- Partials      106     109       +3     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Sypher845 Sypher845 changed the title Feat : vuln summary command feat : vuln summary command Mar 11, 2026
Comment on lines +40 to +43
fmt.Printf("Total Vulnerabilities: %s%d%s (Fixable: %s%d%s)\n\n",
views.BoldANSI, summary.TotalVuls, views.ResetANSI,
views.BoldANSI, summary.FixableCnt, views.ResetANSI,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not use ANSI styling like this. Instead rely on lipgloss.
have a look at the slog PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Waiting for #739 to get merged

Copy link
Collaborator

Choose a reason for hiding this comment

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

its merged - @Sypher845 - please update

Thanks

Comment on lines +62 to +63
flags.BoolVarP(&withDangerousArtifact, "with-dangerous-artifact", "", false, "Include top 5 dangerous artifact details in summary")
flags.BoolVarP(&withDangerousCVE, "with-dangerous-cve", "", false, "Include top 5 dangerous CVE details in summary")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we have either aliases or like short-forms of this?
I feel like writing --with-dangerous-cve and/or the artifact is just too big and tedious.
Something like
--cve & --art or something for shortforms?
Or anything you can suggest

Copy link
Contributor Author

Choose a reason for hiding this comment

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

--cve and --artifact, is this good?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, that would be good

}
}
empty := barWidth - filled
bar := e.color + strings.Repeat("█", filled) + views.ResetANSI + strings.Repeat("░", empty)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should replace the empty character. Although in mine it shows something like this

Image

And in most modern terminal emulator's they do the same. But for VMs or other cases they look how they do in the PR Description

strings.Repeat("█", filled) + strings.Repeat("─", empty)
// ████████████────────

I think this is better. Cause the actual block is standard unicode and so is the -
The half-filled block looks crude to me (this may as well be a personal opinion)
@bupd @qcserestipy What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image
image

i feel the dot one looks good

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel the line one lol
But you can keep the dot, it isnt bad
@qcserestipy @bupd what are your thoughs?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah the line looks good - feels more modern - and across the cli we use lines - so should be good to go..

Copy link
Collaborator

Choose a reason for hiding this comment

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

2 for 1 - I believe line is the way to go.

}
empty := barWidth - filled
bar := e.color + strings.Repeat("█", filled) + views.ResetANSI + strings.Repeat("░", empty)
fmt.Printf(" %-10s %s %4d\n\n", e.label, bar, e.count)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also add a %age?
Like showing

[XXXXX-----] 43% (4444 CVEs)

Do you think this would be better?

Copy link
Contributor Author

@Sypher845 Sypher845 Mar 12, 2026

Choose a reason for hiding this comment

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

Yeah , adding it would be better as the UI is also having it.

Copy link
Collaborator

@bupd bupd left a comment

Choose a reason for hiding this comment

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

@Sypher845 please resolve conflicts

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.

3 participants