data_models

package
v0.0.0-...-dd13c3c Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddActiveACLRequest

func AddActiveACLRequest(id int64, clientID int64, name string, validThrough time.Time)

* Add active Acl

func AddActiveAliasRequest

func AddActiveAliasRequest(id int64, clientID int64, name string, validThrough time.Time)

* Add active Alias

func CallBlocker

func CallBlocker(acls []ACL, customerID int) (err error)

* Call blocker (GoBGP or Arista)

func CancelBlocker

func CancelBlocker(aclID int64, activationType types.ActivationType) (err error)

* Cancel blocker when update or delete data channel acl

func CheckActiveDataChannelACL

func CheckActiveDataChannelACL(customer *models.Customer, cuid string) (bool, error)

* Check active data channel acl * If data channel acl is active, the server will return true * Else the server will return false

func CheckExistDotsClient

func CheckExistDotsClient(tx *db.Tx, cuid string) (bool, error)

func DeleteACLByName

func DeleteACLByName(tx *db.Tx, clientID int64, name string, now time.Time) (bool, error)

func DeleteAliasByName

func DeleteAliasByName(tx *db.Tx, clientID int64, name string, now time.Time) (bool, error)

func DeleteClientByCuid

func DeleteClientByCuid(tx *db.Tx, customer *models.Customer, cuid string) (bool, error)

func FindACLByID

func FindACLByID(id int64) (data_db_models.ACL, error)

* Find acl by id * * parameter: * id the id of data_client * return: * acl the data_acl

func FindAllACLs

func FindAllACLs() (acls []data_db_models.ACL, err error)

* Find all Acls in DB

func FindAllAliases

func FindAllAliases() (aliases []data_db_models.Alias, err error)

* Find all Alias in DB

func FindClientByID

func FindClientByID(id int64) (data_db_models.Client, error)

* Find client by id * * parameter: * id the id of data_client * return: * client the data_client

func FindCuidsByCustomerId

func FindCuidsByCustomerId(tx *db.Tx, customer *models.Customer) (cuids []string, err error)

* Find all cuids by customerId. * * parameter: * customerId the id of the Customer * return: * cuids the list of cuid * error the error

func GetActiveACLMap

func GetActiveACLMap() map[int64]ActiveACLRequest

* Get active Acl

func GetActiveAliasMap

func GetActiveAliasMap() map[int64]ActiveAliasRequest

* Get active Alias

func GetDataChannelAclAcceptList

func GetDataChannelAclAcceptList(customer *models.Customer, cuid string) ([]string, error)

* Get data channel acl accept list * return * List data channel acl with action is accept

func GetMaxPriority

func GetMaxPriority(engine *xorm.Engine) (maxPriority int, err error)

Get priority is max value

func IsActive

func IsActive(customerId int, cuid string, activationType types.ActivationType) (bool, error)

* Return activation status that is active or inactive * * return: * bool * true status is active * false status is inactive

func ManageExpiredAliasAndAcl

func ManageExpiredAliasAndAcl(lifetimeInterval int)

* Management expired Alias and Acl

func RemoveActiveACLRequest

func RemoveActiveACLRequest(id int64)

* Remove Active Acl

func RemoveActiveAliasRequest

func RemoveActiveAliasRequest(id int64)

* Remove active Alias

func RemoveOverlapIPPrefix

func RemoveOverlapIPPrefix(targetPrefix []types.IPPrefix) []types.IPPrefix

Remove overlap IPPrefix

func ToActivationType

func ToActivationType(activationType int) types.ActivationType

* Parse int activation type to ACL activation type * * return: * acl activation type

func UpdatePriorityAcl

func UpdatePriorityAcl(session *xorm.Session, lenNewAcl int, pointPriority int) (err error)

Update priority of acl

Types

type ACL

type ACL struct {
	Id           int64
	Client       *Client
	Priority     int
	ACL          types.ACL
	ValidThrough time.Time
}

func FindACLByName

func FindACLByName(tx *db.Tx, client *Client, name string, now time.Time) (*ACL, error)

func NewACL

func NewACL(client *Client, acl types.ACL, now time.Time, lifetime time.Duration) ACL

func (*ACL) IsActive

func (acl *ACL) IsActive() (bool, error)

* Return ACL activation status that is active or inactive * * return: * bool * true ACL is active * false ACL is inactive

func (*ACL) Save

func (acl *ACL) Save(tx *db.Tx) error

func (*ACL) ToTypesACL

func (acl *ACL) ToTypesACL(now time.Time) (*types.ACL, error)

type ACLs

type ACLs []ACL

func FindACLs

func FindACLs(tx *db.Tx, client *Client, now time.Time) (ACLs, error)

func (ACLs) GetEmptyTypesACLs

func (acls ACLs) GetEmptyTypesACLs() *types.ACLs

func (ACLs) ToTypesACLs

func (acls ACLs) ToTypesACLs(now time.Time) (*types.ACLs, error)

type APPair

type APPair struct {
	Acl        ACL
	Protection models.Protection
}

func GetACLWithActivateWhenMitigating

func GetACLWithActivateWhenMitigating(customer *models.Customer, cuid string) ([]APPair, error)

* Get acl with activateType = 'activate-when-mitigating'

type ActiveACLRequest

type ActiveACLRequest struct {
	ID           int64
	ClientID     int64
	Name         string
	ValidThrough time.Time
}

* Struct for Active Acl Request.

type ActiveAliasRequest

type ActiveAliasRequest struct {
	ID           int64
	ClientID     int64
	Name         string
	ValidThrough time.Time
}

* Struct for Active Alias Request.

type Alias

type Alias struct {
	Id           int64
	Client       *Client
	Alias        types.Alias
	ValidThrough time.Time
}

func FindAliasByName

func FindAliasByName(tx *db.Tx, client *Client, name string, now time.Time) (*Alias, error)

func NewAlias

func NewAlias(client *Client, alias types.Alias, now time.Time, lifetime time.Duration) Alias

func (*Alias) GetFqdnAsTarget

func (a *Alias) GetFqdnAsTarget() (targetList []models.Target, err error)

* Get mitigation FQDNs as target type * * return: * targetList list of the target FQDNs * err error

func (*Alias) GetPrefixAsTarget

func (a *Alias) GetPrefixAsTarget() (targetList []models.Target, err error)

* Get alias prefixes as target type * * return: * targetList list of the target Prefixes

func (*Alias) GetUriAsTarget

func (a *Alias) GetUriAsTarget() (targetList []models.Target, err error)

* Get mitigation URIs as target type * * return: * targetList list of the target URIs * err error

func (*Alias) Save

func (alias *Alias) Save(tx *db.Tx) error

func (*Alias) ToTypesAlias

func (alias *Alias) ToTypesAlias(now time.Time) (*types.Alias, error)

type Aliases

type Aliases []Alias

func FindAliases

func FindAliases(tx *db.Tx, client *Client, now time.Time) (Aliases, error)

func (Aliases) GetEmptyTypesAliases

func (aliases Aliases) GetEmptyTypesAliases() *types.Aliases

func (Aliases) ToTypesAliases

func (aliases Aliases) ToTypesAliases(now time.Time) (*types.Aliases, error)

type AttackMapping

type AttackMapping struct {
	Id                int64
	AttackId          int
	AttackDescription string
}

type Client

type Client struct {
	Id       int64
	Customer *models.Customer
	Cuid     string
	Cdid     *string
}

func FindClientByCuid

func FindClientByCuid(tx *db.Tx, customer *models.Customer, cuid string) (*Client, error)

func NewClient

func NewClient(customer *models.Customer, cuid string, cdid *string) Client

func (*Client) Save

func (client *Client) Save(tx *db.Tx) error

type Vendor

type Vendor struct {
	Id              int64
	ClientId        int64
	VendorId        int
	VendorName      string
	DescriptionLang string
	LastUpdated     uint64
	AttackMapping   []AttackMapping
}

func FindVendorByVendorId

func FindVendorByVendorId(tx *db.Tx, clientId int64, vendorId int) (Vendor, error)

Find vendor-mapping by vendor-id

func NewVendorMapping

func NewVendorMapping(clientId int64, bodyData types.Vendor) Vendor

New vendor-mapping

func (*Vendor) Save

func (vendor *Vendor) Save(tx *db.Tx) error

Insert vendor-mapping into DB

type Vendors

type Vendors []Vendor

func FindVendorMappingByClientId

func FindVendorMappingByClientId(tx *db.Tx, clientId *int64) (Vendors, error)

Find vendor-mapping by client-id

func (Vendors) ToTypesVendorMapping

func (vendors Vendors) ToTypesVendorMapping(depth *int) *types.VendorMapping

Convert vendor-mapping to types vendor-mapping

Jump to

Keyboard shortcuts

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