Documentation ¶
Overview ¶
Package gopwned implements the REST api of haveibeenpwned.com for easy querying. More specifically package gopwned implements the version 3 (V3) of the API.
Index ¶
- type Breach
- type Client
- func (c *Client) GetABreachedSite(site string) (*Breach, error)
- func (c *Client) GetAccountBreaches(account, domain string, truncate, unverified bool) ([]*Breach, error)
- func (c *Client) GetAccountPastes(email string) ([]*Paste, error)
- func (c *Client) GetBreachedSites(domainFilter string) ([]*Breach, error)
- func (c *Client) GetDataClasses() (*DataClasses, error)
- func (c *Client) GetPwnedPasswords(chars string, addPadding bool) ([]byte, error)
- type DataClasses
- type Paste
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Breach ¶
type Breach struct { Name string `json:"Name,omitempty"` Title string `json:"Title,omitempty"` Domain string `json:"Domain,omitempty"` BreachDate string `json:"BreachDate,omitempty"` AddedDate string `json:"AddedDate,omitempty"` ModifiedDate string `json:"ModifiedDate,omitempty"` PwnCount int `json:"PwnCount,omitempty"` Description string `json:"Description,omitempty"` DataClasses *DataClasses `json:"DataClasses,omitempty"` IsVerified bool `json:"IsVerified,omitempty"` IsFabricated bool `json:"IsFabricated,omitempty"` IsSensitive bool `json:"IsSensitive,omitempty"` IsRetired bool `json:"IsRetired,omitempty"` IsSpamList bool `json:"IsSpamList,omitempty"` LogoPath string `json:"LogoPath,omitempty"` }
Breach holds all breach information returned from the API.
type Client ¶
type Client struct { Token string UserAgent string BaseURL *url.URL PwnPwdURL *url.URL // contains filtered or unexported fields }
Client represents a client interfact to the haveibeenpwned.com API.
func NewClient ¶
NewClient creates a new haveibeenpwned.com API client. It expects 2 arguments 1) a `http.Client` 2) an API key
Currently, the 1st argument will default to `http.DefaultClient` if no arguments are given. The 2nd argument will default to an empty string, which means the client will not be able to call certain endpoints as per the API version changes in V3. For more information: https://haveibeenpwned.com/API/v3
func (*Client) GetABreachedSite ¶ added in v0.0.2
GetABreachedSite - returns all details of a single breach by its breach "name". This breach "name" is a stable value in the haveibeenpwned.com data-sets. An example of a breach "name" would be "Adobe" instead of "adobe.com".
func (*Client) GetAccountBreaches ¶ added in v0.0.2
func (c *Client) GetAccountBreaches(account, domain string, truncate, unverified bool) ([]*Breach, error)
GetAccountBreaches - returns a list of all breaches of a particular account has been involved in. This function checks if an HIBP API key is provided, if not it will throw an error. The function accepts 4 arguments, with 1 of them being required. They are:
- account - The account is not case sensitive and is URL encoded before sending to the endpoint. (required)
- domain - Filters the result set to only breaches against the domain specified. (e.g. adobe.com)
- truncate - Instructs the API to return the full breach data instead of, by default, only the name of the breach.
- unverified - Instructs the API not to include unverified breaches instead of, by default, returning both verified and unverified.
func (*Client) GetAccountPastes ¶ added in v0.0.2
GetAccountPastes - returns a list of pastes based on the email provided. This function checks if an HIBP API key is provided, if not it will throw an error.
func (*Client) GetBreachedSites ¶ added in v0.0.2
GetBreachedSites - returns a list of all details of each breach. A breach: an instance of a system having been compromised and data disclosed. This function accepts an option argument which can be used to filter on a specific breached domain (e.g. adobe.com) which may not be the same as the breach "Title"
func (*Client) GetDataClasses ¶
func (c *Client) GetDataClasses() (*DataClasses, error)
GetDataClasses - returns an alphabetically ordered list of data classes exposed during a breach. A "data class" is an attribute of a record compromised in a breach. E.g. "Email addresses" and "Passwords"
func (*Client) GetPwnedPasswords ¶ added in v0.0.2
GetPwnedPasswords - returns a list of suffixes that has a similar prefix hash, i.e., the first 5 characters of SHA-1 hash of the password and the count of how many times that suffix has been seen in the data set. This function requires exactly 1 argument which is the 1st 5 characters of the hash of the password as a string.
type DataClasses ¶
type DataClasses []string
DataClasses holds all data classes exposed from breaches returned from the API.