Skip to main content

A HackerOne API client for Python

Project description

h1

https://img.shields.io/pypi/pyversions/h1.svg https://img.shields.io/pypi/v/h1.svg

A HackerOne API client for Python. The API closely maps to the REST API that HackerOne provides. Documentation for their API is available here.

License

MIT

Installation

For installation via pip:

pip install h1

For development, In the project root run:

virtualenv env
source env/bin/activate
make bootstrap

The manual approach should work as well:

python setup.py install

Examples

Initializing the Client

>>> from h1.client import HackerOneClient
>>> from h1.models import Report
>>> c = HackerOneClient("YOUR-API-TOKEN-IDENTIFIER", "YOUR-API-TOKEN")

Getting all reports created in the last day

HackerOneClient.find_resources() allows you to specify a resource to find (only Report is supported for now) and some criteria to filter on. The only required filter is program, which must be set to the target HackerOne program’s name. Any additional filters may be passed as kwargs, and everything in HackerOne’s filter documentation should be supported.

For example, here’s how we’d get all reports created in the past 24 hours:

>>> import datetime as dt
>>> day_ago = dt.datetime.now() - dt.timedelta(days=1)
>>> listing = c.find_resources(Report, program=["test-program"], created_at__gt=day_ago)
>>> len(listing)
3
>>> listing[0].title
u'This is a test report!'

Getting all resolved reports in a program

Similarly, if we filter on state we can get all the resolved reports:

>>> resolved_listing = c.find_resources(Report, program=["test-program"], state=["resolved"])
>>> resolved_listing[0].title

Getting a specific report by ID

HackerOneClient.get_resource() allows you to pass a resource type (again, currently just Report,) and an ID to fetch:

>>> report = c.get_resource(Report, 110306)
>>> report.title
u'Test RCE SQLi'
>>> report.state
u'not-applicable'

Tallying report counts by user

Here’s an example of using the client to figure out who your most prolific reporters are:

>>> from collections import Counter
>>> reporter_count = Counter()
>>> all_reports = c.find_resources(Report, program=["test-program"])
>>> for report in all_reports:
...     reporter_count[report.reporter] += 1
...
>>> print(reporter_count)
Counter({<User - bestreporter>: 21, <User - another_reporter>: 12, <User - r3p0rt3r>: 2, <User - newbie>: 1})

Running Tests

virtualenv env
source env/bin/activate
make bootstrap
make test

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

h1-1.4.2.tar.gz (17.7 kB view details)

Uploaded Source

File details

Details for the file h1-1.4.2.tar.gz.

File metadata

  • Download URL: h1-1.4.2.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for h1-1.4.2.tar.gz
Algorithm Hash digest
SHA256 48c531f756e441d5782f4b62e658b060da8808004d0da2e3690afe057088beb8
MD5 2075ada523b0880ca785a7219da5d5aa
BLAKE2b-256 e5ef99c2c6e306317f51a0ccac73d8650c99eddc59b8f36520e80cb673a17299

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page