api

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const MaxTotal = 10_000

Variables

This section is empty.

Functions

func Batch

func Batch[T any](c *Client, tasks []BatchTask[T], opts ...BatchOption) ([]mo.Result[T], error)

func BatchResultToRaw

func BatchResultToRaw(r mo.Result[*Response]) *json.RawMessage

func GetLast7Days added in v0.0.5

func GetLast7Days(t time.Time) (days []string)

func GetToday added in v0.0.5

func GetToday() time.Time

func PrefixedPath

func PrefixedPath(path string) string

func SetHost

func SetHost(host string)

Types

type BatchOption

type BatchOption func(*BatchOptions)

func WithBatchMaxConcurrency

func WithBatchMaxConcurrency(max int) BatchOption

func WithBatchTimeout

func WithBatchTimeout(timeout int) BatchOption

type BatchOptions

type BatchOptions struct {
	MaxConcurrency int
	Timeout        int
}

type BatchTask

type BatchTask[T any] func(c *Client, ctx context.Context) mo.Result[T]

type ChannelOption added in v0.0.4

type ChannelOption func(*ChannelOptions)

func WithChannelEmailAddresses added in v0.0.4

func WithChannelEmailAddresses(emailAddresses []string) ChannelOption

func WithChannelFrequency added in v0.0.4

func WithChannelFrequency(frequency string) ChannelOption

func WithChannelIgnoreTime added in v0.0.4

func WithChannelIgnoreTime(ignoreTime bool) ChannelOption

func WithChannelIsActive added in v0.0.4

func WithChannelIsActive(isActive bool) ChannelOption

func WithChannelIsDefault added in v0.0.4

func WithChannelIsDefault(isDefault bool) ChannelOption

func WithChannelName added in v0.0.4

func WithChannelName(name string) ChannelOption

func WithChannelPermissions added in v0.0.4

func WithChannelPermissions(permissions []string) ChannelOption

func WithChannelType added in v0.0.4

func WithChannelType(channelType string) ChannelOption

func WithChannelUTCTime added in v0.0.4

func WithChannelUTCTime(utcTime string) ChannelOption

func WithChannelWebhookURL added in v0.0.4

func WithChannelWebhookURL(webhookURL string) ChannelOption

func WithChannelWeekDays added in v0.0.4

func WithChannelWeekDays(weekDays []string) ChannelOption

type ChannelOptions added in v0.0.4

type ChannelOptions struct {
	Channel struct {
		Type           string   `json:"type"`
		Name           string   `json:"name"`
		WebhookURL     string   `json:"webhookURL,omitempty"`
		Frequency      string   `json:"frequency,omitempty"`
		EmailAddresses []string `json:"emailAddresses,omitempty"`
		UTCTime        string   `json:"utcTime,omitempty"`
		IsActive       bool     `json:"isActive,omitempty"`
		IsDefault      bool     `json:"isDefault,omitempty"`
		IgnoreTime     bool     `json:"ignoreTime,omitempty"`
		WeekDays       []string `json:"weekDays,omitempty"`
		Permissions    []string `json:"permissions,omitempty"`
	} `json:"channel"`
}

type Client

type Client struct {
	APIKey  string
	Agent   string
	Err     error
	BaseURL *url.URL
	// contains filtered or unexported fields
}

func NewClient

func NewClient(APIKey string) *Client

func (*Client) BulkGetDataDumpList added in v0.0.5

func (c *Client) BulkGetDataDumpList(path string) (*DataDumpList, error)

func (*Client) CreateChannel added in v0.0.4

func (c *Client) CreateChannel(opts ...ChannelOption) (*Response, error)

func (*Client) CreateIncident

func (c *Client) CreateIncident(opts ...IncidentOption) (*Response, error)

func (*Client) CreateSavedSearch

func (c *Client) CreateSavedSearch(opts ...SavedSearchOption) (*Response, error)

func (*Client) CreateSubscription

func (c *Client) CreateSubscription(opts ...SubscriptionOption) (*Response, error)

func (*Client) Do

func (c *Client) Do(r *Request) (resp *Response, err error)

func (*Client) Download

func (c *Client) Download(path, output string) (n int64, err error)

func (*Client) GetDataDumpList added in v0.0.5

func (c *Client) GetDataDumpList(path string) (*DataDumpList, error)

func (*Client) GetResult

func (c *Client) GetResult(uuid string) (*Response, error)

func (*Client) IterateHostname

func (c *Client) IterateHostname(hostname string, opts ...HostnameIteratorOption) (*HostnameIterator, error)

func (*Client) NewBatchScanTask

func (c *Client) NewBatchScanTask(url string, opts ...ScanOption) BatchTask[*Response]

func (*Client) NewBatchScanWithWaitTask

func (c *Client) NewBatchScanWithWaitTask(url string, maxWait int, opts ...ScanOption) BatchTask[*Response]

func (*Client) NewRequest

func (c *Client) NewRequest() *Request

func (*Client) NewScanRequest

func (c *Client) NewScanRequest(url string, opts ...ScanOption) *Request

func (*Client) Scan

func (c *Client) Scan(url string, options ...ScanOption) (*ScanResult, error)

func (*Client) Search

func (c *Client) Search(q string, options ...IteratorOption) (*Iterator, error)

func (*Client) SetAPIKey

func (c *Client) SetAPIKey(key string) *Client

func (*Client) SetAgent

func (c *Client) SetAgent(agent string) *Client

func (*Client) SetBaseURL

func (c *Client) SetBaseURL(url *url.URL) *Client

func (*Client) SetDisableCompression added in v0.0.5

func (c *Client) SetDisableCompression(disable bool) *Client

func (*Client) SetRetryTransport

func (c *Client) SetRetryTransport() *Client

func (*Client) SetTransport

func (c *Client) SetTransport(transport http.RoundTripper) *Client

func (*Client) StoreLiveScanResult

func (c *Client) StoreLiveScanResult(scannerId string, scanId string, opts ...LiveScanStoreOption) (*Response, error)

func (*Client) StructureSearch

func (c *Client) StructureSearch(uuid string, options ...IteratorOption) (*Iterator, error)

func (*Client) TriggerLiveScan

func (c *Client) TriggerLiveScan(id string, opts ...LiveScanOption) (*Response, error)

func (*Client) TriggerNonBlockingLiveScan

func (c *Client) TriggerNonBlockingLiveScan(id string, opts ...LiveScanOption) (*Response, error)

func (*Client) URL

func (c *Client) URL(path string) (*url.URL, error)

func (*Client) UpdateChannel added in v0.0.4

func (c *Client) UpdateChannel(id string, opts ...ChannelOption) (*Response, error)

func (*Client) UpdateIncident

func (c *Client) UpdateIncident(id string, opts ...IncidentOption) (*Response, error)

func (*Client) UpdateSavedSearch

func (c *Client) UpdateSavedSearch(id string, opts ...SavedSearchOption) (*Response, error)

func (*Client) UpdateSubscription

func (c *Client) UpdateSubscription(id string, opts ...SubscriptionOption) (*Response, error)

func (*Client) WaitAndGetResult

func (c *Client) WaitAndGetResult(ctx context.Context, uuid string, maxWait int) (*Response, error)

type DataDumpFile added in v0.0.5

type DataDumpFile struct {
	Size      int64  `json:"size"`
	Path      string `json:"path"`
	Timestamp string `json:"timestamp"`
}

type DataDumpList added in v0.0.5

type DataDumpList struct {
	Files []DataDumpFile  `json:"files"`
	Raw   json.RawMessage `json:"-"`
}

func (*DataDumpList) PrettyJSON added in v0.0.5

func (r *DataDumpList) PrettyJSON() string

func (*DataDumpList) UnmarshalJSON added in v0.0.5

func (r *DataDumpList) UnmarshalJSON(data []byte) error

type GetContentFn

type GetContentFn func() (io.ReadCloser, error)

type HostnameIterator

type HostnameIterator struct {
	PageState string
	HasMore   bool
	// contains filtered or unexported fields
}

func (*HostnameIterator) Iterate

func (it *HostnameIterator) Iterate() iter.Seq2[*json.RawMessage, error]

type HostnameIteratorOption

type HostnameIteratorOption func(*HostnameIterator) error

func HostnameIteratorAll

func HostnameIteratorAll(all bool) HostnameIteratorOption

func HostnameIteratorLimit

func HostnameIteratorLimit(limit int) HostnameIteratorOption

limit is the maximum number of results that will be returned by the iterator. note that this is not the same as the API endpoint's "limit" query parameter.

func HostnameIteratorPageState

func HostnameIteratorPageState(pageState string) HostnameIteratorOption

func HostnameIteratorSize

func HostnameIteratorSize(size int) HostnameIteratorOption

size is the number of results returned by the iterator in each batch.

type HostnameResults

type HostnameResults struct {
	Item      string            `json:"item"`
	Results   []json.RawMessage `json:"results"`
	PageState string            `json:"pageState"`
	Raw       json.RawMessage   `json:"-"`
}

func (*HostnameResults) UnmarshalJSON

func (r *HostnameResults) UnmarshalJSON(data []byte) error

type IncidentOption

type IncidentOption func(*IncidentOptions)

func WithIncidentChannels

func WithIncidentChannels(channels []string) IncidentOption

func WithIncidentCountries

func WithIncidentCountries(countries []string) IncidentOption

func WithIncidentCountriesPerInterval

func WithIncidentCountriesPerInterval(countriesPerInterval int) IncidentOption

func WithIncidentExpireAfter

func WithIncidentExpireAfter(expireAfter int) IncidentOption

func WithIncidentExpireAt

func WithIncidentExpireAt(expireAt string) IncidentOption

func WithIncidentObservable

func WithIncidentObservable(observable string) IncidentOption

func WithIncidentProfile

func WithIncidentProfile(incidentProfile string) IncidentOption

func WithIncidentScanInterval

func WithIncidentScanInterval(scanInterval int) IncidentOption

func WithIncidentScanIntervalAfterMalicious

func WithIncidentScanIntervalAfterMalicious(scanIntervalAfterMalicious int) IncidentOption

func WithIncidentScanIntervalAfterSuspended

func WithIncidentScanIntervalAfterSuspended(scanIntervalAfterSuspended int) IncidentOption

func WithIncidentScanIntervalMode

func WithIncidentScanIntervalMode(scanIntervalMode string) IncidentOption

func WithIncidentStopDelayInactive

func WithIncidentStopDelayInactive(stopDelayInactive int) IncidentOption

func WithIncidentStopDelayMalicious

func WithIncidentStopDelayMalicious(stopDelayMalicious int) IncidentOption

func WithIncidentStopDelaySuspended

func WithIncidentStopDelaySuspended(stopDelaySuspended int) IncidentOption

func WithIncidentUserAgents

func WithIncidentUserAgents(userAgents []string) IncidentOption

func WithIncidentUserAgentsPerInterval

func WithIncidentUserAgentsPerInterval(userAgentsPerInterval int) IncidentOption

func WithIncidentVisibility

func WithIncidentVisibility(visibility string) IncidentOption

func WithIncidentWatchedAttributes

func WithIncidentWatchedAttributes(watchedAttributes []string) IncidentOption

type IncidentOptions

type IncidentOptions struct {
	Incident struct {
		// common options
		ExpireAfter                int      `json:"expireAfter"`
		ScanInterval               int      `json:"scanInterval"`
		ScanIntervalMode           string   `json:"scanIntervalMode"`
		WatchedAttributes          []string `json:"watchedAttributes"`
		UserAgents                 []string `json:"userAgents"`
		UserAgentsPerInterval      int      `json:"userAgentsPerInterval"`
		Countries                  []string `json:"countries"`
		CountriesPerInterval       int      `json:"countriesPerInterval"`
		StopDelaySuspended         int      `json:"stopDelaySuspended"`
		StopDelayInactive          int      `json:"stopDelayInactive"`
		StopDelayMalicious         int      `json:"stopDelayMalicious"`
		ScanIntervalAfterSuspended int      `json:"scanIntervalAfterSuspended"`
		ScanIntervalAfterMalicious int      `json:"scanIntervalAfterMalicious"`
		// common fields
		Visibility      string `json:"visibility"`
		IncidentProfile string `json:"incidentProfile,omitempty"`
		ExpireAt        string `json:"expireAt,omitempty"`
		// create & updated fields
		Channels   []string `json:"channels"`
		Observable string   `json:"observable"`
	} `json:"incident"`
}

type Iterator

type Iterator struct {
	HasMore bool
	Total   int
	// contains filtered or unexported fields
}

func (*Iterator) Iterate

func (it *Iterator) Iterate() iter.Seq2[*SearchResult, error]

type IteratorOption

type IteratorOption func(*Iterator) error

func IteratorAll

func IteratorAll(all bool) IteratorOption

func IteratorCollapse added in v0.0.5

func IteratorCollapse(collapse string) IteratorOption

func IteratorDatasource

func IteratorDatasource(datasource string) IteratorOption

func IteratorLimit

func IteratorLimit(n int) IteratorOption

func IteratorQuery

func IteratorQuery(q string) IteratorOption

func IteratorSearchAfter

func IteratorSearchAfter(searchAfter string) IteratorOption

func IteratorSize

func IteratorSize(n int) IteratorOption

type JSONError

type JSONError struct {
	Status      int             `json:"status,omitempty"`
	Message     string          `json:"message"`
	Description string          `json:"description,omitempty"`
	Raw         json.RawMessage `json:"-"`
}

func (JSONError) Error

func (e JSONError) Error() string

func (*JSONError) UnmarshalJSON

func (r *JSONError) UnmarshalJSON(data []byte) error

type LiveScanOption

type LiveScanOption func(*LiveScanOptions)

func WithLiveScanScannerCaptureDelay

func WithLiveScanScannerCaptureDelay(delay int) LiveScanOption

func WithLiveScanScannerDisableFeatures

func WithLiveScanScannerDisableFeatures(features []string) LiveScanOption

func WithLiveScanScannerEnableFeatures

func WithLiveScanScannerEnableFeatures(features []string) LiveScanOption

func WithLiveScanScannerExtraHeaders

func WithLiveScanScannerExtraHeaders(headers map[string]string) LiveScanOption

func WithLiveScanScannerPageTimeout

func WithLiveScanScannerPageTimeout(timeout int) LiveScanOption

func WithLiveScanTaskURL

func WithLiveScanTaskURL(url string) LiveScanOption

func WithLiveScanTaskVisibility

func WithLiveScanTaskVisibility(visibility string) LiveScanOption

type LiveScanOptions

type LiveScanOptions struct {
	Task struct {
		URL        string `json:"url"`
		Visibility string `json:"visibility"`
	} `json:"task"`
	Scanner struct {
		PageTimeout     int               `json:"pageTimeout"`
		CaptureDelay    int               `json:"captureDelay"`
		ExtraHeaders    map[string]string `json:"extraHeaders,omitempty"`
		EnableFeatures  []string          `json:"enableFeatures,omitempty"`
		DisableFeatures []string          `json:"disableFeatures,omitempty"`
	} `json:"scanner"`
}

type LiveScanStoreOption

type LiveScanStoreOption func(*LiveScanStoreOptions)

func WithLiveScanStoreTaskVisibility

func WithLiveScanStoreTaskVisibility(visibility string) LiveScanStoreOption

type LiveScanStoreOptions

type LiveScanStoreOptions struct {
	Task struct {
		Visibility string `json:"visibility"`
	} `json:"task"`
}

type Request

type Request struct {
	Headers     http.Header
	QueryParams map[string]string
	Path        string
	Method      string
	Body        []byte
	GetBody     GetContentFn

	RawRequest *http.Request
	// contains filtered or unexported fields
}

func (*Request) Delete

func (r *Request) Delete(path string) (*Response, error)

func (*Request) Do

func (r *Request) Do() (resp *Response, err error)

func (*Request) Get

func (r *Request) Get(path string) (*Response, error)

func (*Request) Post

func (r *Request) Post(path string) (*Response, error)

func (*Request) Put

func (r *Request) Put(path string) (*Response, error)

func (*Request) Send

func (r *Request) Send(method, path string) (*Response, error)

func (*Request) SetBodyBytes

func (r *Request) SetBodyBytes(body []byte) *Request

func (*Request) SetBodyJSONBytes

func (r *Request) SetBodyJSONBytes(body []byte) *Request

func (*Request) SetBodyString

func (r *Request) SetBodyString(body string) *Request

func (*Request) SetContentType

func (r *Request) SetContentType(contentType string) *Request

func (*Request) SetContext

func (r *Request) SetContext(ctx context.Context) *Request

func (*Request) SetHeader

func (r *Request) SetHeader(key, value string) *Request

func (*Request) SetHeaders

func (r *Request) SetHeaders(headers map[string]string) *Request

func (*Request) SetMethod

func (r *Request) SetMethod(method string) *Request

func (*Request) SetPath

func (r *Request) SetPath(path string) *Request

func (*Request) SetQueryParam

func (r *Request) SetQueryParam(key, value string) *Request

func (*Request) SetQueryParams

func (r *Request) SetQueryParams(params map[string]string) *Request

type Response

type Response struct {
	*http.Response

	Request *Request
	// contains filtered or unexported fields
}

func (*Response) Error

func (r *Response) Error() error

func (*Response) GetContentType

func (r *Response) GetContentType() string

func (*Response) IsError

func (r *Response) IsError() bool

func (*Response) IsSuccess

func (r *Response) IsSuccess() bool

func (*Response) PrettyJSON

func (r *Response) PrettyJSON() string

func (*Response) ToBytes

func (r *Response) ToBytes() (body []byte, err error)

func (*Response) ToJSON

func (r *Response) ToJSON() (*json.RawMessage, error)

func (*Response) ToString

func (r *Response) ToString() (string, error)

func (*Response) Unmarshal

func (r *Response) Unmarshal(v any) error

type RetryTransport

type RetryTransport struct {
	Transport http.RoundTripper
}

func (*RetryTransport) RoundTrip

func (t *RetryTransport) RoundTrip(req *http.Request) (*http.Response, error)

type SavedSearchOption

type SavedSearchOption func(*SavedSearchOptions)

func WithSavedSearchDatasource

func WithSavedSearchDatasource(datasource string) SavedSearchOption

func WithSavedSearchDescription

func WithSavedSearchDescription(description string) SavedSearchOption

func WithSavedSearchLongDescription

func WithSavedSearchLongDescription(longDescription string) SavedSearchOption

func WithSavedSearchName

func WithSavedSearchName(name string) SavedSearchOption

func WithSavedSearchOwnerDescription

func WithSavedSearchOwnerDescription(ownerDescription string) SavedSearchOption

func WithSavedSearchPass

func WithSavedSearchPass(pass int) SavedSearchOption

func WithSavedSearchPermissions

func WithSavedSearchPermissions(permissions []string) SavedSearchOption

func WithSavedSearchQuery

func WithSavedSearchQuery(query string) SavedSearchOption

func WithSavedSearchTLP

func WithSavedSearchTLP(tlp string) SavedSearchOption

func WithSavedSearchTags

func WithSavedSearchTags(tags []string) SavedSearchOption

func WithSavedSearchUserTags

func WithSavedSearchUserTags(userTags []string) SavedSearchOption

type SavedSearchOptions

type SavedSearchOptions struct {
	Search struct {
		Datasource       string   `json:"datasource"`
		Name             string   `json:"name"`
		Query            string   `json:"query"`
		TLP              string   `json:"tlp"`
		Permissions      []string `json:"permissions"`
		Pass             int      `json:"pass"`
		Description      string   `json:"description,omitempty"`
		LongDescription  string   `json:"longDescription,omitempty"`
		OwnerDescription string   `json:"ownerDescription,omitempty"`
		Tags             []string `json:"tags,omitempty"`
		UserTags         []string `json:"userTags,omitempty"`
	} `json:"search"`
}

type ScanOption

type ScanOption func(*ScanOptions)

func WithScanCountry

func WithScanCountry(country string) ScanOption

func WithScanCustomAgent

func WithScanCustomAgent(customAgent string) ScanOption

func WithScanOverrideSafety

func WithScanOverrideSafety(overrideSafety string) ScanOption

func WithScanReferer

func WithScanReferer(referer string) ScanOption

func WithScanTags

func WithScanTags(tags []string) ScanOption

func WithScanVisibility

func WithScanVisibility(visibility string) ScanOption

type ScanOptions

type ScanOptions struct {
	URL            string    `json:"url"`
	CustomAgent    *string   `json:"customagent,omitempty"`
	Referer        *string   `json:"referer,omitempty"`
	Visibility     *string   `json:"visibility,omitempty"`
	Tags           *[]string `json:"tags,omitempty"`
	OverrideSafety *string   `json:"overrideSafety,omitempty"`
	Country        *string   `json:"country,omitempty"`
}

type ScanResult

type ScanResult struct {
	UUID string          `json:"uuid"`
	Raw  json.RawMessage `json:"-"`
}

func (*ScanResult) PrettyJSON

func (r *ScanResult) PrettyJSON() string

func (*ScanResult) UnmarshalJSON

func (r *ScanResult) UnmarshalJSON(data []byte) error

type SearchResult

type SearchResult struct {
	Sort []any           `json:"sort"`
	Raw  json.RawMessage `json:"-"`
}

func (*SearchResult) UnmarshalJSON

func (r *SearchResult) UnmarshalJSON(data []byte) error

type SearchResults

type SearchResults struct {
	Results []SearchResult  `json:"results"`
	HasMore bool            `json:"has_more"`
	Total   int             `json:"total"`
	Raw     json.RawMessage `json:"-"`
}

func (*SearchResults) UnmarshalJSON

func (r *SearchResults) UnmarshalJSON(data []byte) error

type SubscriptionOption

type SubscriptionOption func(*SubscriptionOptions)

func WithSubscriptionDescription

func WithSubscriptionDescription(description string) SubscriptionOption

func WithSubscriptionEmailAddresses

func WithSubscriptionEmailAddresses(emailAddresses []string) SubscriptionOption

func WithSubscriptionFrequency

func WithSubscriptionFrequency(frequency string) SubscriptionOption

func WithSubscriptionIgnoreTime

func WithSubscriptionIgnoreTime(ignoreTime bool) SubscriptionOption

func WithSubscriptionIsActive

func WithSubscriptionIsActive(isActive bool) SubscriptionOption

func WithSubscriptionName

func WithSubscriptionName(name string) SubscriptionOption

func WithSubscriptionSearchIds

func WithSubscriptionSearchIds(searchIds []string) SubscriptionOption

type SubscriptionOptions

type SubscriptionOptions struct {
	Subscription struct {
		SearchIds      []string `json:"searchIds"`
		Frequency      string   `json:"frequency"`
		EmailAddresses []string `json:"emailAddresses"`
		Name           string   `json:"name"`
		Description    string   `json:"description,omitempty"`
		IsActive       bool     `json:"isActive"`
		IgnoreTime     bool     `json:"ignoreTime"`
	} `json:"subscription"`
}

Jump to

Keyboard shortcuts

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