Documentation ¶
Overview ¶
Package infinigo is a library implementing the CylanceV Infinity API v2.0
Written by Slavik Markovich at Demisto
Index ¶
- Constants
- Variables
- func SetErrorLog(logger *log.Logger) func(*Client) error
- func SetTraceLog(logger *log.Logger) func(*Client) error
- type Client
- func (c *Client) Query(classifiers string, hash ...string) (resp map[string]QueryResponse, err error)
- func (c *Client) Upload(confirmCode string, data io.Reader) (resp map[string]UploadResponse, err error)
- func (c *Client) UploadFile(confirmCode, path string) (resp map[string]UploadResponse, err error)
- type Common
- type Error
- type OptionFunc
- type QueryResponse
- type UploadResponse
Constants ¶
const ( DefaultURL = "https://api.cylance.com/apiv2/" // DefaultURL is the URL for the API endpoint AuthHeader = "X-IAUTH" // AuthHeader for the API key ContentTypeHeader = "Content-Type" // Header for Content-Type ContentLengthHeader = "Content-Length" // Header for Content-Length GzipContentType = "application/xgzip" )
Variables ¶
var ( // ErrMissingCredentials is returned when API key is missing ErrMissingCredentials = &Error{ID: "missing_credentials", Details: "You must provide the Infinity API key"} )
Functions ¶
func SetErrorLog ¶
SetErrorLog sets the logger for critical messages. It is nil by default.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client interacts with the services provided by Infinity.
func New ¶
func New(options ...OptionFunc) (*Client, error)
New creates a new CylanceV Infinity client.
The caller can configure the new client by passing configuration options to the func.
Example:
client, err := infinigo.New( infinigo.SetKey("some key"), infinigo.SetUrl("https://some.url.com:port/"), infinigo.SetErrorLog(log.New(os.Stderr, "Cylance: ", log.Lshortfile))
If no URL is configured, Client uses DefaultURL by default.
If no HttpClient is configured, then http.DefaultClient is used. You can use your own http.Client with some http.Transport for advanced scenarios.
An error is also returned when some configuration option is invalid.
func (*Client) Query ¶
func (c *Client) Query(classifiers string, hash ...string) (resp map[string]QueryResponse, err error)
Query the Infinity API for a given list of endpoints If classifier is not provided, "all" will be selected. Options are none, ml, industry, human, all. Hashes can be any MD5, SHA1 and SHA256
func (*Client) Upload ¶
func (c *Client) Upload(confirmCode string, data io.Reader) (resp map[string]UploadResponse, err error)
Upload a file to Infinity API
func (*Client) UploadFile ¶
func (c *Client) UploadFile(confirmCode, path string) (resp map[string]UploadResponse, err error)
UploadFile to the Infinity API
type Error ¶
type Error struct { ID string `json:"id"` // ID of the error Details string `json:"details"` // Details of the error }
Error structs are returned from this library for known error conditions
type OptionFunc ¶
OptionFunc is a function that configures a Client. It is used in New
func SetHTTPClient ¶
func SetHTTPClient(httpClient *http.Client) OptionFunc
SetHTTPClient can be used to specify the http.Client to use when making HTTP requests to Infinity API.
func SetKey ¶
func SetKey(key string) OptionFunc
SetKey sets the Infinity API key To receive a key, please contact support@cylance.com
type QueryResponse ¶
type QueryResponse struct { Common GeneralScore float32 `json:"generalscore"` // GeneralScore of the requested hash ConfirmCode string `json:"confirmcode"` // If a file is requested to provide answer Classifiers map[string]float32 `json:"classifiers"` // If classifiers are requested, provide a score per classifier }
QueryResponse for the query API endpoint
type UploadResponse ¶
type UploadResponse struct {
Common
}