Documentation
¶
Index ¶
- func AutoMigrate(db *gorm.DB) (err error)
- func KnownFiles() *knownFileRepository
- func Machines() *machineRepository
- func MustAutoMigrate(db *gorm.DB)
- func MustOpen(dbUrl string) *gorm.DB
- func Open(dbUrl string) (*gorm.DB, error)
- func Packages() *packageRepository
- func ReportRuns() *reportRunRepository
- func ScannedFiles() *scannedFileRepository
- type Datastore
- type DbOp
- type FileStatus
- type JSONField
- type KnownFile
- type Machine
- type OsType
- type Package
- type ReportRun
- type ScannedFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AutoMigrate ¶
func KnownFiles ¶
func KnownFiles() *knownFileRepository
func MustAutoMigrate ¶
func ReportRuns ¶
func ReportRuns() *reportRunRepository
func ScannedFiles ¶
func ScannedFiles() *scannedFileRepository
Types ¶
type Datastore ¶
type Datastore interface {
Machines() *machineRepository
Packages() *packageRepository
KnownFiles() *knownFileRepository
ScannedFiles() *scannedFileRepository
ReportRuns() *reportRunRepository
}
type FileStatus ¶
type FileStatus byte
const ( FileStatusUnknown FileStatus = 0 FileStatusSafe FileStatus = 1 FileStatusCommon FileStatus = 100 FileStatusMalicious FileStatus = 255 )
func (FileStatus) String ¶
func (f FileStatus) String() string
type JSONField ¶
type JSONField[T any] struct { Val T }
func (JSONField[T]) GormDBDataType ¶
func (JSONField[T]) MarshalJSON ¶
func (*JSONField[T]) UnmarshalJSON ¶
type KnownFile ¶
type KnownFile struct {
ID uint `gorm:"primarykey"`
// Path, Hashes, Indexed
Path *string `gorm:"varchar(1024)"`
SHA1 *string `gorm:"type:char(40);index"`
SHA256 *string `gorm:"type:char(64);index"`
MD5 *string `gorm:"type:char(32);index"`
// File info
Size *int64 `gorm:"default:null"`
MimeType *string `gorm:"default:null"`
// Wether was scraped or voted for
PackageID *uint
Package Package `gorm:"foreignKey:PackageID"`
// File Status
Status FileStatus `gorm:"notnull;default:0"`
}
type Machine ¶
type Machine struct {
ID uint `gorm:"primarykey"`
Hostname string `gorm:"type:varchar(255);uniqueIndex:;notnull"`
MachineId string `gorm:"type:varchar(255);uniqueIndex:;notnull"`
}
Machine represents information about a machine on the network. It also contains info whether the machine is allowed to submit files.
type Package ¶
type Package struct {
ID uint `gorm:"primarykey"`
Name string `gorm:"uniqueIndex:uniqpkg"`
Filename string
MD5Sum *string `gorm:"default:null"`
SHA256 *string `gorm:"default:null"`
Version string `gorm:"uniqueIndex:uniqpkg"`
Size uint64
Architecture string `gorm:"uniqueIndex:uniqpkg"`
Distro string `gorm:"uniqueIndex:uniqpkg"`
Component string `gorm:"uniqueIndex:uniqpkg"`
OsType OsType `gorm:"uniqueIndex:uniqpkg"`
CreatedAt time.Time
UpdatedAt time.Time
ScrapedAt time.Time `gorm:"default:null"`
}
type ReportRun ¶
type ReportRun struct {
ID uuid.UUID `gorm:"type:char(36);primarykey;default:uuid()"`
CreatedAt time.Time
IP string
MachineID uint
Machine Machine `gorm:"foreignKey:MachineID"`
Files []ScannedFile `gorm:"foreignKey:ReportRunID"`
}
ReportRun represents information about a machine on the network. It also contains info whether the machine is allowed to submit files.
type ScannedFile ¶
type ScannedFile struct {
ID uint `gorm:"primarykey"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
// Path
Path string `gorm:"type:varchar(1024);notnull"`
// Hashes
SHA1 *string `gorm:"type:char(40);check:at_least_one,(sha1 IS NOT NULL) OR (sha256 IS NOT NULL) OR (md5 IS NOT NULL)"`
SHA256 *string `gorm:"type:char(64)"`
MD5 *string `gorm:"type:char(32)"`
// File info
Size int64 `gorm:"notnull;default:-1"`
Mode uint32 `gorm:"notnull;default:4294967295"`
MimeType string `gorm:"type:varchar(255);notnull"`
// File times
Mtime *int64 `gorm:"type:long"`
Atime *int64 `gorm:"type:long"`
Ctime *int64 `gorm:"type:long"`
// Users
Owner *uint32
Group *uint32
// Run info
ReportRunID uuid.UUID
ReportRun ReportRun `gorm:"foreignKey:ReportRunID"`
// Submitting Machine info
MachineID uint
Machine Machine `gorm:"foreignKey:MachineID"`
}
Click to show internal directories.
Click to hide internal directories.