Documentation
¶
Index ¶
- func CheckResponse(r *http.Response) error
- func NewTenableError(resp *Response, httpError error) error
- type APIKeyAuthTransport
- type Analysis
- type AnalysisBody
- type AnalysisFilter
- type AnalysisQuery
- type AnalysisResponse
- type AnalysisResultSet
- type AnalysisService
- type AuthenticationService
- type Client
- func (c *Client) Do(req *http.Request, v interface{}) (*Response, error)
- func (c *Client) NewRawRequest(method, urlStr string, body io.Reader) (*http.Request, error)
- func (c *Client) NewRawRequestWithContext(ctx context.Context, method, urlStr string, body io.Reader) (*http.Request, error)
- func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)
- func (c *Client) NewRequestWithContext(ctx context.Context, method, urlStr string, body interface{}) (*http.Request, error)
- type CurrentUser
- type CurrentUserResponse
- type CurrentUserService
- type Error
- type Family
- type Organization
- type PreferenceItem
- type Repository
- type RepositoryResponse
- type RepositoryService
- type Response
- type Role
- type Severity
- type User
- type UserPrefItem
- type VPRContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckResponse ¶
CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. The caller is responsible to analyze the response body. The body can contain JSON (if the error is intended) or xml (sometimes Tenable just failes).
func NewTenableError ¶
NewTenableError creates a new Tenable Error
Types ¶
type APIKeyAuthTransport ¶
type APIKeyAuthTransport struct { APIKey string APISecret string // Transport is the underlying HTTP transport to use when making requests. // It will default to http.DefaultTransport if nil. Transport http.RoundTripper }
APIKeyAuthTransport is an http.RoundTripper that authenticates all requests using HTTP APIKey Authentication with the provided username and password.
func (*APIKeyAuthTransport) Client ¶
func (t *APIKeyAuthTransport) Client() *http.Client
Client returns an *http.Client that makes requests that are authenticated using HTTP APIKey Authentication. This is a nice little bit of sugar so we can just get the client instead of creating the client in the calling code. If it's necessary to send more information on client init, the calling code can always skip this and set the transport itself.
type Analysis ¶
type Analysis struct { PluginID string `json:"pluginID"` Severity Severity `json:"severity,omitempty"` VPRScore string `json:"vprScore,omitempty"` VPRContext interface{} `json:"vprContext,omitempty"` IP string `json:"ip,omitempty"` UUID string `json:"uuid,omitempty"` Port string `json:"port,omitempty"` Protocol string `json:"protocol,omitempty"` Name string `json:"name,omitempty"` DNSName string `json:"dnsName,omitempty"` MACAddress string `json:"macAddress,omitempty"` NetBiosName string `json:"netBiosName,omitempty"` Uniqueness string `json:"uniqueness,omitempty"` HostUniqueness string `json:"hostUniqueness,omitempty"` Family Family `json:"family,omitempty"` Repository Repository `json:"repository,omitempty"` PluginInfo string `json:"pluginInfo,omitempty"` }
type AnalysisBody ¶
type AnalysisBody struct { Query AnalysisQuery `json:"query"` SourceType string `json:"sourceType"` Columns interface{} `json:"columns"` Type string `json:"type"` }
type AnalysisFilter ¶
type AnalysisQuery ¶
type AnalysisQuery struct { Name string `json:"name"` Description string `json:"description"` Context string `json:"context"` Status int64 `json:"status"` CreatedTime int64 `json:"createdTime"` ModifiedTime int64 `json:"modifiedTime"` Groups []string `json:"groups"` Type string `json:"type"` Tool string `json:"tool"` SourceType string `json:"sourceType"` StartOffset int64 `json:"startOffset"` EndOffset int64 `json:"endOffset"` Filters []AnalysisFilter `json:"filters"` VulnTool string `json:"vulnTool"` }
type AnalysisResponse ¶
type AnalysisResponse struct { Type string `json:",type,omitempty"` Response AnalysisResultSet `json:"response,omitempty"` ErrorCode int `json:"error_code,omitempty"` ErrorMsg string `json:"error_msg,omitempty"` Warnings []string `json:"warnings,omitempty"` Timestamp int `json:"timestamp,omitempty"` }
Analysis represents a Tenable user.
type AnalysisResultSet ¶
type AnalysisResultSet struct { TotalRecords string `json:"totalRecords,omitempty"` ReturnedRecords int64 `json:"returnedRecords,omitempty"` StartOffset string `json:"startOffset,omitempty"` EndOffset string `json:"endOffset,omitempty"` MatchingDataElementCount string `json:"MatchingDataElementCount,omitempty"` Results []Analysis `json:"results,omitempty"` }
type AnalysisService ¶
type AnalysisService struct {
// contains filtered or unexported fields
}
AnalysisService handles users for the Tenable instance / API.
Tenable API docs: https://docs.tenable.com/tenablesc/api/Analysis.htm
func (*AnalysisService) Post ¶
func (s *AnalysisService) Post(body interface{}) (*AnalysisResponse, *Response, error)
Get wraps PostWithContext using the background context.
func (*AnalysisService) PostWithContext ¶
func (s *AnalysisService) PostWithContext(ctx context.Context, body interface{}) (*AnalysisResponse, *Response, error)
PostWithContext gets user info from Tenable using its Account Id
Tenable API docs: https://docs.tenable.com/tenablesc/api/Analysis.htm
type AuthenticationService ¶
type AuthenticationService struct {
// contains filtered or unexported fields
}
AuthenticationService handles users for the Tenable instance / API.
Tenable API docs: https://docs.tenable.com/tenablesc/api/index.htm
func (*AuthenticationService) Authenticated ¶
func (s *AuthenticationService) Authenticated() bool
Authenticated reports if the current Client has authentication details for Jira
func (*AuthenticationService) SetAPIKeyAuth
deprecated
func (s *AuthenticationService) SetAPIKeyAuth(api_key, api_secret string)
SetAPIKeyAuth sets api_key and api_secret for the APIKey auth against the Jira instance.
Deprecated: Use APIKeyAuthTransport instead
type Client ¶
type Client struct { // Services used for talking to different parts of the Tenable API. Analysis *AnalysisService Authentication *AuthenticationService CurrentUser *CurrentUserService Repository *RepositoryService // contains filtered or unexported fields }
A Client manages communication with the Tenable API.
func NewClient ¶
NewClient returns a new Tenable API client. If a nil httpClient is provided, http.DefaultClient will be used. To use API methods which require authentication you can follow the preferred solution and provide an http.Client that will perform the authentication for you with OAuth and HTTP Basic (such as that provided by the golang.org/x/oauth2 library). As an alternative you can use Session Cookie based authentication provided by this package as well. See https://docs.tenable.com/tenablesc/api_best_practices/Content/ScApiBestPractices/APIKeyAuthorization.htm baseURL is the HTTP endpoint of your Tenable instance and should always be specified with a trailing slash.
func (*Client) Do ¶
Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.
func (*Client) NewRawRequest ¶
NewRawRequest wraps NewRawRequestWithContext using the background context.
func (*Client) NewRawRequestWithContext ¶
func (c *Client) NewRawRequestWithContext(ctx context.Context, method, urlStr string, body io.Reader) (*http.Request, error)
NewRawRequestWithContext creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the baseURL of the Client. Allows using an optional native io.Reader for sourcing the request body.
func (*Client) NewRequest ¶
NewRequest wraps NewRequestWithContext using the background context.
func (*Client) NewRequestWithContext ¶
func (c *Client) NewRequestWithContext(ctx context.Context, method, urlStr string, body interface{}) (*http.Request, error)
NewRequestWithContext creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the baseURL of the Client. If specified, the value pointed to by body is JSON encoded and included as the request body.
type CurrentUser ¶
type CurrentUser struct {
User
}
CurrentUserResponse represents a Tenable user response
type CurrentUserResponse ¶
type CurrentUserResponse struct { // "type": "regular", Type string // "response": { Response CurrentUser `json:"response"` // "error_code": 0, ErrorCode int `json:"error_code"` // "error_msg": "", ErrorMsg string `json:"error_msg"` // "warnings": [], Warnings []string // "timestamp": 1657818772 Timestamp int }
CurrentUser represents a Tenable user.
type CurrentUserService ¶
type CurrentUserService struct {
// contains filtered or unexported fields
}
CurrentUserService handles users for the Tenable instance / API.
Tenable API docs: https://docs.tenable.com/tenablesc/api/CurrentUser.htm
func (*CurrentUserService) Get ¶
func (s *CurrentUserService) Get() (*CurrentUser, *Response, error)
Get wraps GetWithContext using the background context.
func (*CurrentUserService) GetWithContext ¶
func (s *CurrentUserService) GetWithContext(ctx context.Context) (*CurrentUser, *Response, error)
GetWithContext gets user info from Tenable using its Account Id
Tenable API docs: https://docs.tenable.com/tenablesc/api/CurrentUser.md
type Error ¶
type Error struct { HTTPError error ErrorMessages []string `json:"errorMessages"` Errors map[string]string `json:"errors"` }
Error message from Tenable
type Organization ¶
type PreferenceItem ¶
type Repository ¶
type RepositoryResponse ¶
type RepositoryResponse struct { // "type": "regular", Type string // "response": { Response []Repository `json:"response"` // "error_code": 0, ErrorCode int `json:"error_code"` // "error_msg": "", ErrorMsg string `json:"error_msg"` // "warnings": [], Warnings []string // "timestamp": 1657818772 Timestamp int }
Repository represents a Tenable user.
type RepositoryService ¶
type RepositoryService struct {
// contains filtered or unexported fields
}
RepositoryService handles users for the Tenable instance / API.
Tenable API docs: https://docs.tenable.com/tenablesc/api/Repository.htm
func (*RepositoryService) Get ¶
func (s *RepositoryService) Get(requestType, fields string) ([]Repository, *Response, error)
Get wraps GetWithContext using the background context.
func (*RepositoryService) GetWithContext ¶
func (s *RepositoryService) GetWithContext(ctx context.Context, requestType, fields string) ([]Repository, *Response, error)
GetWithContext gets user info from Tenable using its Account Id
Tenable API docs: https://docs.tenable.com/tenablesc/api/Repository.htm
type Response ¶
Response represents Tenable API response. It wraps http.Response returned from API and provides information about paging.
type User ¶
type User struct { ID interface{} `json:"id"` Status string `json:"status,omitempty"` // "0", Username string `json:"username,omitempty"` // "admin", LDAPUsername string `json:"ldapUsername,omitempty"` // "", Firstname string `json:"firstname,omitempty"` // "Admin", Lastname string `json:"lastname,omitempty"` // "User", Title string `json:"title,omitempty"` // "Application Administrator", Email string `json:"email,omitempty"` // "", Address string `json:"address,omitempty"` // "", City string `json:"city,omitempty"` // "", State string `json:"state,omitempty"` // "", Country string `json:"country,omitempty"` // "", Phone string `json:"phone,omitempty"` // "", Fax string `json:"fax,omitempty"` // "", CreatedTime string `json:"createdTime,omitempty"` // "1432921843", ModifiedTime string `json:"modifiedTime,omitempty"` // "1453473716", LastLogin string `json:"lastLogin,omitempty"` // "1454350174", LastLoginIP string `json:"lastLoginIP,omitempty"` // "172.20.0.0", MustChangePassword string `json:"mustChangePassword,omitempty"` // "false", Locked string `json:"locked,omitempty"` // "false", FailedLogin string `json:"failedLogins,omitempty"` // "0", AuthType string `json:"authType,omitempty"` // "tns", Fingerprint string `json:"fingerprint,omitempty"` // null, Password string `json:"password,omitempty"` // "SET", Preferences []PreferenceItem Organization Organization OrgName string `json:"orgName,omitempty"` UserPrefs []UserPrefItem UUID string `json:"uuid,omitempty"` }