wallarm

package module
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2021 License: MIT Imports: 15 Imported by: 1

README

wallarm-go

build PkgGoDev codecov Go Report Card

Table of Contents

Note: This library is in active development and highly suggested to use carefully.

A Go library for interacting with Wallarm API. This library allows you to:

  • Manage applications
  • Manage nodes
  • Manage integrations
  • Manage triggers
  • Manage users
  • Manage the blacklist
  • Switch the WAF/Scanner/Active Threat Verification modes
  • Inquire found vulnerabilities

Install

You need a working Go environment

go get github.com/416e64726579/wallarm-go

Getting Started

The sample code could be similar

package main

import (
	"log"
	"net/http"
	"os"

	wallarm "github.com/416e64726579/wallarm-go"
)

func main() {

	wapiHost, exist := os.LookupEnv("WALLARM_API_HOST")
	if !exist {
		wapiHost = "https://api.wallarm.com"
	}
	wapiUUID, exist := os.LookupEnv("WALLARM_API_UUID")
	if !exist {
		log.Fatal("ENV variable WALLARM_API_UUID is not present")
	}
	wapiSecret, exist := os.LookupEnv("WALLARM_API_SECRET")
	if !exist {
		log.Fatal("ENV variable WALLARM_API_SECRET is not present")
	}

	authHeaders := make(http.Header)
	authHeaders.Add("X-WallarmAPI-UUID", wapiUUID)
	authHeaders.Add("X-WallarmAPI-Secret", wapiSecret)

	// Construct a new API object
	api, err := wallarm.New(wallarm.UsingBaseURL(wapiHost), wallarm.Headers(authHeaders))
	if err != nil {
		log.Print(err)
	}

	// Fetch user details
	u, err := api.UserDetails()
	if err != nil {
		log.Print(err)
	}
	// Print user specific data
	log.Println(u.Body)

	// Change global WAF mode to monitoring
	mode := wallarm.ClientUpdate{
		Filter: &wallarm.ClientFilter{
			ID: 1,
		},
		Fields: &wallarm.ClientFields{
			Mode: "monitoring",
		},
	}
	c, err := api.ClientUpdate(&mode)
	if err != nil {
		log.Print(err)
	}
	// Print client data
	log.Println(c)

	// Create a trigger when the number of attacks more than 1000 in 10 minutes
	filter := wallarm.TriggerFilters{
		ID:       "ip_address",
		Operator: "eq",
		Values:   []interface{}{"2.2.2.2"},
	}

	var filters []wallarm.TriggerFilters
	filters = append(filters, filter)

	action := wallarm.TriggerActions{
		ID: "send_notification",
		Params: wallarm.TriggerActionParams{
			IntegrationIds: []int{5},
		},
	}

	var actions []wallarm.TriggerActions
	actions = append(actions, action)

	triggerBody := wallarm.TriggerCreate{
		Trigger: &wallarm.TriggerParam{
			Name:       "New Terraform Trigger Telegram",
			Comment:    "This is a description set by Terraform",
			TemplateID: "attacks_exceeded",
			Enabled:    true,
			Filters:    &filters,
			Actions:    &actions,
		},
	}

	triggerResp, err := api.TriggerCreate(&triggerBody, 1)
	if err != nil {
		log.Print(err)
	}
	// Print trigger metadata
	log.Println(triggerResp)
}

License

MIT licensed

Documentation

Overview

Package wallarm implements the Wallarm v2 API.

Index

Constants

View Source
const (
	// Version is the client version
	Version = "0.0.14"
)

Variables

View Source
var ErrExistingResource = errors.New("This resource has already been created earlier")

ErrExistingResource is returned when resource was created other than Terrafom ways - directly via the API.

View Source
var ErrInvalidCredentials = errors.New("Credentials are not set. Specify UUID and Secret")

ErrInvalidCredentials is raised when not all the credentials are presented.

Functions

func Contains added in v0.0.4

func Contains(a interface{}, x interface{}) bool

Contains wraps methods (for string and int) to check if List contains the element.

Types

type API

API holds the configuration for the current API client. A client should not be modified concurrently.

func New

func New(opts ...Option) (API, error)

New creates a new Wallarm API client.

type Action

type Action interface {
	HintRead(hintBody *HintRead) (*HintReadResp, error)
	RuleRead(ruleBody *ActionRead) (*ActionFetch, error)
	HintCreate(ruleBody *ActionCreate) (*ActionCreateResp, error)
	RuleDelete(actionID int) error
	HintDelete(hintbody *HintDelete) error
}

Action contains operations available on Action resource

type ActionBody

type ActionBody struct {
	ID           int             `json:"id"`
	ActionID     int             `json:"actionid"`
	Clientid     int             `json:"clientid"`
	Action       []ActionDetails `json:"action"`
	CreateTime   int             `json:"create_time"`
	CreateUserid int             `json:"create_userid"`
	Validated    bool            `json:"validated"`
	System       bool            `json:"system"`
	RegexID      interface{}     `json:"regex_id"`
	UpdatedAt    int             `json:"updated_at"`
	Type         string          `json:"type"`
	Enabled      bool            `json:"enabled"`
	Mode         string          `json:"mode"`
	Regex        string          `json:"regex"`
	Point        []interface{}   `json:"point"`
	AttackType   string          `json:"attack_type"`
	Rules        []string        `json:"rules"`
	// Headers for the Set Response Headers Rule
	// are defined by these two parameters.
	Name   string        `json:"name"`
	Values []interface{} `json:"values"`
}

ActionBody is an inner body for the Action and Hint responses.

type ActionCreate

type ActionCreate struct {
	Type       string              `json:"type"`
	Action     *[]ActionDetails    `json:"action,omitempty"`
	Clientid   int                 `json:"clientid,omitempty"`
	Validated  bool                `json:"validated"`
	Point      TwoDimensionalSlice `json:"point,omitempty"`
	Rules      []string            `json:"rules,omitempty"`
	AttackType string              `json:"attack_type,omitempty"`
	Mode       string              `json:"mode,omitempty"`
	Counter    string              `json:"counter,omitempty"`
	Regex      string              `json:"regex,omitempty"`
	RegexID    int                 `json:"regex_id,omitempty"`
	Enabled    *bool               `json:"enabled,omitempty"`
	Name       string              `json:"name,omitempty"`
	Values     []string            `json:"values,omitempty"`
	Comment    string              `json:"comment,omitempty"`
}

ActionCreate is a creation skeleton for the Rule.

type ActionCreateResp

type ActionCreateResp struct {
	Status int         `json:"status"`
	Body   *ActionBody `json:"body"`
}

ActionCreateResp is the response of just created Rule.

type ActionDetails added in v0.0.6

type ActionDetails struct {
	Type  string        `json:"type,omitempty"`
	Point []interface{} `json:"point,omitempty"`
	Value interface{}   `json:"value,omitempty"`
}

ActionDetails defines the Action of how to parse the request. Point represents a part of the request where the condition should be satisfied. ActionDetails is used to define the particular assets of the Action field.

type ActionFetch added in v0.0.7

type ActionFetch struct {
	Status int `json:"status"`
	Body   []struct {
		ID                int           `json:"id"`
		Clientid          int           `json:"clientid"`
		Name              interface{}   `json:"name"`
		Conditions        []interface{} `json:"conditions"`
		Hints             int           `json:"hints"`
		GroupedHintsCount int           `json:"grouped_hints_count"`
		UpdatedAt         int           `json:"updated_at"`
	} `json:"body"`
}

ActionFetch is a response struct which portrays all conditions set for requests of filtered type.

type ActionFilter

type ActionFilter struct {
	ID         []int               `json:"id,omitempty"`
	NotID      []int               `json:"!id,omitempty"`
	Clientid   []int               `json:"clientid,omitempty"`
	HintsCount TwoDimensionalSlice `json:"hints_count,omitempty"`
	HintType   []string            `json:"hint_type,omitempty"`
}

ActionFilter is the specific filter for getting the rules. This is an inner structure.

type ActionRead

type ActionRead struct {
	Filter *ActionFilter `json:"filter"`
	Limit  int           `json:"limit"`
	Offset int           `json:"offset"`
}

ActionRead is used as a filter to fetch the rules.

type AppCreate

type AppCreate struct {
	*AppFilter
	Name string `json:"name"`
}

AppCreate is a request body to set ID and Name for the App.

type AppDelete

type AppDelete struct {
	Filter *AppFilter `json:"filter"`
}

AppDelete is a root object for deleting filter.

type AppFilter added in v0.0.7

type AppFilter struct {
	ID       int `json:"id"`
	Clientid int `json:"clientid"`
}

AppFilter is used to filter applications by ID and ClientID.

type AppRead

type AppRead struct {
	Limit  int            `json:"limit"`
	Offset int            `json:"offset"`
	Filter *AppReadFilter `json:"filter"`
}

AppRead is a request body for filtration of the App.

type AppReadFilter

type AppReadFilter struct {
	Clientid []int `json:"clientid"`
}

AppReadFilter is a filter by Client ID.

type AppReadResp

type AppReadResp struct {
	Status int `json:"status"`
	Body   []struct {
		*AppCreate
		Deleted bool `json:"deleted"`
	} `json:"body"`
}

AppReadResp is a response with parameters of the application.

type AppUpdate

type AppUpdate struct {
	Filter *AppUpdateFilter `json:"filter"`
	Fields *AppUpdateFields `json:"fields"`
}

AppUpdate is a request body to update Fields in the existing Application defined by Filter.

type AppUpdateFields

type AppUpdateFields struct {
	Name string `json:"name"`
}

AppUpdateFields is used as identificator what should be changed in Application. Only Name is supported.

type AppUpdateFilter

type AppUpdateFilter struct {
	*AppReadFilter
	ID int `json:"id"`
}

AppUpdateFilter is used as a filter with ID of the Application.

type Application added in v0.0.15

type Application interface {
	AppRead(appBody *AppRead) (*AppReadResp, error)
	AppCreate(appBody *AppCreate) error
	AppDelete(appBody *AppDelete) error
	AppUpdate(appBody *AppUpdate) error
}

Application contains operations available on Application resource

type Blacklist added in v0.0.15

type Blacklist interface {
	BlacklistRead(clientID int) ([]BlacklistRead, error)
	BlacklistCreate(blacklistBody *BlacklistCreate) error
	BlacklistDelete(clientID int, ids []int) error
}

Blacklist contains operations available on Blacklist resource

type BlacklistCreate

type BlacklistCreate struct {
	Bulks *[]Bulk `json:"bulk"`
}

BlacklistCreate is a root object to fill the blacklist

type BlacklistRead

type BlacklistRead struct {
	Body struct {
		Result            string      `json:"result"`
		Total             int         `json:"total"`
		Continuation      interface{} `json:"continuation"`
		EventContinuation string      `json:"event_continuation"`
		Objects           []struct {
			ID           int           `json:"id"`
			Clientid     int           `json:"clientid"`
			Country      string        `json:"country"`
			Poolid       int           `json:"poolid"`
			StillAttacks bool          `json:"still_attacks"`
			IP           string        `json:"ip"`
			ExpireAt     int           `json:"expire_at"`
			Tags         []interface{} `json:"tags"`
			BlockedAt    int           `json:"blocked_at"`
			Reason       string        `json:"reason"`
			Tor          interface{}   `json:"tor"`
			Datacenter   interface{}   `json:"datacenter"`
			ProxyType    interface{}   `json:"proxy_type"`
		} `json:"objects"`
	} `json:"body"`
}

BlacklistRead is used to unmarshal blacklist Read function

type Bulk

type Bulk struct {
	IP       string `json:"ip"`
	ExpireAt int    `json:"expire_at"`
	Reason   string `json:"reason"`
	Poolid   int    `json:"poolid"`
	Clientid int    `json:"clientid"`
}

Bulk is used to define IP address, applications, time and reason

type Client added in v0.0.15

type Client interface {
	ClientUpdate(clientBody *ClientUpdate) (*ClientInfo, error)
	ClientRead(clientBody *ClientRead) (*ClientInfo, error)
}

Client contains operations available on Client resource

type ClientFields

type ClientFields struct {
	Mode                string `json:"mode,omitempty"`
	ScannerMode         string `json:"scanner_mode,omitempty"`
	AttackRecheckerMode string `json:"attack_rechecker_mode,omitempty"`
}

ClientFields defines fields which are subject to update.

type ClientFilter

type ClientFilter struct {
	ID int `json:"id"`
}

ClientFilter is used for filtration. ID is a Client ID entity.

type ClientInfo added in v0.0.6

type ClientInfo struct {
	Status int `json:"status"`
	Body   []struct {
		ClientFilter
		Name             string   `json:"name"`
		Components       []string `json:"components"`
		VulnPrefix       string   `json:"vuln_prefix"`
		SupportPlan      string   `json:"support_plan"`
		DateFormat       string   `json:"date_format"`
		Mode             string   `json:"mode"`
		BlockingType     string   `json:"blocking_type"`
		ScannerMode      string   `json:"scanner_mode"`
		QratorBlacklists bool     `json:"qrator_blacklists"`
		Notifications    struct {
			ReportDaily struct {
				Email     []interface{} `json:"email"`
				Telegram  []interface{} `json:"telegram"`
				Slack     []interface{} `json:"slack"`
				Splunk    []interface{} `json:"splunk"`
				PagerDuty []interface{} `json:"pager_duty"`
			} `json:"report_daily"`
			ReportWeekly struct {
				Email     []interface{} `json:"email"`
				Telegram  []interface{} `json:"telegram"`
				Slack     []interface{} `json:"slack"`
				Splunk    []interface{} `json:"splunk"`
				PagerDuty []interface{} `json:"pager_duty"`
			} `json:"report_weekly"`
			ReportMonthly struct {
				Email     []interface{} `json:"email"`
				Telegram  []interface{} `json:"telegram"`
				Slack     []interface{} `json:"slack"`
				Splunk    []interface{} `json:"splunk"`
				PagerDuty []interface{} `json:"pager_duty"`
			} `json:"report_monthly"`
			System struct {
				Email     []interface{} `json:"email"`
				Telegram  []interface{} `json:"telegram"`
				Slack     []interface{} `json:"slack"`
				Splunk    []interface{} `json:"splunk"`
				PagerDuty []interface{} `json:"pager_duty"`
			} `json:"system"`
			Vuln struct {
				Email     []interface{} `json:"email"`
				Telegram  []interface{} `json:"telegram"`
				Slack     []interface{} `json:"slack"`
				Splunk    []interface{} `json:"splunk"`
				PagerDuty []interface{} `json:"pager_duty"`
			} `json:"vuln"`
			Scope struct {
				Email     []interface{} `json:"email"`
				Telegram  []interface{} `json:"telegram"`
				Slack     []interface{} `json:"slack"`
				Splunk    []interface{} `json:"splunk"`
				PagerDuty []interface{} `json:"pager_duty"`
			} `json:"scope"`
		} `json:"notifications"`
		LastScan            interface{} `json:"last_scan"`
		ScannerCluster      string      `json:"scanner_cluster"`
		ScannerScopeCluster string      `json:"scanner_scope_cluster"`
		ScannerState        struct {
			LastScan      int         `json:"last_scan"`
			LastVuln      int         `json:"last_vuln"`
			LastVulnCheck interface{} `json:"last_vuln_check"`
			LastWapi      interface{} `json:"last_wapi"`
		} `json:"scanner_state"`
		Language            string `json:"language"`
		AttackRecheckerMode string `json:"attack_rechecker_mode"`
		VulnRecheckerMode   string `json:"vuln_rechecker_mode"`
		Validated           bool   `json:"validated"`
		Enabled             bool   `json:"enabled"`
		CreateAt            int    `json:"create_at"`
		Partnerid           int    `json:"partnerid"`
		CanEnableBlacklist  bool   `json:"can_enable_blacklist"`
		BlacklistDisabledAt int    `json:"blacklist_disabled_at"`
		HiddenVulns         bool   `json:"hidden_vulns"`
		ScannerPriority     string `json:"scanner_priority"`
	} `json:"body"`
}

ClientInfo is the response on the Client Read. It shows the common information about the client.

type ClientRead added in v0.0.6

type ClientRead struct {
	Filter *ClientReadFilter `json:"filter"`
	Limit  int               `json:"limit"`
	Offset int               `json:"offset"`
}

ClientRead is used for filtration of Client Info.

type ClientReadFilter added in v0.0.6

type ClientReadFilter struct {
	ClientFilter
	Enabled bool   `json:"enabled,omitempty"`
	Name    string `json:"name,omitempty"`
}

ClientReadFilter is the inner object for Filter.

type ClientUpdate added in v0.0.6

type ClientUpdate struct {
	Filter *ClientFilter `json:"filter"`
	Fields *ClientFields `json:"fields"`
}

ClientUpdate is a root object for updating.

type EmailIntegrationCreate

type EmailIntegrationCreate struct {
	Name     string               `json:"name,omitempty"`
	Active   bool                 `json:"active"`
	Target   []string             `json:"target,omitempty"`
	Events   *[]IntegrationEvents `json:"events,omitempty"`
	Type     string               `json:"type,omitempty"`
	Clientid int                  `json:"clientid,omitempty"`
}

EmailIntegrationCreate is a root object of `Create` action for the `email` integration. Temporary workaround (`Target` is a slice instead of string) to not check type many times. Then it will be changed to interface{} with type checking

type GetVulnFilter

type GetVulnFilter struct {
	Status string `json:"status"`
}

GetVulnFilter is used to filter the vulnerability status Possible values: "active", "closed", "falsepositive"

type GetVulnRead

type GetVulnRead struct {
	Filter    *GetVulnFilter `json:"filter"`
	Limit     int            `json:"limit"`
	Offset    int            `json:"offset"`
	OrderBy   string         `json:"order_by"`
	OrderDesc bool           `json:"order_desc"`
}

GetVulnRead is a root object for requesting vulnerabilities. Limit is a number between 0 - 1000 Offset is a number between 0 - 1000

type GetVulnReadResp

type GetVulnReadResp struct {
	Status int `json:"status"`
	Body   []struct {
		ValidateTime   int         `json:"validate_time"`
		InvalidateTime interface{} `json:"invalidate_time"`
		LastCheck      interface{} `json:"last_check"`
		Incidents      interface{} `json:"incidents"`
		ID             int         `json:"id"`
		Wid            string      `json:"wid"`
		Template       string      `json:"template"`
		Status         string      `json:"status"`
		Target         string      `json:"target"`
		Type           string      `json:"type"`
		Threat         int         `json:"threat"`
		Clientid       int         `json:"clientid"`
		TestrunID      interface{} `json:"testrun_id"`
		TicketStatus   interface{} `json:"ticket_status"`
		TicketHistory  []struct {
			Time    int         `json:"time"`
			Type    string      `json:"type"`
			Message string      `json:"message"`
			Link    interface{} `json:"link"`
		} `json:"ticket_history"`
		Method         string `json:"method"`
		Domain         string `json:"domain"`
		Path           string `json:"path"`
		Parameter      string `json:"parameter"`
		Title          string `json:"title"`
		Description    string `json:"description"`
		Additional     string `json:"additional"`
		ExploitExample string `json:"exploit_example"`
		Filter         []struct {
			Method    string `json:"method"`
			Domain    string `json:"domain"`
			Path      string `json:"path"`
			Parameter string `json:"parameter"`
		} `json:"filter"`
		Validated       bool        `json:"validated"`
		Hidden          bool        `json:"hidden"`
		DetectionMethod string      `json:"detection_method"`
		VulnRecheckType interface{} `json:"vuln_recheck_type"`
		TemplateParams  struct {
			Method         string `json:"method"`
			Domain         string `json:"domain"`
			Path           string `json:"path"`
			Parameter      string `json:"parameter"`
			ExploitExample string `json:"exploit_example"`
		} `json:"template_params,omitempty"`
	} `json:"body"`
}

GetVulnReadResp is the response on the inquiry of vulnerabilities by filter

type HintDelete

type HintDelete struct {
	Filter *HintDeleteFilter `json:"filter"`
}

HintDelete is used for removal of Rule by Hint ID.

type HintDeleteFilter

type HintDeleteFilter struct {
	Clientid []int `json:"clientid"`
	ID       int   `json:"id"`
}

HintDeleteFilter is used as a filter by Hint ID.

type HintFilter

type HintFilter struct {
	Clientid        []int    `json:"clientid,omitempty"`
	ActionID        []int    `json:"actionid,omitempty"`
	ID              []int    `json:"id,omitempty"`
	NotID           []int    `json:"!id,omitempty"`
	NotActionID     []int    `json:"!actionid,omitempty"`
	CreateUserid    []int    `json:"create_userid,omitempty"`
	NotCreateUserid []int    `json:"!create_userid,omitempty"`
	CreateTime      [][]int  `json:"create_time,omitempty"`
	NotCreateTime   [][]int  `json:"!create_time,omitempty"`
	System          bool     `json:"system,omitempty"`
	Type            []string `json:"type,omitempty"`
}

HintFilter is used as a filter by Action ID.

type HintRead

type HintRead struct {
	Filter    *HintFilter `json:"filter"`
	OrderBy   string      `json:"order_by"`
	OrderDesc bool        `json:"order_desc"`
	Limit     int         `json:"limit"`
	Offset    int         `json:"offset"`
}

HintRead is used to define whether action of the rule exists.

type HintReadResp

type HintReadResp struct {
	Status int           `json:"status"`
	Body   *[]ActionBody `json:"body"`
}

HintReadResp is the response of filtered rules by Action ID.

type Integration added in v0.0.15

type Integration interface {
	IntegrationCreate(integrationBody *IntegrationCreate) (*IntegrationCreateResp, error)
	IntegrationUpdate(integrationBody *IntegrationCreate, integrationID int) (*IntegrationCreateResp, error)
	IntegrationRead(clientID int, id int) (*IntegrationObject, error)
	IntegrationDelete(integrationID int) error
	IntegrationWithAPICreate(integrationBody *IntegrationWithAPICreate) (*IntegrationCreateResp, error)
	IntegrationWithAPIUpdate(integrationBody *IntegrationWithAPICreate, integrationID int) (*IntegrationCreateResp, error)
	EmailIntegrationCreate(emailBody *EmailIntegrationCreate) (*IntegrationCreateResp, error)
	EmailIntegrationUpdate(integrationBody *EmailIntegrationCreate, integrationID int) (*IntegrationCreateResp, error)
}

Integration contains operations available on Integration resource

type IntegrationCreate

type IntegrationCreate struct {
	Name     string               `json:"name"`
	Active   bool                 `json:"active"`
	Target   string               `json:"target"`
	Events   *[]IntegrationEvents `json:"events"`
	Type     string               `json:"type"`
	Clientid int                  `json:"clientid,omitempty"`
}

IntegrationCreate defines how to configure Integration. `Type` possible values: "insight_connect", "opsgenie", "slack",

"pager_duty", "splunk", "sumo_logic"

type IntegrationCreateResp added in v0.0.7

type IntegrationCreateResp struct {
	Body struct {
		Result            string `json:"result"`
		IntegrationObject `json:"object"`
	} `json:"body"`
}

IntegrationCreateResp represents successful creating of an integration entity with the associative parameters.

type IntegrationEvents

type IntegrationEvents struct {
	Event  string `json:"event"`
	Active bool   `json:"active"`
}

IntegrationEvents represents `Events` object while creating a new integration. Event possible values: "hit", "vuln", "system", "scope". If `IntegrationObject.Type` is "opsgenie" possible values: "hit", "vuln". `Active` identifies whether the current Event should be reported.

type IntegrationObject

type IntegrationObject struct {
	ID        int         `json:"id"`
	Active    bool        `json:"active"`
	Name      string      `json:"name"`
	Type      string      `json:"type"`
	CreatedAt int         `json:"created_at"`
	CreatedBy string      `json:"created_by"`
	Target    interface{} `json:"target"`
	Events    []struct {
		IntegrationEvents
	} `json:"events"`
}

IntegrationObject is an inner object for the Read function containing. ID is a unique identifier of the Integration.

type IntegrationRead

type IntegrationRead struct {
	Body struct {
		Result string               `json:"result"`
		Object *[]IntegrationObject `json:"object"`
	} `json:"body"`
}

IntegrationRead is the response on the Read action. This is used for correct Unmarshalling of the response as a container.

type IntegrationWithAPICreate

type IntegrationWithAPICreate struct {
	Name     string                    `json:"name"`
	Active   bool                      `json:"active"`
	Target   *IntegrationWithAPITarget `json:"target"`
	Events   *[]IntegrationEvents      `json:"events"`
	Type     string                    `json:"type"`
	Clientid int                       `json:"clientid,omitempty"`
}

IntegrationWithAPICreate is a root object of Create action for Integrations. It aids to set `Events` to trigger this integration. `Type` possible values: "web_hooks" `Target` is a struct for a Webhooks endpoint containing params such as URL, Token, etc.

type IntegrationWithAPITarget

type IntegrationWithAPITarget struct {
	Token       string                 `json:"token,omitempty"`
	API         string                 `json:"api,omitempty"`
	URL         string                 `json:"url,omitempty"`
	HTTPMethod  string                 `json:"http_method,omitempty"`
	Headers     map[string]interface{} `json:"headers"`
	CaFile      string                 `json:"ca_file"`
	CaVerify    bool                   `json:"ca_verify"`
	Timeout     int                    `json:"timeout,omitempty"`
	OpenTimeout int                    `json:"open_timeout,omitempty"`
}

IntegrationWithAPITarget is used to create an Integration with the following parameters. On purpose to fulfil a custom Webhooks integration.

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
}

Logger defines the interface this library needs to use logging This is a subset of the methods implemented in the log package

type Node added in v0.0.15

type Node interface {
	NodeCreate(nodeBody *NodeCreate) (*NodeCreateResp, error)
	NodeDelete(nodeID int) error
	NodeRead(clientID int, typeNode string) (*NodeRead, error)
	NodeReadByFilter(getNodeBody *NodeReadByFilter) (*NodeReadPOST, error)
}

Node contains operations available on Node resource

type NodeCreate

type NodeCreate struct {
	Hostname string `json:"hostname"`
	Type     string `json:"type"`
	Clientid int    `json:"clientid"`
}

NodeCreate represents options to set for the Node for creating.

type NodeCreateResp

type NodeCreateResp struct {
	Status int           `json:"status"`
	Body   *NodeReadBody `json:"body"`
}

NodeCreateResp is the API response on the Create action containing information about one concrete node. Used to get specific parameters of the created Node such as time of last syncronisation along with relevant LOM and Proton files.

type NodeFilter added in v0.0.5

type NodeFilter struct {
	UUID     string `json:"uuid,omitempty"`
	IP       string `json:"ip,omitempty"`
	Hostname string `json:"hostname,omitempty"`
}

NodeFilter is a filter object to convey for the Node request

type NodeRead added in v0.0.15

type NodeRead struct {
	Status int            `json:"status"`
	Body   []NodeReadBody `json:"body"`
}

NodeRead represents a root object of the fetching action for Nodes. It allows to iterate over several Nodes.

type NodeReadBody added in v0.0.15

type NodeReadBody struct {
	*NodeReadBodyPOST
	ID                  int         `json:"id"`
	UUID                string      `json:"uuid"`
	IP                  interface{} `json:"ip"`
	LastActivity        interface{} `json:"last_activity"`
	LastAnalytic        interface{} `json:"last_analytic"`
	ProtondbVersion     interface{} `json:"protondb_version"`
	LomVersion          interface{} `json:"lom_version"`
	InstanceCount       int         `json:"instance_count"`
	ActiveInstanceCount int         `json:"active_instance_count"`
	Token               string      `json:"token"`
	RequestsAmount      int         `json:"requests_amount"`
	Secret              string      `json:"secret"`
}

NodeReadBody is used to find out configurations and parameters of one specific Node.

type NodeReadBodyPOST added in v0.0.15

type NodeReadBodyPOST struct {
	Type              string      `json:"type"`
	ID                string      `json:"id"`
	IP                string      `json:"ip"`
	Hostname          string      `json:"hostname"`
	LastActivity      int         `json:"last_activity"`
	Enabled           bool        `json:"enabled"`
	Clientid          int         `json:"clientid"`
	LastAnalytic      int         `json:"last_analytic"`
	CreateTime        int         `json:"create_time"`
	CreateFrom        string      `json:"create_from"`
	ProtondbVersion   int         `json:"protondb_version"`
	LomVersion        int         `json:"lom_version"`
	ProtondbUpdatedAt interface{} `json:"protondb_updated_at"`
	LomUpdatedAt      interface{} `json:"lom_updated_at"`
	NodeEnvParams     struct {
		Packages struct {
		} `json:"packages"`
	} `json:"node_env_params"`
	Active bool `json:"active"`
}

NodeReadBodyPOST is used as an additional response on the GET request to fetch the statuses for all the Nodes.

type NodeReadByFilter added in v0.0.15

type NodeReadByFilter struct {
	Filter    *NodeFilter `json:"filter"`
	Limit     int         `json:"limit"`
	Offset    int         `json:"offset"`
	OrderBy   string      `json:"order_by,omitempty"`
	OrderDesc bool        `json:"order_desc,omitempty"`
}

NodeReadByFilter is used to fetch Nodes by POST method using filter by UUID/IP/Hostname

type NodeReadPOST added in v0.0.15

type NodeReadPOST struct {
	Status int                `json:"status"`
	Body   []NodeReadBodyPOST `json:"body"`
}

NodeReadPOST represents a root object of the fetching of Nodes.

type Option

type Option func(*api) error

Option is a functional option for configuring the API client

func HTTPClient

func HTTPClient(client *http.Client) Option

HTTPClient accepts a custom *http.Client for making API calls.

func Headers

func Headers(headers http.Header) Option

Headers allows you to set custom HTTP headers when making API calls (e.g. for satisfying HTTP proxies, or for debugging).

func UserAgent

func UserAgent(userAgent string) Option

UserAgent allows to set custome User-Agent header.

func UsingBaseURL added in v0.0.15

func UsingBaseURL(apiURL string) Option

UsingBaseURL allows to set the Wallarm API endpoint

func UsingLogger

func UsingLogger(logger Logger) Option

UsingLogger can be set if you want to get log output from this API instance By default no log output is emitted

func UsingRetryPolicy

func UsingRetryPolicy(maxRetries int, minRetryDelaySecs int, maxRetryDelaySecs int) Option

UsingRetryPolicy applies a non-default number of retries and min/max retry delays This will be used when the client exponentially backs off after errored requests

type RetryPolicy

type RetryPolicy struct {
	MaxRetries    int
	MinRetryDelay time.Duration
	MaxRetryDelay time.Duration
}

RetryPolicy specifies number of retries and min/max retry delays This config is used when the client exponentially backs off after errored requests

type Scanner added in v0.0.15

type Scanner interface {
	ScannerCreate(scannerBody *ScannerCreate) (*ScannerCreateBody, error)
	ScannerDelete(scannerBody *ScannerDelete, resType string) error
	ScannerUpdate(scannerBody *ScannerUpdate, resType string, resID int) error
}

Scanner contains operations available on Scanner resource

type ScannerCreate

type ScannerCreate struct {
	Query    string `json:"query"`
	Clientid int    `json:"clientid"`
}

ScannerCreate is a request query to put in a new resource.

type ScannerCreateBody

type ScannerCreateBody struct {
	Body struct {
		Result  string `json:"result"`
		Objects []struct {
			Rps                     interface{} `json:"rps"`
			ID                      int         `json:"id"`
			IP                      string      `json:"ip"`
			Domain                  string      `json:"domain"`
			New                     bool        `json:"new"`
			Datacenter              interface{} `json:"datacenter"`
			Disabled                bool        `json:"disabled"`
			CreatedAt               string      `json:"created_at"`
			UpdatedAt               string      `json:"updated_at"`
			LastDisabled            interface{} `json:"last_disabled"`
			Group                   bool        `json:"group"`
			ParentID                int         `json:"parent_id"`
			Clientid                int         `json:"clientid"`
			EnabledDomainBinds      int         `json:"enabled_domain_binds"`
			DisabledDomainBinds     int         `json:"disabled_domain_binds"`
			EnabledServiceBinds     int         `json:"enabled_service_binds"`
			DisabledServiceBinds    int         `json:"disabled_service_binds"`
			DiscoveredAutomatically bool        `json:"discovered_automatically"`
			DisabledEdge            interface{} `json:"disabled_edge"`
		} `json:"objects"`
	} `json:"body"`
}

ScannerCreateBody is a response on the Create action.

type ScannerDelete

type ScannerDelete struct {
	Bulk *[]ScannerDeleteBulk `json:"bulk"`
}

ScannerDelete is used to delete scanner resources in bulk.

type ScannerDeleteBulk

type ScannerDeleteBulk struct {
	Filter *ScannerFilter `json:"filter"`
}

ScannerDeleteBulk is used to update scope resource.

type ScannerFilter added in v0.0.7

type ScannerFilter struct {
	*ScannerCreate
	ID []int `json:"id"`
}

ScannerFilter is used as a filter for delete query.

type ScannerUpdate

type ScannerUpdate struct {
	Disabled bool `json:"disabled"`
	Clientid int  `json:"clientid"`
}

ScannerUpdate is used to update scope resource. The only field is disabling of resource so far.

type Trigger

type Trigger interface {
	TriggerRead(clientID int) (*TriggerRead, error)
	TriggerCreate(triggerBody *TriggerCreate, clientID int) (*TriggerCreateResp, error)
	TriggerDelete(clientID, triggerID int) error
	TriggerUpdate(triggerBody *TriggerCreate, clientID, triggerID int) (*TriggerResp, error)
}

Trigger contains operations available on Triggers resource

type TriggerActions

type TriggerActions struct {
	ID     string `json:"id"`
	Params struct {
		IntegrationIds []int `json:"integration_ids,omitempty"`
		LockTime       int   `json:"lock_time,omitempty"`
	} `json:"params"`
}

TriggerActions is used to specify params for Trigger["Actions"] which is used as a slice

type TriggerCreate

type TriggerCreate struct {
	Trigger *TriggerParam `json:"trigger"`
}

TriggerCreate is used to define JSON body for create action

type TriggerCreateResp added in v0.0.7

type TriggerCreateResp struct {
	*TriggerResp `json:"trigger"`
}

TriggerCreateResp is the response on the creating a trigger.

type TriggerFilters

type TriggerFilters struct {
	ID       string        `json:"id"`
	Operator string        `json:"operator"`
	Values   []interface{} `json:"values"`
}

TriggerFilters is used to specify params for Trigger["Filters"] which is used as a slice

type TriggerParam added in v0.0.15

type TriggerParam struct {
	Filters    *[]TriggerFilters `json:"filters"`
	Actions    *[]TriggerActions `json:"actions"`
	TemplateID string            `json:"template_id"`
	Threshold  *TriggerThreshold `json:"threshold"`
	Enabled    bool              `json:"enabled"`
	Name       string            `json:"name,omitempty"`
	Comment    string            `json:"comment,omitempty"`
}

TriggerParam is used to specify params for TriggerCreate

type TriggerRead

type TriggerRead struct {
	Triggers []TriggerResp `json:"triggers"`
}

TriggerRead is the response which contains information about all the created Triggers within an account

type TriggerResp added in v0.0.7

type TriggerResp struct {
	ID       int           `json:"id"`
	Name     string        `json:"name"`
	Comment  interface{}   `json:"comment"`
	Enabled  bool          `json:"enabled"`
	ClientID int           `json:"client_id"`
	Filters  []interface{} `json:"filters"`
	Actions  []struct {
		ID string `json:"id"`
	} `json:"actions"`
	Thresholds []struct {
		Operator string `json:"operator"`
		Period   int    `json:"period"`
		Count    int    `json:"count"`
	} `json:"thresholds"`
	Template struct {
		ID      string `json:"id"`
		Filters []struct {
			ID               string        `json:"id"`
			Required         bool          `json:"required"`
			Values           []interface{} `json:"values"`
			AllowedOperators []string      `json:"allowed_operators"`
			Operator         string        `json:"operator"`
		} `json:"filters"`
		Threshold struct {
			AllowedOperators []string `json:"allowed_operators"`
			Operator         string   `json:"operator"`
			Period           int      `json:"period"`
			Count            int      `json:"count"`
		} `json:"threshold"`
		Actions []struct {
			ID     string `json:"id"`
			Params struct {
				LockTime int `json:"lock_time"`
			} `json:"params,omitempty"`
		} `json:"actions"`
	} `json:"template"`
	Threshold struct {
		Operator string `json:"operator"`
		Period   int    `json:"period"`
		Count    int    `json:"count"`
	} `json:"threshold"`
}

TriggerResp is returned on successful trigger updating and creating

type TriggerThreshold

type TriggerThreshold struct {
	Period           int      `json:"period"`
	Operator         string   `json:"operator"`
	AllowedOperators []string `json:"allowed_operators"`
	Count            int      `json:"count"`
}

TriggerThreshold is used to specify params for Trigger["Threshold"]

type TwoDimensionalSlice added in v0.0.11

type TwoDimensionalSlice [][]interface{}

TwoDimensionalSlice is used for Point and HintsCount structures.

type User added in v0.0.15

type User interface {
	UserRead(userBody *UserGet) (*UserRead, error)
	UserCreate(userBody *UserCreate) (*UserDetails, error)
	UserDelete(userBody *UserDelete) error
	UserUpdate(userBody *UserUpdate) error
	UserDetails() (*UserDetails, error)
}

User contains operations available on User resource

type UserCreate

type UserCreate struct {
	Email       string   `json:"email"`
	Phone       string   `json:"phone,omitempty"`
	Password    string   `json:"password"`
	Username    string   `json:"username"`
	Realname    string   `json:"realname"`
	Permissions []string `json:"permissions"`
	Clientid    int      `json:"clientid,omitempty"`
}

UserCreate is a POST body for the request to create a new user with the following parameters

type UserDelete

type UserDelete struct {
	Filter *UserFilter `json:"filter"`
}

UserDelete is utilised to Delete Users

type UserDetails

type UserDetails struct {
	Status int         `json:"status"`
	Body   *UserParams `json:"body"`
}

UserDetails is used as a response for request about the specific User. For example, it may be used to find out a parameter (Client ID) for the current user which auth params are used

type UserFields

type UserFields struct {
	Phone          string   `json:"phone,omitempty"`
	Realname       string   `json:"realname,omitempty"`
	Permissions    []string `json:"permissions,omitempty"`
	Clientid       int      `json:"clientid,omitempty"`
	Timezone       string   `json:"timezone,omitempty"`
	JobTitle       string   `json:"job_title,omitempty"`
	ResultsPerPage int      `json:"results_per_page,omitempty"`
	DefaultPool    string   `json:"default_pool,omitempty"`
	Enabled        bool     `json:"enabled,omitempty"`
	Password       string   `json:"password,omitempty"`
	Notifications  struct {
		ReportDaily struct {
			Email bool `json:"email,omitempty"`
			Sms   bool `json:"sms,omitempty"`
		} `json:"report_daily,omitempty"`
		ReportWeekly struct {
			Email bool `json:"email,omitempty"`
			Sms   bool `json:"sms,omitempty"`
		} `json:"report_weekly,omitempty"`
		ReportMonthly struct {
			Email bool `json:"email,omitempty"`
			Sms   bool `json:"sms,omitempty"`
		} `json:"report_monthly,omitempty"`
		System struct {
			Email bool `json:"email,omitempty"`
			Sms   bool `json:"sms,omitempty"`
		} `json:"system,omitempty"`
		Vuln struct {
			Email bool `json:"email,omitempty"`
			Sms   bool `json:"sms,omitempty"`
		} `json:"vuln,omitempty"`
	} `json:"notifications,omitempty"`
	SearchTemplates struct {
	} `json:"search_templates,omitempty"`
}

UserFields represents fields of the Users for Update function

type UserFilter

type UserFilter struct {
	ID       int    `json:"id,omitempty"`
	Clientid int    `json:"clientid,omitempty"`
	UUID     string `json:"uuid,omitempty"`
	Username string `json:"username,omitempty"`
	Email    string `json:"email,omitempty"`
}

UserFilter is intended to filter Users for the Delete purpose

type UserGet

type UserGet struct {
	Limit     int         `json:"limit"`
	OrderBy   string      `json:"order_by"`
	OrderDesc bool        `json:"order_desc"`
	Filter    *UserFilter `json:"filter"`
}

UserGet is used for Read function purposes (to request Users by a GET method)

type UserParams added in v0.0.6

type UserParams struct {
	*UserCreate
	Phone             interface{} `json:"phone"`
	ID                int         `json:"id"`
	UUID              string      `json:"uuid"`
	ActualPermissions []string    `json:"actual_permissions"`
	MfaEnabled        bool        `json:"mfa_enabled"`
	CreateBy          int64       `json:"create_by"`
	CreateAt          int         `json:"create_at"`
	CreateFrom        string      `json:"create_from"`
	Enabled           bool        `json:"enabled"`
	Validated         bool        `json:"validated"`
	PasswordChanged   int         `json:"password_changed"`
	LoginHistory      []struct {
		Time int    `json:"time"`
		IP   string `json:"ip"`
	} `json:"login_history"`
	Timezone        string      `json:"timezone"`
	ResultsPerPage  int         `json:"results_per_page"`
	DefaultPool     string      `json:"default_pool"`
	DefaultPoolid   interface{} `json:"default_poolid"`
	LastReadNewsID  int         `json:"last_read_news_id"`
	SearchTemplates struct {
	} `json:"search_templates"`
	Notifications struct {
		ReportDaily struct {
			Email bool `json:"email"`
			Sms   bool `json:"sms"`
		} `json:"report_daily"`
		ReportWeekly struct {
			Email bool `json:"email"`
			Sms   bool `json:"sms"`
		} `json:"report_weekly"`
		ReportMonthly struct {
			Email bool `json:"email"`
			Sms   bool `json:"sms"`
		} `json:"report_monthly"`
		Vuln struct {
			Email bool `json:"email"`
			Sms   bool `json:"sms"`
		} `json:"vuln"`
		Scope struct {
			Email bool `json:"email"`
			Sms   bool `json:"sms"`
		} `json:"scope"`
		System struct {
			Email bool `json:"email"`
			Sms   bool `json:"sms"`
		} `json:"system"`
	} `json:"notifications"`
	Components               []string    `json:"components"`
	Language                 string      `json:"language"`
	LastLoginTime            int         `json:"last_login_time"`
	DateFormat               string      `json:"date_format"`
	TimeFormat               string      `json:"time_format"`
	JobTitle                 interface{} `json:"job_title"`
	AvailableAuthentications []string    `json:"available_authentications"`
	FrontendURL              string      `json:"frontend_url"`
}

UserParams wraps the entire parameters of the User entity

type UserRead

type UserRead struct {
	Status int          `json:"status"`
	Body   []UserParams `json:"body"`
}

UserRead is used as a response for the Read function for the User endpoints

type UserUpdate

type UserUpdate struct {
	*UserFilter `json:"filter,omitempty"`
	*UserFields `json:"fields,omitempty"`
	Limit       int    `json:"limit,omitempty"`
	Offset      int    `json:"offset,omitempty"`
	OrderBy     string `json:"order_by,omitempty"`
	OrderDesc   bool   `json:"order_desc,omitempty"`
}

UserUpdate is used to Update Users

type Vulnerability added in v0.0.15

type Vulnerability interface {
	GetVulnRead(getVulnBody *GetVulnRead) (*GetVulnReadResp, error)
}

Vulnerability contains operations available on Vulnerability resource

Jump to

Keyboard shortcuts

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