Skip to content

Commit

Permalink
To allow the retrieval of a target's in-scope assets, add querying ca…
Browse files Browse the repository at this point in the history
…pability for Structured Scopes
  • Loading branch information
sam-bee committed Apr 8, 2024
1 parent e7bf5fe commit b2c6bd7
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions pkg/hackers/structuredscopes.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package hackers

import (
"context"
"fmt"

"github.com/liamg/hackerone/pkg/api"
)

type getStructuredScopesResponse struct {
Data []api.StructuredScope `json:"data"`
Links api.Links `json:"links"`
}

// GetStructuredScopes returns a list of structured scopes for a given program. If there are further pages, nextPage will be >0.
func (a *API) GetStructuredScopes(ctx context.Context, handle string, pageOptions *api.PageOptions) (programs []api.StructuredScope, nextPage int, err error) {
var response getStructuredScopesResponse
path := fmt.Sprintf(
"/hackers/programs/%s/structured_scopes?page[number]=%d&page[size]=%d",
handle,
pageOptions.GetPageNumber(),
pageOptions.GetPageSize(),
)
if err := a.client.Get(ctx, path, &response); err != nil {
return nil, 0, err
}
if response.Links.Next != "" {
nextPage = pageOptions.GetPageNumber() + 1
}
return response.Data, nextPage, nil
}

0 comments on commit b2c6bd7

Please sign in to comment.