forked from liamg/hackerone
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To allow the retrieval of a target's in-scope assets, add querying ca…
…pability for Structured Scopes
- Loading branch information
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |