database

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2018 License: MIT Imports: 8 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Db *gorm.DB

Db is the database handler

View Source
var Products []Product

Products contains all currently available products and is used for the switcher in the header

View Source
var Versions []Version

Versions contains all currently available versions and is used for the switcher in the header

Functions

func InitDb

func InitDb(connection string) error

InitDb sets up the database

Types

type Comment

type Comment struct {
	ID        uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time

	CrashID  uuid.UUID `sql:"type:uuid DEFAULT NULL"`
	ReportID uuid.UUID `sql:"type:uuid DEFAULT NULL"`

	UserID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
	User   User

	Content template.HTML
}

Comment defines the structure of a comment

type Crash

type Crash struct {
	ID        uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time

	Signature     string
	Module        string
	AllCrashCount uint `gorm:"-"`
	WinCrashCount uint `gorm:"-"`
	MacCrashCount uint `gorm:"-"`

	Reports  []Report
	Comments []Comment

	FirstReported time.Time
	LastReported  time.Time

	ProductID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
	Product   Product

	Versions []*Version `gorm:"many2many:crash_versions;"`

	Fixed *time.Time `sql:"DEFAULT NULL"`
}

Crash database model

type Migration added in v1.2.0

type Migration struct {
	ID        uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
	CreatedAt time.Time
	UpdatedAt time.Time

	Component string `gorm:"unique,index"`
	Version   string
}

Migration is a table for the component versions

type Product

type Product struct {
	ID        uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time

	Name string
	Slug string
}

Product defines the structure of a product

func (*Product) AfterDelete

func (c *Product) AfterDelete(tx *gorm.DB) error

AfterDelete is called on deleting Products, updates the variable

func (*Product) AfterSave

func (c *Product) AfterSave(tx *gorm.DB) error

AfterSave is called on saving Products, updates the variable

type Report

type Report struct {
	ID        uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time

	CrashID uuid.UUID `sql:"type:uuid DEFAULT NULL"`
	Crash   Crash

	ProcessUptime int
	EMail         string
	Comment       string
	Processed     bool

	Os            string
	OsVersion     string
	Arch          string
	Signature     string
	Module        string
	CrashLocation string
	CrashPath     string
	CrashLine     int

	Comments []Comment

	ReportContentJSON string        `sql:"type:JSONB NOT NULL DEFAULT '{}'::JSONB" json:"-"`
	Report            ReportContent `gorm:"-"`

	ProductID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
	Product   Product

	VersionID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
	Version   Version

	ProcessingTime float64
}

Report database model

func (*Report) AfterFind

func (c *Report) AfterFind() error

AfterFind is called on finds, maps JSON string to Report

func (*Report) BeforeSave

func (c *Report) BeforeSave() error

BeforeSave is called before a crashreport is saved and maps the Report to a JSON string

type ReportContent

type ReportContent struct {
	CrashInfo struct {
		Address        string `json:"address"`
		CrashingThread int    `json:"crashing_thread"`
		Type           string `json:"type"`
	} `json:"crash_info"`
	CrashingThread struct {
		Frames []struct {
			Frame          int    `json:"frame"`
			MissingSymbols bool   `json:"missing_symbols,omitempty"`
			Module         string `json:"module"`
			ModuleOffset   string `json:"module_offset"`
			Offset         string `json:"offset"`
			Registers      struct {
				R10 string `json:"r10,omitempty"`
				R11 string `json:"r11,omitempty"`
				R12 string `json:"r12,omitempty"`
				R13 string `json:"r13,omitempty"`
				R14 string `json:"r14,omitempty"`
				R15 string `json:"r15,omitempty"`
				R8  string `json:"r8,omitempty"`
				R9  string `json:"r9,omitempty"`
				Rax string `json:"rax,omitempty"`
				Rbp string `json:"rbp,omitempty"`
				Rbx string `json:"rbx,omitempty"`
				Rcx string `json:"rcx,omitempty"`
				Rdi string `json:"rdi,omitempty"`
				Rdx string `json:"rdx,omitempty"`
				Rip string `json:"rip,omitempty"`
				Rsi string `json:"rsi,omitempty"`
				Rsp string `json:"rsp,omitempty"`
			} `json:"registers,omitempty"`
			Trust          string `json:"trust"`
			File           string `json:"file,omitempty"`
			Function       string `json:"function,omitempty"`
			FunctionOffset string `json:"function_offset,omitempty"`
			Line           int    `json:"line,omitempty"`
		} `json:"frames"`
		ThreadsIndex int `json:"threads_index"`
		TotalFrames  int `json:"total_frames"`
	} `json:"crashing_thread"`
	MainModule int `json:"main_module"`
	Modules    []struct {
		BaseAddr       string `json:"base_addr"`
		CodeID         string `json:"code_id"`
		DebugFile      string `json:"debug_file"`
		DebugID        string `json:"debug_id"`
		EndAddr        string `json:"end_addr"`
		Filename       string `json:"filename"`
		LoadedSymbols  bool   `json:"loaded_symbols,omitempty"`
		Version        string `json:"version"`
		MissingSymbols bool   `json:"missing_symbols,omitempty"`
	} `json:"modules"`
	Pid       int `json:"pid"`
	Sensitive struct {
		Exploitability string `json:"exploitability"`
	} `json:"sensitive"`
	Status     string `json:"status"`
	SystemInfo struct {
		CPUArch  string `json:"cpu_arch"`
		CPUCount int    `json:"cpu_count"`
		CPUInfo  string `json:"cpu_info"`
		Os       string `json:"os"`
		OsVer    string `json:"os_ver"`
	} `json:"system_info"`
	ThreadCount int `json:"thread_count"`
	Threads     []struct {
		FrameCount int `json:"frame_count"`
		Frames     []struct {
			Frame          int    `json:"frame"`
			MissingSymbols bool   `json:"missing_symbols,omitempty"`
			Module         string `json:"module"`
			ModuleOffset   string `json:"module_offset"`
			Offset         string `json:"offset"`
			Trust          string `json:"trust"`
			File           string `json:"file,omitempty"`
			Function       string `json:"function,omitempty"`
			FunctionOffset string `json:"function_offset,omitempty"`
			Line           int    `json:"line,omitempty"`
		} `json:"frames"`
	} `json:"threads"`
}

ReportContent of a crashreport

type Symfile

type Symfile struct {
	ID        uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time

	Os string

	Arch string
	Code string `gorm:"unique;index"`
	Name string

	ProductID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
	Product   Product

	VersionID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
	Version   Version
}

Symfile database model

type User

type User struct {
	ID        uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time

	Name    string
	IsAdmin bool

	Comments []Comment
}

User defines the structure of a user

type Version

type Version struct {
	ID        uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time

	Name    string
	Slug    string
	GitRepo string
	Ignore  bool

	ProductID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
	Product   Product

	Crashes []*Crash `gorm:"many2many:crash_versions;"`
}

Version defines the structure of a product

func (*Version) AfterDelete added in v1.1.0

func (c *Version) AfterDelete(tx *gorm.DB) error

AfterDelete is called on deleting Versions, updates the variable

func (*Version) AfterSave added in v1.1.0

func (c *Version) AfterSave(tx *gorm.DB) error

AfterSave is called on saving Versions, updates the variable

Jump to

Keyboard shortcuts

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