db

package
v0.0.0-...-a33310b Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Unknown  severity = "Unknown"
	Info     severity = "Info"
	Low      severity = "Low"
	Medium   severity = "Medium"
	High     severity = "High"
	Critical severity = "Critical"
)
View Source
const PrintMaxDescriptionLength = 150

PrintMaxDescriptionLength max length a description can have when printing as table

View Source
const PrintMaxURLLength = 65

PrintMaxURLLength max length a URL can have when printing as table

Variables

View Source
var (
	TaskStatusPending         string = "pending"
	TaskStatusCrawling        string = "crawling"
	TaskStatusScanning        string = "scanning"
	TaskStatusNuclei          string = "nuclei"
	TaskStatusRunning         string = "running"
	TaskStatusFinished        string = "finished"
	TaskStatusFailed          string = "failed"
	TaskStatusPaused          string = "paused"
	DefaultWorkspaceTaskTitle string = "Default task"
)
View Source
var Connection = InitDb()
View Source
var SourceBrowser = "Browser"
View Source
var SourceCrawler = "Crawler"
View Source
var SourceFuzzer = "Fuzzer"
View Source
var SourceHijack = "Hijack"
View Source
var SourceProxy = "Proxy"
View Source
var SourceRepeater = "Repeater"
View Source
var SourceScanner = "Scanner"
View Source
var TaskJobSortFieldMap = map[string]string{
	"id":                       "id",
	"history_method":           "histories.method",
	"history_url":              "histories.url",
	"history_status":           "histories.status_code",
	"history_parameters_count": "histories.parameters_count",
	"title":                    "title",
	"status":                   "status",
	"started_at":               "started_at",
	"completed_at":             "completed_at",
	"created_at":               "created_at",
	"updated_at":               "updated_at",
}

Functions

func GetDatabaseSize

func GetDatabaseSize() (string, error)

func GetSeverityOrder

func GetSeverityOrder(severityStr string) int

Helper function to get severity order based on the given severity string

func IsValidSource

func IsValidSource(source string) bool

func NewSeverity

func NewSeverity(s string) severity

func Paginate

func Paginate(p *Pagination) func(db *gorm.DB) *gorm.DB

Paginate Gorm scope to paginate queries based on Paginator

func PrintHistory

func PrintHistory(history History)

PrintHistory prints a history record

func PrintInteraction

func PrintInteraction(interaction OOBInteraction) string

func PrintIssue

func PrintIssue(issue Issue)

Types

type BaseModel

type BaseModel struct {
	ID        uint           `gorm:"primaryKey" json:"id"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}

type BaseUUIDModel

type BaseUUIDModel struct {
	ID        uuid.UUID      `gorm:"type:uuid;default:uuid_generate_v4()" json:"id" validate:"required,uuid"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}

type DatabaseConnection

type DatabaseConnection struct {
	// contains filtered or unexported fields
}

func InitDb

func InitDb() *DatabaseConnection

func (*DatabaseConnection) ConstructSitemap

func (d *DatabaseConnection) ConstructSitemap(filter SitemapFilter) ([]*SitemapNode, error)

func (*DatabaseConnection) CreateDefaultWorkspace

func (d *DatabaseConnection) CreateDefaultWorkspace() (*Workspace, error)

func (*DatabaseConnection) CreateHistory

func (d *DatabaseConnection) CreateHistory(record *History) (*History, error)

CreateHistory saves an history item to the database

func (*DatabaseConnection) CreateInteraction

func (d *DatabaseConnection) CreateInteraction(item *OOBInteraction) (*OOBInteraction, error)

CreateInteraction saves an issue to the database

func (*DatabaseConnection) CreateIssue

func (d *DatabaseConnection) CreateIssue(issue Issue) (Issue, error)

CreateIssue saves an issue to the database

func (*DatabaseConnection) CreateOOBTest

func (d *DatabaseConnection) CreateOOBTest(item OOBTest) (OOBTest, error)

CreateOOBTest saves an OOBTest to the database

func (*DatabaseConnection) CreatePlaygroundCollection

func (d *DatabaseConnection) CreatePlaygroundCollection(collection *PlaygroundCollection) error

CreatePlaygroundCollection creates a new PlaygroundCollection record.

func (*DatabaseConnection) CreatePlaygroundSession

func (d *DatabaseConnection) CreatePlaygroundSession(session *PlaygroundSession) error

CreatePlaygroundSession creates a new PlaygroundSession record.

func (*DatabaseConnection) CreateRefreshToken

func (d *DatabaseConnection) CreateRefreshToken(refreshToken *RefreshToken) error

func (*DatabaseConnection) CreateTask

func (d *DatabaseConnection) CreateTask(task *Task) (*Task, error)

func (*DatabaseConnection) CreateTaskJob

func (d *DatabaseConnection) CreateTaskJob(item *TaskJob) (*TaskJob, error)

func (*DatabaseConnection) CreateUser

func (d *DatabaseConnection) CreateUser(user *User) (*User, error)

func (*DatabaseConnection) CreateWebSocketConnection

func (d *DatabaseConnection) CreateWebSocketConnection(connection *WebSocketConnection) error

func (*DatabaseConnection) CreateWebSocketMessage

func (d *DatabaseConnection) CreateWebSocketMessage(message *WebSocketMessage) error

func (*DatabaseConnection) CreateWorkspace

func (d *DatabaseConnection) CreateWorkspace(workspace *Workspace) (*Workspace, error)

CreateWorkspace saves a workspace to the database

func (*DatabaseConnection) DeactivateUser

func (d *DatabaseConnection) DeactivateUser(id uuid.UUID) error

func (*DatabaseConnection) DeleteHistory

func (d *DatabaseConnection) DeleteHistory(filter HistoryDeletionFilter) (deletedCount int64, err error)

DeleteHistory deletes history items based on the provided filter

func (*DatabaseConnection) DeleteRefreshToken

func (d *DatabaseConnection) DeleteRefreshToken(userID uuid.UUID) error

func (*DatabaseConnection) DeleteTask

func (d *DatabaseConnection) DeleteTask(id uint) error

func (*DatabaseConnection) DeleteWorkspace

func (d *DatabaseConnection) DeleteWorkspace(id uint) error

DeleteWorkspace deletes a workspace by ID

func (*DatabaseConnection) GetChildrenHistories

func (d *DatabaseConnection) GetChildrenHistories(parent *History) ([]*HistorySummary, error)

func (*DatabaseConnection) GetHistoriesByID

func (d *DatabaseConnection) GetHistoriesByID(ids []uint) ([]History, error)

GetHistoriesByID retrieves a list of history records by their IDs

func (*DatabaseConnection) GetHistory

func (d *DatabaseConnection) GetHistory(id uint) (history History, err error)

GetHistory get a single history record by ID

func (*DatabaseConnection) GetHistoryByID

func (d *DatabaseConnection) GetHistoryByID(id uint) (*History, error)

func (*DatabaseConnection) GetHistoryFromURL

func (d *DatabaseConnection) GetHistoryFromURL(urlString string) (history History, err error)

GetHistory get a single history record by URL

func (*DatabaseConnection) GetInteraction

func (d *DatabaseConnection) GetInteraction(interactionID uint) (*OOBInteraction, error)

GetInteraction fetches an OOBInteraction by its ID, including its associated OOBTest.

func (*DatabaseConnection) GetIssue

func (d *DatabaseConnection) GetIssue(id int, includeRelated bool) (issue Issue, err error)

GetIssue get a single issue by ID

func (*DatabaseConnection) GetOrCreateDefaultWorkspaceTask

func (d *DatabaseConnection) GetOrCreateDefaultWorkspaceTask(workspaceID uint) (*Task, error)

func (*DatabaseConnection) GetOrCreateJWTFromTokenAndHistory

func (d *DatabaseConnection) GetOrCreateJWTFromTokenAndHistory(jwtToken string, historyID uint) (*JsonWebToken, error)

GetOrCreateJWTFromTokenAndHistory checks if JWT with the same signature already exists in the DB

func (*DatabaseConnection) GetOrCreateWorkspace

func (d *DatabaseConnection) GetOrCreateWorkspace(workspace *Workspace) (*Workspace, error)

GetOrCreateWorkspace gets a workspace with the given code, or creates it if it doesn't exist

func (*DatabaseConnection) GetPlaygroundCollection

func (d *DatabaseConnection) GetPlaygroundCollection(id uint) (*PlaygroundCollection, error)

GetPlaygroundCollection retrieves a single PlaygroundCollection by its ID.

func (*DatabaseConnection) GetPlaygroundSession

func (d *DatabaseConnection) GetPlaygroundSession(id uint) (*PlaygroundSession, error)

GetPlaygroundSession retrieves a single PlaygroundSession by its ID.

func (*DatabaseConnection) GetRefreshToken

func (d *DatabaseConnection) GetRefreshToken(userID uuid.UUID) (*RefreshToken, error)

func (*DatabaseConnection) GetRootHistoryNodes

func (d *DatabaseConnection) GetRootHistoryNodes(workspaceID uint) ([]*HistorySummary, error)

func (*DatabaseConnection) GetTaskByID

func (d *DatabaseConnection) GetTaskByID(id uint) (*Task, error)

func (*DatabaseConnection) GetTaskJobByID

func (d *DatabaseConnection) GetTaskJobByID(id uint) (*TaskJob, error)

func (*DatabaseConnection) GetUserByEmail

func (d *DatabaseConnection) GetUserByEmail(email string) (*User, error)

func (*DatabaseConnection) GetUserByID

func (d *DatabaseConnection) GetUserByID(id uuid.UUID) (*User, error)

func (*DatabaseConnection) GetWorkspaceByCode

func (d *DatabaseConnection) GetWorkspaceByCode(code string) (*Workspace, error)

GetWorkspaceByCode gets a workspace by code

func (*DatabaseConnection) GetWorkspaceByID

func (d *DatabaseConnection) GetWorkspaceByID(id uint) (*Workspace, error)

GetWorkspaceByID gets a workspace by ID

func (*DatabaseConnection) HistoryExists

func (d *DatabaseConnection) HistoryExists(id uint) (bool, error)

HistoryExists checks if a history record exists

func (*DatabaseConnection) InitializeWorkspacePlayground

func (d *DatabaseConnection) InitializeWorkspacePlayground(workspaceID uint) error

func (*DatabaseConnection) ListHistory

func (d *DatabaseConnection) ListHistory(filter HistoryFilter) (items []*History, count int64, err error)

ListHistory Lists history

func (*DatabaseConnection) ListInteractions

func (d *DatabaseConnection) ListInteractions(filter InteractionsFilter) (items []*OOBInteraction, count int64, err error)

ListInteractions Lists interactions

func (*DatabaseConnection) ListIssues

func (d *DatabaseConnection) ListIssues(filter IssueFilter) (issues []*Issue, count int64, err error)

ListIssues Lists issues

func (*DatabaseConnection) ListIssuesGrouped

func (d *DatabaseConnection) ListIssuesGrouped(filter IssueFilter) ([]*GroupedIssue, error)

func (*DatabaseConnection) ListJsonWebTokens

func (d *DatabaseConnection) ListJsonWebTokens(filters JwtFilters) ([]*JsonWebToken, error)

func (*DatabaseConnection) ListPlaygroundCollections

func (d *DatabaseConnection) ListPlaygroundCollections(filters PlaygroundCollectionFilters) ([]*PlaygroundCollection, int64, error)

ListPlaygroundCollections retrieves a list of PlaygroundCollections with filters, sorting, and pagination.

func (*DatabaseConnection) ListPlaygroundSessions

func (d *DatabaseConnection) ListPlaygroundSessions(filters PlaygroundSessionFilters) ([]*PlaygroundSession, int64, error)

ListPlaygroundSessions retrieves a list of PlaygroundSessions with filters, sorting, and pagination.

func (*DatabaseConnection) ListTaskJobs

func (d *DatabaseConnection) ListTaskJobs(filter TaskJobFilter) (items []*TaskJob, count int64, err error)

func (*DatabaseConnection) ListTasks

func (d *DatabaseConnection) ListTasks(filter TaskFilter) (items []*Task, count int64, err error)

func (*DatabaseConnection) ListWebSocketConnections

func (d *DatabaseConnection) ListWebSocketConnections(filter WebSocketConnectionFilter) ([]WebSocketConnection, int64, error)

func (*DatabaseConnection) ListWebSocketMessages

func (d *DatabaseConnection) ListWebSocketMessages(filter WebSocketMessageFilter) ([]WebSocketMessage, int64, error)

func (*DatabaseConnection) ListWorkspaces

func (d *DatabaseConnection) ListWorkspaces(filters WorkspaceFilters) (items []*Workspace, count int64, err error)

ListWorkspaces Lists workspaces

func (*DatabaseConnection) MatchInteractionWithOOBTest

func (d *DatabaseConnection) MatchInteractionWithOOBTest(interaction OOBInteraction) (OOBTest, error)

func (*DatabaseConnection) NewTask

func (d *DatabaseConnection) NewTask(workspaceID uint, playgroundSessionID *uint, title, status string) (*Task, error)

func (*DatabaseConnection) NewTaskJob

func (d *DatabaseConnection) NewTaskJob(taskID uint, title string, status TaskJobStatus, historyID uint) (*TaskJob, error)

func (*DatabaseConnection) SaveRefreshToken

func (d *DatabaseConnection) SaveRefreshToken(userID uuid.UUID, token string) error

func (*DatabaseConnection) SetTaskStatus

func (d *DatabaseConnection) SetTaskStatus(id uint, status string) error

func (*DatabaseConnection) TaskExists

func (d *DatabaseConnection) TaskExists(id uint) (bool, error)

TaskExists checks if a workspace exists

func (*DatabaseConnection) TaskJobExists

func (d *DatabaseConnection) TaskJobExists(id uint) (bool, error)

TaskJobExists checks if a task job exists

func (*DatabaseConnection) UpdatePlaygroundCollection

func (d *DatabaseConnection) UpdatePlaygroundCollection(id uint, collection *PlaygroundCollection) error

UpdatePlaygroundCollection updates an existing PlaygroundCollection record.

func (*DatabaseConnection) UpdatePlaygroundSession

func (d *DatabaseConnection) UpdatePlaygroundSession(id uint, session *PlaygroundSession) error

UpdatePlaygroundSession updates an existing PlaygroundSession record.

func (*DatabaseConnection) UpdateTask

func (d *DatabaseConnection) UpdateTask(id uint, task *Task) (*Task, error)

func (*DatabaseConnection) UpdateTaskJob

func (d *DatabaseConnection) UpdateTaskJob(item *TaskJob) (*TaskJob, error)

func (*DatabaseConnection) UpdateWebSocketConnection

func (d *DatabaseConnection) UpdateWebSocketConnection(connection *WebSocketConnection) error

func (*DatabaseConnection) UpdateWorkspace

func (d *DatabaseConnection) UpdateWorkspace(id uint, updatedWorkspace *Workspace) error

UpdateWorkspace updates a workspace by its ID with the provided fields

func (*DatabaseConnection) WorkspaceExists

func (d *DatabaseConnection) WorkspaceExists(id uint) (bool, error)

WorkspaceExists checks if a workspace exists

type GroupedIssue

type GroupedIssue struct {
	Title    string       `json:"title"`
	Code     string       `json:"code"`
	Count    int          `json:"count"`
	Severity string       `json:"severity"`
	Items    []*IssueItem `json:"items"`
}

type History

type History struct {
	// Similar schema: https://github.com/gilcrest/httplog
	BaseModel
	StatusCode           int               `gorm:"index" json:"status_code"`
	URL                  string            `gorm:"index" json:"url"`
	Depth                int               `gorm:"index" json:"depth"`
	RequestHeaders       datatypes.JSON    `json:"request_headers"  swaggerignore:"true"`
	RequestBody          []byte            `json:"request_body"`
	RequestBodySize      int               `gorm:"index" json:"request_body_size"`
	RequestContentLength int64             `json:"request_content_length"`
	ResponseHeaders      datatypes.JSON    `json:"response_headers" swaggerignore:"true"`
	ResponseBody         []byte            `json:"response_body"`
	RequestContentType   string            `gorm:"index" json:"request_content_type"`
	ResponseBodySize     int               `gorm:"index" json:"response_body_size"`
	ResponseContentType  string            `gorm:"index" json:"response_content_type"`
	RawRequest           []byte            `json:"raw_request"`
	RawResponse          []byte            `json:"raw_response"`
	Method               string            `gorm:"index" json:"method"`
	Proto                string            `json:"proto" gorm:"index"`
	ParametersCount      int               `gorm:"index" json:"parameters_count"`
	Evaluated            bool              `gorm:"index" json:"evaluated"`
	Note                 string            `json:"note"`
	Source               string            `gorm:"index" json:"source"`
	JsonWebTokens        []JsonWebToken    `gorm:"many2many:json_web_token_histories;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"json_web_tokens"`
	Workspace            Workspace         `json:"-" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	WorkspaceID          *uint             `json:"workspace_id" gorm:"index"`
	TaskID               *uint             `json:"task_id" gorm:"index" `
	Task                 Task              `json:"-" gorm:"foreignKey:TaskID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	PlaygroundSessionID  *uint             `json:"playground_session_id" gorm:"index" `
	PlaygroundSession    PlaygroundSession `json:"-" gorm:"foreignKey:PlaygroundSessionID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}

History holds table for storing requests history found

func (*History) GetRequestHeadersAsMap

func (h *History) GetRequestHeadersAsMap() (map[string][]string, error)

func (*History) GetResponseHeadersAsMap

func (h *History) GetResponseHeadersAsMap() (map[string][]string, error)

func (*History) GetResponseHeadersAsString

func (h *History) GetResponseHeadersAsString() (string, error)

func (History) Pretty

func (h History) Pretty() string

func (History) String

func (h History) String() string

func (History) TableHeaders

func (h History) TableHeaders() []string

func (History) TableRow

func (h History) TableRow() []string

type HistoryDeletionFilter

type HistoryDeletionFilter struct {
	StatusCodes          []int    `json:"status_codes"`
	Methods              []string `json:"methods"`
	ResponseContentTypes []string `json:"response_content_types"`
	RequestContentTypes  []string `json:"request_content_types"`
	Sources              []string `json:"sources"`
	WorkspaceID          uint     `json:"workspace_id"`
}

HistoryDeletionFilter holds criteria for deleting history items

type HistoryFilter

type HistoryFilter struct {
	StatusCodes          []int    `json:"status_codes" validate:"omitempty,dive,numeric"`
	Methods              []string `json:"methods" validate:"omitempty,dive,oneof=GET POST PUT DELETE PATCH HEAD OPTIONS TRACE"`
	ResponseContentTypes []string `json:"response_content_types" validate:"omitempty,dive,ascii"`
	RequestContentTypes  []string `json:"request_content_types" validate:"omitempty,dive,ascii"`
	Sources              []string `json:"sources" validate:"omitempty,dive,ascii"`
	Pagination           Pagination
	WorkspaceID          uint   `json:"workspace_id" validate:"omitempty,numeric"`
	SortBy               string `` // Validate to be one of the listed fields
	/* 143-byte string literal not displayed */
	SortOrder           string `json:"sort_order" validate:"omitempty,oneof=asc desc"` // Validate to be either "asc" or "desc"
	TaskID              uint   `json:"task_id" validate:"omitempty,numeric"`
	IDs                 []uint `json:"ids" validate:"omitempty,dive,numeric"`
	PlaygroundSessionID uint   `json:"playground_session_id" validate:"omitempty,numeric"`
}

HistoryFilter represents available history filters

type HistorySummary

type HistorySummary struct {
	ID              uint   `json:"id"`
	Depth           int    `json:"depth"`
	URL             string `json:"url"`
	StatusCode      int    `json:"status_code"`
	Method          string `json:"method"`
	ParametersCount int    `json:"parameters_count"`
}

type IntSlice

type IntSlice []int

func (*IntSlice) Scan

func (c *IntSlice) Scan(value interface{}) error

func (IntSlice) Value

func (c IntSlice) Value() (driver.Value, error)

type InteractionsFilter

type InteractionsFilter struct {
	QTypes      []string
	Protocols   []string
	FullIDs     []string
	Pagination  Pagination
	WorkspaceID uint
}

type Issue

type Issue struct {
	BaseModel
	Code          string           `gorm:"index" json:"code"`
	Title         string           `gorm:"index" json:"title"`
	Description   string           `json:"description"`
	Details       string           `json:"details"`
	Remediation   string           `json:"remediation"`
	Cwe           int              `json:"cwe"`
	URL           string           `gorm:"index" json:"url"`
	StatusCode    int              `gorm:"index" json:"status_code"`
	HTTPMethod    string           `gorm:"index" json:"http_method"`
	Payload       string           `json:"payload"`
	Request       []byte           `json:"request"`
	Response      []byte           `json:"response"`
	FalsePositive bool             `gorm:"index" json:"false_positive"`
	Confidence    int              `gorm:"index" json:"confidence"`
	References    StringSlice      `json:"references"`
	Severity      severity         `gorm:"index,type:severity;default:'Info'" json:"severity"`
	CURLCommand   string           `json:"curl_command"`
	Note          string           `json:"note"`
	Workspace     Workspace        `json:"-" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	WorkspaceID   *uint            `json:"workspace_id" gorm:"index"`
	Interactions  []OOBInteraction `json:"interactions" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	Requests      []History        `json:"requests" gorm:"many2many:issue_requests;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	TaskID        *uint            `json:"task_id" gorm:"index"`
	Task          Task             `json:"-" gorm:"foreignKey:TaskID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	TaskJobID     *uint            `json:"task_job_id" gorm:"index;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
	TaskJob       TaskJob          `json:"-" gorm:"foreignKey:TaskJobID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
}

Issue holds table for storing issues found

func CreateIssueFromHistoryAndTemplate

func CreateIssueFromHistoryAndTemplate(history *History, code IssueCode, details string, confidence int, severity string, workspaceID, taskID, taskJobID *uint) (Issue, error)

func FillIssueFromHistoryAndTemplate

func FillIssueFromHistoryAndTemplate(history *History, code IssueCode, details string, confidence int, severity string, workspaceID, taskID, taskJobID *uint) *Issue

func GetIssueTemplateByCode

func GetIssueTemplateByCode(code IssueCode) *Issue

func (Issue) AddInteraction

func (i Issue) AddInteraction(interaction OOBInteraction) error

AddInteraction adds an interaction to an issue in the database.

func (Issue) IsEmpty

func (i Issue) IsEmpty() bool

func (Issue) Pretty

func (i Issue) Pretty() string

func (Issue) String

func (i Issue) String() string

func (Issue) TableHeaders

func (i Issue) TableHeaders() []string

func (Issue) TableRow

func (i Issue) TableRow() []string

func (Issue) UpdateFalsePositive

func (i Issue) UpdateFalsePositive(value bool) error

UpdateFalsePositive updates the FalsePositive attribute of an issue in the database.

type IssueCode

type IssueCode string
var (
	ApacheStrutsDevModeCode              IssueCode = "apache_struts_dev_mode"
	ApacheTapestryExceptionCode          IssueCode = "apache_tapestry_exception"
	AspNetMvcHeaderCode                  IssueCode = "asp_net_mvc_header"
	Base32EncodedDataInParameterCode     IssueCode = "base32_encoded_data_in_parameter"
	Base36EncodedDataInParameterCode     IssueCode = "base36_encoded_data_in_parameter"
	Base64EncodedDataInParameterCode     IssueCode = "base64_encoded_data_in_parameter"
	BlindSqlInjectionCode                IssueCode = "blind_sql_injection"
	CacheControlHeaderCode               IssueCode = "cache_control_header"
	CdnDetectedCode                      IssueCode = "cdn_detected"
	ClientSidePrototypePollutionCode     IssueCode = "client_side_prototype_pollution"
	CloudDetectedCode                    IssueCode = "cloud_detected"
	CorsCode                             IssueCode = "cors"
	CrlfInjectionCode                    IssueCode = "crlf_injection"
	CsrfCode                             IssueCode = "csrf"
	DatabaseErrorsCode                   IssueCode = "database_errors"
	DbConnectionStringsCode              IssueCode = "db_connection_strings"
	DirectoryListingCode                 IssueCode = "directory_listing"
	DjangoDebugExceptionCode             IssueCode = "django_debug_exception"
	EmailAddressesCode                   IssueCode = "email_addresses"
	EsiDetectedCode                      IssueCode = "esi_detected"
	EsiInjectionCode                     IssueCode = "esi_injection"
	ExposedApiCredentialsCode            IssueCode = "exposed_api_credentials"
	FileUploadDetectedCode               IssueCode = "file_upload_detected"
	ForbiddenBypassCode                  IssueCode = "forbidden_bypass"
	GrailsExceptionCode                  IssueCode = "grails_exception"
	HeaderInsightsReportCode             IssueCode = "header_insights_report"
	Http2DetectedCode                    IssueCode = "http2_detected"
	Http3DetectedCode                    IssueCode = "http3_detected"
	HttpMethodsCode                      IssueCode = "http_methods"
	IdorCode                             IssueCode = "idor"
	IncorrectContentTypeHeaderCode       IssueCode = "incorrect_content_type_header"
	JavaDeserializationCode              IssueCode = "java_deserialization"
	JavaSerializedObjectDetectedCode     IssueCode = "java_serialized_object_detected"
	JavaServerHeaderCode                 IssueCode = "java_server_header"
	JettyServerHeaderCode                IssueCode = "jetty_server_header"
	JwtDetectedCode                      IssueCode = "jwt_detected"
	Log4shellCode                        IssueCode = "log4shell"
	MissingContentTypeHeaderCode         IssueCode = "missing_content_type_header"
	MixedContentCode                     IssueCode = "mixed_content"
	NosqlInjectionCode                   IssueCode = "nosql_injection"
	OobCommunicationsCode                IssueCode = "oob_communications"
	OpenRedirectCode                     IssueCode = "open_redirect"
	OsCmdInjectionCode                   IssueCode = "os_cmd_injection"
	ParameterPollutionCode               IssueCode = "parameter_pollution"
	PasswordFieldAutocompleteEnabledCode IssueCode = "password_field_autocomplete_enabled"
	PasswordInGetRequestCode             IssueCode = "password_in_get_request"
	PrivateIpsCode                       IssueCode = "private_ips"
	PrivateKeysCode                      IssueCode = "private_keys"
	ReflectedInputCode                   IssueCode = "reflected_input"
	RemoteFileInclusionCode              IssueCode = "remote_file_inclusion"
	SecretsInJsCode                      IssueCode = "secrets_in_js"
	ServerHeaderCode                     IssueCode = "server_header"
	ServerSidePrototypePollutionCode     IssueCode = "server_side_prototype_pollution"
	SessionTokenInUrlCode                IssueCode = "session_token_in_url"
	SniInjectionCode                     IssueCode = "sni_injection"
	SqlInjectionCode                     IssueCode = "sql_injection"
	SsiDetectedCode                      IssueCode = "ssi_detected"
	SsiInjectionCode                     IssueCode = "ssi_injection"
	SsrfCode                             IssueCode = "ssrf"
	SstiCode                             IssueCode = "ssti"
	StorageBucketDetectedCode            IssueCode = "storage_bucket_detected"
	StrictTransportSecurityHeaderCode    IssueCode = "strict_transport_security_header"
	TechStackFingerprintCode             IssueCode = "tech_stack_fingerprint"
	Text4shellCode                       IssueCode = "text4shell"
	UnencryptedPasswordSubmissionCode    IssueCode = "unencrypted_password_submission"
	VulnerableJavascriptDependencyCode   IssueCode = "vulnerable_javascript_dependency"
	WafDetectedCode                      IssueCode = "waf_detected"
	WebsocketDetectedCode                IssueCode = "websocket_detected"
	XAspVersionHeaderCode                IssueCode = "x_asp_version_header"
	XFrameOptionsHeaderCode              IssueCode = "x_frame_options_header"
	XPoweredByHeaderCode                 IssueCode = "x_powered_by_header"
	XXssProtectionHeaderCode             IssueCode = "x_xss_protection_header"
	XpathInjectionCode                   IssueCode = "xpath_injection"
	XsltInjectionCode                    IssueCode = "xslt_injection"
	XssReflectedCode                     IssueCode = "xss_reflected"
	XxeCode                              IssueCode = "xxe"
)

type IssueFilter

type IssueFilter struct {
	Codes       []string
	WorkspaceID uint
	TaskID      uint
	TaskJobID   uint
	URL         string
}

IssueFilter represents available issue filters

type IssueItem

type IssueItem struct {
	ID         uint   `json:"id"`
	URL        string `json:"url"`
	Confidence int    `json:"confidence"`
}

type IssueTemplate

type IssueTemplate struct {
	Code        IssueCode `json:"code"`
	Title       string    `json:"title"`
	Description string    `json:"description"`
	Remediation string    `json:"remediation"`
	Cwe         int       `json:"cwe"`
	Severity    string    `json:"severity"`
	References  []string  `json:"references"`
}

type IssuesStats

type IssuesStats struct {
	Unknown  int64 `json:"unknown"`
	Info     int64 `json:"info"`
	Low      int64 `json:"low"`
	Medium   int64 `json:"medium"`
	High     int64 `json:"high"`
	Critical int64 `json:"critical"`
}

type JsonWebToken

type JsonWebToken struct {
	BaseModel
	Token       string         `gorm:"type:text" json:"token"`
	Header      datatypes.JSON `gorm:"type:json" json:"header" swaggerignore:"true"`
	Payload     datatypes.JSON `gorm:"type:json" json:"payload" swaggerignore:"true"`
	Signature   string         `gorm:"type:text" json:"signature"`
	Algorithm   string         `gorm:"type:text" json:"algorithm"`
	Issuer      string         `gorm:"type:text" json:"issuer"`
	Subject     string         `gorm:"type:text" json:"subject"`
	Audience    string         `gorm:"type:text" json:"audience"`
	Expiration  time.Time      `gorm:"type:timestamp" json:"expiration"`
	IssuedAt    time.Time      `gorm:"type:timestamp" json:"issued_at"`
	Histories   []History      `gorm:"many2many:json_web_token_histories;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"histories"`
	Workspace   Workspace      `json:"-" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	WorkspaceID *uint          `json:"workspace_id"`
}

func FillJwtFromToken

func FillJwtFromToken(jwtToken string) (*JsonWebToken, error)

FillJwtFromToken fills a JsonWebToken struct with data extracted from the given JWT token.

func (JsonWebToken) Pretty

func (j JsonWebToken) Pretty() string

func (JsonWebToken) String

func (j JsonWebToken) String() string

func (JsonWebToken) TableHeaders

func (j JsonWebToken) TableHeaders() []string

func (JsonWebToken) TableRow

func (j JsonWebToken) TableRow() []string

type JwtFilters

type JwtFilters struct {
	Algorithm   string `json:"algorithm" validate:"omitempty,oneof=HS256 HS384 HS512 RS256 RS384 RS512 ES256 ES384 ES512"`
	Issuer      string `json:"issuer"`
	Subject     string `json:"subject"`
	Audience    string `json:"audience"`
	SortBy      string `json:"sort_by" validate:"omitempty,oneof=token header issuer id algorithm subject audience expiration issued_at"` // Example validation rule for sort_by
	SortOrder   string `json:"sort_order" validate:"omitempty,oneof=asc desc"`                                                            // Example validation rule for sort_order
	WorkspaceID uint   `json:"workspace_id" validate:"omitempty,numeric"`
}

type MessageDirection

type MessageDirection string
const (
	MessageSent     MessageDirection = "sent"
	MessageReceived MessageDirection = "received"
)

type OOBInteraction

type OOBInteraction struct {
	BaseModel
	OOBTestID *uint   `json:"oob_test_id"`
	OOBTest   OOBTest `gorm:"foreignKey:OOBTestID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`

	Protocol      string    `json:"protocol"`
	FullID        string    `json:"full_id"`
	UniqueID      string    `json:"unique_id"`
	QType         string    `json:"qtype"`
	RawRequest    string    `json:"raw_request"`
	RawResponse   string    `json:"raw_response"`
	RemoteAddress string    `json:"remote_address"`
	Timestamp     time.Time `json:"timestamp"`
	Workspace     Workspace `json:"-" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	WorkspaceID   *uint     `json:"workspace_id"`
	IssueID       *uint     `json:"issue_id"`
}

func (OOBInteraction) Pretty

func (o OOBInteraction) Pretty() string

func (OOBInteraction) String

func (o OOBInteraction) String() string

func (OOBInteraction) TableHeaders

func (o OOBInteraction) TableHeaders() []string

func (OOBInteraction) TableRow

func (o OOBInteraction) TableRow() []string

type OOBTest

type OOBTest struct {
	BaseModel
	Code              IssueCode `json:"code"`
	TestName          string    `json:"test_name"`
	Target            string    `json:"target"`
	HistoryID         *uint     `json:"history_id"`
	HistoryItem       *History  `gorm:"foreignKey:HistoryID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
	InteractionDomain string    `gorm:"index" json:"interaction_domain"`
	InteractionFullID string    `gorm:"index" json:"interaction_id"`
	Payload           string    `json:"payload"`
	InsertionPoint    string    `json:"insertion_point"`
	Workspace         Workspace `json:"-" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	WorkspaceID       *uint     `json:"workspace_id"`
	Task              Task      `json:"-" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	TaskID            *uint     `json:"task_id"`
	TaskJobID         *uint     `json:"task_job_id" gorm:"index;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
	TaskJob           TaskJob   `json:"-" gorm:"foreignKey:TaskJobID"`
}

func (OOBTest) Pretty

func (o OOBTest) Pretty() string

func (OOBTest) String

func (o OOBTest) String() string

func (OOBTest) TableHeaders

func (o OOBTest) TableHeaders() []string

func (OOBTest) TableRow

func (o OOBTest) TableRow() []string

type Pagination

type Pagination struct {
	Page     int
	PageSize int
}

Pagination used to store pagination config

func (*Pagination) GetData

func (p *Pagination) GetData() (offset int, limit int)

type PlaygroundCollection

type PlaygroundCollection struct {
	BaseModel
	Name        string              `json:"name"`
	Description string              `json:"description"`
	Sessions    []PlaygroundSession `gorm:"foreignKey:CollectionID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	WorkspaceID uint                `json:"workspace_id" gorm:"index"`
	Workspace   Workspace           `json:"-" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}

PlaygroundCollection represents a collection of playground sessions.

type PlaygroundCollectionFilters

type PlaygroundCollectionFilters struct {
	Query       string `json:"query"`
	SortBy      string `json:"sort_by" validate:"omitempty,oneof=id name description created_at updated_at"`
	SortOrder   string `json:"sort_order" validate:"omitempty,oneof=asc desc"`
	WorkspaceID uint   `json:"workspace_id" validate:"omitempty,numeric"`
	Pagination
}

PlaygroundCollectionFilters contains filters for listing PlaygroundCollections.

type PlaygroundSession

type PlaygroundSession struct {
	BaseModel
	Name string                `json:"name"`
	Type PlaygroundSessionType `json:"type"`
	// OriginalRequest   History               `json:"-" gorm:"foreignKey:OriginalRequestID"`
	OriginalRequestID *uint `json:"original_request_id"`
	// Task              Task                 `json:"-" gorm:"foreignKey:TaskID"`
	// TaskID            *uint                `json:"task_id"`
	CollectionID uint                 `json:"collection_id"`
	Collection   PlaygroundCollection `json:"-" gorm:"foreignKey:CollectionID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
	WorkspaceID  uint                 `json:"workspace_id" gorm:"index"`
	Workspace    Workspace            `json:"-" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	Histories    []History            `gorm:"foreignKey:PlaygroundSessionID" json:"-"`
}

PlaygroundSession represents a playground session.

type PlaygroundSessionFilters

type PlaygroundSessionFilters struct {
	Query             string                `json:"query"`
	Type              PlaygroundSessionType `json:"type"`
	OriginalRequestID uint                  `json:"original_request_id"`
	// TaskID            uint                  `json:"task_id"`
	CollectionID uint   `json:"collection_id"`
	WorkspaceID  uint   `json:"workspace_id"`
	SortBy       string `json:"sort_by" validate:"omitempty,oneof=id name type workspace_id collection_id created_at updated_at"`
	SortOrder    string `json:"sort_order" validate:"omitempty,oneof=asc desc"`
	Pagination
}

PlaygroundSessionFilters contains filters for listing PlaygroundSessions.

type PlaygroundSessionType

type PlaygroundSessionType string

PlaygroundSessionType represents the type of a playground session.

const (
	ManualType PlaygroundSessionType = "manual"
	FuzzType   PlaygroundSessionType = "fuzz"
)

type Policy

type Policy struct {
	BaseModel
	Name        string `json:"name"`
	Description string `json:"description"`
}

type RefreshToken

type RefreshToken struct {
	BaseUUIDModel
	UserID uuid.UUID `gorm:"type:uuid;not null"`
	Token  string    `gorm:"type:text;not null"`
}

type RequestsStats

type RequestsStats struct {
	Crawler int64 `json:"crawler"`
	Scanner int64 `json:"scanner"`
}

type SitemapFilter

type SitemapFilter struct {
	WorkspaceID uint `json:"workspace_id" validate:"omitempty,numeric"`
	TaskID      uint `json:"task_id" validate:"omitempty,numeric"`
}

type SitemapNode

type SitemapNode struct {
	ID       uint            `json:"id"`
	OtherIDs []uint          `json:"other_ids,omitempty"`
	Depth    int             `json:"depth"`
	URL      string          `json:"url"`
	Path     string          `json:"path"`
	Type     SitemapNodeType `json:"type"`
	Children []*SitemapNode  `json:"children"`
}

type SitemapNodeType

type SitemapNodeType string
const (
	// Generic
	SitemapNodeTypeRoot      SitemapNodeType = "root"
	SitemapNodeTypeDirectory SitemapNodeType = "directory"
	SitemapNodeTypeFile      SitemapNodeType = "file"
	SitemapNodeTypeQuery     SitemapNodeType = "query"
	// Specific (file extensions)
	SitemapNodeTypePhp      SitemapNodeType = "php"
	SitemapNodeTypeAsp      SitemapNodeType = "asp"
	SitemapNodeTypeJsp      SitemapNodeType = "jsp"
	SitemapNodeTypeJs       SitemapNodeType = "js"
	SitemapNodeTypeCss      SitemapNodeType = "css"
	SitemapNodeTypeHtml     SitemapNodeType = "html"
	SitemapNodeTypeXml      SitemapNodeType = "xml"
	SitemapNodeTypeJson     SitemapNodeType = "json"
	SitemapNodeTypeYaml     SitemapNodeType = "yaml"
	SitemapNodeTypeSql      SitemapNodeType = "sql"
	SitemapNodeTypeImage    SitemapNodeType = "image"
	SitemapNodeTypeVideo    SitemapNodeType = "video"
	SitemapNodeTypeAudio    SitemapNodeType = "audio"
	SitemapNodeTypeMarkdown SitemapNodeType = "markdown"
	SitemapNodeTypeFont     SitemapNodeType = "font"
)

type StringSlice

type StringSlice []string

func (*StringSlice) Scan

func (c *StringSlice) Scan(value interface{}) error

func (StringSlice) Value

func (c StringSlice) Value() (driver.Value, error)

type Task

type Task struct {
	BaseModel
	Title               string            `json:"title"`
	Status              string            `gorm:"index" json:"status"`
	StartedAt           time.Time         `json:"started_at"`
	FinishedAt          time.Time         `json:"finished_at"`
	Workspace           Workspace         `json:"-" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	WorkspaceID         uint              `json:"workspace_id" gorm:"index" `
	Histories           []History         `gorm:"foreignKey:TaskID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE" json:"-"`
	Issues              []Issue           `gorm:"foreignKey:TaskID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE" json:"-"`
	Stats               TaskStats         `gorm:"-" json:"stats,omitempty"`
	PlaygroundSessionID *uint             `gorm:"index" json:"playground_session_id"`
	PlaygroundSession   PlaygroundSession `json:"-" gorm:"foreignKey:PlaygroundSessionID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE"`
}

func (Task) Pretty

func (t Task) Pretty() string

Pretty provides a more formatted, user-friendly representation of the Task.

func (Task) String

func (t Task) String() string

String provides a basic textual representation of the Task.

func (Task) TableHeaders

func (t Task) TableHeaders() []string

func (Task) TableRow

func (t Task) TableRow() []string

type TaskFilter

type TaskFilter struct {
	Query               string     `json:"query" validate:"omitempty,dive,ascii"`
	Statuses            []string   `json:"statuses" validate:"omitempty,dive,oneof=crawling scanning nuclei running finished failed paused"`
	Pagination          Pagination `json:"pagination"`
	WorkspaceID         uint       `json:"workspace_id" validate:"omitempty,numeric"`
	FetchStats          bool       `json:"fetch_stats"`
	PlaygroundSessionID uint       `json:"playground_session_id"`
}

type TaskJob

type TaskJob struct {
	BaseModel
	Title       string        `json:"title"`
	TaskID      uint          `json:"task_id"`
	Task        Task          `json:"-" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	Status      TaskJobStatus `gorm:"index" json:"status"`
	StartedAt   time.Time     `json:"started_at"`
	CompletedAt time.Time     `json:"completed_at"`
	HistoryID   uint          `json:"history_id"`
	History     History       `json:"history" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
}

type TaskJobFilter

type TaskJobFilter struct {
	Query       string     `json:"query" validate:"omitempty,dive,ascii"`
	Statuses    []string   `json:"statuses" validate:"omitempty,dive,oneof=scheduled running finished failed"`
	Titles      []string   `json:"titles" validate:"omitempty,dive,ascii"`
	Pagination  Pagination `json:"pagination"`
	TaskID      uint       `json:"task_id" validate:"omitempty,numeric"`
	StatusCodes []int      `json:"status_codes" validate:"omitempty,dive,numeric"`
	Methods     []string   `json:"methods" validate:"omitempty,dive,oneof=GET POST PUT DELETE PATCH HEAD OPTIONS TRACE"`
	SortBy      string     `` /* 170-byte string literal not displayed */
	SortOrder   string     `json:"sort_order" validate:"omitempty,oneof=asc desc"`
}

type TaskJobStatus

type TaskJobStatus string
var (
	TaskJobScheduled TaskJobStatus = "scheduled"
	TaskJobRunning   TaskJobStatus = "running"
	TaskJobFinished  TaskJobStatus = "finished"
	TaskJobFailed    TaskJobStatus = "failed"
)

type TaskStats

type TaskStats struct {
	Requests RequestsStats `json:"requests"`
	Issues   IssuesStats   `json:"issues"`
}

type User

type User struct {
	BaseUUIDModel
	Email        string `gorm:"type:varchar(255);not null;unique" json:"email" validate:"required,email,lte=255"`
	PasswordHash string `json:"password_hash,omitempty"`
	Active       bool   `json:"active" validate:"required,len=1"`
}

type WebSocketConnection

type WebSocketConnection struct {
	BaseModel
	URL             string             `json:"url"`
	RequestHeaders  datatypes.JSON     `json:"request_headers" swaggerignore:"true"`
	ResponseHeaders datatypes.JSON     `json:"response_headers" swaggerignore:"true"`
	StatusCode      int                `gorm:"index" json:"status_code"`
	StatusText      string             `json:"status_text"`
	Messages        []WebSocketMessage `json:"messages" gorm:"foreignKey:ConnectionID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	ClosedAt        time.Time          `json:"closed_at"` // timestamp for when the connection is closed
	Workspace       Workspace          `json:"-" gorm:"constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	WorkspaceID     *uint              `json:"workspace_id"`
	TaskID          *uint              `json:"task_id" gorm:"index" `
	Task            Task               `json:"-" gorm:"foreignKey:TaskID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;"`
	Source          string             `json:"source"`
}

func (WebSocketConnection) Pretty

func (c WebSocketConnection) Pretty() string

func (WebSocketConnection) String

func (c WebSocketConnection) String() string

func (WebSocketConnection) TableHeaders

func (c WebSocketConnection) TableHeaders() []string

func (WebSocketConnection) TableRow

func (c WebSocketConnection) TableRow() []string

type WebSocketConnectionFilter

type WebSocketConnectionFilter struct {
	Pagination
	WorkspaceID uint     `json:"workspace_id" validate:"required"`
	TaskID      uint     `json:"task_id"`
	Sources     []string `json:"sources" validate:"omitempty,dive,ascii"`
}

type WebSocketMessage

type WebSocketMessage struct {
	BaseModel
	ConnectionID uint             `json:"connection_id"`
	Opcode       float64          `json:"opcode"`
	Mask         bool             `gorm:"index" json:"mask"`
	PayloadData  string           `json:"payload_data"`
	Timestamp    time.Time        `json:"timestamp"`              // timestamp for when the message was sent/received
	Direction    MessageDirection `gorm:"index" json:"direction"` // direction of the message
}

func (WebSocketMessage) Pretty

func (m WebSocketMessage) Pretty() string

func (WebSocketMessage) String

func (m WebSocketMessage) String() string

func (WebSocketMessage) TableHeaders

func (m WebSocketMessage) TableHeaders() []string

func (WebSocketMessage) TableRow

func (m WebSocketMessage) TableRow() []string

type WebSocketMessageFilter

type WebSocketMessageFilter struct {
	Pagination
	ConnectionID uint
}

type Workspace

type Workspace struct {
	BaseModel
	Code        string `gorm:"index,unique" json:"code"`
	Title       string `json:"title"`
	Description string `json:"description"`
}

Workspace is used to group projects

func (Workspace) Pretty

func (w Workspace) Pretty() string

Pretty provides a more formatted, user-friendly representation of the Workspace.

func (Workspace) String

func (w Workspace) String() string

String provides a basic textual representation of the Workspace.

func (Workspace) TableHeaders

func (w Workspace) TableHeaders() []string

func (Workspace) TableRow

func (w Workspace) TableRow() []string

type WorkspaceFilters

type WorkspaceFilters struct {
	Query      string `json:"query" validate:"omitempty,dive,ascii"`
	Pagination Pagination
}

Jump to

Keyboard shortcuts

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