CrowdStrike / gofalcon

Golang-based SDK to CrowdStrike's APIs
MIT License
60 stars 43 forks source link

Missing pagination on ContainerImages.CombinedImageVulnerabilitySummary #432

Closed hazcod closed 6 months ago

hazcod commented 6 months ago

Hi,

I'm looking into fetching all image assessment related vulnerabilities using the Go SDK, version v0.6.0.

I noticed that there is no After argument in CombinedImageVulnerabilitySummaryParams, which means there is no way to pass a pagination token. *queryResult.GetPayload().Meta.Pagination.LastPage() also does not exist, so i'm curious how one is supposed to do pagination (akin to Spotlight)l with this? Thanks!

Example code:

func (cs *CrowdStrike) GetImageVulnerabilities(ctx context.Context) ([]ImageVulnerability, error) {
    round := 0
    paginationToken := ""
    for {
        // Query vulnerabilities from Falcon
        cs.logger.WithField("round", round).Debug("fetching image vulnerabilities")

        queryResult, err := cs.client.ContainerImages.CombinedImageVulnerabilitySummary(
            &container_images.CombinedImageVulnerabilitySummaryParams{
                Cid:        "",
                Registry:   "",
                Repository: "",
                Tag:        "",
                Context:    ctx,
                // ??
            },
        )
        if err != nil {
            return nil, fmt.Errorf("could not query image vulnerabilities: %v\n", err)
        }

        cs.logger.WithField("total", len(queryResult.GetPayload().Resources)).Debug("vulns returned")

        // Process each vulnerability
        for _, vuln := range queryResult.GetPayload().Resources {
            // TODO
        }

        // Stop pagination if we reached the end
        paginationToken = *queryResult.GetPayload().Meta.Pagination.LastPage() // ??
        if paginationToken == "" {
            break
        }
    }
}
ffalor commented 6 months ago

I reached out to the owners of that endpoint and they said this endpoint provides summarized info about an image, so pagination is not needed.