db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: MIT Imports: 26 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDBLocked = xerrors.New("database is locked")

ErrDBLocked :

Functions

This section is empty.

Types

type DB

type DB interface {
	Name() string
	OpenDB(dbType, dbPath string, debugSQL bool, option Option) error
	MigrateDB() error
	CloseDB() error

	IsGoCTIModelV1() (bool, error)
	GetFetchMeta() (*models.FetchMeta, error)
	UpsertFetchMeta(*models.FetchMeta) error

	InsertCti([]models.Technique, []models.CveToTechniques, []models.Attacker) error
	GetCtiByCtiID(string) (models.CTI, error)
	GetCtisByMultiCtiID([]string) ([]models.CTI, error)
	GetTechniqueIDsByCveID(string) ([]string, error)
	GetTechniqueIDsByMultiCveID([]string) (map[string][]string, error)
	GetAttackerIDsByTechniqueIDs([]string) ([]string, error)
}

DB :

func NewDB

func NewDB(dbType string, dbPath string, debugSQL bool, option Option) (driver DB, err error)

NewDB :

type Option

type Option struct {
	RedisTimeout time.Duration
}

Option :

type RDBDriver

type RDBDriver struct {
	// contains filtered or unexported fields
}

RDBDriver :

func (*RDBDriver) CloseDB

func (r *RDBDriver) CloseDB() (err error)

CloseDB close Database

func (*RDBDriver) GetAttackerIDsByTechniqueIDs

func (r *RDBDriver) GetAttackerIDsByTechniqueIDs(techniqueIDs []string) ([]string, error)

GetAttackerIDsByTechniqueIDs :

func (*RDBDriver) GetCtiByCtiID

func (r *RDBDriver) GetCtiByCtiID(ctiID string) (models.CTI, error)

GetCtiByCtiID :

func (*RDBDriver) GetCtisByMultiCtiID

func (r *RDBDriver) GetCtisByMultiCtiID(ctiIDs []string) ([]models.CTI, error)

GetCtisByMultiCtiID :

func (*RDBDriver) GetFetchMeta

func (r *RDBDriver) GetFetchMeta() (fetchMeta *models.FetchMeta, err error)

GetFetchMeta get FetchMeta from Database

func (*RDBDriver) GetTechniqueIDsByCveID

func (r *RDBDriver) GetTechniqueIDsByCveID(cveID string) ([]string, error)

GetTechniqueIDsByCveID :

func (*RDBDriver) GetTechniqueIDsByMultiCveID

func (r *RDBDriver) GetTechniqueIDsByMultiCveID(cveIDs []string) (map[string][]string, error)

GetTechniqueIDsByMultiCveID :

func (*RDBDriver) InsertCti

func (r *RDBDriver) InsertCti(techniques []models.Technique, mappings []models.CveToTechniques, attackers []models.Attacker) (err error)

InsertCti :

func (*RDBDriver) IsGoCTIModelV1

func (r *RDBDriver) IsGoCTIModelV1() (bool, error)

IsGoCTIModelV1 determines if the DB was created at the time of go-cti Model v1

func (*RDBDriver) MigrateDB

func (r *RDBDriver) MigrateDB() error

MigrateDB migrates Database

func (*RDBDriver) Name

func (r *RDBDriver) Name() string

Name return db name

func (*RDBDriver) OpenDB

func (r *RDBDriver) OpenDB(dbType, dbPath string, debugSQL bool, _ Option) (err error)

OpenDB opens Database

func (*RDBDriver) UpsertFetchMeta

func (r *RDBDriver) UpsertFetchMeta(fetchMeta *models.FetchMeta) error

UpsertFetchMeta upsert FetchMeta to Database

type RedisDriver

type RedisDriver struct {
	// contains filtered or unexported fields
}

RedisDriver is Driver for Redis

func (*RedisDriver) CloseDB

func (r *RedisDriver) CloseDB() (err error)

CloseDB close Database

func (*RedisDriver) GetAttackerIDsByTechniqueIDs

func (r *RedisDriver) GetAttackerIDsByTechniqueIDs(techniqueIDs []string) ([]string, error)

GetAttackerIDsByTechniqueIDs :

func (*RedisDriver) GetCtiByCtiID

func (r *RedisDriver) GetCtiByCtiID(ctiID string) (models.CTI, error)

GetCtiByCtiID :

func (*RedisDriver) GetCtisByMultiCtiID

func (r *RedisDriver) GetCtisByMultiCtiID(ctiIDs []string) ([]models.CTI, error)

GetCtisByMultiCtiID :

func (*RedisDriver) GetFetchMeta

func (r *RedisDriver) GetFetchMeta() (*models.FetchMeta, error)

GetFetchMeta get FetchMeta from Database

func (*RedisDriver) GetTechniqueIDsByCveID

func (r *RedisDriver) GetTechniqueIDsByCveID(cveID string) ([]string, error)

GetTechniqueIDsByCveID :

func (*RedisDriver) GetTechniqueIDsByMultiCveID

func (r *RedisDriver) GetTechniqueIDsByMultiCveID(cveIDs []string) (map[string][]string, error)

GetTechniqueIDsByMultiCveID :

func (*RedisDriver) InsertCti

func (r *RedisDriver) InsertCti(techniques []models.Technique, mappings []models.CveToTechniques, attackers []models.Attacker) error

InsertCti :

func (*RedisDriver) IsGoCTIModelV1

func (r *RedisDriver) IsGoCTIModelV1() (bool, error)

IsGoCTIModelV1 determines if the DB was created at the time of go-cti Model v1

func (*RedisDriver) MigrateDB

func (r *RedisDriver) MigrateDB() error

MigrateDB migrates Database

func (*RedisDriver) Name

func (r *RedisDriver) Name() string

Name return db name

func (*RedisDriver) OpenDB

func (r *RedisDriver) OpenDB(_, dbPath string, _ bool, option Option) error

OpenDB opens Database

func (*RedisDriver) UpsertFetchMeta

func (r *RedisDriver) UpsertFetchMeta(fetchMeta *models.FetchMeta) error

UpsertFetchMeta upsert FetchMeta to Database

Jump to

Keyboard shortcuts

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