models

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreatePage

func CreatePage(url string, title string, statusCode int, body string, headers PropertyMap) (uint, error)

func CreatePhoneNumber

func CreatePhoneNumber(webPageID int, interNum, natNum string, code string) error

func GetDB

func GetDB() *gorm.DB

func SetupDatabase

func SetupDatabase(dbUrl string) *gorm.DB

SetupDatabase also auto migrates the models if there are any changes

Types

type Crypto

type Crypto struct {
	Model
	//WebPageID is the serves as a foreign key to web_pages
	WebPageID    int            `json:"pageId"`
	PGPKeys      pq.StringArray `json:"PGPKey" gorm:"type:text[]"`
	Certificates pq.StringArray `json:"Certificates" gorm:"type:text[]"`
	Wallets      pq.StringArray `json:"Wallets" gorm:"type:text[]"`
}

Crypto stores various cryptographic findings, such as

func CryptoCreate

func CryptoCreate(c Crypto) (Crypto, error)

type Email

type Email struct {
	Model
	//WebPageID is the serves as a foreign key to web_pages
	WebPageID int            `json:"pageId"`
	Emails    pq.StringArray `json:"emails" gorm:"type:text[]"`
}

Email stores processed emails that are found within a web page.

func CreateEmails

func CreateEmails(pageId int, emails []string) *Email

type Model

type Model struct {
	ID uint `gorm:"primaryKey"`
}

type PageData

type PageData struct {
	URL        string      `json:"url" gorm:"uniqueIndex;not null"`
	Title      string      `json:"title" gorm:"Index"`
	StatusCode int         `json:"statusCode" gorm:"Index;not null"`
	Body       string      `json:"body" gorm:"type:text"`
	Headers    PropertyMap `json:"headers" gorm:"type:jsonb"`
}

PageData is embedded into the webPage model for structured data

type PhoneNumber

type PhoneNumber struct {
	Model

	//WebPageID is the serves as a foreign key to web_pages
	WebPageID           int    `json:"pageId"`
	InternationalNumber string `json:"internationalNumber" gorm:"uniqueIndex"`
	NationalNumber      string `json:"nationalNumber" gorm:"unique"`
	CountryCode         string `json:"countryCode"`
}

type PropertyMap

type PropertyMap map[string]interface{}

PropertyMap is the postgres implementation of jsonb in go.

func (*PropertyMap) Scan

func (p *PropertyMap) Scan(src interface{}) error

Scan unmarshals a JSON-encoded byte slice into a PropertyMap. It assigns the result to the PropertyMap (p) or returns an error.

func (PropertyMap) Value

func (p PropertyMap) Value() (driver.Value, error)

type WebPage

type WebPage struct {
	Model
	PageData `json:"pageData"`
	//References are here for exporting structured data from the webPage model.
	Emails       *Email              `json:"email" gorm:"foreignKey:WebPageID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	PhoneNumbers *PhoneNumber        `json:"phoneNumbers" gorm:"foreignKey:WebPageID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	Crypto       *Crypto             `json:"crypto" gorm:"foreignKey:WebPageID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	Wordpress    *WordpressFootPrint `json:"wordpress" gorm:"foreignKey:WebPageID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}

type WordpressFootPrint

type WordpressFootPrint struct {
	Model
	//WebPageID is the serves as a foreign key to web_pages
	WebPageID     int            `json:"pageId"`
	WordpressHtml pq.StringArray `json:"wordpressHtml" gorm:"type:text[]"`
}

func CreateWordPressFootPrint

func CreateWordPressFootPrint(pageId int, html []string) *WordpressFootPrint

func (WordpressFootPrint) TableName

func (WordpressFootPrint) TableName() string

Jump to

Keyboard shortcuts

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