safty

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Tools = make(map[string]SaftyTool)

Tools 存储所有注册的安全检查器 key: 检查器名称 value: 检查器实例

Functions

func CheckContent

func CheckContent(content interface{}) (types.CheckResult, error)

CheckContent 使用指定的检查器检查内容 参数:

  • content: 要检查的内容,可以是任意类型

返回值:

  • bool: 内容是否安全
  • CheckResult: 检查结果,包括是否安全、风险级别、原因和详细信息
  • error: 检查过程中发生的错误

func CheckContentByToolName

func CheckContentByToolName(toolName string, content interface{}) (types.CheckResult, error)

CheckContentByToolName 使用指定的检查器检查内容 参数:

  • toolName: 要使用的检查器名称
  • content: 要检查的内容,可以是任意类型

返回值:

  • bool: 内容是否安全
  • CheckResult: 检查结果,包括是否安全、风险级别、原因和详细信息
  • error: 检查过程中发生的错误

func GetAllSafeToolsName

func GetAllSafeToolsName() []string

GetAllSafeToolsName 获取所有可用的安全检查器的名称

func InitSaftyTools

func InitSaftyTools() error

InitSaftyTools 初始化所有安全检查器 在系统启动时调用此函数来注册所有可用的安全检查器

func RegisterTool

func RegisterTool(name string, tool SaftyTool)

RegisterTool 注册一个新的安全检查器 参数:

  • name: 检查器名称
  • tool: 检查器实例

Types

type SaftyTool

type SaftyTool interface {
	// Name 返回检查器的名称
	Name() string
	// Init 初始化检查器
	// 返回值:
	//   - error: 初始化过程中发生的错误
	Init() error
	// Check 执行内容安全检查
	// 参数:
	//   - data: 要检查的内容
	// 返回值:
	//   - bool: 内容是否安全
	//   - types.CheckResult: 检查结果
	//   - error: 检查过程中发生的错误
	Check(data string) (types.CheckResult, error)
}

SaftyTool 定义了内容安全检查器的接口 所有具体的安全检查器都需要实现这个接口

Directories

Path Synopsis
providers

Jump to

Keyboard shortcuts

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