db

package
v0.0.0-...-269099d Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const TaskStatusDown = "down"
View Source
const TaskStatusError = "error"
View Source
const TaskStatusRunning = "running"

Variables

View Source
var GlobalDB *gorm.DB

Functions

func AddPlugin

func AddPlugin(plugin Plugin) bool

func AddResult

func AddResult(result Result) bool

func AddTask

func AddTask(task *Task) bool

func AddVulnerability

func AddVulnerability(vul Vulnerability) bool

func AddWebapp

func AddWebapp(app Webapp) bool

func DeletePlugin

func DeletePlugin(id int) bool

func DeleteResult

func DeleteResult(id int) bool

func DeleteTask

func DeleteTask(id int) bool

func DeleteVulnerability

func DeleteVulnerability(id int) bool

func DeleteWebapp

func DeleteWebapp(id int) bool

func DownTask

func DownTask(id int) bool

func EditPlugin

func EditPlugin(id int, plugin Plugin) bool

func EditVulnerability

func EditVulnerability(id int, vul Vulnerability) bool

func EditWebapp

func EditWebapp(id int, app Webapp) bool

func ErrorTask

func ErrorTask(id int) bool

func ExistPluginByID

func ExistPluginByID(id int) bool

func ExistPluginByVulId

func ExistPluginByVulId(vul_id string) bool

func ExistResultByID

func ExistResultByID(id int) bool

func ExistTaskByID

func ExistTaskByID(id int) bool

func ExistVulnerabilityByID

func ExistVulnerabilityByID(id int) bool

func ExistVulnerabilityByNameZh

func ExistVulnerabilityByNameZh(name_zh string) bool

func ExistWebappById

func ExistWebappById(id int) bool

func ExistWebappByName

func ExistWebappByName(name string) bool

func GenPluginVulId

func GenPluginVulId() (string, error)

func GetPluginsTotal

func GetPluginsTotal(field *PluginSearchField) (total int64)

func GetResultTotal

func GetResultTotal(field *ResultSearchField) (total int64)

func GetTaskTotal

func GetTaskTotal(field *TaskSearchField) (total int64)

func GetVulnerabilitiesTotal

func GetVulnerabilitiesTotal(field *VulnerabilitySearchField) (total int64)

func GetWebappsTotal

func GetWebappsTotal(field *WebappSearchField) (total int64)

func ResetPassword

func ResetPassword(id int, newpassword string)

ResetPassword

func Setup

func Setup()

Types

type Auth

type Auth struct {
	gorm.Model
	Id       int    `gorm:"primary_key" json:"id"`
	Username string `json:"username"`
	Password string `json:"password"`
}

func CheckAuth

func CheckAuth(username, password string) (bool, *Auth)

CheckAuth checks if authentication information exists

type Plugin

type Plugin struct {
	Id            int            `gorm:"primary_key" json:"id"`
	VulId         string         `gorm:"column:vul_id" json:"vul_id"`
	Affects       string         `gorm:"column:affects" json:"affects" binding:"required"`
	JsonPoc       datatypes.JSON `gorm:"column:json_poc" json:"json_poc"`
	Enable        bool           `gorm:"column:enable" json:"enable"`
	Desc          int            `gorm:"column:description" json:"description"`
	Vulnerability *Vulnerability `gorm:"foreignkey:Desc"`
}

func GetPlugin

func GetPlugin(id int) (plugin Plugin)

func GetPlugins

func GetPlugins(page int, pageSize int, field *PluginSearchField) (plugins []Plugin)

type PluginSearchField

type PluginSearchField struct {
	Search       string
	EnableField  int `binding:"oneof=0 1"`
	AffectsField string
}

type Result

type Result struct {
	//gorm.Model
	Id         int            `gorm:"primary_key" json:"id"`
	Vul        bool           `gorm:"column:vul" json:"vul"`
	Detail     datatypes.JSON `gorm:"column:detail" json:"detail"`
	PluginId   string         `gorm:"plugin_id" json:"plugin_id"`
	PluginName string         `gorm:"plugin_name" json:"plugin_name"`
	TaskId     int            `gorm:"task_id" json:"task_id"`
}

func GetResult

func GetResult(page int, pageSize int, field *ResultSearchField) (results []Result)

type ResultSearchField

type ResultSearchField struct {
	Search    string
	TaskField int
	VulField  int
}

type Task

type Task struct {
	//gorm.Model
	Id       int      `gorm:"primary_key" json:"id"`
	Remarks  string   `gorm:"column:remarks" json:"remarks"`
	Target   string   `gorm:"type:longtext" json:"target"`
	Operator string   `gorm:"type:string" json:"operator"`
	Status   string   `gorm:"type:string" json:"status"`
	Results  []Result `gorm:"foreignKey:TaskId;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"results"`
}

func GetTask

func GetTask(page int, pageSize int, field *TaskSearchField) (tasks []Task)

type TaskSearchField

type TaskSearchField struct {
	Search string
}

type Vulnerability

type Vulnerability struct {
	gorm.Model
	Id            int     `gorm:"primary_key" json:"id"`
	NameZh        string  `gorm:"column:name_zh" json:"name_zh" binding:"required"`
	Cve           string  `gorm:"column:cve" json:"cve"`
	Cnnvd         string  `gorm:"column:cnnvd" json:"cnnvd"`
	Severity      string  `gorm:"column:severity" json:"severity"`
	Category      string  `gorm:"column:category" json:"category"`
	Description   string  `gorm:"type:longtext" json:"description"`
	Suggestion    string  `gorm:"type:longtext" json:"suggestion"`
	Language      string  `gorm:"column:language" json:"language"`
	Webapp        int     `gorm:"column:webapp" json:"webapp"`
	ForeignWebapp *Webapp `gorm:"foreignKey:Webapp"`
}

func GetVulnerabilities

func GetVulnerabilities(page int, pageSize int, field *VulnerabilitySearchField) (vuls []Vulnerability)

func GetVulnerability

func GetVulnerability(id int) (vul Vulnerability)

type VulnerabilitySearchField

type VulnerabilitySearchField struct {
	Search        string
	CategoryField string
	WebappField   int
}

type Webapp

type Webapp struct {
	Id       int    `gorm:"primary_key" json:"id"`
	Name     string `gorm:"column:name" json:"name" binding:"required"`
	Provider string `gorm:"column:provider" json:"provider"`
	Remarks  string `gorm:"column:remarks" json:"remarks"`
}

func GetWebapp

func GetWebapp(id int) (app Webapp)

func GetWebapps

func GetWebapps(page int, pageSize int, field *WebappSearchField) (apps []Webapp)

type WebappSearchField

type WebappSearchField struct {
	Search string
}

Jump to

Keyboard shortcuts

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