Skip to content

asecurityteam/bug_crowd_client

Repository files navigation

Bugcrowd api client.

travis-status-image pypi-version-image

This package provides an implementation of the Bugcrowd api.


Installation

To install simply run

pip install bug-crowd-api-client

Using this library

To create a Bugcrowd client
    from bug_crowd.client import BugcrowdClient
    client = BugcrowdClient('API_TOKEN')
To get bug bounties
    from bug_crowd.client import BugcrowdClient
    client = BugcrowdClient('API_TOKEN')
    bounties = client.get_bounties()
To get submissions for a bug bounty
    from bug_crowd.client import BugcrowdClient
    client = BugcrowdClient('API_TOKEN')
    bounty = client.get_bounties()[0]
    submissions = list(client.get_submissions(bounty))
To create a bug bounty submission
    import datetime

    from bug_crowd.client import BugcrowdClient
    client = BugcrowdClient('API_TOKEN')
    bounty = client.get_bounties()[0]
    submission_fields = {
        'substate': 'unresolved',
        'title': 'Example submission',
        'submitted_at': datetime.datetime.utcnow(),
        'description_markdown': 'Example description',
    }

    resp = client.create_submission(bounty, submission_fields).result()
    resp.raise_for_status()
    submission = resp.json()
To update a bug bounty submission
    from bug_crowd.client import BugcrowdClient
    client = BugcrowdClient('API_TOKEN')
    bounty = client.get_bounties()[0]
    submission = client.get_submissions(bounty)[0]

    resp = client.update_submission(
        submission,
        title='A new title',
        vrt_id='cross_site_scripting_xss',
        custom_fields={'example': 'value'},
    ).result()
    resp.raise_for_status()
    updated_submission = resp.json()
To comment on a bug bounty submission
    from bug_crowd.client import BugcrowdClient
    client = BugcrowdClient('API_TOKEN')
    bounty = client.get_bounties()[0]
    submission = client.get_submissions(bounty)[0]

    resp = client.comment_on_submission(
        submission,
        'A comment',
        comment_type='tester_message',
    ).result()
    resp.raise_for_status()
    comment = resp.json()
To transition a bug bounty submission to a status
    from bug_crowd.client import BugcrowdClient

    client = BugcrowdClient('API_TOKEN')
    bounty = client.get_bounties()[0]
    submission = client.get_submissions(bounty)[0]

    resp = client.transition_submission(
        submission,
        'triaged',
    ).result()
    resp.raise_for_status()
To get file attachments on a bug bounty submission
    from bug_crowd.client import BugcrowdClient

    client = BugcrowdClient('API_TOKEN')
    bounty = client.get_bounties()[0]
    submission = client.get_submissions(bounty)[0]

    attachments = client.get_attachments_for_submission(submission)