model

package
v0.0.209 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddNewProgramIfNotExist added in v0.0.203

func AddNewProgramIfNotExist(db *gorm.DB, programName string, config json.RawMessage, scopes, otoscopes []string) (*int, error)

func DeleteProgramWithProgramName added in v0.0.207

func DeleteProgramWithProgramName(db *gorm.DB, programName string) error

DeleteProgramWithProgramName deletes a Program by its ProgramName.

func GetAllLiveSubdomainWithScopeName added in v0.0.207

func GetAllLiveSubdomainWithScopeName(db *gorm.DB, scope string) ([]string, error)

func GetAllSubdomainWithScopeName added in v0.0.205

func GetAllSubdomainWithScopeName(db *gorm.DB, scope string) ([]string, error)

func InsertOrUpdateProgram added in v0.0.203

func InsertOrUpdateProgram(db *gorm.DB, program *Program) error

insertOrUpdateProgram inserts a new record or updates an existing one based on the ProgramName.

func UpsertHttp added in v0.0.207

func UpsertHttp(db *gorm.DB, http Http)

UpsertHttp performs an upsert (insert or update) operation on the Http model

func UpsertLiveSubdomain added in v0.0.205

func UpsertLiveSubdomain(db *gorm.DB, domain, subdomain string, ips []string, tag string) error

UpsertLives inserts or updates a live subdomain entry in the database.

func UpsertSubdomain added in v0.0.203

func UpsertSubdomain(db *gorm.DB, programName string, subDomain string, provider string) error

Always a single string for the provider

Types

type BaseModel

type BaseModel struct {
	Id        int          `gorm:"primaryKey"`
	CreatedAt time.Time    `gorm:"type:TIMESTAMP with time zone;default:CURRENT_TIMESTAMP; not null;"`
	UpdatedAt sql.NullTime `gorm:"type:TIMESTAMP with time zone;default:CURRENT_TIMESTAMP;  null;"`
}

func (*BaseModel) BeforeCreate

func (m *BaseModel) BeforeCreate(tx *gorm.DB) (err error)

func (*BaseModel) BeforeUpdate

func (m *BaseModel) BeforeUpdate(tx *gorm.DB) (err error)

type CreateHuntRequest

type CreateHuntRequest struct {
	Name string `json:"name" binding:"required,min:3,max:100"`
}

type CreateUpdateProgramRequest

type CreateUpdateProgramRequest struct {
	ProgramName string          `json:"name" binding:"required,min:3,max:100"`
	Config      json.RawMessage `json:"config"`
	Scopes      []string        `json:"scopes"`
	Otoscopes   []string        `json:"otoscopes"`
}

type CreateUpdateSubDomainRequest

type CreateUpdateSubDomainRequest struct {
	ProgramName string   `json:"programName" binding:"required"`
	SubDomain   string   `json:"subDomain" binding:"required"`
	Providers   []string `json:"providers"`
}

type Http added in v0.0.205

type Http struct {
	BaseModel
	ProgramName string      `gorm:"type:text;not null;uniqueIndex:idx_program_subdomain"`
	SubDomain   string      `gorm:"type:text;not null;uniqueIndex:idx_program_subdomain"`
	Scope       string      `gorm:"type:text;not null"`
	IPs         StringArray `gorm:"type:text[]"`
	Tech        StringArray `gorm:"type:text[]"`
	Title       string      `gorm:"type:text"`
	StatusCode  string      `gorm:"type:text"`
	Headers     MapField    `gorm:"type:jsonb"`
	URL         string      `gorm:"type:text"`
	FinalURL    string      `gorm:"type:text"`
	Favicon     string      `gorm:"type:text"`
}

Http represents the HTTP model

func GetAllHttp added in v0.0.206

func GetAllHttp(db *gorm.DB) ([]Http, error)

func GetAllHttpWithScope added in v0.0.206

func GetAllHttpWithScope(db *gorm.DB, scope string) ([]Http, error)

type Hunt

type Hunt struct {
	BaseModel
	Name string `gorm:"type:text;"`
}

type HuntResponse

type HuntResponse struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
}

type LiveSubdomain added in v0.0.205

type LiveSubdomain struct {
	BaseModel
	ProgramName string      `gorm:"type:text;not null;uniqueIndex:idx_program_subdomain"` // Composite unique index
	Subdomain   string      `gorm:"type:text;not null;uniqueIndex:idx_program_subdomain"` // Same unique index name
	Scope       string      `gorm:"type:text;not null"`
	IPs         StringArray `gorm:"type:text[]"`
	Tag         string      `gorm:"type:text"`
}

LiveSubdomains represents the live subdomains model

func GetAllLiveSubdomainWithScope added in v0.0.205

func GetAllLiveSubdomainWithScope(db *gorm.DB, scope string) ([]LiveSubdomain, error)

GetAllLiveSubdomainWithScope fetches all subdomains associated with a given scope

func GetAllLiveSubdomainWithScopeAndDomain added in v0.0.207

func GetAllLiveSubdomainWithScopeAndDomain(db *gorm.DB, scope string, domain string) ([]LiveSubdomain, error)

GetAllLiveSubdomainWithScope fetches all subdomains associated with a given scope

func GetLiveSubdomain added in v0.0.207

func GetLiveSubdomain(db *gorm.DB, subdomain string) (*LiveSubdomain, error)

GetLiveSubdomain fetches a LiveSubdomain record by subdomain.

type MapField added in v0.0.205

type MapField map[string]interface{}

MapField type to handle JSONB fields in PostgreSQL

func (*MapField) Scan added in v0.0.205

func (mf *MapField) Scan(value interface{}) error

Scan implements the sql.Scanner interface for MapField

func (MapField) Value added in v0.0.205

func (mf MapField) Value() (driver.Value, error)

Value implements the driver.Valuer interface for MapField

type Program

type Program struct {
	BaseModel
	ProgramName string          `gorm:"type:text;not null;uniqueIndex"` // Unique and indexed
	Config      json.RawMessage `gorm:"type:jsonb;default:null"`        // Dictionary field, nullable
	Scopes      pq.StringArray  `gorm:"type:text[]"`                    // Correctly handle PostgreSQL text[]
	Otoscopes   pq.StringArray  `gorm:"type:text[]"`                    // Correctly handle PostgreSQL text[]

}

Import pq package for PostgreSQL support

func FindDomainWithProgramName added in v0.0.203

func FindDomainWithProgramName(db *gorm.DB, programName string) (*Program, error)

FindDomainWithProgramName queries a Program by its ProgramName

func GetAllPrograms added in v0.0.204

func GetAllPrograms(db *gorm.DB) ([]Program, error)

getAllPrograms retrieves all programs from the database

func GetProgramByProgramName added in v0.0.207

func GetProgramByProgramName(db *gorm.DB, programName string) (Program, error)

GetProgramByProgramName fetches a Program by its ProgramName

func GetProgramByScope added in v0.0.205

func GetProgramByScope(db *gorm.DB, domain string) (*Program, error)

use abuse db GetProgramByScope retrieves the first program that matches the given scope.

type ProgramResponse

type ProgramResponse struct {
	Id          int             `json:"id"`
	ProgramName string          `json:"programName"`
	Config      json.RawMessage `json:"config"`
	Otoscopes   []string        `json:"otoscopes"`
	CreatedAt   time.Time       `json:"createdat"`
	UpdatedAt   sql.NullTime    `json:"updatedat"`
}

type StringArray added in v0.0.203

type StringArray []string

StringArray custom type for PostgreSQL text[]

func (*StringArray) Scan added in v0.0.203

func (sa *StringArray) Scan(value interface{}) error

Scan implements the sql.Scanner interface for StringArray

func (StringArray) Value added in v0.0.203

func (sa StringArray) Value() (driver.Value, error)

Value implements the driver.Valuer interface for StringArray

type SubDomainResponse

type SubDomainResponse struct {
	Id          int          `json:"id"`
	ProgramName string       `json:"programName"`
	SubDomain   string       `json:"subDomain"`
	Providers   []string     `json:"providers"`
	CreatedAt   time.Time    `json:"createdat"`
	UpdatedAt   sql.NullTime `json:"updatedat"`
}

type Subdomain

type Subdomain struct {
	BaseModel
	ProgramName string      `gorm:"type:text;not null;uniqueIndex:idx_program_subdomain"` // Named unique index
	SubDomain   string      `gorm:"type:text;not null;uniqueIndex:idx_program_subdomain"` // Same unique index name
	Scope       string      `gorm:"type:text; `
	Providers   StringArray `gorm:"type:text[]"`
}

/////////////////////////////////////////////////////////////

func FindSubdomainByProgramAndSubdomain added in v0.0.203

func FindSubdomainByProgramAndSubdomain(db *gorm.DB, programName, subDomain string) (*Subdomain, error)

func GetAllSubdomainWithScope added in v0.0.205

func GetAllSubdomainWithScope(db *gorm.DB, scope string) ([]Subdomain, error)

GetAllSubdomainWithScope fetches all subdomains associated with a given scope

func (Subdomain) Indexes added in v0.0.203

func (Subdomain) Indexes() []string

func (Subdomain) TableName added in v0.0.203

func (Subdomain) TableName() string

تعریف ایندکس ترکیبی

type UpdateHuntRequest

type UpdateHuntRequest struct {
	Name string `json:"name" binding:"required,min:3,max:100"`
}

Jump to

Keyboard shortcuts

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