Skip to content

Commit

Permalink
add newResponse for function SearchAllPages
Browse files Browse the repository at this point in the history
This is necessary as using the current response to iterate over pages
corrupts data that are slices, such as the tags within imageInfo. This is beacause
the memory address from the previous response will still contain data from the previous request.
By creating a new response using the nextPage url we get a new spot in memory to put the next
requests data.
  • Loading branch information
aircraft-cerier committed Apr 25, 2022
1 parent 70de12f commit fb3f038
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion api/v2_vulnerabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,12 @@ func (svc *v2HostVulnerabilityService) SearchAllPages(filters SearchFilter) (
for {
all = append(all, response.Data...)

pageOk, err = svc.client.NextPage(&response)
newResponse := VulnerabilitiesContainersResponse{
Paging: response.Paging,
}
pageOk, err = svc.client.NextPage(&newResponse)
if err == nil && pageOk {
response = newResponse
continue
}
break
Expand Down

0 comments on commit fb3f038

Please sign in to comment.