Documentation ¶
Overview ¶
Package safebrowsing provides access to the Safe Browsing API.
For product documentation, see: https://developers.google.com/safe-browsing/
Library status ¶
These client libraries are officially supported by Google. However, this library is considered complete and is in maintenance mode. This means that we will address critical bugs and security issues but will not add any new features.
When possible, we recommend using our newer [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go) that are still actively being worked and iterated on.
Creating a client ¶
Usage example:
import "google.golang.org/api/safebrowsing/v5" ... ctx := context.Background() safebrowsingService, err := safebrowsing.NewService(ctx)
In this example, Google Application Default Credentials are used for authentication. For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
Other authentication options ¶
To use an API key for authentication (note: some APIs do not support API keys), use google.golang.org/api/option.WithAPIKey:
safebrowsingService, err := safebrowsing.NewService(ctx, option.WithAPIKey("AIza..."))
To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow, use google.golang.org/api/option.WithTokenSource:
config := &oauth2.Config{...} // ... token, err := config.Exchange(ctx, ...) safebrowsingService, err := safebrowsing.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
See google.golang.org/api/option.ClientOption for details on options.
Index ¶
- type GoogleSecuritySafebrowsingV5FullHash
- type GoogleSecuritySafebrowsingV5FullHashFullHashDetail
- type GoogleSecuritySafebrowsingV5SearchHashesResponse
- type HashesSearchCall
- func (c *HashesSearchCall) Context(ctx context.Context) *HashesSearchCall
- func (c *HashesSearchCall) Do(opts ...googleapi.CallOption) (*GoogleSecuritySafebrowsingV5SearchHashesResponse, error)
- func (c *HashesSearchCall) Fields(s ...googleapi.Field) *HashesSearchCall
- func (c *HashesSearchCall) HashPrefixes(hashPrefixes ...string) *HashesSearchCall
- func (c *HashesSearchCall) Header() http.Header
- func (c *HashesSearchCall) IfNoneMatch(entityTag string) *HashesSearchCall
- type HashesService
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GoogleSecuritySafebrowsingV5FullHash ¶
type GoogleSecuritySafebrowsingV5FullHash struct { // FullHash: The matching full hash. This is the SHA256 hash. The length // will be exactly 32 bytes. FullHash string `json:"fullHash,omitempty"` // FullHashDetails: Unordered list. A repeated field identifying the // details relevant to this full hash. FullHashDetails []*GoogleSecuritySafebrowsingV5FullHashFullHashDetail `json:"fullHashDetails,omitempty"` // ForceSendFields is a list of field names (e.g. "FullHash") to // unconditionally include in API requests. By default, fields with // empty or default values are omitted from API requests. However, any // non-pointer, non-interface field appearing in ForceSendFields will be // sent to the server regardless of whether the field is empty or not. // This may be used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "FullHash") to include in // API requests with the JSON null value. By default, fields with empty // values are omitted from API requests. However, any field with an // empty value appearing in NullFields will be sent to the server as // null. It is an error if a field in this list has a non-empty value. // This may be used to include null fields in Patch requests. NullFields []string `json:"-"` }
GoogleSecuritySafebrowsingV5FullHash: The full hash identified with one or more matches.
func (*GoogleSecuritySafebrowsingV5FullHash) MarshalJSON ¶
func (s *GoogleSecuritySafebrowsingV5FullHash) MarshalJSON() ([]byte, error)
type GoogleSecuritySafebrowsingV5FullHashFullHashDetail ¶
type GoogleSecuritySafebrowsingV5FullHashFullHashDetail struct { // Attributes: Unordered list. Additional attributes about those full // hashes. This may be empty. // // Possible values: // "THREAT_ATTRIBUTE_UNSPECIFIED" - Unknown. // "CANARY" - Indicates that the threat_type should not be used for // enforcement. // "FRAME_ONLY" - Indicates that the threat_type should only be used // for enforcement on frames. Attributes []string `json:"attributes,omitempty"` // ThreatType: The type of threat. This field will never be empty. // // Possible values: // "THREAT_TYPE_UNSPECIFIED" - Unknown. // "MALWARE" - Malware threat type. // "SOCIAL_ENGINEERING" - Social engineering threat type. // "UNWANTED_SOFTWARE" - Unwanted software threat type. // "POTENTIALLY_HARMFUL_APPLICATION" - Potentially harmful application // threat type. ThreatType string `json:"threatType,omitempty"` // ForceSendFields is a list of field names (e.g. "Attributes") to // unconditionally include in API requests. By default, fields with // empty or default values are omitted from API requests. However, any // non-pointer, non-interface field appearing in ForceSendFields will be // sent to the server regardless of whether the field is empty or not. // This may be used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "Attributes") to include in // API requests with the JSON null value. By default, fields with empty // values are omitted from API requests. However, any field with an // empty value appearing in NullFields will be sent to the server as // null. It is an error if a field in this list has a non-empty value. // This may be used to include null fields in Patch requests. NullFields []string `json:"-"` }
GoogleSecuritySafebrowsingV5FullHashFullHashDetail: Details about a matching full hash. An important note about forward compatibility: new threat types and threat attributes may be added by the server at any time; those additions are considered minor version changes. It is Google's policy not to expose minor version numbers in APIs (see https://cloud.google.com/apis/design/versioning), so clients MUST be prepared to receive FullHashDetail messages containing ThreatType enum values or ThreatAttribute enum values that are considered invalid by the client. Therefore, it is the client's responsibility to check for the validity of all ThreatType and ThreatAttribute enum values; if any value is considered invalid, the client MUST disregard the entire FullHashDetail message.
func (*GoogleSecuritySafebrowsingV5FullHashFullHashDetail) MarshalJSON ¶
func (s *GoogleSecuritySafebrowsingV5FullHashFullHashDetail) MarshalJSON() ([]byte, error)
type GoogleSecuritySafebrowsingV5SearchHashesResponse ¶
type GoogleSecuritySafebrowsingV5SearchHashesResponse struct { // CacheDuration: The client-side cache duration. The client shall add // this duration to the current time to determine the expiration time. // The expiration time then applies to every hash prefix queried by the // client in the request, regardless of how many full hashes are // returned in the response. Even if the server returns no full hashes // for a particular hash prefix, this fact should also be cached by the // client. Important: the client must not assume that the server will // return the same cache duration for all responses. The server may // choose different cache durations for different responses depending on // the situation. CacheDuration string `json:"cacheDuration,omitempty"` // FullHashes: Unordered list. The unordered list of full hashes found. FullHashes []*GoogleSecuritySafebrowsingV5FullHash `json:"fullHashes,omitempty"` // ServerResponse contains the HTTP response code and headers from the // server. googleapi.ServerResponse `json:"-"` // ForceSendFields is a list of field names (e.g. "CacheDuration") to // unconditionally include in API requests. By default, fields with // empty or default values are omitted from API requests. However, any // non-pointer, non-interface field appearing in ForceSendFields will be // sent to the server regardless of whether the field is empty or not. // This may be used to include empty fields in Patch requests. ForceSendFields []string `json:"-"` // NullFields is a list of field names (e.g. "CacheDuration") to include // in API requests with the JSON null value. By default, fields with // empty values are omitted from API requests. However, any field with // an empty value appearing in NullFields will be sent to the server as // null. It is an error if a field in this list has a non-empty value. // This may be used to include null fields in Patch requests. NullFields []string `json:"-"` }
GoogleSecuritySafebrowsingV5SearchHashesResponse: The response returned after searching threat hashes. Note that if nothing is found, the server will return an OK status (HTTP status code 200) with the `full_hashes` field empty, rather than returning a NOT_FOUND status (HTTP status code 404).
func (*GoogleSecuritySafebrowsingV5SearchHashesResponse) MarshalJSON ¶
func (s *GoogleSecuritySafebrowsingV5SearchHashesResponse) MarshalJSON() ([]byte, error)
type HashesSearchCall ¶
type HashesSearchCall struct {
// contains filtered or unexported fields
}
func (*HashesSearchCall) Context ¶
func (c *HashesSearchCall) Context(ctx context.Context) *HashesSearchCall
Context sets the context to be used in this call's Do method. Any pending HTTP request will be aborted if the provided context is canceled.
func (*HashesSearchCall) Do ¶
func (c *HashesSearchCall) Do(opts ...googleapi.CallOption) (*GoogleSecuritySafebrowsingV5SearchHashesResponse, error)
Do executes the "safebrowsing.hashes.search" call. Exactly one of *GoogleSecuritySafebrowsingV5SearchHashesResponse or error will be non-nil. Any non-2xx status code is an error. Response headers are in either *GoogleSecuritySafebrowsingV5SearchHashesResponse.ServerResponse.Heade r or (if a response was returned at all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check whether the returned error was because http.StatusNotModified was returned.
func (*HashesSearchCall) Fields ¶
func (c *HashesSearchCall) Fields(s ...googleapi.Field) *HashesSearchCall
Fields allows partial responses to be retrieved. See https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more information.
func (*HashesSearchCall) HashPrefixes ¶
func (c *HashesSearchCall) HashPrefixes(hashPrefixes ...string) *HashesSearchCall
HashPrefixes sets the optional parameter "hashPrefixes": Required. The hash prefixes to be looked up.
func (*HashesSearchCall) Header ¶
func (c *HashesSearchCall) Header() http.Header
Header returns an http.Header that can be modified by the caller to add HTTP headers to the request.
func (*HashesSearchCall) IfNoneMatch ¶
func (c *HashesSearchCall) IfNoneMatch(entityTag string) *HashesSearchCall
IfNoneMatch sets the optional parameter which makes the operation fail if the object's ETag matches the given value. This is useful for getting updates only after the object has changed since the last request. Use googleapi.IsNotModified to check whether the response error from Do is the result of In-None-Match.
type HashesService ¶
type HashesService struct {
// contains filtered or unexported fields
}
func NewHashesService ¶
func NewHashesService(s *Service) *HashesService
func (*HashesService) Search ¶
func (r *HashesService) Search() *HashesSearchCall
Search: Search for full hashes matching the specified prefixes. This is a custom method as described by guidance at https://google.aip.dev/136
type Service ¶
type Service struct { BasePath string // API endpoint base URL UserAgent string // optional additional User-Agent fragment Hashes *HashesService // contains filtered or unexported fields }
func New
deprecated
New creates a new Service. It uses the provided http.Client for requests.
Deprecated: please use NewService instead. To provide a custom HTTP client, use option.WithHTTPClient. If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
func NewService ¶
NewService creates a new Service.