Skip to content

feat/vuln list command#748

Open
Sypher845 wants to merge 7 commits intogoharbor:mainfrom
Sypher845:feat/vuln-list-command
Open

feat/vuln list command#748
Sypher845 wants to merge 7 commits intogoharbor:mainfrom
Sypher845:feat/vuln-list-command

Conversation

@Sypher845
Copy link
Copy Markdown
Contributor

Note: This is the secoond PR for the isue #723

Description

The PR adds the new harbor vuln list command. A command that displays the list of vulnerabilities along with filtering from the Security Hub.

image

Command usage

  • harbor vuln list (No filters)
    Kooha-2026-03-17-04-14-39
    The CVE-IDs are hyperlinked to aquasec website (provided by the api)

  • harbor vuln list --query "k=v , , , k=[min~max]" : Using query flag based filtering
    Kooha-2026-03-17-04-22-05

  • harbor vuln list (flags based filtering) : Using flags for filtering
    Kooha-2026-03-17-04-27-36

  • harbor vuln list --fixable: Show only fixable vulnerabilities (cli side)
    Kooha-2026-03-17-04-29-26

  • harbor vuln list --exclude : woks oppposite of query flag (cli side)
    Kooha-2026-03-17-04-37-00

Type of Change

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

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 16, 2026

Codecov Report

❌ Patch coverage is 0% with 237 lines in your changes missing coverage. Please review.
✅ Project coverage is 7.66%. Comparing base (60ad0bd) to head (013e125).
⚠️ Report is 119 commits behind head on main.

Files with missing lines Patch % Lines
pkg/api/vulnerability_handler.go 0.00% 133 Missing ⚠️
cmd/harbor/root/vulnerability/list.go 0.00% 63 Missing ⚠️
pkg/views/vulnerability/list/view.go 0.00% 40 Missing ⚠️
cmd/harbor/root/vulnerability/cmd.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             main    #748      +/-   ##
=========================================
- Coverage   10.99%   7.66%   -3.33%     
=========================================
  Files         173     272      +99     
  Lines        8671   13406    +4735     
=========================================
+ Hits          953    1027      +74     
- Misses       7612   12266    +4654     
- Partials      106     113       +7     

☔ 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.

Signed-off-by: Sypher845 <suyashpatil845@gmail.com>
Signed-off-by: Sypher845 <suyashpatil845@gmail.com>
Signed-off-by: Sypher845 <suyashpatil845@gmail.com>
@Sypher845 Sypher845 force-pushed the feat/vuln-list-command branch from 2dc9c47 to 7b28626 Compare March 19, 2026 22:02
Signed-off-by: Sypher845 <suyashpatil845@gmail.com>
@Sypher845 Sypher845 force-pushed the feat/vuln-list-command branch from 7b28626 to a744965 Compare March 19, 2026 22:09
@Sypher845
Copy link
Copy Markdown
Contributor Author

@NucleoFusion Please take a look

Copy link
Copy Markdown
Contributor

@NucleoFusion NucleoFusion left a comment

Choose a reason for hiding this comment

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

Instead of --page-size 0 I think a special flag would be better, since its not that user friendly and hard to describe in the help

@Sypher845
Copy link
Copy Markdown
Contributor Author

--all flag works?

@NucleoFusion
Copy link
Copy Markdown
Contributor

Yep

Signed-off-by: Sypher845 <suyashpatil845@gmail.com>
@Sypher845 Sypher845 force-pushed the feat/vuln-list-command branch from 3fd8703 to 86b2cf3 Compare March 20, 2026 12:31
@Sypher845
Copy link
Copy Markdown
Contributor Author

@NucleoFusion Ptal :)

@Sypher845
Copy link
Copy Markdown
Contributor Author

@NucleoFusion any update on this?

@NucleoFusion
Copy link
Copy Markdown
Contributor

@NucleoFusion any update on this?

Yeah I will have a look at it.
A little sick currently, mb.

@Sypher845
Copy link
Copy Markdown
Contributor Author

No worries, get well soon!

Copy link
Copy Markdown
Contributor

@NucleoFusion NucleoFusion left a comment

Choose a reason for hiding this comment

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

this look good, but waiting for some clarifications

Comment on lines +66 to +77
flags := cmd.Flags()
flags.Int64VarP(&opts.Page, "page", "", 1, "Page number")
flags.Int64VarP(&opts.PageSize, "page-size", "", 10, "Size of per page")
flags.StringVarP(&opts.Q, "query", "q", "", "Filter vulnerabilities with a ',' separated query string like exact k=v and range k=[min~max]")
flags.StringVarP(&opts.CVEID, "cve-id", "", "", "Filter by exact CVE ID")
flags.StringVarP(&opts.CVSSScore, "cvss-score", "", "", "Filter by CVSS v3 score range (e.g. 7.0~10.0) or exact score (e.g. 7.0)")
flags.StringVarP(&opts.Severity, "severity", "", "", "Filter by severity level")
flags.StringVarP(&opts.Repository, "repository", "", "", "Filter by exact repository name")
flags.StringVarP(&opts.ProjectName, "project-name", "", "", "Filter by exact project name")
flags.StringVarP(&opts.Package, "package", "", "", "Filter by exact package name")
flags.StringVarP(&opts.Tag, "tag", "", "", "Filter by exact artifact tag")
flags.StringVarP(&opts.Digest, "digest", "", "", "Filter by exact artifact digest")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@bupd @qcserestipy
Should we have this many flags? would it be better to just have the Q param?
And since I am planning a PR on adding validKeys and usage to the query param about how it works in #731 .

Cause managing the current BuildQuery function takes the flags and just creates the full query, so integrating these two would be a little unintuitive.
And then also another problem is the individual flags are rigid, no support for exact/fuzzy switch, and there are also the Q params rigidity, like the params dont allow/follow 2 exact matching, they only do one. Using the Q would also allow or and and.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

one thing to note, the SecurityHub API doesn't actually suport the fuzzy match, union and intersection for vuln fields.

Signed-off-by: Sypher845 <suyashpatil845@gmail.com>
@Sypher845
Copy link
Copy Markdown
Contributor Author

Sypher845 commented Mar 25, 2026

@NucleoFusion removed the query flag, PTAL

Copy link
Copy Markdown
Contributor

@NucleoFusion NucleoFusion left a comment

Choose a reason for hiding this comment

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

minor changes, works well

Signed-off-by: Sypher845 <suyashpatil845@gmail.com>
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.

2 participants