schema

package
v1.4.4-alpha1202-loadi... Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: AGPL-3.0 Imports: 29 Imported by: 35

Documentation

Index

Constants

View Source
const (
	AI_CONTEN_MAIN_TEXT  = "text"
	AI_CONTENT_MAIN_CODE = "code"
	AI_CONTENT_LOG       = "log"
)
View Source
const (
	AI_CONTEN_SUB_PLAIN     = "plain"
	AI_CONTENT_SUB_MARKDOWN = "markdown"
)
View Source
const (
	AI_REACT_LOOP_ACTION_REQUIRE_TOOL           = "require_tool"
	AI_REACT_LOOP_ACTION_ASK_FOR_CLARIFICATION  = "ask_for_clarification"
	AI_REACT_LOOP_ACTION_DIRECTLY_ANSWER        = "directly_answer"
	AI_REACT_LOOP_ACTION_KNOWLEDGE_ENHANCE      = "knowledge_enhance_answer"
	AI_REACT_LOOP_ACTION_REQUIRE_AI_BLUEPRINT   = "require_ai_blueprint"
	AI_REACT_LOOP_ACTION_REQUEST_PLAN_EXECUTION = "request_plan_and_execution"
)
View Source
const (
	AI_REACT_LOOP_NAME_DEFAULT         = "default"
	AI_REACT_LOOP_NAME_WRITE_YAKLANG   = "write_yaklang_code"
	AI_REACT_LOOP_NAME_JAVA_DECOMPILER = "java_decompiler"
	AI_REACT_LOOP_NAME_HTTP_DIFFER     = "http_differ"
	AI_REACT_LOOP_NAME_PE_TASK         = "pe_task"
	AI_REACT_LOOP_NAME_PLAN            = "plan"
)
View Source
const (
	AI_Call_Tool  = "call_tool"
	AI_Task_Index = "task_index"
)
View Source
const (
	KEY_SCHEMA_YAKIT_DATABASE uint8 = iota
	KEY_SCHEMA_PROFILE_DATABASE
	KEY_SCHEMA_CVE_DATABASE
	KEY_SCHEMA_CVE_DESCRIPTION_DATABASE
	KEY_SCHEMA_VULINBOX_DATABASE
	KEY_SCHEMA_SSA_DATABASE
)
View Source
const (
	// "syntaxflow" | "nuclei" | "mitm" | "port-scan" | "codec" | "yak"
	SCRIPT_TYPE_SYNTAXFLOW string = "syntaxflow"
	SCRIPT_TYPE_NASL       string = "nasl"
	SCRIPT_TYPE_NUCLEI     string = "nuclei"
	SCRIPT_TYPE_MITM       string = "mitm"
	SCRIPT_TYPE_PORT_SCAN  string = "port-scan"
	SCRIPT_TYPE_CODEC      string = "codec"
	SCRIPT_TYPE_YAK        string = "yak"
)
View Source
const (
	REPORT_ITEM_TYPE_MARKDOWN             = "markdown"
	REPORT_ITEM_TYPE_DIVIDER              = "divider"
	REPORT_ITEM_TYPE_TABLE                = "json-table"
	REPORT_ITEM_SEARCH_TYPE_TABLE         = "search-json-table"
	REPORT_ITEM_TYPE_PIE_GRAPH            = "pie-graph"
	REPORT_ITEM_TYPE_VERTICAL_BAR_GRAPH   = "vertical-bar-graph"
	REPORT_ITEM_TYPE_HORIZONTAL_BAR_GRAPH = "horizontal-bar-graph"
	REPORT_ITEM_TYPE_RAW                  = "raw"
	REPORT_ITEM_TYPE_CODE                 = "code"
	REPORT_ITEM_TYPE_WORDCLOUD            = "wordcloud"
)
View Source
const (
	SYNTAXFLOWSCAN_EXECUTING = "executing"
	SYNTAXFLOWSCAN_PAUSED    = "paused"
	SYNTAXFLOWSCAN_DONE      = "done"
	SYNTAXFLOWSCAN_ERROR     = "error"
)
View Source
const (
	META_Data_UUID  = "meta_data_UUID"
	META_Data_Title = "meta_data_title"
	META_Repos_UUID = "meta_repos_UUID"
)
View Source
const COLORPREFIX = "YAKIT_COLOR_"
View Source
const ERModelEntityBroadcastType = "er_model_entity"
View Source
const ERModelRelationshipBroadcastType = "er_model_relationship"
View Source
const KnowledgeBaseEntryBroadcastType = "knowledge_base_entry"
View Source
const SYNTAXFLOWSCAN_PROGRAM_SPLIT = ","
View Source
const (
	ServerPushType_SSARisk = "ssa_risk"
)
View Source
const VectorStoreDocumentBroadcastType = "vector_store_document"

Variables

View Source
var (
	HTTPFlow_SourceType_MITM    = "mitm"
	HTTPFlow_SourceType_SCAN    = "scan"
	HTTPFlow_SourceType_CRAWLER = "basic-crawler"
	HTTPFlow_SourceType_HAR     = "har"
)
View Source
var (
	FLOW_COLOR_RED    = yakitColor("RED")
	FLOW_COLOR_GREEN  = yakitColor("GREEN")
	FLOW_COLOR_BLUE   = yakitColor("BLUE")
	FLOW_COLOR_YELLOW = yakitColor("YELLOW")
	FLOW_COLOR_ORANGE = yakitColor("ORANGE")
	FLOW_COLOR_PURPLE = yakitColor("PURPLE")
	FLOW_COLOR_CYAN   = yakitColor("CYAN")
	FLOW_COLOR_GREY   = yakitColor("GREY")
)
View Source
var FORGE_TYPE_Config = "config"
View Source
var FORGE_TYPE_YAK = "yak"
View Source
var HotPatchTemplateTableName = "hot_patch_template"
View Source
var (
	KnowledgeEntryType_QuestionIndex = "question_index"
)

ProfileTables 这些表是独立与项目之外的,每一个用户的数据都不一样

ProjectTables 这些表是和项目关联的,导出项目可以直接复制给用户

View Source
var (
	WebFuzzerResponseTTLCache = utils.NewTTLCache[*ypb.FuzzerResponse](30 * time.Minute)
)
View Source
var WebFuzzerTaskTTLCache = utils.NewTTLCache[*ypb.HistoryHTTPFuzzerTask](30 * time.Minute)

Functions

func ApplyPatches

func ApplyPatches(db *gorm.DB, key uint8)

func AutoMigrate

func AutoMigrate(db *gorm.DB, key uint8)

func DeleteSyntaxFlowScanTask

func DeleteSyntaxFlowScanTask(db *gorm.DB, taskId string) error

func GetAllSFPurposeTypes

func GetAllSFPurposeTypes() []string

func GetAllSFSeverityTypes

func GetAllSFSeverityTypes() []string

func GetAllSFSupportLanguage

func GetAllSFSupportLanguage() []string

func GetDefaultSSADatabase

func GetDefaultSSADatabase() *gorm.DB

func GetGormProfileDatabase

func GetGormProfileDatabase() *gorm.DB

func GetGormProjectDatabase

func GetGormProjectDatabase() *gorm.DB

func KeySchemaToName

func KeySchemaToName(i uint8) string

func RegisterDatabasePatch

func RegisterDatabasePatch(key uint8, patch func(db *gorm.DB))

func RegisterDatabaseSchema

func RegisterDatabaseSchema(key uint8, schema ...any)

func SSARiskTypeVerbose

func SSARiskTypeVerbose(s string) string

func SaveSyntaxFlowScanTask

func SaveSyntaxFlowScanTask(db *gorm.DB, task *SyntaxFlowScanTask) error

func SetBroadCast_Data

func SetBroadCast_Data(f func(typeString string, data any))

func SetDefaultSSADatabase

func SetDefaultSSADatabase(d *gorm.DB)

func SetGormProfileDatabase

func SetGormProfileDatabase(d *gorm.DB)

set from consts package

func SetGormProjectDatabase

func SetGormProjectDatabase(d *gorm.DB)

set from consts package

func SimpleBuildEntityFilter

func SimpleBuildEntityFilter(reposName string, entityTypes, names, HiddenIndex, keywords []string) *ypb.EntityFilter

func TrimWhitespaceExceptSpace

func TrimWhitespaceExceptSpace(r rune) bool

Types

type AIAgentRuntime

type AIAgentRuntime struct {
	gorm.Model

	Uuid              string `json:"uuid" gorm:"unique_index"`
	PersistentSession string `gorm:"index"`
	Name              string `json:"name"`
	Seq               int64  `json:"seq" gorm:"index"`

	TypeName       AIAgentRuntimeType `gorm:"index"`
	QuotedTimeline string             `json:"timeline"`

	QuotedUserInput string `json:"quoted_user_input"`
	ForgeName       string `json:"forge_name"`
}

func (*AIAgentRuntime) GetTimeline

func (a *AIAgentRuntime) GetTimeline() string

func (*AIAgentRuntime) GetUserInput

func (a *AIAgentRuntime) GetUserInput() string

func (*AIAgentRuntime) ToGRPC

func (a *AIAgentRuntime) ToGRPC() *ypb.AITask

type AIAgentRuntimeType

type AIAgentRuntimeType string
const (
	AIAgentRuntimeType_PlanAndExec AIAgentRuntimeType = "plan-exec"
	AIAgentRuntimeType_ReAct       AIAgentRuntimeType = "re-act"
	AIAgentRuntimeType_Unknown     AIAgentRuntimeType = ""
)

type AIForge

type AIForge struct {
	gorm.Model

	ForgeVerboseName   string
	ForgeName          string `gorm:"unique_index"`
	ForgeContent       string
	ForgeType          string // "yak" or "json"
	ParamsUIConfig     string
	Params             string // cli params
	UserPersistentData string // for user preferences
	Description        string // forge description
	Tools              string // tools
	ToolKeywords       string // tool keywords
	Actions            string
	Tags               string

	InitPrompt       string
	PersistentPrompt string
	PlanPrompt       string
	ResultPrompt     string

	IsTemporary bool // for temporary use, will be cleaned up later
}

func GRPC2AIForge

func GRPC2AIForge(forge *ypb.AIForge) *AIForge

func (*AIForge) AfterCreate

func (a *AIForge) AfterCreate(tx *gorm.DB) (err error)

func (*AIForge) AfterDelete

func (a *AIForge) AfterDelete(tx *gorm.DB) (err error)

func (*AIForge) AfterUpdate

func (a *AIForge) AfterUpdate(tx *gorm.DB) (err error)

func (*AIForge) GetDescription

func (a *AIForge) GetDescription() string

func (*AIForge) GetKeywords

func (a *AIForge) GetKeywords() []string

func (*AIForge) GetName

func (a *AIForge) GetName() string

func (*AIForge) ToGRPC

func (a *AIForge) ToGRPC() *ypb.AIForge

todo schema2grpc model

type AIMemoryCollection

type AIMemoryCollection struct {
	gorm.Model

	// 会话ID,每个会话有一个独立的HNSW索引
	SessionID string `json:"session_id" gorm:"unique_index;not null"`

	// HNSW Graph 的二进制序列化数据
	GraphBinary []byte `json:"graph_binary" gorm:"type:blob"`

	// HNSW 参数配置
	M           int     `json:"m" gorm:"default:16"`             // 最大邻居数
	Ml          float64 `json:"ml" gorm:"default:0.25"`          // 层生成因子
	EfSearch    int     `json:"ef_search" gorm:"default:20"`     // 搜索时的候选节点数
	EfConstruct int     `json:"ef_construct" gorm:"default:200"` // 构建时的候选节点数

	// 向量维度(固定为7维 - C.O.R.E. P.A.C.T.)
	Dimension int `json:"dimension" gorm:"default:7"`
}

AIMemoryCollection 存储AI记忆的HNSW索引信息

func (*AIMemoryCollection) BeforeSave

func (a *AIMemoryCollection) BeforeSave() error

func (*AIMemoryCollection) TableName

func (a *AIMemoryCollection) TableName() string

type AIMemoryEntity

type AIMemoryEntity struct {
	gorm.Model

	// 记忆条目唯一标识
	MemoryID string `json:"memory_id" gorm:"unique_index;not null"`

	// 会话ID,关联到特定的AI会话
	SessionID string `json:"session_id" gorm:"index;not null"`

	// 记忆内容
	Content string `json:"content" gorm:"type:text;not null"`

	// 领域标签,用于分类和过滤
	Tags StringArray `json:"tags" gorm:"type:text"`

	// 潜在问题列表,用于RAG检索
	PotentialQuestions StringArray `json:"potential_questions" gorm:"type:text"`

	// C.O.R.E. P.A.C.T. Framework 评分 (0.0-1.0)
	C_Score float64 `json:"c_score"` // Connectivity Score 关联度
	O_Score float64 `json:"o_score"` // Origin Score 来源与确定性
	R_Score float64 `json:"r_score"` // Relevance Score 相关性
	E_Score float64 `json:"e_score"` // Emotion Score 情感
	P_Score float64 `json:"p_score"` // Preference Score 个人偏好
	A_Score float64 `json:"a_score"` // Actionability Score 可操作性
	T_Score float64 `json:"t_score"` // Temporality Score 时效性

	// C.O.R.E. P.A.C.T. 向量,用于快速过滤和排序
	CorePactVector FloatArray `json:"core_pact_vector" gorm:"type:text"`
}

AIMemoryEntity 存储AI记忆条目

func (*AIMemoryEntity) BeforeSave

func (a *AIMemoryEntity) BeforeSave() error

func (*AIMemoryEntity) TableName

func (a *AIMemoryEntity) TableName() string

type AIYakTool

type AIYakTool struct {
	gorm.Model

	Name string `json:"name" gorm:"unique_index"`
	// 展示给用户的名称
	VerboseName string `json:"verbose_name"`
	Description string `json:"description" gorm:"type:text;index"`
	Keywords    string `json:"keywords" gorm:"type:text;index"`
	Content     string `json:"content" gorm:"type:text"`
	Params      string `json:"params" gorm:"type:text"`
	Path        string `json:"path" gorm:"type:text;index"`
	Hash        string `json:"hash"`
	IsFavorite  bool   `json:"is_favorite" gorm:"default:false;index"`
}

func (*AIYakTool) BeforeSave

func (d *AIYakTool) BeforeSave() error

func (*AIYakTool) CalcHash

func (d *AIYakTool) CalcHash() string

func (*AIYakTool) TableName

func (*AIYakTool) TableName() string

func (*AIYakTool) ToGRPC

func (a *AIYakTool) ToGRPC() *ypb.AITool

type AiApiKeys

type AiApiKeys struct {
	gorm.Model
	APIKey        string    `json:"api_key" gorm:"index"`
	AllowedModels string    `json:"allowed_models"`
	InputBytes    int64     `json:"input_bytes"`                // 输入字节数统计
	OutputBytes   int64     `json:"output_bytes"`               // 输出字节数统计
	UsageCount    int64     `json:"usage_count"`                // 使用次数统计
	SuccessCount  int64     `json:"success_count"`              // 成功请求数
	FailureCount  int64     `json:"failure_count"`              // 失败请求数
	LastUsedTime  time.Time `json:"last_used_time"`             // 上次使用时间
	Active        bool      `json:"active" gorm:"default:true"` // 新增:API Key 激活状态
}

type AiCheckpoint

type AiCheckpoint struct {
	gorm.Model

	CoordinatorUuid    string           `json:"coordinator_uuid" gorm:"index"`
	Seq                int64            `json:"seq" gorm:"index"`
	Type               AiCheckpointType `json:"type" gorm:"index"`
	RequestQuotedJson  string           `json:"request_quoted_json"`
	ResponseQuotedJson string           `json:"response_quoted_json"`
	Finished           bool             `json:"finished"`

	Hash string `json:"hash" gorm:"unique_index"`
}

func (*AiCheckpoint) BeforeSave

func (c *AiCheckpoint) BeforeSave() error

func (*AiCheckpoint) CalcHash

func (c *AiCheckpoint) CalcHash() string

type AiCheckpointType

type AiCheckpointType string
const (
	AiCheckpointType_AIInteractive AiCheckpointType = "ai-request"
	AiCheckpointType_ToolCall      AiCheckpointType = "tool-call"
	AiCheckpointType_Review        AiCheckpointType = "review"
)

type AiOutputEvent

type AiOutputEvent struct {
	gorm.Model
	CoordinatorId string
	Type          EventType

	NodeId      string
	IsSystem    bool
	IsStream    bool
	IsReason    bool
	IsSync      bool
	StreamDelta []byte
	IsJson      bool
	Content     []byte

	SyncID    string
	EventUUID string

	Timestamp int64

	// task index
	TaskIndex string

	// task uuid
	TaskUUID string
	// disable markdown render
	DisableMarkdown bool
	CallToolID      string

	Processes []*AiProcess `gorm:"many2many:ai_processes_and_events;"`

	ContentType string
	AIService   string
}

func (*AiOutputEvent) GetContentJSONPath

func (e *AiOutputEvent) GetContentJSONPath(p string) string

func (*AiOutputEvent) GetInteractiveId

func (e *AiOutputEvent) GetInteractiveId() string

func (*AiOutputEvent) IsInteractive

func (e *AiOutputEvent) IsInteractive() bool

func (*AiOutputEvent) ShouldSave

func (e *AiOutputEvent) ShouldSave() bool

func (*AiOutputEvent) String

func (e *AiOutputEvent) String() string

func (*AiOutputEvent) ToExecResult

func (e *AiOutputEvent) ToExecResult() *ypb.ExecResult

func (*AiOutputEvent) ToGRPC

func (e *AiOutputEvent) ToGRPC() *ypb.AIOutputEvent

type AiProcess

type AiProcess struct {
	gorm.Model
	ProcessType string           `json:"process_type"`
	ProcessId   string           `json:"process_id" `
	Events      []*AiOutputEvent `gorm:"many2many:ai_processes_and_events;"`
}

type AiProvider

type AiProvider struct {
	gorm.Model

	WrapperName  string `json:"wrapper_name" gorm:"index"`
	ModelName    string `json:"model_name" gorm:"index"`
	TypeName     string `json:"type_name" gorm:"index"`
	DomainOrURL  string `json:"domain_or_url" gorm:"index"`
	APIKey       string `json:"api_key" gorm:"index"`
	NoHTTPS      bool   `json:"no_https"`
	ProviderMode string `json:"provider_mode" gorm:"default:'chat'"` // Provider 模式: "chat" 或 "embedding"

	// 可用性指标
	SuccessCount  int64 `json:"success_count"`  // 成功请求总数
	FailureCount  int64 `json:"failure_count"`  // 失败请求总数
	TotalRequests int64 `json:"total_requests"` // 总请求数

	// 最后一次请求信息
	LastRequestTime   time.Time `json:"last_request_time"`   // 最后一次请求时间
	LastRequestStatus bool      `json:"last_request_status"` // 最后一次请求状态 (true=成功, false=失败)
	LastLatency       int64     `json:"last_latency"`        // 最后一次请求延迟 (毫秒)

	// 健康状态
	IsHealthy             bool      `json:"is_healthy"`                                    // 提供者是否健康
	HealthCheckTime       time.Time `json:"health_check_time"`                             // 最后一次健康检查时间
	IsFirstCheckCompleted bool      `json:"is_first_check_completed" gorm:"default:false"` // 首次健康检查是否完成
}

type AliveHost

type AliveHost struct {
	gorm.Model

	Hash string `json:"hash"`

	IP        string `json:"ip"`
	IPInteger int64  `json:"ip_integer"`

	// 设置运行时 ID 为了关联具体漏洞
	RuntimeId string `json:"runtime_id"`
}

type AnalyzedHTTPFlow

type AnalyzedHTTPFlow struct {
	gorm.Model
	ResultId        string          `json:"result_id" gorm:"index"`
	Rule            string          `json:"rule"`
	RuleVerboseName string          `json:"rule_verbose_name"`
	HTTPFlowId      int64           `json:"http_flow_id"`
	ExtractedData   []ExtractedData `json:"extracted_data"`
}

func (*AnalyzedHTTPFlow) ToGRPCModel

func (h *AnalyzedHTTPFlow) ToGRPCModel() *ypb.HTTPFlowRuleData

type BackProject

type BackProject struct {
	Project
	FolderName      string `json:"folder_name"`
	ChildFolderName string `json:"child_folder_name"`
}

func (*BackProject) BackGRPCModel

func (p *BackProject) BackGRPCModel() *ypb.ProjectDescription

type Briefing

type Briefing struct {
	gorm.Model

	SourceXmlUrl    string
	RssFeedHash     string
	Hash            string     `gorm:"columns:hash;unique_index"`
	Title           string     `json:"title,omitempty"`
	Description     string     `json:"description,omitempty"`
	Content         string     `json:"content,omitempty"`
	Link            string     `json:"link,omitempty"`
	Updated         string     `json:"updated,omitempty"`
	UpdatedParsed   *time.Time `json:"updatedParsed,omitempty"`
	Published       string     `json:"published,omitempty"`
	PublishedParsed *time.Time `json:"publishedParsed,omitempty"`
	Author          string     `json:"author,omitempty"`
	AuthorEmail     string     `json:"author_email,omitempty"`
	GUID            string     `json:"guid,omitempty"`
	ImageUrl        string     `json:"image_url,omitempty"`
	ImageName       string     `json:"image_name,omitempty"`
	Categories      string     `json:"categories,omitempty"`
	Tags            string     `json:"tags"`
	IsRead          bool       `json:"is_read"`
}

func (*Briefing) BeforeSave

func (b *Briefing) BeforeSave() error

func (*Briefing) CalcHash

func (b *Briefing) CalcHash() string

type BroadCastHandler

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

func GetBroadCast_Data

func GetBroadCast_Data() *BroadCastHandler

func (*BroadCastHandler) Call

func (b *BroadCastHandler) Call(typeString string, data any)

type CPE

type CPE struct {
	Part     string `yaml:"part,omitempty" json:"part"`
	Vendor   string `yaml:"vendor,omitempty" json:"vendor"`
	Product  string `yaml:"product,omitempty" json:"product"`
	Version  string `yaml:"version,omitempty" json:"version"`
	Update   string `yaml:"update,omitempty" json:"update"`
	Edition  string `yaml:"edition,omitempty" json:"edition"`
	Language string `yaml:"language,omitempty" json:"language"`
}

func (*CPE) Init

func (c *CPE) Init()

func (*CPE) String

func (c *CPE) String() string

type CodecFlow

type CodecFlow struct {
	gorm.Model
	FlowName   string
	WorkFlow   []byte
	WorkFlowUI string
}

func (*CodecFlow) ToGRPC

func (cf *CodecFlow) ToGRPC() *ypb.CustomizeCodecFlow

type Domain

type Domain struct {
	gorm.Model

	Domain    string `json:"domain" gorm:"index"`
	IPAddr    string `json:"ip_addr"`
	IPInteger int64  `json:"ip_integer"`

	HTTPTitle string

	Hash string `json:"hash" gorm:"unique_index"`

	Tags string `json:"tags"`
}

func (*Domain) BeforeSave

func (d *Domain) BeforeSave() error

func (*Domain) CalcHash

func (d *Domain) CalcHash() string

func (*Domain) FillDomainHTTPInfo

func (d *Domain) FillDomainHTTPInfo()

type ERModelEntity

type ERModelEntity struct {
	gorm.Model

	RepositoryUUID    string      `gorm:"index"`
	EntityName        string      `gorm:"index"`
	Uuid              string      `gorm:"unique_index"`
	Description       string      // 对该实体的简要描述
	EntityType        string      // 实体的类型或类别
	EntityTypeVerbose string      // 实体类型的详细描述
	Attributes        MetadataMap `gorm:"type:text" json:"attributes"`

	RuntimeID string
}

ERModelEntity 是知识库中所有事物的基本单元

func EntityGRPCToModel

func EntityGRPCToModel(e *ypb.Entity) *ERModelEntity

func (*ERModelEntity) AfterCreate

func (a *ERModelEntity) AfterCreate(tx *gorm.DB) (err error)

func (*ERModelEntity) AfterDelete

func (a *ERModelEntity) AfterDelete(tx *gorm.DB) (err error)

func (*ERModelEntity) AfterUpdate

func (a *ERModelEntity) AfterUpdate(tx *gorm.DB) (err error)

func (*ERModelEntity) BeforeSave

func (e *ERModelEntity) BeforeSave() error

func (*ERModelEntity) Dump

func (e *ERModelEntity) Dump() string

func (*ERModelEntity) String

func (e *ERModelEntity) String() string

func (*ERModelEntity) TableName

func (e *ERModelEntity) TableName() string

func (*ERModelEntity) ToGRPC

func (e *ERModelEntity) ToGRPC() *ypb.Entity

func (*ERModelEntity) ToRAGContent

func (e *ERModelEntity) ToRAGContent() string

type ERModelRelationship

type ERModelRelationship struct {
	gorm.Model

	Uuid           string `gorm:"unique_index"`
	RepositoryUUID string `gorm:"index"`

	SourceEntityID uint
	TargetEntityID uint

	SourceEntityIndex       string
	TargetEntityIndex       string
	RelationshipType        string
	RelationshipTypeVerbose string
	Hash                    string      `gorm:"unique_index"`
	Attributes              MetadataMap `gorm:"type:text" json:"attributes"`

	RuntimeID string
}

func RelationshipGRPCToModel

func RelationshipGRPCToModel(r *ypb.Relationship) *ERModelRelationship

func (*ERModelRelationship) AfterCreate

func (r *ERModelRelationship) AfterCreate(tx *gorm.DB) (err error)

func (*ERModelRelationship) AfterDelete

func (r *ERModelRelationship) AfterDelete(tx *gorm.DB) (err error)

func (*ERModelRelationship) AfterUpdate

func (r *ERModelRelationship) AfterUpdate(tx *gorm.DB) (err error)

func (*ERModelRelationship) BeforeSave

func (r *ERModelRelationship) BeforeSave() error

func (*ERModelRelationship) CalcHash

func (r *ERModelRelationship) CalcHash() string

func (*ERModelRelationship) String

func (r *ERModelRelationship) String() string

func (*ERModelRelationship) TableName

func (r *ERModelRelationship) TableName() string

func (*ERModelRelationship) ToGRPC

func (r *ERModelRelationship) ToGRPC() *ypb.Relationship

func (*ERModelRelationship) ToRAGContent

func (r *ERModelRelationship) ToRAGContent(src string, dst string) string

type EntityRepository

type EntityRepository struct {
	gorm.Model

	RAGID          string `gorm:"index"`
	Uuid           string `gorm:"unique_index"`
	EntityBaseName string `gorm:"index"`
	Description    string
}

func (*EntityRepository) BeforeSave

func (e *EntityRepository) BeforeSave() error

func (*EntityRepository) TableName

func (e *EntityRepository) TableName() string

func (*EntityRepository) ToGRPC

func (e *EntityRepository) ToGRPC() *ypb.EntityRepository

type EventType

type EventType string
const (
	EVENT_TYPE_STREAM              EventType = "stream"
	EVENT_TYPE_STREAM_START        EventType = "stream_start"
	EVENT_TYPE_STRUCTURED          EventType = "structured"
	EVENT_TYPE_AI_REVIEW_START     EventType = "ai_review_start"
	EVENT_TYPE_AI_REVIEW_COUNTDOWN EventType = "ai_review_countdown"
	EVENT_TYPE_AI_REVIEW_END       EventType = "ai_review_end"

	// Token 开销情况
	EVENT_TYPE_CONSUMPTION EventType = "consumption" // token consumption include `{"input_"}`

	// 探活
	EVENT_TYPE_PONG EventType = "pong" // ping response ping-pong is a check for alive item

	// 压力值
	EVENT_TYPE_PRESSURE EventType = "pressure" // pressure for ai context percent

	EVENT_TYPE_AI_FIRST_BYTE_COST_MS EventType = "ai_first_byte_cost_ms" // first byte cost
	EVENT_TYPE_AI_TOTAL_COST_MS      EventType = "ai_total_cost_ms"      // first byte cost

	// AI 请求用户交互
	EVENT_TYPE_REQUIRE_USER_INTERACTIVE = "require_user_interactive"

	// risk control prompt is the prompt for risk control
	// contains score, reason, and other information to help uesr interactivation
	EVENT_TYPE_RISK_CONTROL_PROMPT = "risk_control_prompt"

	EVENT_TOOL_CALL_START       = "tool_call_start"       // tool call start event, used to emit the tool call start information
	EVENT_TOOL_CALL_STATUS      = "tool_call_status"      // tool call status event, used to emit the tool call status information
	EVENT_TOOL_CALL_USER_CANCEL = "tool_call_user_cancel" // tool call user cancel event, used to emit the tool call user cancel information
	EVENT_TOOL_CALL_DONE        = "tool_call_done"        // tool call end event, used to emit the tool call end information
	EVENT_TOOL_CALL_ERROR       = "tool_call_error"       // tool call error event, used to emit the tool call error information
	EVENT_TOOL_CALL_SUMMARY     = "tool_call_summary"     // tool call summary event, used to emit the tool call summary information
	EVENT_TOOL_CALL_DECISION    = "tool_call_decision"    // tool call decision event, used to emit the tool call decision information

	EVENT_TYPE_START_PLAN_AND_EXECUTION    EventType = "start_plan_and_execution"
	EVENT_TYPE_FAIL_PLAN_AND_EXECUTION     EventType = "fail_plan_and_execution"
	EVENT_TYPE_END_PLAN_AND_EXECUTION      EventType = "end_plan_and_execution"
	EVENT_TYPE_PLAN                        EventType = "plan"
	EVENT_TYPE_PERMISSION_REQUIRE          EventType = "permission_require"
	EVENT_TYPE_TASK_REVIEW_REQUIRE         EventType = "task_review_require"
	EVENT_TYPE_PLAN_REVIEW_REQUIRE         EventType = "plan_review_require"
	EVENT_TYPE_TOOL_USE_REVIEW_REQUIRE     EventType = "tool_use_review_require"
	EVENT_TYPE_EXEC_AIFORGE_REVIEW_REQUIRE EventType = "exec_aiforge_review_require"

	EVENT_PLAN_TASK_ANALYSIS EventType = "plan_task_analysis" // plan task analysis event, used to emit the plan task analysis information

	EVENT_TYPE_TOOL_CALL_WATCHER EventType = "tool_call_watcher" // tool call watcher event, used to emit the tool call watcher information. user can cancel this tool call

	EVENT_TYPE_REVIEW_RELEASE EventType = "review_release"

	EVENT_TYPE_INPUT EventType = "input"

	EVENT_TYPE_AID_CONFIG = "aid_config" // aid config event, used to emit the current config information

	EVENT_TYPE_YAKIT_EXEC_RESULT = "yak_exec_result" // yakit exec result event, used to emit the yakit exec result information
	EVENT_TYPE_YAKIT_RISK        = "yak_risk"        // yakit risk event, used to emit the yakit risk information

	// AI 推理过程通用事件类型
	EVENT_TYPE_THOUGHT     EventType = "thought"     // AI 思考过程(适用于 ReAct、CoT 等推理模式)
	EVENT_TYPE_ACTION      EventType = "action"      // AI 行动执行(工具调用、函数执行等)
	EVENT_TYPE_OBSERVATION EventType = "observation" // AI 观察结果(工具执行结果、环境反馈等)
	EVENT_TYPE_ITERATION   EventType = "iteration"   // AI 迭代信息(循环推理、多轮对话等)
	EVENT_TYPE_RESULT      EventType = "result"      // AI 最终结果(推理结论、任务完成等)

	EVENT_TYPE_KNOWLEDGE            EventType = "knowledge"      // AI 知识增强(外部知识、上下文信息等)
	EVENT_TYPE_TASK_ABOUT_KNOWLEDGE EventType = "task_knowledge" // 同步任务相关的已查询到的知识
	// YakLang 代码编辑器事件
	EVENT_TYPE_YAKLANG_CODE_EDITOR EventType = "yaklang_code_editor"

	EVENT_TYPE_FILESYSTEM_PIN_DIRECTORY EventType = "filesystem_pin_directory" // pin_directory means pin a directory in the filesystem
	EVENT_TYPE_FILESYSTEM_PIN_FILENAME  EventType = "filesystem_pin_filename"  // pin_filename means pin a filename in the filesystem

	EVENT_TYPE_FOCUS_ON_LOOP   EventType = "focus_on"
	EVENT_TYPE_LOSE_FOCUS_LOOP EventType = "lose_focus"

	// AI Memory Operation
	EVENT_TYPE_MEMORY_SEARCH_QUICKLY  EventType = "memory_search_quickly"  // quickly memory search event, used to emit the quickly memory search information
	EVENT_TYPE_MEMORY_SEARCH_SPECIFIC EventType = "memory_search_specific" // specific memory search event, used to emit the specific memory search information
	EVENT_TYPE_MEMORY_BUILD           EventType = "memory_build"           // memory build event, used to emit the memory build information
	EVENT_TYPE_MEMORY_SAVE            EventType = "memory_save"            // memory build event, used to emit the memory saving into database
	EVENT_TYPE_MEMORY_ADD_CONTEXT     EventType = "memory_add_context"
	EVENT_TYPE_MEMORY_REMOVE_CONTEXT  EventType = "memory_remove_context"
	EVENT_TYPE_MEMORY_CONTEXT         EventType = "memory_context" // memory context sync event, used to emit all memory context information

	// AI Task Execution Mode Switch
	EVENT_TYPE_AI_TASK_SWITCHED_TO_ASYNC EventType = "ai_task_switched_to_async" // AI task switched to async execution event

	EVENT_TYPE_REFERENCE_MATERIAL EventType = "reference_material" // 引用材料
)

type ExecHistory

type ExecHistory struct {
	gorm.Model

	Hash string `gorm:"unique_index"`

	RuntimeId     string `json:"runtime_id" gorm:"unique_index"`
	Script        string `json:"script"`
	ScriptId      string `json:"script_id" gorm:"index"`
	TimestampNano int64  `json:"timestamp"`
	FromYakModule string `json:"from_yak_module" gorm:"index"`
	DurationMs    int64  `json:"duration_ms"`
	Params        string `json:"params"`
	Stdout        string `json:"stdout"`
	Stderr        string `json:"stderr"`
	Ok            bool   `json:"ok"`
	Reason        string `json:"reason"`

	StdoutLen int64 `json:"stdout_len" gorm:"-"`
	StderrLen int64 `json:"stderr_len" gorm:"-"`

	// json
	Messages string `json:"messages"`
}

func (*ExecHistory) BeforeSave

func (f *ExecHistory) BeforeSave() error

func (*ExecHistory) CalcHash

func (f *ExecHistory) CalcHash() string

func (*ExecHistory) ToGRPCModel

func (f *ExecHistory) ToGRPCModel() *ypb.ExecHistoryRecord

type ExecResult

type ExecResult struct {
	gorm.Model

	YakScriptName string `json:"yak_script_name" gorm:"index"`
	Raw           string `json:"raw"`
}

func (*ExecResult) ToGRPCModel

func (e *ExecResult) ToGRPCModel() *ypb.ExecResult

type ExtractedData

type ExtractedData struct {
	gorm.Model

	// sourcetype 一般来说是标注数据来源
	SourceType string `gorm:"index"`

	// trace id 表示数据源的 ID
	TraceId string `gorm:"index"`

	// 提取数据的正则数据
	Regexp string

	// 规则 Verbose
	RuleVerbose string

	// UTF8 safe escape
	Data string

	// DataIndex 表示数据的位置
	DataIndex int

	// Length 表示数据的长度
	Length int

	// IsMatchRequest 表示是否是匹配请求
	IsMatchRequest bool

	AnalyzedHTTPFlowId uint `gorm:"index"`
}

type FloatArray

type FloatArray []float32

FloatArray 用于在数据库中存储浮点数数组的自定义类型 实现了 driver.Valuer 和 sql.Scanner 接口,支持数据库存储和读取

func (*FloatArray) Scan

func (f *FloatArray) Scan(value interface{}) error

Scan 实现 sql.Scanner 接口,用于将数据库存储的值转换回 []float64

func (FloatArray) Value

func (f FloatArray) Value() (driver.Value, error)

Value 实现 driver.Valuer 接口,用于将 []float64 转换为数据库可以存储的值

type GeneralRule

type GeneralRule struct {
	gorm.Model
	*CPE
	RuleName        string `json:"指纹名称" gorm:"unique_index"`
	WebPath         string `json:"web路径"`
	ExtInfo         string
	MatchExpression string              `json:"指纹规则"`
	Groups          []*GeneralRuleGroup `gorm:"many2many:general_rule_and_group;"`
}

func GRPCGeneralRuleToSchemaGeneralRule

func GRPCGeneralRuleToSchemaGeneralRule(gr *ypb.FingerprintRule) *GeneralRule

func (*GeneralRule) String

func (g *GeneralRule) String() string

func (*GeneralRule) ToGRPCModel

func (gr *GeneralRule) ToGRPCModel() *ypb.FingerprintRule

type GeneralRuleGroup

type GeneralRuleGroup struct {
	gorm.Model
	GroupName string         `json:"group_name" gorm:"unique_index"`
	Rules     []*GeneralRule `gorm:"many2many:general_rule_and_group;"`
}

func GRPCFingerprintGroupToSchemaGeneralRuleGroup

func GRPCFingerprintGroupToSchemaGeneralRuleGroup(grpcGroup *ypb.FingerprintGroup) *GeneralRuleGroup

func (*GeneralRuleGroup) ToGRPCModel

func (s *GeneralRuleGroup) ToGRPCModel() *ypb.FingerprintGroup

type GeneralStorage

type GeneralStorage struct {
	gorm.Model

	Key string `json:"key" gorm:"unique_index"`

	// 经过 JSON + Strconv
	Value string `json:"value"`

	// 过期时间
	ExpiredAt time.Time

	// YAKIT SUBPROC_ENV
	ProcessEnv bool

	// 帮助信息,描述这个变量是干嘛的
	Verbose string

	// 描述变量所在的组是啥
	Group string
}

func (*GeneralStorage) EnableProcessEnv

func (s *GeneralStorage) EnableProcessEnv()

func (*GeneralStorage) ToGRPCModel

func (s *GeneralStorage) ToGRPCModel() *ypb.GeneralStorage

type GroupInfo

type GroupInfo struct {
	LayerLevel int
	Key        string
	Neighbors  []string
}

GroupInfo 用于存储 HNSW 图结构中节点连接信息的自定义类型 实现了 driver.Valuer 和 sql.Scanner 接口,支持在数据库中存储复杂结构

func (*GroupInfo) Scan

func (g *GroupInfo) Scan(value interface{}) error

Scan 实现 sql.Scanner 接口,用于将数据库存储的值转换回 GroupInfo

func (GroupInfo) Value

func (g GroupInfo) Value() (driver.Value, error)

Value 实现 driver.Valuer 接口,用于将 GroupInfo 转换为数据库可以存储的值

type HTTPFlow

type HTTPFlow struct {
	gorm.Model

	HiddenIndex        string `gorm:"index" json:"hidden_index,omitempty"`
	NoFixContentLength bool   `json:"no_fix_content_length" json:"no_fix_content_length,omitempty"`
	Hash               string `gorm:"unique_index" json:"unique_index,omitempty"`
	IsHTTPS            bool   `json:"is_https,omitempty"`
	Url                string `gorm:"index" json:"url,omitempty"`
	Path               string `json:"path,omitempty"`
	Method             string `json:"method,omitempty"`
	RequestLength      int64  `json:"request_length,omitempty"`
	BodyLength         int64  `json:"body_length,omitempty"`
	ContentType        string `json:"content_type,omitempty"`
	StatusCode         int64  `json:"status_code,omitempty"`
	SourceType         string `json:"source_type,omitempty"`
	Request            string `json:"request,omitempty"`
	Response           string `json:"response,omitempty"`
	Duration           int64  `json:"duration,omitempty"`
	GetParamsTotal     int    `json:"get_params_total,omitempty"`
	PostParamsTotal    int    `json:"post_params_total,omitempty"`
	CookieParamsTotal  int    `json:"cookie_params_total,omitempty"`
	IPAddress          string `json:"ip_address,omitempty"`
	RemoteAddr         string `json:"remote_addr,omitempty"`
	IPInteger          int    `json:"ip_integer,omitempty"`
	Tags               string `json:"tags,omitempty"` // 用来打标!
	Payload            string `json:"payload,omitempty"`

	// Websocket 相关字段
	IsWebsocket bool `json:"is_websocket,omitempty"`
	// 用来计算 websocket hash, 每次连接都不一样,一般来说,内部对象 req 指针足够了
	WebsocketHash string `json:"websocket_hash,omitempty"`

	RuntimeId   string         `json:"runtime_id,omitempty" gorm:"index"`
	FromPlugin  string         `json:"from_plugin,omitempty"`
	ProcessName sql.NullString `json:"process_name,omitempty"`

	// friendly for gorm build instance, not for store
	// 这两个字段不参与数据库存储,但是在序列化的时候,会被覆盖
	// 主要用来标记用户的 Request 和 Response 是否超大
	IsRequestOversize  bool `gorm:"-" json:"is_request_oversize,omitempty"`
	IsResponseOversize bool `gorm:"-" json:"is_response_oversize,omitempty"`

	IsReadTooSlowResponse      bool   `json:"is_read_too_slow_response,omitempty"`
	IsTooLargeResponse         bool   `json:"is_too_large_response,omitempty"`
	TooLargeResponseHeaderFile string `json:"too_large_response_header_file,omitempty"`
	TooLargeResponseBodyFile   string `json:"too_large_response_body_file,omitempty"`
	// 同步到企业端
	UploadOnline bool   `json:"upload_online,omitempty"`
	Host         string `json:"host,omitempty"`
}

func (*HTTPFlow) AddTag

func (f *HTTPFlow) AddTag(appendTags ...string)

颜色与 Tag API

func (*HTTPFlow) AddTagToFirst

func (f *HTTPFlow) AddTagToFirst(appendTags ...string)

func (*HTTPFlow) AfterCreate

func (f *HTTPFlow) AfterCreate(tx *gorm.DB) (err error)

func (*HTTPFlow) AfterDelete

func (f *HTTPFlow) AfterDelete(tx *gorm.DB) (err error)

func (*HTTPFlow) AfterUpdate

func (f *HTTPFlow) AfterUpdate(tx *gorm.DB) (err error)

func (*HTTPFlow) BeforeSave

func (f *HTTPFlow) BeforeSave() error

func (*HTTPFlow) Blue

func (f *HTTPFlow) Blue()

func (*HTTPFlow) CalcCacheHash

func (f *HTTPFlow) CalcCacheHash(full bool) string

func (*HTTPFlow) CalcHash

func (f *HTTPFlow) CalcHash() string

func (*HTTPFlow) ColorSharp

func (f *HTTPFlow) ColorSharp(rgbHex string)

func (*HTTPFlow) Cyan

func (f *HTTPFlow) Cyan()

func (*HTTPFlow) GetRequest

func (f *HTTPFlow) GetRequest() string

func (*HTTPFlow) GetResponse

func (f *HTTPFlow) GetResponse() string

func (*HTTPFlow) Green

func (f *HTTPFlow) Green()

func (*HTTPFlow) Grey

func (f *HTTPFlow) Grey()

func (*HTTPFlow) HasColor

func (f *HTTPFlow) HasColor(color string) bool

func (*HTTPFlow) Orange

func (f *HTTPFlow) Orange()

func (*HTTPFlow) Purple

func (f *HTTPFlow) Purple()

func (*HTTPFlow) Red

func (f *HTTPFlow) Red()

func (*HTTPFlow) SetRequest

func (f *HTTPFlow) SetRequest(req string)

func (*HTTPFlow) SetResponse

func (f *HTTPFlow) SetResponse(rsp string)

func (*HTTPFlow) Yellow

func (f *HTTPFlow) Yellow()

type Host

type Host struct {
	gorm.Model

	IP        string `json:"ip" gorm:"unique_index"`
	IPInteger int64  `json:"ip_integer"`

	IsInPublicNet bool

	// splite by comma
	Domains string
}

type HotPatchTemplate

type HotPatchTemplate struct {
	gorm.Model
	Name    string `json:"name"`
	Content string `json:"content"`
	Type    string `json:"type"`
}

func (*HotPatchTemplate) TableName

func (*HotPatchTemplate) TableName() string

TableName overrides the table name used by User to `profiles`

func (*HotPatchTemplate) ToGRPCModel

func (t *HotPatchTemplate) ToGRPCModel() *ypb.HotPatchTemplate

type HybridScanTask

type HybridScanTask struct {
	gorm.Model

	TaskId string `gorm:"unique_index"`
	// executing
	// paused
	// done
	Status              string
	Reason              string // user cancel / finished / recover failed so on
	SurvivalTaskIndexes string // 暂停的时候正在执行的任务

	// struct{ https bool; request bytes }[]
	Targets string
	// string[]
	Plugins         string
	TotalTargets    int64
	TotalPlugins    int64
	TotalTasks      int64
	FinishedTasks   int64
	FinishedTargets int64

	ScanConfig []byte

	HybridScanTaskSource string
}

type I18n

type I18n struct {
	Zh string `json:"zh"`
	En string `json:"en"`
}

func GetActionI18n

func GetActionI18n(action string) *I18n

func NodeIdToI18n

func NodeIdToI18n(nodeId string, isStream bool) *I18n

func (*I18n) I18nToYPB_I18n

func (i18n *I18n) I18nToYPB_I18n() *ypb.I18N

type KnowledgeBaseEntry

type KnowledgeBaseEntry struct {
	gorm.Model

	// 知识库名称
	KnowledgeBaseID int64 `gorm:"not null" json:"knowledge_base_id"`

	RelatedEntityUUIDS string // split by ","

	// 知识标题(和知识库名称应该是联合唯一索引)
	KnowledgeTitle string `gorm:"not null" json:"knowledge_title"`

	// 知识类型(如:CoreConcept、Standard、Guideline等)
	KnowledgeType string `gorm:"index;not null" json:"knowledge_type"`

	// 重要性评分(1-10)
	ImportanceScore int `gorm:"index" json:"importance_score"`

	// 关键词列表,用于快速搜索和分类
	Keywords StringArray `gorm:"type:text" json:"keywords"`

	// 知识详细信息,包含具体内容描述
	KnowledgeDetails string `gorm:"type:text" json:"knowledge_details"`

	// 知识摘要,简要概述
	Summary string `gorm:"type:text" json:"summary"`

	// 来源页码或章节编号
	SourcePage int `gorm:"index" json:"source_page"`

	// 潜在问题列表,这些问题可能与该知识条目相关
	PotentialQuestions StringArray `gorm:"type:text" json:"potential_questions"`

	// 潜在问题向量,用于快速搜索潜在问题
	PotentialQuestionsVector FloatArray `gorm:"type:text" json:"potential_questions_vector"`

	// 唯一标识符,用于在向量索引中唯一标识该知识条目
	HiddenIndex string `gorm:"unique_index"`
}

KnowledgeBase 表示知识库条目 用于存储各种标准、指南等知识库信息

func (*KnowledgeBaseEntry) AfterCreate

func (e *KnowledgeBaseEntry) AfterCreate(tx *gorm.DB) (err error)

func (*KnowledgeBaseEntry) AfterDelete

func (e *KnowledgeBaseEntry) AfterDelete(tx *gorm.DB) (err error)

func (*KnowledgeBaseEntry) AfterUpdate

func (e *KnowledgeBaseEntry) AfterUpdate(tx *gorm.DB) (err error)

func (*KnowledgeBaseEntry) BeforeSave

func (e *KnowledgeBaseEntry) BeforeSave() error

func (*KnowledgeBaseEntry) TableName

func (e *KnowledgeBaseEntry) TableName() string

type KnowledgeBaseInfo

type KnowledgeBaseInfo struct {
	gorm.Model

	RAGID string `gorm:"index"`
	// 知识库名称(唯一)
	KnowledgeBaseName string `gorm:"unique_index;not null" json:"knowledge_base_name"`

	// 知识库描述
	KnowledgeBaseDescription string `gorm:"type:text" json:"knowledge_base_description"`

	// 知识库类型
	KnowledgeBaseType string `gorm:"index;not null" json:"knowledge_base_type"`

	SerialVersionUID string `gorm:"index" json:"serial_version_uid"`
}

func (*KnowledgeBaseInfo) TableName

func (v *KnowledgeBaseInfo) TableName() string

type LoginSession

type LoginSession struct {
	gorm.Model

	SessionID string    `json:"session_id" gorm:"index"`
	ExpiresAt time.Time `json:"expires_at"`
}

type MCPServer

type MCPServer struct {
	gorm.Model

	Name    string `gorm:"index;not null" json:"name"` // 服务器名称
	Type    string `gorm:"index;not null" json:"type"` // 服务器类型 (stdio/sse)
	URL     string `gorm:"type:text" json:"url"`       // 服务器URL (for sse type)
	Command string `gorm:"type:text" json:"command"`   // 启动命令 (for stdio type)
	Enable  bool   `gorm:"default:true" json:"enable"` // 是否启用
}

MCPServer MCP服务器配置模型

func (*MCPServer) TableName

func (m *MCPServer) TableName() string

func (*MCPServer) ToGRPC

func (m *MCPServer) ToGRPC() *ypb.MCPServer

ToGRPC 转换为gRPC响应格式

func (*MCPServer) ToGRPCWithTools

func (m *MCPServer) ToGRPCWithTools(tools []*ypb.MCPServerTool) *ypb.MCPServer

ToGRPCWithTools 转换为包含工具列表的gRPC响应格式

type MapEx

type MapEx[K comparable, V any] map[K]V

func (*MapEx[K, V]) Scan

func (m *MapEx[K, V]) Scan(value interface{}) error

func (MapEx[K, V]) Value

func (m MapEx[K, V]) Value() (driver.Value, error)

type MarkdownDoc

type MarkdownDoc struct {
	gorm.Model

	YakScriptId   int64  `json:"yak_script_id" gorm:"index"`
	YakScriptName string `json:"yak_script_name" gorm:"index"`
	Markdown      string `json:"markdown"`
}
type MenuItem struct {
	gorm.Model

	Group         string `json:"group" `
	Verbose       string `json:"verbose"`
	YakScriptName string `json:"yak_script_name"`
	Hash          string `json:"-" gorm:"unique_index"`

	// quoted json
	BatchPluginFilterJson string `json:"batch_plugin_filter_json"`
	Mode                  string `json:"mode"`
	MenuSort              int64  `json:"menu_sort"`
	GroupSort             int64  `json:"group_sort"`
}
func (m *MenuItem) BeforeSave() error
func (m *MenuItem) CalcHash() string

type MetadataMap

type MetadataMap map[string]interface{}

MetadataMap 用于存储文档元数据的自定义类型 实现了 driver.Valuer 和 sql.Scanner 接口,支持在数据库中存储 map 类型数据

func (MetadataMap) GetDataUUID

func (m MetadataMap) GetDataUUID() (string, bool)

func (MetadataMap) GetReposUUID

func (m MetadataMap) GetReposUUID() (string, bool)

func (MetadataMap) GetTitle

func (m MetadataMap) GetTitle() (string, bool)

func (*MetadataMap) Scan

func (m *MetadataMap) Scan(value interface{}) error

Scan 实现 sql.Scanner 接口,用于将数据库存储的值转换回 map

func (MetadataMap) Value

func (m MetadataMap) Value() (driver.Value, error)

Value 实现 driver.Valuer 接口,用于将 map 转换为数据库可以存储的值

type NaslScript

type NaslScript struct {
	gorm.Model
	OriginFileName  string `json:"origin_file_name"`
	Hash            string `json:"hash" gorm:"unique_index"`
	OID             string `json:"oid"`
	CVE             string `json:"cve"`
	ScriptName      string `json:"script_name"`
	Script          string `json:"script"`
	Tags            string `json:"tags,omitempty"`
	Version         string `json:"version"`
	Category        string `json:"category"`
	Family          string `json:"family"`
	Copyright       string `json:"copyright"`
	Dependencies    string `json:"dependencies,omitempty"`
	RequirePorts    string `json:"require_ports,omitempty"`
	RequireUdpPorts string `json:"require_udp_ports,omitempty"`
	ExcludeKeys     string `json:"exclude_keys,omitempty"`
	Xref            string `json:"xref,omitempty"`
	Preferences     string `json:"preferences,omitempty"`
	BugtraqId       string `json:"bugtraqId,omitempty"`
	MandatoryKeys   string `json:"mandatory_keys,omitempty"`
	Timeout         int    `json:"timeout,omitempty"`
	RequireKeys     string `json:"require_keys,omitempty"`
}

func (*NaslScript) CalcHash

func (p *NaslScript) CalcHash() string

func (*NaslScript) CreateOrUpdateNaslScript

func (p *NaslScript) CreateOrUpdateNaslScript(db *gorm.DB) error

func (*NaslScript) GetContent

func (s *NaslScript) GetContent() string

func (*NaslScript) GetScriptName

func (s *NaslScript) GetScriptName() string

func (*NaslScript) GetType

func (s *NaslScript) GetType() string

func (*NaslScript) ToYakScript

func (p *NaslScript) ToYakScript() *YakScript
type NavigationBar struct {
	gorm.Model
	Group         string `json:"group" `
	YakScriptName string `json:"yak_script_name"`
	Hash          string `json:"-" gorm:"unique_index"`
	Mode          string `json:"mode"`
	VerboseSort   int64  `json:"verbose_sort"`
	GroupSort     int64  `json:"group_sort"`
	Route         string `json:"route"`
	Verbose       string `json:"verbose"`
	GroupLabel    string `json:"group_label"`
	VerboseLabel  string `json:"verbose_label"`
}
func (m *NavigationBar) CalcHash() string

type Note

type Note struct {
	gorm.Model

	Title   string `json:"title"`
	Content string `json:"content"`
}

func (*Note) ToGRPCModel

func (n *Note) ToGRPCModel() *ypb.Note

type Payload

type Payload struct {
	gorm.Model

	// Must: payload group
	Group string `json:"group" gorm:"index"`

	// payload folder
	Folder     *string `json:"folder" gorm:"column:folder;default:''"`          // default empty string
	GroupIndex *int64  `json:"group_index" gorm:"column:group_index;default:0"` // default 0

	// strconv Quoted
	// Must: payload data
	Content *string `json:"content"`

	// hit count
	HitCount *int64 `json:"hit_count" gorm:"column:hit_count;default:0"` // default 0

	// the group save in file only contain one payload, and this `payload.IsFile = true` `payload.Content` is filepath
	IsFile *bool `json:"is_file" gorm:"column:is_file;default:false"` // default false

	// Hash string
	Hash string `json:"hash" gorm:"unique_index"`
}

func NewPayloadFromGRPCModel

func NewPayloadFromGRPCModel(p *ypb.Payload) *Payload

func (*Payload) BeforeCreate

func (p *Payload) BeforeCreate() error

func (*Payload) BeforeSave

func (p *Payload) BeforeSave() error

func (*Payload) BeforeUpdate

func (p *Payload) BeforeUpdate() error

func (*Payload) CalcHash

func (p *Payload) CalcHash() string

func (*Payload) GetContent

func (p *Payload) GetContent() string

func (*Payload) GetIsFile

func (p *Payload) GetIsFile() bool

func (*Payload) ToGRPCModel

func (p *Payload) ToGRPCModel() *ypb.Payload

type PluginEnv

type PluginEnv struct {
	gorm.Model
	Key   string `gorm:"unique_index"`
	Value string
}

type PluginGroup

type PluginGroup struct {
	gorm.Model

	YakScriptName string `json:"yak_script_name" gorm:"index"`
	Group         string `json:"group"`
	Hash          string `json:"hash" gorm:"unique_index"`
	TemporaryId   string `json:"temporary_id"`
	IsPocBuiltIn  bool   `json:"is_poc_built_in"`
}

func (*PluginGroup) CalcHash

func (p *PluginGroup) CalcHash() string

type Port

type Port struct {
	gorm.Model

	Host        string `json:"host" gorm:"index"`
	IPInteger   int    `json:"ip_integer" gorm:"column:ip_integer" json:"ip_integer"`
	Port        int    `json:"port" gorm:"index"`
	Proto       string `json:"proto"`
	ServiceType string `json:"service_type"`
	State       string `json:"state"`
	Reason      string `json:"reason"`
	Fingerprint string `json:"fingerprint"`
	CPE         string `json:"cpe"`
	HtmlTitle   string `json:"html_title"`
	From        string `json:"from"`
	Hash        string `json:"hash"`
	TaskName    string `json:"task_name"`

	// runtime id 运行时 ID
	RuntimeId string `json:"runtime_id"`
}

func (*Port) BeforeSave

func (p *Port) BeforeSave() error

func (*Port) CalcHash

func (p *Port) CalcHash() string

type Progress

type Progress struct {
	gorm.Model
	RuntimeId            string
	CurrentProgress      float64
	YakScriptOnlineGroup string
	// 记录指针
	LastRecordPtr int64
	TaskName      string
	// 额外信息
	ExtraInfo string

	ProgressSource string

	// 任务记录的参数
	ProgressTaskParam []byte

	// 目标 大部分的progress都应该有制定目标,所以尝试提取出来作为单独的数据使用
	Target string
}

type Project

type Project struct {
	gorm.Model

	ProjectName string
	Description string

	DatabasePath string

	IsCurrentProject bool
	FolderID         int64
	ChildFolderID    int64
	Type             string
	// Hash string `gorm:"unique_index"`
	// 企业版 项目模块及项目编号
	ExternalModule      string
	ExternalProjectCode string
}

Project 描述一个 Yakit 项目 一般项目数据都是应该用 ProjectDatabase 作为连接的 但是项目本身的元数据应该存在 ProfileDatabase 中

func (*Project) CalcHash

func (p *Project) CalcHash() string

type ProjectGeneralStorage

type ProjectGeneralStorage struct {
	gorm.Model

	Key string `json:"key" gorm:"unique_index"`

	// 经过 JSON + Strconv
	Value string `json:"value"`

	// 过期时间
	ExpiredAt time.Time

	// YAKIT SUBPROC_ENV
	ProcessEnv bool

	// 帮助信息,描述这个变量是干嘛的
	Verbose string

	// 描述变量所在的组是啥
	Group string
}

type RAGDocumentType

type RAGDocumentType string
const (
	RAGDocumentType_Entity        RAGDocumentType = "entity"         // 实体
	RAGDocumentType_Relationship  RAGDocumentType = "relationship"   // 关系
	RAGDocumentType_Knowledge     RAGDocumentType = "knowledge"      // 知识
	RAGDocumentType_KHop          RAGDocumentType = "khop"           // 图
	RAGDocumentType_QuestionIndex RAGDocumentType = "question_index" // 问题索引

	RAGDocumentType_Unclassified RAGDocumentType = ""
)

type Report

type Report struct {
	TitleValue string        `json:"title"`
	OwnerValue string        `json:"owner"`
	FromValue  string        `json:"from"`
	Items      []*ReportItem `json:"items"`
}

func (*Report) BarGraphHorizontal

func (r *Report) BarGraphHorizontal(items ...interface{})

func (*Report) BarGraphVertical

func (r *Report) BarGraphVertical(items ...interface{})

func (*Report) Code

func (r *Report) Code(items interface{})

func (*Report) Divider

func (r *Report) Divider()

func (*Report) From

func (r *Report) From(i interface{}, items ...interface{})

func (*Report) Markdown

func (r *Report) Markdown(i string)

func (*Report) Owner

func (r *Report) Owner(i interface{}, items ...interface{})

func (*Report) PieGraph

func (r *Report) PieGraph(items ...interface{})

func (*Report) Raw

func (r *Report) Raw(items interface{})

func (*Report) RawTable

func (r *Report) RawTable(items interface{})

func (*Report) Save

func (r *Report) Save() int

func (*Report) SaveForIRify

func (r *Report) SaveForIRify() int

func (*Report) SearchTable

func (r *Report) SearchTable(i interface{}, raw ...interface{})

func (*Report) Table

func (r *Report) Table(i interface{}, raw ...interface{})

func (*Report) Title

func (r *Report) Title(i interface{}, items ...interface{})

func (*Report) ToRecord

func (r *Report) ToRecord() (*ReportRecord, error)

func (*Report) WordCloud

func (r *Report) WordCloud(items ...interface{})

type ReportItem

type ReportItem struct {
	Type    string `json:"type"`
	Content string `json:"content"`
}

type ReportRecord

type ReportRecord struct {
	gorm.Model

	Title       string
	PublishedAt time.Time `json:"published_at"`
	Hash        string    `json:"hash" gorm:"unique_index"`
	Owner       string    `json:"owner"`
	From        string    `json:"from"`
	QuotedJson  string    `json:"quoted_json"`
}

func (*ReportRecord) BeforeSave

func (r *ReportRecord) BeforeSave()

func (*ReportRecord) CalcHash

func (r *ReportRecord) CalcHash() string

func (*ReportRecord) ToGRPCModel

func (i *ReportRecord) ToGRPCModel() *ypb.Report

func (*ReportRecord) ToReport

func (r *ReportRecord) ToReport() (*Report, error)

type Risk

type Risk struct {
	gorm.Model

	Hash string `json:"hash"`

	// essential
	IP        string `json:"ip"`
	IPInteger int64  `json:"ip_integer"`

	// extraTargets
	Url  string `json:"url"`
	Port int    `json:"port"`
	Host string `json:"host"`

	//
	Title           string `json:"title"`
	TitleVerbose    string `json:"title_verbose"`
	Description     string `json:"description"`
	Solution        string `json:"solution"`
	RiskType        string `json:"risk_type"`
	RiskTypeVerbose string `json:"risk_verbose"`
	Parameter       string `json:"parameter"`
	Payload         string `json:"payload"`
	Details         string `json:"details"`
	Severity        string `json:"severity"`

	// 来源于哪个插件?
	FromYakScript string `json:"from_yak_script"`
	YakScriptUUID string `json:"yak_script_uuid"`

	// 等待验证中?
	WaitingVerified bool `json:"waiting_verified"`
	// 用于验证的 ReverseToken
	ReverseToken string `json:"reverse_token"`

	// 设置运行时 ID 为了关联具体漏洞
	RuntimeId      string `json:"runtime_id"`
	QuotedRequest  string `json:"quoted_request"`
	QuotedResponse string `json:"quoted_response"`

	// 潜在威胁:用于输出合规性质的漏洞内容
	IsPotential bool `json:"is_potential"`

	CVE                 string `json:"cve"`
	IsRead              bool   `json:"is_read"`
	Ignore              bool   `json:"ignore"`
	UploadOnline        bool   `json:"upload_online"`
	TaskName            string `json:"task_name"`
	CveAccessVector     string `json:"cve_access_vector"`
	CveAccessComplexity string `json:"cve_access_complexity"`
	Tags                string `json:"tags"`

	// SyntaxFlow
	ResultID    uint   `json:"result_id"`
	Variable    string `json:"variable"`
	ProgramName string `json:"program_name"`
}

func (*Risk) AfterCreate

func (r *Risk) AfterCreate(tx *gorm.DB) (err error)

func (*Risk) AfterDelete

func (r *Risk) AfterDelete(tx *gorm.DB) (err error)

func (*Risk) AfterUpdate

func (r *Risk) AfterUpdate(tx *gorm.DB) (err error)

func (*Risk) BeforeSave

func (p *Risk) BeforeSave() error

func (*Risk) ColorizedShow

func (p *Risk) ColorizedShow()

func (*Risk) ToGRPCModel

func (p *Risk) ToGRPCModel() *ypb.Risk

type RssFeed

type RssFeed struct {
	gorm.Model

	SourceXmlUrl    string
	Hash            string     `gorm:"columns:hash;unique_index"`
	Title           string     `json:"title,omitempty"`
	Description     string     `json:"description,omitempty"`
	Link            string     `json:"link,omitempty"`
	FeedLink        string     `json:"feedLink,omitempty"`
	Updated         string     `json:"updated,omitempty"`
	UpdatedParsed   *time.Time `json:"updatedParsed,omitempty"`
	Published       string     `json:"published,omitempty"`
	PublishedParsed *time.Time `json:"publishedParsed,omitempty"`
	Author          string     `json:"author,omitempty"`
	AuthorEmail     string     `json:"author_email,omitempty"`
	Language        string     `json:"language,omitempty"`
	ImageUrl        string     `json:"image_url,omitempty"`
	ImageName       string     `json:"image_name,omitempty"`
	Copyright       string     `json:"copyright,omitempty"`
	Generator       string     `json:"generator,omitempty"`
	Categories      string     `json:"categories,omitempty"`
	FeedType        string     `json:"feedType"`
	FeedVersion     string     `json:"feedVersion"`
}

func (*RssFeed) BeforeSave

func (b *RssFeed) BeforeSave() error

func (*RssFeed) CalcHash

func (b *RssFeed) CalcHash() string

type SSADiffCompareType

type SSADiffCompareType string
const (
	CustomDiff SSADiffCompareType = "custom"
	RiskDiff                      = "risk"
)

func ValidSSADiffResultCompareType

func ValidSSADiffResultCompareType(typ string) SSADiffCompareType

type SSADiffResult

type SSADiffResult struct {
	*gorm.Model
	BaseLine string
	Compare  string
	RuleName string // rule name

	BaseLineRiskHash string
	CompareRiskHash  string

	Status string
	//CompareType 比较类型,是custom还是risk
	CompareType    string
	DiffResultKind string //结果类型,是taskID还是program

	Hash string `gorm:"uniqueIndex"`
}

func (*SSADiffResult) BeforeCreate

func (d *SSADiffResult) BeforeCreate()

func (*SSADiffResult) BeforeSave

func (d *SSADiffResult) BeforeSave()

func (*SSADiffResult) BeforeUpdate

func (d *SSADiffResult) BeforeUpdate()

func (*SSADiffResult) CalcHash

func (d *SSADiffResult) CalcHash() string

func (SSADiffResult) TableName

func (SSADiffResult) TableName() string

TableName ensures GORM uses the correct table name

type SSADiffResultKind

type SSADiffResultKind string
const (
	Unknown   SSADiffResultKind = "unknown"
	RuntimeId SSADiffResultKind = "runtimeId" //task ID
	Program   SSADiffResultKind = "program"   //利用Program来进行对比
)

func ValidSSADiffResultKind

func ValidSSADiffResultKind(typ string) SSADiffResultKind

type SSAProject

type SSAProject struct {
	gorm.Model
	// 项目基础信息
	ProjectName string             `json:"project_name" gorm:"index;not null;comment:项目名称"`
	Description string             `json:"description,omitempty" gorm:"comment:项目描述"`
	Tags        string             `json:"tags,omitempty" gorm:"comment:项目标签"`
	Language    ssaconfig.Language `json:"language" gorm:"index;comment:项目语言"`
	URL         string             `json:"url,omitempty" gorm:"index;comment:项目源码地址"`
	// 配置选项
	Config []byte `json:"config"`
	Hash   string `json:"hash" gorm:"unique_index"`
}

SSAProject 用于配置SSA的项目信息,包括项目名称、源码获取方式以及编译、扫描选项等

func (*SSAProject) BeforeCreate

func (p *SSAProject) BeforeCreate(tx *gorm.DB) error

func (*SSAProject) BeforeSave

func (p *SSAProject) BeforeSave(tx *gorm.DB) error

func (*SSAProject) BeforeUpdate

func (p *SSAProject) BeforeUpdate(tx *gorm.DB) error

func (*SSAProject) GetConfig

func (p *SSAProject) GetConfig() (*ssaconfig.Config, error)

func (*SSAProject) GetTagsList

func (p *SSAProject) GetTagsList() []string

func (*SSAProject) SetConfig

func (p *SSAProject) SetConfig(config *ssaconfig.Config) error

func (*SSAProject) SetTagsList

func (p *SSAProject) SetTagsList(tags []string)

func (*SSAProject) ToGRPCModelBasic

func (p *SSAProject) ToGRPCModelBasic() *ypb.SSAProject

type SSARisk

type SSARisk struct {
	gorm.Model

	Hash string `json:"hash" gorm:"unique_index"`

	// risk info
	Title        string             `json:"title"`
	TitleVerbose string             `json:"title_verbose"`
	Description  string             `json:"description" gorm:"type:longtext"`
	Solution     string             `json:"solution" gorm:"type:longtext"`
	RiskType     string             `json:"risk_type"`
	Details      string             `json:"details"`
	Severity     SyntaxFlowSeverity `json:"severity" gorm:"index"`
	Language     string             `json:"language"`
	// 潜在威胁:用于输出合规性质的漏洞内容
	IsPotential bool `json:"is_potential"`

	// risk info
	CVE                 string      `json:"cve"`
	CWE                 StringArray `gorm:"type:text" json:"cwe"`
	IsRead              bool        `json:"is_read"`
	Ignore              bool        `json:"ignore"`
	UploadOnline        bool        `json:"upload_online"`
	CveAccessVector     string      `json:"cve_access_vector"`
	CveAccessComplexity string      `json:"cve_access_complexity"`
	Tags                string      `json:"tags"`

	// 来源于哪个规则
	FromRule string `json:"from_rule"`
	// 来源于哪个项目
	ProgramName string `json:"program_name" gorm:"index"`
	// file url yakurl
	CodeSourceUrl string `json:"code_source_url" gorm:"index"`
	CodeRange     string `json:"code_range" gorm:"type:longtext"`
	CodeFragment  string `json:"code_fragment" gorm:"type:longtext"`
	// for query risk
	FunctionName string `json:"function_name" gorm:"index"`
	Line         int64  `json:"line" gorm:"index"`
	// 设置运行时 ID 关联 SyntaxflowTask
	RuntimeId string `json:"runtime_id" gorm:"index"`
	// for query result
	ResultID uint64 `json:"result_id"` // result
	Variable string `json:"variable"`  // result/variable
	Index    int64  `json:"index"`     // result/variable/index

	// 最新处置状态
	LatestDisposalStatus string `json:"latest_disposal_status" gorm:"index;default:'not_set'"`
	// Risk 特征哈希,用于区分不同批次扫描的同一个漏洞
	// 包含 SSA 信息(disam、function)、FileUrl、SfRule 信息(ruleId、variableName、level)
	RiskFeatureHash string `json:"risk_feature_hash" gorm:"index"`

	SSAProjectID uint64 `json:"ssa_project_id" gorm:"index"`
}

func (*SSARisk) AfterCreate

func (s *SSARisk) AfterCreate(tx *gorm.DB) (err error)

func (*SSARisk) AfterUpdate

func (s *SSARisk) AfterUpdate(tx *gorm.DB) (err error)

func (*SSARisk) BeforeCreate

func (s *SSARisk) BeforeCreate(tx *gorm.DB) (err error)

func (*SSARisk) CalcHash

func (s *SSARisk) CalcHash() string

func (*SSARisk) GetAlertMsg

func (s *SSARisk) GetAlertMsg() string

func (*SSARisk) String

func (s *SSARisk) String() string

func (*SSARisk) ToGRPCModel

func (s *SSARisk) ToGRPCModel() *ypb.SSARisk

type SSARiskDisposalStatus

type SSARiskDisposalStatus string
const (
	SSARiskDisposalStatus_NotSet     SSARiskDisposalStatus = "not_set"    // 未处置
	SSARiskDisposalStatus_NotIssue   SSARiskDisposalStatus = "not_issue"  // 不是问题
	SSARiskDisposalStatus_Suspicious SSARiskDisposalStatus = "suspicious" // 疑似问题
	SSARiskDisposalStatus_IsIssue    SSARiskDisposalStatus = "is_issue"   // 存在漏洞
)

SSARisk 处置状态

func ValidSSARiskDisposalStatus

func ValidSSARiskDisposalStatus(s string) SSARiskDisposalStatus

type SSARiskDisposals

type SSARiskDisposals struct {
	gorm.Model
	TaskId    string `json:"task_id" gorm:"index"`
	SSARiskID int64  `json:"ssa_risk_id" gorm:"index"`
	// RiskFeatureHash 用于标识风险特征的唯一哈希值,可以用来实现处置的继承
	RiskFeatureHash string `json:"risk_feature_hash" gorm:"index;not null"`
	Status          string `json:"status" gorm:"index"`
	Comment         string `json:"comment" gorm:"type:text"`
}

func (*SSARiskDisposals) AfterCreate

func (s *SSARiskDisposals) AfterCreate(tx *gorm.DB) error

func (*SSARiskDisposals) AfterDelete

func (s *SSARiskDisposals) AfterDelete(tx *gorm.DB) error

func (*SSARiskDisposals) AfterUpdate

func (s *SSARiskDisposals) AfterUpdate(tx *gorm.DB) error

func (*SSARiskDisposals) BeforeCreate

func (s *SSARiskDisposals) BeforeCreate()

func (*SSARiskDisposals) BeforeSave

func (s *SSARiskDisposals) BeforeSave()

func (*SSARiskDisposals) BeforeUpdate

func (s *SSARiskDisposals) BeforeUpdate()

func (*SSARiskDisposals) ToGRPCModel

func (s *SSARiskDisposals) ToGRPCModel() *ypb.SSARiskDisposalData

type ScreenRecorder

type ScreenRecorder struct {
	gorm.Model

	// 保存到本地的路径
	Filename  string
	NoteInfo  string
	Project   string
	Hash      string `json:"hash" gorm:"unique_index"`
	VideoName string
	Cover     string `gorm:"type:longtext"`
	Duration  string
}

func (*ScreenRecorder) BeforeSave

func (s *ScreenRecorder) BeforeSave() error

func (*ScreenRecorder) CalcHash

func (s *ScreenRecorder) CalcHash() string

type ScriptOrRule

type ScriptOrRule interface {
	GetScriptName() string
	GetContent() string
	GetType() string
}

type SlicesEx

type SlicesEx[K comparable] []K

func (*SlicesEx[K]) Scan

func (s *SlicesEx[K]) Scan(value interface{}) error

func (*SlicesEx[K]) Value

func (s *SlicesEx[K]) Value() (driver.Value, error)

type Snippets

type Snippets struct {
	gorm.Model
	SnippetId   string `gorm:"uniqueIndex;not null" json:"snippet_id"`
	SnippetName string `gorm:"type:text;not null" json:"snippet_name"`
	SnippetBody string `gorm:"type:text;not null" json:"snippet_data"`
	SnippetDesc string `gorm:"type:text" json:"snippet_desc"`

	SnippetLevel SnippetsLevel `gorm:"type:text;not null" json:"snippet_level"`
	SnippetState SnippetsType  `gorm:"type:text;not null" json:"snippet_state"`
}

func NewSnippets

func NewSnippets(req *ypb.SnippetsRequest) *Snippets

func (Snippets) TableName

func (Snippets) TableName() string

TableName 指定表名

type SnippetsLevel

type SnippetsLevel string
const (
	Snippets_Level_None          SnippetsLevel = "none"
	Snippets_Level_Method        SnippetsLevel = "method"
	Snippets_Level_Function      SnippetsLevel = "function"
	Snippets_Level_Constructor   SnippetsLevel = "constructor"
	Snippets_Level_Field         SnippetsLevel = "field"
	Snippets_Level_Variable      SnippetsLevel = "variable"
	Snippets_Level_Class         SnippetsLevel = "class"
	Snippets_Level_Struct        SnippetsLevel = "struct"
	Snippets_Level_Interface     SnippetsLevel = "interface"
	Snippets_Level_Module        SnippetsLevel = "module"
	Snippets_Level_Property      SnippetsLevel = "property"
	Snippets_Level_Event         SnippetsLevel = "event"
	Snippets_Level_Operator      SnippetsLevel = "operator"
	Snippets_Level_Unit          SnippetsLevel = "unit"
	Snippets_Level_Value         SnippetsLevel = "value"
	Snippets_Level_Constant      SnippetsLevel = "constant"
	Snippets_Level_Enum          SnippetsLevel = "enum"
	Snippets_Level_EnumMember    SnippetsLevel = "enum_member"
	Snippets_Level_Keyword       SnippetsLevel = "keyword"
	Snippets_Level_Text          SnippetsLevel = "text"
	Snippets_Level_Color         SnippetsLevel = "color"
	Snippets_Level_File          SnippetsLevel = "file"
	Snippets_Level_Reference     SnippetsLevel = "reference"
	Snippets_Level_CustomColor   SnippetsLevel = "custom_color"
	Snippets_Level_Folder        SnippetsLevel = "folder"
	Snippets_Level_TypeParameter SnippetsLevel = "type_parameter"
	Snippets_Level_User          SnippetsLevel = "user"
	Snippets_Level_Issue         SnippetsLevel = "issue"
	Snippets_Level_Snippet       SnippetsLevel = "snippet"
)

func SwitcSnippetsLevel

func SwitcSnippetsLevel(in string) SnippetsLevel

type SnippetsType

type SnippetsType string
const (
	Snippets_Type_None SnippetsType = "none"
	Snippets_Type_Http SnippetsType = "http"
	Snippets_Type_Yak  SnippetsType = "yak"
)

func SwitcSnippetsType

func SwitcSnippetsType(in string) SnippetsType

type StringArray

type StringArray []string

StringArray 用于存储字符串数组的自定义类型 实现了 driver.Valuer 和 sql.Scanner 接口,支持数据库存储和读取

func (*StringArray) Scan

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

Scan 实现 sql.Scanner 接口,用于将数据库存储的值转换回 []string

func (StringArray) Value

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

Value 实现 driver.Valuer 接口,用于将 []string 转换为数据库可以存储的值

type SyntaxFlowDescInfo

type SyntaxFlowDescInfo struct {
	// RuleId 关联的规则ID
	RuleId string `json:"rule_id"`

	// Title 告警标题(英文)
	Title string `json:"title"`

	// TitleZh 告警标题(中文)
	TitleZh string `json:"title_zh"`

	// Description 告警详细描述
	// 说明检测到的问题和影响
	Description string `json:"description"`

	// Solution 解决方案
	// 提供修复建议和最佳实践
	Solution string `json:"solution"`

	// Tag 告警标签
	Tag string `json:"tag"`

	// Severity 严重程度
	// 可选值: info(信息)、low(低危)、middle(中危)、high(高危)、critical(严重)
	Severity SyntaxFlowSeverity `json:"severity"`

	// Purpose 告警目的
	// 可选值: audit(审计)、vuln(漏洞)、config(配置)、security(安全)
	Purpose SyntaxFlowRulePurposeType `json:"purpose"`

	// OnlyMsg 是否仅使用自定义消息
	// true: 只使用 Msg 字段的内容
	// false: 使用完整的结构化信息(Title + Description)
	OnlyMsg bool `json:"only_msg"`

	// Msg 自定义消息内容
	// 当 OnlyMsg=true 时,直接使用此消息作为告警内容
	Msg string `json:"msg"`

	// CVE 关联的 CVE 编号
	CVE string `json:"cve"`

	// CWE 关联的 CWE 列表
	CWE StringArray `json:"cwe"`

	// RiskType 风险类型分类
	RiskType string

	// ExtraInfo 额外信息
	// 键值对形式存储其他自定义信息
	ExtraInfo map[string]string `json:"extra_info"`
}

SyntaxFlowDescInfo 规则描述信息 用于描述规则和创建风险告警,支持多变量独立告警配置

func ToSyntaxFlowAlertDesc

func ToSyntaxFlowAlertDesc(message *ypb.AlertMessage) *SyntaxFlowDescInfo

func (*SyntaxFlowDescInfo) ShortMessage

func (info *SyntaxFlowDescInfo) ShortMessage() string

func (*SyntaxFlowDescInfo) String

func (info *SyntaxFlowDescInfo) String() string

func (*SyntaxFlowDescInfo) ToYpbSyntaxFlowRuleDesc

func (s *SyntaxFlowDescInfo) ToYpbSyntaxFlowRuleDesc() *ypb.AlertMessage

type SyntaxFlowGroup

type SyntaxFlowGroup struct {
	gorm.Model
	GroupName string            `json:"group_name" gorm:"unique_index"`
	IsBuildIn bool              `json:"is_build_in" gorm:"index"`
	Rules     []*SyntaxFlowRule `gorm:"many2many:syntax_flow_rule_and_group;"`
}

func (*SyntaxFlowGroup) ToGRPCModel

func (s *SyntaxFlowGroup) ToGRPCModel() *ypb.SyntaxFlowGroup

type SyntaxFlowRule

type SyntaxFlowRule struct {
	gorm.Model

	// RuleId 规则唯一标识符(UUID)
	// 用于全局唯一标识一个规则,支持跨数据库/跨平台同步
	RuleId string `gorm:"unique_index"`

	// Version 规则版本号
	// 用于版本管理和更新检测,格式如 "1.0.0"、"2.1.3" 等
	// 下载规则时会比较本地和在线版本,决定是否需要更新
	Version string

	// Hash 规则内容哈希值
	// 基于 RuleId、RuleName、Content、Tag、OpCodes 计算
	// 用于快速检测规则内容是否变化,确保数据一致性
	Hash string `json:"hash" gorm:"unique_index"`

	// RuleName 规则名称(唯一)
	// 用于标识和查询规则,如 "java-sql-injection"、"runtime-command-exec"
	// 必须唯一,不可重复
	RuleName string `gorm:"unique_index"`

	// Title 规则标题(英文)
	// 简短描述规则用途,如 "SQL Injection Detection"
	Title string

	// TitleZh 规则标题(中文)
	// 中文标题,如 "SQL注入检测"
	TitleZh string

	// Language 规则适用的编程语言
	// 如 "java"、"php"、"javascript" 等
	// 支持的语言列表见 ssaconfig.GetAllSupportedLanguages()
	Language ssaconfig.Language

	// Purpose 规则用途/目的
	// 可选值: audit(审计)、vuln(漏洞)、config(配置)、security(安全)
	Purpose SyntaxFlowRulePurposeType

	// Tag 规则标签
	// 用于分类和筛选,可包含多个标签,如 "injection,security,owasp"
	Tag string

	// CWE 通用弱点枚举列表
	// Common Weakness Enumeration,如 ["CWE-89", "CWE-564"]
	// 用于标准化漏洞分类
	CWE StringArray `gorm:"type:text" json:"cwe"`

	// CVE 通用漏洞编号
	// Common Vulnerabilities and Exposures,如 "CVE-2021-12345"
	CVE string

	// RiskType 风险类型
	// 用于区分不同类型的安全风险
	RiskType string

	// Type 规则类型
	// 可选值: "sf"(SyntaxFlow)、"yak"(Yak 脚本)
	Type SyntaxFlowRuleType

	// Severity 严重程度
	// 可选值: info(信息)、low(低危)、middle(中危)、high(高危)、critical(严重)
	Severity SyntaxFlowSeverity

	// IsBuildInRule 是否为内置规则
	// true: 系统自带规则,通常不可修改
	// false: 用户自定义规则
	IsBuildInRule bool

	// Verified 规则是否已验证
	// true: 规则已经过测试和验证,质量有保证
	// false: 未验证的规则,可能需要进一步测试
	Verified bool

	// NeedUpdate 规则相较于远端是否有改动
	// true: 远端下载到本地后有新的改动(需要进行冲突检测)
	// false: 远端下载到本地后没有改动(可以直接覆盖最新版本)
	NeedUpdate bool

	// Content 规则主体内容(最重要)
	// SyntaxFlow 规则代码或 Yak 脚本代码
	// 这是规则的核心,定义了检测逻辑
	// 示例:
	//   desc(title: "SQL注入")
	//   executeQuery(* as $sql) as $result;
	//   alert $result;
	Content string

	// Description 规则详细描述
	// 说明规则的检测目标、原理等
	// 如 "检测使用字符串拼接构造 SQL 查询的安全风险"
	Description string

	// AlertDesc 告警描述映射
	// 键为变量名(如 "$result"),值为对应的告警信息
	// 用于为不同的检测结果提供不同的告警描述
	AlertDesc MapEx[string, *SyntaxFlowDescInfo] `gorm:"type:text"`

	// Solution 解决方案
	// 提供修复建议,如 "使用预编译语句(PreparedStatement)"
	Solution string

	// AllowIncluded 是否允许被其他规则包含
	// true: 可以作为库规则被其他规则引用
	// false: 独立规则,不能被包含
	AllowIncluded bool

	// IncludedName 包含时使用的名称
	// 当 AllowIncluded=true 时,其他规则通过此名称引用本规则
	IncludedName string

	// OpCodes 操作码(本地使用)
	// 编译后的字节码或中间表示,用于优化执行性能
	OpCodes string

	// Groups 规则所属的分组列表
	// 多对多关系,一个规则可以属于多个分组
	// 通过中间表 syntax_flow_rule_and_group 关联
	Groups []*SyntaxFlowGroup `gorm:"many2many:syntax_flow_rule_and_group;"`
}

SyntaxFlowRule SyntaxFlow 规则定义 用于存储和管理静态代码分析规则,支持多语言代码扫描和漏洞检测

func (*SyntaxFlowRule) BeforeCreate

func (s *SyntaxFlowRule) BeforeCreate() error

func (*SyntaxFlowRule) BeforeSave

func (s *SyntaxFlowRule) BeforeSave() error

func (*SyntaxFlowRule) CalcHash

func (s *SyntaxFlowRule) CalcHash() string

func (*SyntaxFlowRule) GetAlertInfo

func (s *SyntaxFlowRule) GetAlertInfo(name string) (*SyntaxFlowDescInfo, bool)

func (*SyntaxFlowRule) GetContent

func (s *SyntaxFlowRule) GetContent() string

func (*SyntaxFlowRule) GetInfo

func (s *SyntaxFlowRule) GetInfo() *SyntaxFlowDescInfo

func (*SyntaxFlowRule) GetScriptName

func (s *SyntaxFlowRule) GetScriptName() string

func (*SyntaxFlowRule) GetType

func (s *SyntaxFlowRule) GetType() string

func (*SyntaxFlowRule) ToGRPCModel

func (s *SyntaxFlowRule) ToGRPCModel() *ypb.SyntaxFlowRule

type SyntaxFlowRulePurposeType

type SyntaxFlowRulePurposeType string

SyntaxFlowRulePurposeType 规则用途类型 定义规则的使用目的和场景

const (
	// SFR_PURPOSE_AUDIT 审计用途
	// 用于代码质量审计、最佳实践检查
	SFR_PURPOSE_AUDIT SyntaxFlowRulePurposeType = "audit"

	// SFR_PURPOSE_VULN 漏洞检测
	// 用于发现安全漏洞和脆弱点
	SFR_PURPOSE_VULN SyntaxFlowRulePurposeType = "vuln"

	// SFR_PURPOSE_CONFIG 配置检查
	// 用于检测配置错误和安全配置问题
	SFR_PURPOSE_CONFIG SyntaxFlowRulePurposeType = "config"

	// SFR_PURPOSE_SECURITY 安全检查
	// 用于一般性安全问题检测
	SFR_PURPOSE_SECURITY SyntaxFlowRulePurposeType = "security"
)

func ValidPurpose

func ValidPurpose(i any) SyntaxFlowRulePurposeType

type SyntaxFlowRuleType

type SyntaxFlowRuleType string

SyntaxFlowRuleType 规则类型 定义规则的实现方式(SyntaxFlow 或 Yak 脚本)

const (
	// SFR_RULE_TYPE_YAK Yak 脚本类型规则
	// 使用 Yak 脚本语言编写的规则,功能更灵活
	SFR_RULE_TYPE_YAK SyntaxFlowRuleType = "yak"

	// SFR_RULE_TYPE_SF SyntaxFlow 类型规则
	// 使用 SyntaxFlow DSL 编写的规则,专注于数据流分析
	SFR_RULE_TYPE_SF SyntaxFlowRuleType = "sf"
)

func ValidRuleType

func ValidRuleType(i any) SyntaxFlowRuleType

type SyntaxFlowScanTask

type SyntaxFlowScanTask struct {
	gorm.Model
	TaskId   string `gorm:"unique_index"`
	Programs string `gorm:"index"`
	//ProjectName string `gorm:"index"`
	ProjectId uint64 `gorm:"index"`
	// rules
	RulesCount int64

	Status string // executing / done / paused / error
	Reason string // user cancel / finished / recover failed so on

	Kind SyntaxflowResultKind `json:"kind",gorm:"index"` // debug / scan / query

	// 扫描批次
	ScanBatch uint64 `gorm:"index"`
	// query execute
	FailedQuery  int64 // query failed
	SkipQuery    int64 // language not match, skip this rule
	SuccessQuery int64
	// risk
	RiskCount     int64
	InfoCount     int64
	LowCount      int64
	WarningCount  int64
	CriticalCount int64
	HighCount     int64

	// query process
	TotalQuery int64

	// config
	Config []byte `gorm:"type:text"` // new data
}

func GetSyntaxFlowScanTaskById

func GetSyntaxFlowScanTaskById(db *gorm.DB, taskId string) (*SyntaxFlowScanTask, error)

func (*SyntaxFlowScanTask) ToGRPCModel

func (s *SyntaxFlowScanTask) ToGRPCModel() *ypb.SyntaxFlowScanTask

type SyntaxFlowSeverity

type SyntaxFlowSeverity string

SyntaxFlowSeverity 严重程度级别 定义检测到的问题的严重程度

const (
	// SFR_SEVERITY_INFO 信息级别
	// 提示性信息,不影响安全,如代码风格建议
	SFR_SEVERITY_INFO SyntaxFlowSeverity = "info"

	// SFR_SEVERITY_LOW 低危
	// 较小的安全风险,影响有限
	SFR_SEVERITY_LOW SyntaxFlowSeverity = "low"

	// SFR_SEVERITY_WARNING 中危(警告)
	// 中等程度的安全风险,应该修复
	SFR_SEVERITY_WARNING SyntaxFlowSeverity = "middle"

	// SFR_SEVERITY_HIGH 高危
	// 严重的安全风险,需要优先处理
	SFR_SEVERITY_HIGH SyntaxFlowSeverity = "high"

	// SFR_SEVERITY_CRITICAL 严重(危急)
	// 极其严重的安全漏洞,必须立即修复
	SFR_SEVERITY_CRITICAL SyntaxFlowSeverity = "critical"
)

func ValidSeverityType

func ValidSeverityType(i any) SyntaxFlowSeverity

type SyntaxflowResultKind

type SyntaxflowResultKind string
const (
	SFResultKindDebug  SyntaxflowResultKind = "debug"  // 新建插件 调试
	SFResultKindScan   SyntaxflowResultKind = "scan"   // 代码扫描 自动执行
	SFResultKindQuery  SyntaxflowResultKind = "query"  // 代码审计 手动执行
	SFResultKindSearch SyntaxflowResultKind = "search" // 文件名搜索
)

type TrafficPacket

type TrafficPacket struct {
	gorm.Model

	SessionUuid string `gorm:"index"`

	LinkLayerType        string
	NetworkLayerType     string
	TransportLayerType   string
	ApplicationLayerType string
	Payload              string

	// QuotedRaw contains the raw bytes of the packet, quoted such that it can be
	// caution: QuotedRaw is (maybe) not an utf8-valid string
	// quoted-used for save to database
	QuotedRaw string

	EthernetEndpointHardwareAddrSrc string
	EthernetEndpointHardwareAddrDst string
	IsIpv4                          bool
	IsIpv6                          bool
	NetworkEndpointIPSrc            string
	NetworkEndpointIPDst            string
	TransportEndpointPortSrc        int
	TransportEndpointPortDst        int
}

type TrafficSession

type TrafficSession struct {
	gorm.Model

	Uuid string `gorm:"index"`

	// Traffic SessionType Means a TCP Session / ICMP Request-Response / UDP Request-Response
	// DNS Request-Response
	// HTTP Request-Response
	// we can't treat Proto as any transport layer proto or application layer proto
	// because we can't know the proto of a packet before we parse it
	//
	// just use session type as a hint / verbose to group some frames(packets).
	//
	// 1. tcp (reassembled)
	// 2. udp (try figure out request-response)
	// 3. dns
	// 4. http (flow)
	// 5. icmp (request-response)
	// 6. sni (tls client hello)
	SessionType string `gorm:"index"`

	DeviceName string `gorm:"index"`
	DeviceType string

	// LinkLayer physical layer
	IsLinkLayerEthernet bool
	LinkLayerSrc        string
	LinkLayerDst        string

	// NetworkLayer network layer
	IsIpv4          bool
	IsIpv6          bool
	NetworkSrcIP    string
	NetworkSrcIPInt int64
	NetworkDstIP    string
	NetworkDstIPInt int64

	// TransportLayer transport layer
	IsTcpIpStack          bool
	TransportLayerSrcPort int
	TransportLayerDstPort int

	// TCP State Flags
	// PDU Reassembled
	IsTCPReassembled bool
	// TCP SYN Detected? If so, it's a new TCP Session
	// 'half' means we haven't seen a FIN or RST
	IsHalfOpen bool
	// TCP FIN Detected
	IsClosed bool
	// TCP RST Detected
	IsForceClosed bool

	// TLS ClientHello
	HaveClientHello bool
	SNI             string
}

type TrafficTCPReassembledFrame

type TrafficTCPReassembledFrame struct {
	gorm.Model

	SessionUuid string `gorm:"index"`
	QuotedData  string
	Seq         int64
	Timestamp   int64
	Source      string
	Destination string
}

type VectorStoreCollection

type VectorStoreCollection struct {
	gorm.Model

	// 集合名称,在系统中唯一
	Name string `gorm:"unique_index;" json:"name"`

	// 集合描述信息
	Description string `gorm:"type:text" json:"description"`

	// 使用的嵌入模型名称
	ModelName string `gorm:"index" json:"model_name"`

	// 向量维度,所有文档的嵌入向量必须具有相同的维度
	Dimension int `gorm:"not null" json:"dimension"`

	// HNSW 算法参数配置
	M                int     `gorm:"default:16" json:"m"`                        // 最大邻居数,影响图的连接密度
	Ml               float64 `gorm:"default:0.25" json:"ml"`                     // 层生成因子,控制层级分布
	EfSearch         int     `gorm:"default:20" json:"ef_search"`                // 搜索时的候选节点数
	EfConstruct      int     `gorm:"default:200" json:"ef_construct"`            // 构建时的候选节点数
	DistanceFuncType string  `gorm:"default:'cosine'" json:"distance_func_type"` // 距离函数类型(cosine、euclidean等)

	// PQ 算法参数配置
	EnablePQMode bool `gorm:"default:false" json:"enable_pq_mode"`

	Archived bool `gorm:"default:false" json:"archived"`

	UUID  string
	RAGID string `gorm:"index"`

	GraphBinary    []byte `gorm:"type:blob" json:"graph_binary"`
	CodeBookBinary []byte `gorm:"type:blob" json:"code_book_binary"`

	SerialVersionUID string `gorm:"index" json:"serial_version_uid"`
}

VectorStoreCollection 表示向量存储中的集合 用于管理一组具有相同向量维度和配置的文档

func (*VectorStoreCollection) BeforeSave

func (v *VectorStoreCollection) BeforeSave() error

func (*VectorStoreCollection) TableName

func (v *VectorStoreCollection) TableName() string

type VectorStoreDocument

type VectorStoreDocument struct {
	gorm.Model

	// entity / relationship / knowledge
	DocumentType    RAGDocumentType
	EntityID        string `gorm:"index"`
	RelatedEntities string // text split by ","

	DocumentID string `gorm:"uniqueIndex:idx_document_id_collection_id;index;idx_document_id;not null" json:"document_id"`
	UID        []byte `gorm:"blob"`

	// 所属集合的ID,建立外键关系
	CollectionID uint `gorm:"uniqueIndex:idx_document_id_collection_id;not null" json:"collection_id"`

	// 所属集合的 UUID,唯一值
	CollectionUUID string `gorm:"uniqueIndex"`

	// 文档元数据,以 JSON 格式存储,包含原始文本、来源等信息
	Metadata MetadataMap `gorm:"type:text" json:"metadata"`

	// 文档的嵌入向量,以 JSON 格式存储
	PQCode    []byte     `gorm:"type:text" json:"pq_code"`
	Embedding FloatArray `gorm:"type:text" json:"embedding"`

	// 文档的原始文本
	Content string `gorm:"type:text" json:"content"`

	// HNSW 算法中节点存在的最高层级
	MaxLayer int `gorm:"default:0" json:"max_layer"`

	RuntimeID string
}

VectorStoreDocument 表示向量存储中的文档 包含文档的嵌入向量、元数据和 HNSW 图相关信息

func (*VectorStoreDocument) AfterCreate

func (a *VectorStoreDocument) AfterCreate(tx *gorm.DB) (err error)

func (*VectorStoreDocument) AfterDelete

func (a *VectorStoreDocument) AfterDelete(tx *gorm.DB) (err error)

func (*VectorStoreDocument) AfterUpdate

func (a *VectorStoreDocument) AfterUpdate(tx *gorm.DB) (err error)

func (*VectorStoreDocument) BeforeSave

func (v *VectorStoreDocument) BeforeSave() error

func (*VectorStoreDocument) TableName

func (v *VectorStoreDocument) TableName() string

type WebFuzzerConfig

type WebFuzzerConfig struct {
	gorm.Model
	PageId string `gorm:"unique_index"`
	Type   string `gorm:"string"`
	Config string `gorm:"string"`
}

type WebFuzzerLabel

type WebFuzzerLabel struct {
	gorm.Model
	Label string `json:"label"`
	// 模版数据唯一标识,用来兼容做对比
	DefaultDescription string `json:"default_description"`
	Description        string `json:"description"`
	Hash               string `gorm:"unique_index"`
}

func (*WebFuzzerLabel) CalcHash

func (w *WebFuzzerLabel) CalcHash() string

type WebFuzzerResponse

type WebFuzzerResponse struct {
	gorm.Model

	WebFuzzerTaskId int    `json:"web_fuzzer_task_id" gorm:"index"`
	OK              bool   `json:"ok"`
	Request         string `json:"request"`
	Content         string `json:"content"`
	Payload         string `json:"payload"`
	Url             string `json:"url"`
	StatusCode      int    `json:"status_code"`
	DurationMs      int    `json:"duration_ms"`
	Timestamp       int64  `json:"timestamp"`
	HiddenIndex     string `json:"hidden_index" gorm:"index"`
}

func (*WebFuzzerResponse) CalcCacheHash

func (w *WebFuzzerResponse) CalcCacheHash() string

func (*WebFuzzerResponse) ToGRPCModel

func (w *WebFuzzerResponse) ToGRPCModel() (*ypb.FuzzerResponse, error)

type WebFuzzerTask

type WebFuzzerTask struct {
	gorm.Model

	// 原始请求 json+quote
	RawFuzzTaskRequest string `json:"raw_fuzz_task_request"`

	// 对应前端的组织形式
	FuzzerIndex    string `json:"fuzzer_index"`
	FuzzerTabIndex string `json:"fuzzer_tab_index"`

	// HTTP 数据流总量
	HTTPFlowTotal        int    `json:"http_flow_total"`
	HTTPFlowSuccessCount int    `json:"http_flow_success_count"`
	HTTPFlowFailedCount  int    `json:"http_flow_failed_count"`
	Ok                   bool   `json:"ok"`
	Reason               string `json:"reason"` // if not ok
	Host                 string `json:"host"`
	Port                 int    `json:"port"`
	// retry 相关
	RetryRootID uint `json:"retry_root_id"`
}

这个结构用于保存当前测试的结果

包含:基本参数+请求数据

耗时+执行结果

执行结果包含,失败原因与执行成功的原因。

总共有多少个请求

func (*WebFuzzerTask) CalcCacheHash

func (w *WebFuzzerTask) CalcCacheHash() string

func (*WebFuzzerTask) ToGRPCModel

func (w *WebFuzzerTask) ToGRPCModel() *ypb.HistoryHTTPFuzzerTask

func (*WebFuzzerTask) ToGRPCModelDetail

func (w *WebFuzzerTask) ToGRPCModelDetail() *ypb.HistoryHTTPFuzzerTaskDetail

type WebShell

type WebShell struct {
	gorm.Model
	Url string `json:"url" gorm:"index" `
	// pass=payload
	Pass string `json:"pass"`
	// 加密密钥
	SecretKey string `json:"secret_key" gorm:"not null"`
	// 加密模式
	EncryptedMode string `json:"enc_mode" gorm:"column:enc_mode"`
	// 字符集编码
	Charset string `json:"charset" gorm:"default:'UTF-8'"`
	// 冰蝎还是哥斯拉,或者是其他
	ShellType string `json:"shell_type"`
	// 脚本语言
	ShellScript      string `json:"shell_script"`
	Headers          string `json:"headers" gorm:"type:json"`
	Posts            string `json:"posts" gorm:"type:json"`
	Status           bool   `json:"status"`
	Tag              string `json:"tag"`
	Proxy            string `json:"proxy"`
	Remark           string `json:"remark"`
	Hash             string `json:"hash"`
	PacketCodecName  string `json:"packet_codec_name"`
	PayloadCodecName string `json:"payload_codec_name"`
	Os               string `json:"os"`         //操作系统
	Timeout          int64  `json:"timeout"`    //超时时间
	Retry            int64  `json:"retry"`      //重连次数
	BlockSize        int64  `json:"block_size"` //分块大小
	MaxSize          int64  `json:"max_size"`   //上传的最大数量
	IsSession        bool   `json:"is_session"` //是否是session类型
}

func (*WebShell) BeforeSave

func (w *WebShell) BeforeSave() error

func (*WebShell) CalcHash

func (w *WebShell) CalcHash() string

func (*WebShell) ToGRPCModel

func (w *WebShell) ToGRPCModel() *ypb.WebShell

type WebsocketFlow

type WebsocketFlow struct {
	gorm.Model

	// WebsocketFlow 过来的应该有 WebsocketHash
	WebsocketRequestHash string `json:"websocket_request_hash" gorm:"index"`

	FrameIndex  int    `json:"frame_index" gorm:"index"`
	FromServer  bool   `json:"from_server"`
	QuotedData  string `json:"quoted_data"`
	MessageType string `json:"message_type"`
	Tags        string `json:"tags"`

	Hash string `json:"hash"`
}

func (*WebsocketFlow) AddTag

func (f *WebsocketFlow) AddTag(appendTags ...string)

颜色与 Tag API

func (*WebsocketFlow) AddTagToFirst

func (f *WebsocketFlow) AddTagToFirst(appendTags ...string)

func (*WebsocketFlow) BeforeSave

func (f *WebsocketFlow) BeforeSave() error

func (*WebsocketFlow) Blue

func (f *WebsocketFlow) Blue()

func (*WebsocketFlow) CalcHash

func (f *WebsocketFlow) CalcHash() string

func (*WebsocketFlow) Cyan

func (f *WebsocketFlow) Cyan()

func (*WebsocketFlow) Green

func (f *WebsocketFlow) Green()

func (*WebsocketFlow) Grey

func (f *WebsocketFlow) Grey()

func (*WebsocketFlow) HasColor

func (f *WebsocketFlow) HasColor(color string) bool

func (*WebsocketFlow) Orange

func (f *WebsocketFlow) Orange()

func (*WebsocketFlow) Purple

func (f *WebsocketFlow) Purple()

func (*WebsocketFlow) Red

func (f *WebsocketFlow) Red()

func (*WebsocketFlow) ToGRPCModel

func (i *WebsocketFlow) ToGRPCModel() *ypb.WebsocketFlow

func (*WebsocketFlow) Yellow

func (f *WebsocketFlow) Yellow()

type YakScript

type YakScript struct {
	gorm.Model

	ScriptName string `json:"script_name" gorm:"unique_index"`
	Type       string `json:"type" gorm:"index"`
	Content    string `json:"content"`
	Level      string `json:"level"`
	Params     string `json:"params"`
	Help       string `json:"help"`
	Author     string `json:"author"`
	Tags       string `json:"tags,omitempty"`
	Ignored    bool   `json:"ignore"`

	// 加载本地的数据
	FromLocal bool   `json:"from_local"`
	LocalPath string `json:"local_path"`

	// History string
	IsHistory bool `json:"is_history"`

	// Force Interactive
	// Means that this script will be executed in interactive mode
	// cannot load as a plugin or a module by mix caller
	ForceInteractive bool `json:"force_interactive"`

	FromStore bool `json:"from_store"`

	IsGeneralModule      bool   `json:"is_general_module"`
	GeneralModuleVerbose string `json:"general_module_verbose"`
	GeneralModuleKey     string `json:"general_module_key"`
	FromGit              string `json:"from_git"`

	// 这个是自动填写的,一般不需要自己来填写
	// 条件是 Params 中有一个名字为 target 的必填参数
	IsBatchScript bool `json:"is_batch_script"`
	IsExternal    bool `json:"is_external"`

	EnablePluginSelector bool   `json:"enable_plugin_selector"`
	PluginSelectorTypes  string `json:"plugin_selector_types"`

	// Online ID: 线上插件的 ID
	OnlineId           int64  `json:"online_id"`
	OnlineScriptName   string `json:"online_script_name"`
	OnlineContributors string `json:"online_contributors"`
	OnlineIsPrivate    bool   `json:"online_is_private"`

	// 这个插件所属用户 ID
	UserId int64 `json:"user_id"`
	// 这个插件的 UUID
	Uuid           string `json:"uuid"`
	HeadImg        string `json:"head_img"`
	OnlineBaseUrl  string `json:"online_base_url"`
	BaseOnlineId   int64  `json:"BaseOnlineId"`
	OnlineOfficial bool   `json:"online_official"`
	OnlineGroup    string `json:"online_group"`

	IsCorePlugin bool `json:"is_core_plugin"` // 判断是否是核心插件
	// 废弃字段
	RiskType string `json:"risk_type"`
	// 漏洞详情 建议,描述,cwe
	RiskDetail string `json:"risk_detail"`
	// 漏洞类型-补充说明 废弃
	RiskAnnotation string `json:"risk_annotation"`
	// 协作者
	CollaboratorInfo string `json:"collaborator_info"`

	PluginEnvKey string `json:"plugin_env_key"`

	SkipUpdate bool `json:"skip_update"`
	// contains filtered or unexported fields
}

func (*YakScript) AfterCreate

func (s *YakScript) AfterCreate(tx *gorm.DB) (err error)

func (*YakScript) AfterDelete

func (s *YakScript) AfterDelete(tx *gorm.DB) (err error)

func (*YakScript) AfterUpdate

func (s *YakScript) AfterUpdate(tx *gorm.DB) (err error)

func (*YakScript) BeforeSave

func (s *YakScript) BeforeSave() error

func (*YakScript) GetContent

func (s *YakScript) GetContent() string

func (*YakScript) GetParams

func (s *YakScript) GetParams() []*ypb.YakScriptParam

func (*YakScript) GetScriptName

func (s *YakScript) GetScriptName() string

func (*YakScript) GetType

func (s *YakScript) GetType() string

func (*YakScript) ToGRPCModel

func (s *YakScript) ToGRPCModel() *ypb.YakScript

Jump to

Keyboard shortcuts

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