infinigo

package module
v0.0.0-...-e9667bc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2016 License: MIT Imports: 13 Imported by: 2

README

infinigo

CylanceV Infinity public API implementation using Golang

Documentation

Overview

Package infinigo is a library implementing the CylanceV Infinity API v2.0

Written by Slavik Markovich at Demisto

Index

Constants

View Source
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

View Source
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

func SetErrorLog(logger *log.Logger) func(*Client) error

SetErrorLog sets the logger for critical messages. It is nil by default.

func SetTraceLog

func SetTraceLog(logger *log.Logger) func(*Client) error

SetTraceLog specifies the logger to use for output of trace messages like HTTP requests and responses. 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 Common

type Common struct {
	Status     string  `json:"status"`     // Status from Infinity API
	StatusCode float32 `json:"statuscode"` // StatusCode from Infinity API
	Error      string  `json:"error"`      // Error reason for Infinity API error
}

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

func (*Error) Error

func (e *Error) Error() string

type OptionFunc

type OptionFunc func(*Client) error

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

func SetURL

func SetURL(rawurl string) OptionFunc

SetURL defines the URL endpoint for Infinity

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
}

Directories

Path Synopsis
cmd
infcli
Command line interface to CylanceV Infinity API
Command line interface to CylanceV Infinity API

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL