All Projects → uber-go → Hackeroni

uber-go / Hackeroni

Licence: mit
A Go API client for HackerOne (api.hackerone.com)

Programming Languages

go
31211 projects - #10 most used programming language

hackeroni GoDoc Build Status Coverage Status

A Go interface around api.hackerone.com.

Usage

import "github.com/uber-go/hackeroni/h1"

To list all reports matching a filter:

reports, _, err := client.Report.List(h1.ReportListFilter{
	Program: []string{"uber"},
})
if err != nil {
	panic(err)
}
for _, report := range reports {
	fmt.Println("Report Title:", *report.Title)
}

To retrieve a specific report:

report, _, err := client.Report.Get("123456")
if err != nil {
	panic(err)
}
fmt.Println("Report Title:", *report.Title)

Authentication

The h1 library does not directly handle authentication. Instead, when creating a new client, you can pass a http.Client that handles authentication for you. It does provide a APIAuthTransport structure when using API Token authentication. It is used like this:

tp := h1.APIAuthTransport{
	APIIdentifier: "your-h1-api-token-identifier",
	APIToken: "big-long-api-token-from-h1",
}

client := h1.NewClient(tp.Client())

Pagination

All requests for listing resources such as Report support pagination. Pagination options are described in the h1.ListOptions struct and passed to the list methods as an optional parameter. Pages information is available via the h1.ResponseLinks struct embedded in the h1.Response struct.

filter := h1.ReportListFilter{
	Program: []string{"uber"},
}
var listOpts h1.ListOptions

var allReports []h1.Report
for {
	reports, resp, err := client.Report.List(filter, &listOpts)
	if err != nil {
		panic(err)
	}
	allReports = append(allReports, reports...)
	if resp.Links.Next == "" {
		break
	}
	listOpts.Page = resp.Links.NextPageNumber()
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].