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

Is There a Difference Between Structs #322

Closed
nathannaveen opened this issue Jan 17, 2023 · 2 comments · Fixed by #325
Closed

Is There a Difference Between Structs #322

nathannaveen opened this issue Jan 17, 2023 · 2 comments · Fixed by #325

Comments

@nathannaveen
Copy link
Contributor

Hi, I was trying to test pkg/certifier/osv/internal/osv_query/osv_query.go and saw that there are the structs, BatchedResponse and HydratedBatchedResponse:

// BatchedResponse represents an unhydrated batched response from OSV.
type BatchedResponse struct {
Results []MinimalResponse `json:"results"`
}
// HydratedBatchedResponse represents a hydrated batched response from OSV.
type HydratedBatchedResponse struct {
Results []Response `json:"results"`
}

HydratedBatchedResponse only has Results []Response `json:"results"` in it, and BatchedResponse has Results []MinimalResponse `json:"results"` in it.

Response is:

type Response struct {
	Vulns []osv.Entry `json:"vulns"`
}

And MinimalResponse is:

type MinimalResponse struct {
	Vulns []osv.Entry `json:"vulns"`
}

So what makes HydratedBatchedResponse and BatchedResponse different, is there a reason they are two different structs?

@nathannaveen
Copy link
Contributor Author

cc @pxp928, 👀

@pxp928
Copy link
Collaborator

pxp928 commented Jan 18, 2023

@nathannaveen This file was copied over (and slightly modified) from an upstream project (now OSV Scanner). I did create another issue #323 to track that we eventually remove this from GUAC (this issue jogged my memory that I forgot to do that. Thanks for that!). Feel free to remove the redundant structs but overall the whole file will be removed in the near future once I speak with the OSV Scanner maintainers. Currently there is a comment on the file for other that view it in the future:

// This package is currently copied from
// https://github.com/google/osv-scanner/blob/main/internal/osv/osv.go.
// Currently this is not exposed by the upstream project. Once it is
// exposed, this will be removed.

nathannaveen added a commit to nathannaveen/guac that referenced this issue Jan 18, 2023
- Refactored the file `pkg/certifier/osv/internal/osv_query/osv_query.go`
- Removed redundant structs which fixes: guacsec#322
- Removed the `MakeCommitRequest` struct because it wasn't ever used
- Removed the `Hydrate()` function because it isn't ever used
- Also removed `Get()` because it was only used in `Hydrate()`

Signed-off-by: nathannaveen <[email protected]>
@kodiakhq kodiakhq bot closed this as completed in 2409a00 Jan 19, 2023
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 a pull request may close this issue.

2 participants