refactor(go-website): connect vulnerability page to database - #5838
Hidden character warning
refactor(go-website): connect vulnerability page to database#5838michaelkedar wants to merge 5 commits into
Conversation
another-rex
left a comment
There was a problem hiding this comment.
LGTM with some nits.
| mockDownstream := ComputedHierarchy{} | ||
| var mu sync.Mutex | ||
| knownIDs := make(map[string]bool) | ||
| g, ctx := errgroup.WithContext(r.Context()) |
There was a problem hiding this comment.
Set a limit here, we have some very big alias/upstream/related groups
There was a problem hiding this comment.
arbitrarily chose a limit of 20 here
| var vulnIDRegex = regexp.MustCompile(`^[a-zA-Z0-9:_.-]+$`) | ||
|
|
||
| // handleVulnerabilityDetails handles rendering the vulnerability details page or raw JSON for /vulnerability/{vuln_id}. | ||
| func (s *Server) handleVulnerabilityDetails(w http.ResponseWriter, r *http.Request) { |
There was a problem hiding this comment.
No vulnIDRegex check here?
There was a problem hiding this comment.
it's probably not super necessary to have it here - this specifically for the osv.dev/vulnerability/[ID] page, and it might be hypothetically possible we end up with an ID that doesn't match the regex in the database (maybe some old withdrawn vuln or something) and we probably don't want it to be impossible to navigate to.
| return nil, fmt.Errorf("failed to get upstream group: %w", err) | ||
| return nil, err | ||
| } | ||
| upstream := make([]string, len(upstreamGroup.UpstreamIDs)) |
There was a problem hiding this comment.
nit: I think we can use slices.Clone here. I think this pattern is also used elsewhere so can replace those too.
There was a problem hiding this comment.
replaced most instances of that pattern (even if it's unrelated to this PR 🤷)
Populate the individual vulnerability pages from the GCS/datastore.
Stack created with GitHub Stacks CLI • Give Feedback 💬