pub struct Client<T: Transport = UreqTransport> { /* private fields */ }Expand description
A HackerOne API client.
Generic over its Transport so it can be unit-tested with a mock and
embedded with a custom HTTP stack. The default transport is
UreqTransport.
use hackerone_api::Client;
let client = Client::new("my-api-identifier", "my-api-token");
let me = client.me()?;
println!("{:?}", me.username);Implementations§
Source§impl<T: Transport> Client<T>
impl<T: Transport> Client<T>
Sourcepub fn with_transport(base_url: impl Into<String>, transport: T) -> Self
pub fn with_transport(base_url: impl Into<String>, transport: T) -> Self
Build a client over a custom transport (no credentials yet).
Sourcepub fn with_credentials(
self,
identifier: impl Into<String>,
token: impl Into<String>,
) -> Self
pub fn with_credentials( self, identifier: impl Into<String>, token: impl Into<String>, ) -> Self
Attach HTTP Basic credentials (builder style).
Sourcepub fn me(&self) -> Result<User>
pub fn me(&self) -> Result<User>
GET /v1/me — the authenticated user.
This is a customer/profile endpoint. A hacker-only API token
receives 401 here; use Client::my_reports (which hits
/v1/hackers/me/reports) to confirm a hacker token works.
Sourcepub fn programs(&self) -> Result<Page<Program>>
pub fn programs(&self) -> Result<Page<Program>>
GET /v1/me/programs — programs the token can access.
Sourcepub fn program(&self, id: &str) -> Result<Program>
pub fn program(&self, id: &str) -> Result<Program>
GET /v1/programs/{id} — one program by handle or id.
Sourcepub fn structured_scopes(
&self,
program_id: &str,
page: Option<(u32, u32)>,
) -> Result<Page<StructuredScope>>
pub fn structured_scopes( &self, program_id: &str, page: Option<(u32, u32)>, ) -> Result<Page<StructuredScope>>
GET /v1/programs/{id}/structured_scopes — a program’s scopes.
Sourcepub fn reports(&self, query: &ReportQuery) -> Result<Page<Report>>
pub fn reports(&self, query: &ReportQuery) -> Result<Page<Report>>
GET /v1/reports — reports, filtered by query.
Sourcepub fn create_report(&self, report: &CreateHackerReport) -> Result<Report>
pub fn create_report(&self, report: &CreateHackerReport) -> Result<Report>
POST /v1/hackers/reports — submit a report to a program as a hacker.
This is the endpoint a researcher uses to file a report; it posts the
CreateHackerReport body (team_handle + attributes) to the hacker
surface and returns the created Report.
Sourcepub fn my_reports(&self, query: &PageQuery) -> Result<Page<Report>>
pub fn my_reports(&self, query: &PageQuery) -> Result<Page<Report>>
GET /v1/hackers/me/reports — the authenticated hacker’s own reports.
Sourcepub fn my_report(&self, id: &str) -> Result<Report>
pub fn my_report(&self, id: &str) -> Result<Report>
GET /v1/hackers/reports/{id} — one of the authenticated hacker’s reports.
Sourcepub fn hacktivity(&self, query: &HacktivityQuery) -> Result<Page<Hacktivity>>
pub fn hacktivity(&self, query: &HacktivityQuery) -> Result<Page<Hacktivity>>
GET /v1/hackers/hacktivity — the public hacktivity feed.
query.query_string is a Lucene filter, e.g.
severity_rating:critical AND disclosed:true.
Sourcepub fn balance(&self) -> Result<Balance>
pub fn balance(&self) -> Result<Balance>
GET /v1/hackers/payments/balance — the authenticated hacker’s balance.
Sourcepub fn earnings(&self, query: &PageQuery) -> Result<Page<Earning>>
pub fn earnings(&self, query: &PageQuery) -> Result<Page<Earning>>
GET /v1/hackers/payments/earnings — the authenticated hacker’s earnings.
Sourcepub fn add_comment(
&self,
report_id: &str,
message: &str,
) -> Result<Resource<Value>>
pub fn add_comment( &self, report_id: &str, message: &str, ) -> Result<Resource<Value>>
POST /v1/reports/{id}/activities — add a comment.
Sourcepub fn change_state(
&self,
report_id: &str,
state: ReportState,
message: Option<&str>,
) -> Result<Resource<Value>>
pub fn change_state( &self, report_id: &str, state: ReportState, message: Option<&str>, ) -> Result<Resource<Value>>
POST /v1/reports/{id}/state_changes — change a report’s state.
Sourcepub fn weaknesses(&self) -> Result<Page<Weakness>>
pub fn weaknesses(&self) -> Result<Page<Weakness>>
GET /v1/weaknesses — the CWE catalog.