threat

package
v0.0.1-beta Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package threat ----------------------------- @author : EndlessShw @time : 2025/9/15 22:02 @Description : Threat 中涉及的常量 -------------------------------------------

Package threat ----------------------------- @author : EndlessShw @time : 2025/9/28 0:01 @Description : threat 包下的错误提示 -------------------------------------------

Package threat ----------------------------- @author : EndlessShw @time : 2025/9/15 16:20 @Description : 获取 threat 规则文件 -------------------------------------------

Package threat ----------------------------- @author : EndlessShw @time : 2025/9/13 18:09 @Description : 威胁类型类 -------------------------------------------

Package threat ----------------------------- @author : EndlessShw @time : 2025/9/15 22:13 @Description : 工具类 -------------------------------------------

Package threat ----------------------------- @author : EndlessShw @time : 2025/9/17 15:22 @Description : 存放 Threat 相关的变量 -------------------------------------------

Package threat ----------------------------- @author : EndlessShw @time : 2025/9/17 11:08 @Description : todo 验证 threat 远程下载的库是否有问题 -------------------------------------------

Index

Constants

View Source
const (
	CachePath    = "/MyWaf/"
	ThreatPath   = CachePath + "threat/"
	MyWafRes     = "myWaf-resources"
	TmpDirSuffix = "." + MyWafRes + "-%s"
)

point Go 中常量是驼峰命名法,不是全大写

Variables

View Source
var (
	// todo 以后待更新
	DbFilename = "myWaf.tar.zst"
	DbURL      = "" + "/todo/" + DbFilename
)

Functions

func Get

func Get() error

Get 本地或远程获取 threat 规则文件 Get 本地是从 tmp 目录下复制过来;远程是从仓库中获取 todo “是否使用用户指定的规则文件” 的逻辑交给上层处理

func IsUpdated

func IsUpdated() (bool, error)

IsUpdated 检测当前威胁库是否是最新的

Types

type Threat

type Threat int8
const (
	// Undefined 是未定义的攻击类型
	Undefined Threat = iota - 1

	// Custom 表示使用者自定义的类型
	Custom

	// CommonWebAttack 代表常见的 Web 攻击类型
	CommonWebAttack

	// CVE 是常见的 Web CVE
	CVE

	// BadIPAddress 请求 IP 为一些恶意 IP
	// TODO 恶意 IP 的判断可以去接一些情报威胁平台的 API 来辅助判断
	BadIPAddress

	// BadReferrer 和 BadIPAddress 相似,有时请求的 Referrer 是恶意域名,这种的也可以直接排除
	BadReferrer

	// BadCrawler 指的是 UA 头为一些爬虫的特征
	BadCrawler

	// DirectoryBruteforce 表示敏感文件目录读取
	DirectoryBruteforce

	// MaliciousCommand 表示恶意的命令执行
	MaliciousCommand
)

func List

func List() []Threat

List 返回除了 Custom 和 Undefined 的 Threat 数组

func (Threat) Count

func (t Threat) Count() (int, error)

Count 返回指定威胁的数据库的条目数

func (Threat) Filename

func (t Threat) Filename(isFullname bool) (string, error)

Filename 返回文件名或者完整的文件路径

func (Threat) ToString

func (t Threat) ToString() string

ToString 将 Threat 转换成字符串

Jump to

Keyboard shortcuts

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