diff --git a/README.md b/README.md index 2f64711e..3e5ecd36 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,12 @@ This contains key golang libraries for Forta services. ## Bug Bounty We have a [bug bounty program on Immunefi](https://immunefi.com/bounty/forta). Please report any security issues you find through the Immunefi dashboard, or reach out to [tech@forta.org](mailto:tech@forta.org) + +## Webhook + +To extend the client models with new fields, please do not modify generated code directly and instead + +1. update `protocol/webhook/swagger.yml`, +2. do `make swagger` + +and the code will be regenerated by taking into account the latest shape of `swagger.yml`. diff --git a/clients/webhook/client/models/address_bloom_filter.go b/clients/webhook/client/models/address_bloom_filter.go new file mode 100644 index 00000000..5cccedc9 --- /dev/null +++ b/clients/webhook/client/models/address_bloom_filter.go @@ -0,0 +1,63 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// AddressBloomFilter address bloom filter +// +// swagger:model AddressBloomFilter +type AddressBloomFilter struct { + + // bitset + // Example: AAAAAAAAACwAAAAAAAAACwAAAAAAAAAsAAALo5gpbbc= + Bitset string `json:"bitset,omitempty"` + + // item count + // Example: 1 + ItemCount int64 `json:"itemCount,omitempty"` + + // k + // Example: 0x12 + K string `json:"k,omitempty"` + + // m + // Example: 0x34 + M string `json:"m,omitempty"` +} + +// Validate validates this address bloom filter +func (m *AddressBloomFilter) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this address bloom filter based on context it is used +func (m *AddressBloomFilter) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *AddressBloomFilter) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *AddressBloomFilter) UnmarshalBinary(b []byte) error { + var res AddressBloomFilter + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/clients/webhook/client/models/alert.go b/clients/webhook/client/models/alert.go index 00e7c886..c4985322 100644 --- a/clients/webhook/client/models/alert.go +++ b/clients/webhook/client/models/alert.go @@ -8,6 +8,7 @@ package models import ( "context" "encoding/json" + "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" @@ -20,14 +21,13 @@ import ( // swagger:model Alert type Alert struct { + // address bloom filter + AddressBloomFilter *AddressBloomFilter `json:"addressBloomFilter,omitempty"` + // Addresses involved in the source of this alert // Example: ["0x98883145049dec03c00cb7708cbc938058802520","0x1fFa3471A45C22B1284fE5a251eD74F40580a1E3"] Addresses []string `json:"addresses"` - // AddressBloomFilter contains **all** addresses in the alert - // Example: "addressBloomFilter": {"k": 11,"m": 44,"bitset": "AAAAAAAAACwAAAAAAAAACwAAAAAAAAAsAAALo5gpbbc=", item_count: 1} - AddressBloomFilter interface{} `json:"addressBloomFilter,omitempty"` - // alert Id // Example: OZ-GNOSIS-EVENTS AlertID string `json:"alertId,omitempty"` @@ -48,6 +48,9 @@ type Alert struct { // Example: 0xe9cfda18f167de5cdd63c101e38ec0d4cb0a1c2dea80921ecc4405c2b010855f Hash string `json:"hash,omitempty"` + // labels + Labels []*AlertLabel `json:"labels"` + // An associative array of extra links values // Example: {"blockUrl":"https://etherscan.io/block/18646150","explorerUrl":"https://explorer.forta.network/alert/0xd795c365931762afeccf4a440ecee2f7e89820c59136aa46310a8eec54ba96d8"} Links interface{} `json:"links,omitempty"` @@ -74,16 +77,27 @@ type Alert struct { // source Source *AlertSource `json:"source,omitempty"` + + // sources + Sources *AlertSources `json:"sources,omitempty"` } // Validate validates this alert func (m *Alert) Validate(formats strfmt.Registry) error { var res []error + if err := m.validateAddressBloomFilter(formats); err != nil { + res = append(res, err) + } + if err := m.validateFindingType(formats); err != nil { res = append(res, err) } + if err := m.validateLabels(formats); err != nil { + res = append(res, err) + } + if err := m.validateSeverity(formats); err != nil { res = append(res, err) } @@ -92,12 +106,35 @@ func (m *Alert) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateSources(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } +func (m *Alert) validateAddressBloomFilter(formats strfmt.Registry) error { + if swag.IsZero(m.AddressBloomFilter) { // not required + return nil + } + + if m.AddressBloomFilter != nil { + if err := m.AddressBloomFilter.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("addressBloomFilter") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("addressBloomFilter") + } + return err + } + } + + return nil +} + var alertTypeFindingTypePropEnum []interface{} func init() { @@ -152,6 +189,32 @@ func (m *Alert) validateFindingType(formats strfmt.Registry) error { return nil } +func (m *Alert) validateLabels(formats strfmt.Registry) error { + if swag.IsZero(m.Labels) { // not required + return nil + } + + for i := 0; i < len(m.Labels); i++ { + if swag.IsZero(m.Labels[i]) { // not required + continue + } + + if m.Labels[i] != nil { + if err := m.Labels[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("labels" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("labels" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + var alertTypeSeverityPropEnum []interface{} func init() { @@ -225,20 +288,87 @@ func (m *Alert) validateSource(formats strfmt.Registry) error { return nil } +func (m *Alert) validateSources(formats strfmt.Registry) error { + if swag.IsZero(m.Sources) { // not required + return nil + } + + if m.Sources != nil { + if err := m.Sources.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sources") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sources") + } + return err + } + } + + return nil +} + // ContextValidate validate this alert based on the context it is used func (m *Alert) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error + if err := m.contextValidateAddressBloomFilter(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateLabels(ctx, formats); err != nil { + res = append(res, err) + } + if err := m.contextValidateSource(ctx, formats); err != nil { res = append(res, err) } + if err := m.contextValidateSources(ctx, formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } return nil } +func (m *Alert) contextValidateAddressBloomFilter(ctx context.Context, formats strfmt.Registry) error { + + if m.AddressBloomFilter != nil { + if err := m.AddressBloomFilter.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("addressBloomFilter") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("addressBloomFilter") + } + return err + } + } + + return nil +} + +func (m *Alert) contextValidateLabels(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Labels); i++ { + + if m.Labels[i] != nil { + if err := m.Labels[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("labels" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("labels" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + func (m *Alert) contextValidateSource(ctx context.Context, formats strfmt.Registry) error { if m.Source != nil { @@ -255,6 +385,22 @@ func (m *Alert) contextValidateSource(ctx context.Context, formats strfmt.Regist return nil } +func (m *Alert) contextValidateSources(ctx context.Context, formats strfmt.Registry) error { + + if m.Sources != nil { + if err := m.Sources.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("sources") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("sources") + } + return err + } + } + + return nil +} + // MarshalBinary interface implementation func (m *Alert) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/clients/webhook/client/models/alert_label.go b/clients/webhook/client/models/alert_label.go new file mode 100644 index 00000000..4cb6a8ba --- /dev/null +++ b/clients/webhook/client/models/alert_label.go @@ -0,0 +1,70 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// AlertLabel alert label +// +// swagger:model AlertLabel +type AlertLabel struct { + + // confidence + // Example: 0.9 + Confidence float64 `json:"confidence,omitempty"` + + // entity + // Example: 0x113b7cc6b42105dcb8cbfe576590cf7bbc7a12f1 + Entity string `json:"entity,omitempty"` + + // entity type + // Example: ADDRESS + EntityType string `json:"entityType,omitempty"` + + // Label name/identifier + // Example: scammer-eoa + Label string `json:"label,omitempty"` + + // An array of string values + // Example: ["foo=42","bar=123"] + Metadata []string `json:"metadata"` + + // remove + Remove bool `json:"remove,omitempty"` +} + +// Validate validates this alert label +func (m *AlertLabel) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this alert label based on context it is used +func (m *AlertLabel) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *AlertLabel) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *AlertLabel) UnmarshalBinary(b []byte) error { + var res AlertLabel + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/clients/webhook/client/models/alert_sources.go b/clients/webhook/client/models/alert_sources.go new file mode 100644 index 00000000..36fd27ce --- /dev/null +++ b/clients/webhook/client/models/alert_sources.go @@ -0,0 +1,401 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + "strconv" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// AlertSources alert sources +// +// swagger:model AlertSources +type AlertSources struct { + + // alerts + Alerts []*SourceAlert `json:"alerts"` + + // blocks + Blocks []*SourceBlock `json:"blocks"` + + // chains + Chains []*SourceChain `json:"chains"` + + // custom sources + CustomSources []*SourceCustom `json:"customSources"` + + // transactions + Transactions []*SourceTransaction `json:"transactions"` + + // urls + Urls []*SourceURL `json:"urls"` +} + +// Validate validates this alert sources +func (m *AlertSources) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateAlerts(formats); err != nil { + res = append(res, err) + } + + if err := m.validateBlocks(formats); err != nil { + res = append(res, err) + } + + if err := m.validateChains(formats); err != nil { + res = append(res, err) + } + + if err := m.validateCustomSources(formats); err != nil { + res = append(res, err) + } + + if err := m.validateTransactions(formats); err != nil { + res = append(res, err) + } + + if err := m.validateUrls(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *AlertSources) validateAlerts(formats strfmt.Registry) error { + if swag.IsZero(m.Alerts) { // not required + return nil + } + + for i := 0; i < len(m.Alerts); i++ { + if swag.IsZero(m.Alerts[i]) { // not required + continue + } + + if m.Alerts[i] != nil { + if err := m.Alerts[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("alerts" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("alerts" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *AlertSources) validateBlocks(formats strfmt.Registry) error { + if swag.IsZero(m.Blocks) { // not required + return nil + } + + for i := 0; i < len(m.Blocks); i++ { + if swag.IsZero(m.Blocks[i]) { // not required + continue + } + + if m.Blocks[i] != nil { + if err := m.Blocks[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("blocks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("blocks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *AlertSources) validateChains(formats strfmt.Registry) error { + if swag.IsZero(m.Chains) { // not required + return nil + } + + for i := 0; i < len(m.Chains); i++ { + if swag.IsZero(m.Chains[i]) { // not required + continue + } + + if m.Chains[i] != nil { + if err := m.Chains[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("chains" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("chains" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *AlertSources) validateCustomSources(formats strfmt.Registry) error { + if swag.IsZero(m.CustomSources) { // not required + return nil + } + + for i := 0; i < len(m.CustomSources); i++ { + if swag.IsZero(m.CustomSources[i]) { // not required + continue + } + + if m.CustomSources[i] != nil { + if err := m.CustomSources[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("customSources" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("customSources" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *AlertSources) validateTransactions(formats strfmt.Registry) error { + if swag.IsZero(m.Transactions) { // not required + return nil + } + + for i := 0; i < len(m.Transactions); i++ { + if swag.IsZero(m.Transactions[i]) { // not required + continue + } + + if m.Transactions[i] != nil { + if err := m.Transactions[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("transactions" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("transactions" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *AlertSources) validateUrls(formats strfmt.Registry) error { + if swag.IsZero(m.Urls) { // not required + return nil + } + + for i := 0; i < len(m.Urls); i++ { + if swag.IsZero(m.Urls[i]) { // not required + continue + } + + if m.Urls[i] != nil { + if err := m.Urls[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("urls" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("urls" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// ContextValidate validate this alert sources based on the context it is used +func (m *AlertSources) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateAlerts(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateBlocks(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateChains(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateCustomSources(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateTransactions(ctx, formats); err != nil { + res = append(res, err) + } + + if err := m.contextValidateUrls(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *AlertSources) contextValidateAlerts(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Alerts); i++ { + + if m.Alerts[i] != nil { + if err := m.Alerts[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("alerts" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("alerts" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *AlertSources) contextValidateBlocks(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Blocks); i++ { + + if m.Blocks[i] != nil { + if err := m.Blocks[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("blocks" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("blocks" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *AlertSources) contextValidateChains(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Chains); i++ { + + if m.Chains[i] != nil { + if err := m.Chains[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("chains" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("chains" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *AlertSources) contextValidateCustomSources(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.CustomSources); i++ { + + if m.CustomSources[i] != nil { + if err := m.CustomSources[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("customSources" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("customSources" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *AlertSources) contextValidateTransactions(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Transactions); i++ { + + if m.Transactions[i] != nil { + if err := m.Transactions[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("transactions" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("transactions" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +func (m *AlertSources) contextValidateUrls(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Urls); i++ { + + if m.Urls[i] != nil { + if err := m.Urls[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("urls" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("urls" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + +// MarshalBinary interface implementation +func (m *AlertSources) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *AlertSources) UnmarshalBinary(b []byte) error { + var res AlertSources + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/clients/webhook/client/models/source_alert.go b/clients/webhook/client/models/source_alert.go new file mode 100644 index 00000000..70c49021 --- /dev/null +++ b/clients/webhook/client/models/source_alert.go @@ -0,0 +1,50 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SourceAlert source alert +// +// swagger:model SourceAlert +type SourceAlert struct { + + // id + ID string `json:"id,omitempty"` +} + +// Validate validates this source alert +func (m *SourceAlert) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this source alert based on context it is used +func (m *SourceAlert) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SourceAlert) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SourceAlert) UnmarshalBinary(b []byte) error { + var res SourceAlert + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/clients/webhook/client/models/source_block.go b/clients/webhook/client/models/source_block.go new file mode 100644 index 00000000..6d0ca794 --- /dev/null +++ b/clients/webhook/client/models/source_block.go @@ -0,0 +1,56 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SourceBlock source block +// +// swagger:model SourceBlock +type SourceBlock struct { + + // chain Id + ChainID int64 `json:"chainId,omitempty"` + + // hash + Hash string `json:"hash,omitempty"` + + // number + Number int64 `json:"number,omitempty"` +} + +// Validate validates this source block +func (m *SourceBlock) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this source block based on context it is used +func (m *SourceBlock) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SourceBlock) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SourceBlock) UnmarshalBinary(b []byte) error { + var res SourceBlock + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/clients/webhook/client/models/source_chain.go b/clients/webhook/client/models/source_chain.go new file mode 100644 index 00000000..14f53099 --- /dev/null +++ b/clients/webhook/client/models/source_chain.go @@ -0,0 +1,50 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SourceChain source chain +// +// swagger:model SourceChain +type SourceChain struct { + + // chain Id + ChainID int64 `json:"chainId,omitempty"` +} + +// Validate validates this source chain +func (m *SourceChain) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this source chain based on context it is used +func (m *SourceChain) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SourceChain) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SourceChain) UnmarshalBinary(b []byte) error { + var res SourceChain + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/clients/webhook/client/models/source_custom.go b/clients/webhook/client/models/source_custom.go new file mode 100644 index 00000000..8bc5934f --- /dev/null +++ b/clients/webhook/client/models/source_custom.go @@ -0,0 +1,53 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SourceCustom source custom +// +// swagger:model SourceCustom +type SourceCustom struct { + + // name + Name string `json:"name,omitempty"` + + // value + Value string `json:"value,omitempty"` +} + +// Validate validates this source custom +func (m *SourceCustom) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this source custom based on context it is used +func (m *SourceCustom) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SourceCustom) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SourceCustom) UnmarshalBinary(b []byte) error { + var res SourceCustom + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/clients/webhook/client/models/source_transaction.go b/clients/webhook/client/models/source_transaction.go new file mode 100644 index 00000000..a55036ff --- /dev/null +++ b/clients/webhook/client/models/source_transaction.go @@ -0,0 +1,53 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SourceTransaction source transaction +// +// swagger:model SourceTransaction +type SourceTransaction struct { + + // chain Id + ChainID int64 `json:"chainId,omitempty"` + + // hash + Hash string `json:"hash,omitempty"` +} + +// Validate validates this source transaction +func (m *SourceTransaction) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this source transaction based on context it is used +func (m *SourceTransaction) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SourceTransaction) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SourceTransaction) UnmarshalBinary(b []byte) error { + var res SourceTransaction + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/clients/webhook/client/models/source_url.go b/clients/webhook/client/models/source_url.go new file mode 100644 index 00000000..30800c54 --- /dev/null +++ b/clients/webhook/client/models/source_url.go @@ -0,0 +1,50 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// SourceURL source URL +// +// swagger:model SourceURL +type SourceURL struct { + + // url + URL string `json:"url,omitempty"` +} + +// Validate validates this source URL +func (m *SourceURL) Validate(formats strfmt.Registry) error { + return nil +} + +// ContextValidate validates this source URL based on context it is used +func (m *SourceURL) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + return nil +} + +// MarshalBinary interface implementation +func (m *SourceURL) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *SourceURL) UnmarshalBinary(b []byte) error { + var res SourceURL + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +} diff --git a/protocol/webhook/swagger.yml b/protocol/webhook/swagger.yml index 62327373..ce80e799 100644 --- a/protocol/webhook/swagger.yml +++ b/protocol/webhook/swagger.yml @@ -125,6 +125,8 @@ definitions: example: - '0x98883145049dec03c00cb7708cbc938058802520' - '0x1fFa3471A45C22B1284fE5a251eD74F40580a1E3' + addressBloomFilter: + $ref: '#/definitions/AddressBloomFilter' relatedAlerts: type: array items: @@ -133,6 +135,12 @@ definitions: example: - '0xe9cfda18f167de5cdd63c101e38ec0d4cb0a1c2dea80921ecc4405c2b010855f' - '0x533c100d5d7a56ee8448b6b08b5b1ce41ea9d1667086e1d2d4c1f03d09d191b9' + labels: + type: array + items: + $ref: '#/definitions/AlertLabel' + sources: + $ref: '#/definitions/AlertSources' AlertSource: type: object @@ -192,6 +200,119 @@ definitions: format: uint64 example: 1337 + AlertLabel: + type: object + properties: + label: + type: string + description: Label name/identifier + example: scammer-eoa + confidence: + type: number + example: 0.9 + entity: + type: string + example: '0x113b7cc6b42105dcb8cbfe576590cf7bbc7a12f1' + entityType: + type: string + example: ADDRESS + remove: + type: boolean + metadata: + type: array + items: + type: string + description: An array of string values + example: [ foo=42, bar=123 ] + + AlertSources: + type: object + properties: + transactions: + type: array + items: + $ref: '#/definitions/SourceTransaction' + blocks: + type: array + items: + $ref: '#/definitions/SourceBlock' + urls: + type: array + items: + $ref: '#/definitions/SourceURL' + chains: + type: array + items: + $ref: '#/definitions/SourceChain' + alerts: + type: array + items: + $ref: '#/definitions/SourceAlert' + customSources: + type: array + items: + $ref: '#/definitions/SourceCustom' + + SourceTransaction: + type: object + properties: + chainId: + type: integer + hash: + type: string + + SourceBlock: + type: object + properties: + chainId: + type: integer + hash: + type: string + number: + type: integer + + SourceURL: + type: object + properties: + url: + type: string + + SourceChain: + type: object + properties: + chainId: + type: integer + + SourceAlert: + type: object + properties: + id: + type: string + + SourceCustom: + type: object + properties: + name: + type: string + value: + type: string + + AddressBloomFilter: + type: object + properties: + k: + type: string + example: '0x12' + m: + type: string + example: '0x34' + bitset: + type: string + example: 'AAAAAAAAACwAAAAAAAAACwAAAAAAAAAsAAALo5gpbbc=' + itemCount: + type: integer + example: 1 + BotMetricsList: type: array items: