db

package
v0.0.0-...-06d9147 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	Name() string
	OpenDB(string, string, bool, Option) (bool, error)
	CloseDB() error
	MigrateDB() error

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

	Get(string) (*models.CveDetail, error)
	GetMulti([]string) (map[string]models.CveDetail, error)
	GetCveIDsByCpeURI(string) ([]string, []string, error)
	GetByCpeURI(string) ([]models.CveDetail, error)
	InsertJvn([]string) error
	InsertNvd([]string) error
	CountNvd() (int, error)
	CountJvn() (int, error)
}

DB is interface for a database driver

func NewDB

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

NewDB return DB accessor.

type IndexChunk

type IndexChunk struct {
	From, To int
}

IndexChunk has a starting point and an ending point for Chunk

type Option

type Option struct {
	RedisTimeout time.Duration
}

Option :

type RDBDriver

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

RDBDriver is Driver for RDB

func (*RDBDriver) CloseDB

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

CloseDB close Database

func (*RDBDriver) CountJvn

func (r *RDBDriver) CountJvn() (int, error)

CountJvn count jvn table

func (*RDBDriver) CountNvd

func (r *RDBDriver) CountNvd() (int, error)

CountNvd count nvd table

func (*RDBDriver) Get

func (r *RDBDriver) Get(cveID string) (*models.CveDetail, error)

Get Select Cve information from DB.

func (*RDBDriver) GetByCpeURI

func (r *RDBDriver) GetByCpeURI(uri string) ([]models.CveDetail, error)

GetByCpeURI Select Cve information from DB.

func (*RDBDriver) GetCveIDsByCpeURI

func (r *RDBDriver) GetCveIDsByCpeURI(uri string) (nvdCveIDs []string, jvnCveIDs []string, err error)

GetCveIDsByCpeURI Select Cve Ids by by pseudo-CPE

func (*RDBDriver) GetFetchMeta

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

GetFetchMeta get FetchMeta from Database

func (*RDBDriver) GetMulti

func (r *RDBDriver) GetMulti(cveIDs []string) (map[string]models.CveDetail, error)

GetMulti Select Cves information from DB.

func (*RDBDriver) InsertJvn

func (r *RDBDriver) InsertJvn(years []string) error

InsertJvn inserts Cve Information into DB

func (*RDBDriver) InsertNvd

func (r *RDBDriver) InsertNvd(years []string) (err error)

InsertNvd Cve information from DB.

func (*RDBDriver) IsGoCVEDictModelV1

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

IsGoCVEDictModelV1 determines if the DB was created at the time of go-cve-dictionary 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) (locked bool, 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) CountJvn

func (r *RedisDriver) CountJvn() (int, error)

CountJvn count jvn table

func (*RedisDriver) CountNvd

func (r *RedisDriver) CountNvd() (int, error)

CountNvd count nvd table

func (*RedisDriver) Get

func (r *RedisDriver) Get(cveID string) (*models.CveDetail, error)

Get Select Cve information from DB.

func (*RedisDriver) GetByCpeURI

func (r *RedisDriver) GetByCpeURI(uri string) ([]models.CveDetail, error)

GetByCpeURI Select Cve information from DB.

func (*RedisDriver) GetCveIDsByCpeURI

func (r *RedisDriver) GetCveIDsByCpeURI(uri string) ([]string, []string, error)

GetCveIDsByCpeURI Select Cve Ids by by pseudo-CPE

func (*RedisDriver) GetFetchMeta

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

GetFetchMeta get FetchMeta from Database

func (*RedisDriver) GetMulti

func (r *RedisDriver) GetMulti(cveIDs []string) (map[string]models.CveDetail, error)

GetMulti Select Cves information from DB.

func (*RedisDriver) InsertJvn

func (r *RedisDriver) InsertJvn(years []string) error

InsertJvn insert items fetched from JVN.

func (*RedisDriver) InsertNvd

func (r *RedisDriver) InsertNvd(years []string) error

InsertNvd Cve information from DB.

func (*RedisDriver) IsGoCVEDictModelV1

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

IsGoCVEDictModelV1 determines if the DB was created at the time of go-cve-dictionary 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(dbType, dbPath string, _ bool, option Option) (locked bool, err 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