sfweb

package
v1.4.4-alpha1202-diff-... 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: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//go:embed templates/**
	TemplateFS embed.FS

	LangToTemplateMap     = make(map[string][]string)
	TemplateToFilenameMap = make(map[string]string)
	TemplateContentCache  = utils.NewTTLCache[string](5 * time.Minute)
)
View Source
var (
	SfWebLogger      = log.GetLogger("sfweb")
	CHAT_GLM_API_KEY = "CHATGLM_API_KEY"
)

Functions

func CodeBlock

func CodeBlock(lang string, content string) string

func Details

func Details(summary, details string) string

func GetAllSupportedLanguages

func GetAllSupportedLanguages() []ssaconfig.Language

func NewInvalidLangError

func NewInvalidLangError(lang string) error

func NewInvalidTemplateError

func NewInvalidTemplateError(template string) error

func NewReadFileError

func NewReadFileError() error

func NewSyntaxFlowWebServer

func NewSyntaxFlowWebServer(ctx context.Context, opts ...ServerOpt) (string, error)

func ReadWebsocketJSON

func ReadWebsocketJSON(c *websocket.Conn, data any) error

func WriteWebsocketJSON

func WriteWebsocketJSON(c *websocket.Conn, data any) error

Types

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
}

type InvalidLangError

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

func (*InvalidLangError) Error

func (e *InvalidLangError) Error() string

type InvalidSchemeError

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

func NewInvalidSchemeError

func NewInvalidSchemeError(scheme string) *InvalidSchemeError

func (*InvalidSchemeError) Error

func (e *InvalidSchemeError) Error() string

type InvalidTemplateError

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

func (*InvalidTemplateError) Error

func (e *InvalidTemplateError) Error() string

type LogHTTPResponseWriter

type LogHTTPResponseWriter struct {
	http.ResponseWriter
	http.Hijacker

	StatusCode int
	// contains filtered or unexported fields
}

func NewLogHTTPResponseWriter

func NewLogHTTPResponseWriter(w http.ResponseWriter) *LogHTTPResponseWriter

func (*LogHTTPResponseWriter) Raw

func (w *LogHTTPResponseWriter) Raw() []byte

func (*LogHTTPResponseWriter) Write

func (w *LogHTTPResponseWriter) Write(b []byte) (int, error)

func (*LogHTTPResponseWriter) WriteHeader

func (w *LogHTTPResponseWriter) WriteHeader(statusCode int)

type Method

type Method string
const (
	Delete Method = "DELETE"
	Get    Method = "GET"
	Head   Method = "HEAD"
	Post   Method = "POST"
	Put    Method = "PUT"
)

type Query

type Query struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type RateLimitedWebSocketWriter

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

func NewRateLimitedWebSocketWriter

func NewRateLimitedWebSocketWriter(conn *websocket.Conn, rateLimiter *WebSocketRateLimiter) *RateLimitedWebSocketWriter

func (*RateLimitedWebSocketWriter) TryWriteJSON

func (w *RateLimitedWebSocketWriter) TryWriteJSON(data interface{}) error

func (*RateLimitedWebSocketWriter) WriteJSON

func (w *RateLimitedWebSocketWriter) WriteJSON(data interface{}) error

type ReadFileError

type ReadFileError struct{}

func (*ReadFileError) Error

func (e *ReadFileError) Error() string

type ReportFalseNegativeRequest

type ReportFalseNegativeRequest struct {
	// 扫描文件内容
	Content string `json:"content,omitempty"`
	// 语言
	Lang string `json:"lang,omitempty"`
	// 规则名
	RuleName string `json:"rule_name,omitempty"`
}

type ReportFalseNegativeTemplateData

type ReportFalseNegativeTemplateData struct {
	RuleName string
	Content  string
	Lang     string
}

type ReportFalsePositiveRequest

type ReportFalsePositiveRequest struct {
	// 扫描文件内容
	Content string `json:"content,omitempty"`
	// 语言
	Lang string `json:"lang,omitempty"`
	// 风险hash
	RiskHash string `json:"risk_hash,omitempty"`
}

type ReportFalsePositiveTemplateData

type ReportFalsePositiveTemplateData struct {
	Rule    *schema.SyntaxFlowRule
	Risk    *schema.SSARisk
	Content string
	Lang    string
}

type ReportMissingParameterError

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

func NewReportMissingParameterError

func NewReportMissingParameterError(param string) *ReportMissingParameterError

func (*ReportMissingParameterError) Error

type ReportResponse

type ReportResponse struct {
	Link string `json:"link"`
	Body string `json:"body,omitempty"`
}

type ServerConfig

type ServerConfig struct {
	Host               string
	ChatGLMAPIKey      string
	Port               int
	Debug              bool
	Https              bool
	ServerCrtPath      string
	ServerKeyPath      string
	WebSocketRateLimit time.Duration
}

func NewServerConfig

func NewServerConfig() *ServerConfig

type ServerOpt

type ServerOpt func(*ServerConfig)

func WithChatGLMAPIKey

func WithChatGLMAPIKey(apiKey string) ServerOpt

func WithDebug

func WithDebug(debug bool) ServerOpt

func WithHost

func WithHost(host string) ServerOpt

func WithHttps

func WithHttps(https bool) ServerOpt

func WithPort

func WithPort(port int) ServerOpt

func WithServerCrtPath

func WithServerCrtPath(p string) ServerOpt

func WithServerKeyPath

func WithServerKeyPath(p string) ServerOpt

type StatusCodeResponseWriter

type StatusCodeResponseWriter struct {
	http.ResponseWriter
	http.Hijacker
	StatusCode int
}

func NewStatusCodeResponseWriter

func NewStatusCodeResponseWriter(w http.ResponseWriter) *StatusCodeResponseWriter

func (*StatusCodeResponseWriter) WriteHeader

func (w *StatusCodeResponseWriter) WriteHeader(statusCode int)

type SyntaxFlowAIAnalysisRequest

type SyntaxFlowAIAnalysisRequest struct {
	Lang     string `json:"lang"`
	VarName  string `json:"var_name"`
	ResultID int64  `json:"result_id"`
}

type SyntaxFlowAIAnalysisResponse

type SyntaxFlowAIAnalysisResponse struct {
	Message string `json:"message"`
	Error   string `json:"error"`
}

type SyntaxFlowAIAnalysisWriter

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

func NewSyntaxFlowAIAnalysisWriter

func NewSyntaxFlowAIAnalysisWriter(conn *websocket.Conn) *SyntaxFlowAIAnalysisWriter

func (*SyntaxFlowAIAnalysisWriter) Write

func (w *SyntaxFlowAIAnalysisWriter) Write(p []byte) (n int, err error)

type SyntaxFlowScanRequest

type SyntaxFlowScanRequest struct {
	Content        string `json:"content"`
	Lang           string `json:"lang"`
	ControlMessage string `json:"control_message"`
	TimeoutSecond  int    `json:"timeout_second"`
}

type SyntaxFlowScanResponse

type SyntaxFlowScanResponse struct {
	Error    string                `json:"error,omitempty"`
	Message  string                `json:"message,omitempty"`
	Risk     []*SyntaxFlowScanRisk `json:"risk,omitempty"`
	Progress float64               `json:"progress,omitempty"`
}

type SyntaxFlowScanRisk

type SyntaxFlowScanRisk struct {
	RuleName    string `json:"rule_name"`
	Severity    string `json:"severity"`
	Title       string `json:"title"`
	Type        string `json:"type"`
	VarName     string `json:"var_name"`
	ProgramName string `json:"program_name"`
	RiskHash    string `json:"risk_hash"`
	ResultID    uint64 `json:"result_id"`
	Timestamp   int64  `json:"timestamp"`
}

type SyntaxFlowWebServer

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

type TemplateContentResponse

type TemplateContentResponse struct {
	Content string `json:"content"`
}

type TemplateLangResponse

type TemplateLangResponse struct {
	// 支持的语言
	Language []ssaconfig.Language `json:"language"`
}

type TemplateListResponse

type TemplateListResponse struct {
	// 模板
	Template []string `json:"template"`
}

type WebSocketRateLimiter

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

func NewWebSocketRateLimiter

func NewWebSocketRateLimiter(interval time.Duration) *WebSocketRateLimiter

func (*WebSocketRateLimiter) DirectSend

func (r *WebSocketRateLimiter) DirectSend(conn *websocket.Conn, data interface{}) error

func (*WebSocketRateLimiter) TrySend

func (r *WebSocketRateLimiter) TrySend(conn *websocket.Conn, data interface{}) error

type YakURL

type YakURL struct {
	FromRaw  string   `json:"from_raw,omitempty"`
	Location string   `json:"location"`
	Pass     string   `json:"pass,omitempty"`
	Path     string   `json:"path"`
	Query    []*Query `json:"query,omitempty"`
	Schema   string   `json:"schema"`
	User     string   `json:"user,omitempty"`
}

type YakURLKVPair

type YakURLKVPair struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type YakURLRequest

type YakURLRequest struct {
	Body     string  `json:"body"`
	Method   Method  `json:"method"`
	Page     int64   `json:"page,omitempty"`
	Pagesize int64   `json:"pagesize,omitempty"`
	URL      *YakURL `json:"url"`
}

type YakURLResource

type YakURLResource struct {
	Extra             []*YakURLKVPair `json:"extra"`
	HaveChildrenNodes bool            `json:"have_children_nodes"`
	ModifiedTimestamp int64           `json:"modified_timestamp"`
	Path              string          `json:"path"`
	ResourceName      string          `json:"resource_name"`
	ResourceType      string          `json:"resource_type"`
	Size              int64           `json:"size"`
	URL               *YakURL         `json:"url"`
	VerboseName       string          `json:"verbose_name"`
	VerboseSize       string          `json:"verbose_size"`
	VerboseType       string          `json:"verbose_type"`
	YakURLVerbose     string          `json:"yak_url_verbose"`
}

type YakURLResponse

type YakURLResponse struct {
	Page      int64             `json:"page"`
	PageSize  int64             `json:"page_size"`
	Resources []*YakURLResource `json:"resources"`
	Total     int64             `json:"total"`
}

Directories

Path Synopsis
templates

Jump to

Keyboard shortcuts

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