Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:WAF 拦截日志支持导出 #7076

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions agent/i18n/i18n.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ func GetMsgByKey(key string) string {
return content
}

func Get(key string) string {
content, _ := global.I18n.Localize(&i18n.LocalizeConfig{
MessageID: key,
})
if content != "" {
return content
}
return key
}

func GetWithName(key string, name string) string {
var (
dataMap = make(map[string]interface{})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

该代码段的主要问题在于两个地方:

  1. 函数Get没有接受参数。
    在函数GetWithoutParam中,你传递了一个键(key),但未定义任何函数体。

  2. 函数Name和内容被混在同一个变量名里了;
    这些应该是不同类型的字符串(例如:一个名字和一段文字)。

因此,为了改进这段代码,我给出了以下建议:

  1. 使GetWithKeyName这个更简单地接收名为key的整数值并返回相应的文本作为答案。
  2. 删除GetWithName中的数据映射块,并将name与text分开存储为不同的变量以避免混淆。
  3. 如果需要,可以使用Go语言内置类型实现getWithKey或命名变量来更好地区分不同类型的数据。

Expand Down
37 changes: 37 additions & 0 deletions agent/i18n/lang/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,43 @@ ErrGroupInUse: "The IP group is used by the black/white list and cannot be delet
ErrGroupExist: "IP group name already exists"
ErrIPRange: "Wrong IP range"
ErrIPExist: "IP is exit"
urlDefense: 'URL Rules'
urlHelper: 'Forbidden Access URLs'
dirFilter: 'Directory Filtering'
xss: 'XSS'
phpExec: 'PHP Script Execution'
oneWordTrojan: 'One-Liner Trojan'
appFilter: 'Application Dangerous Directory Filtering'
webshell: 'Webshell'
args: 'Parameter Rules'
protocolFilter: 'Protocol Filtering'
javaFileter: 'Java Dangerous File Filtering'
scannerFilter: 'Scanner Filtering'
escapeFilter: 'Escape Filtering'
customRule: 'Custom Rules'
httpMethod: 'HTTP Method Filtering'
fileExt: 'File Upload Restrictions'
defaultIpBlack: 'Malicious IP Group'
cookie: 'Cookie Rules'
urlBlack: 'URL Blacklist'
uaBlack: 'User-Agent Blacklist'
attackCount: 'Attack Frequency Limit'
fileExtCheck: 'File Upload Restrictions'
geoRestrict: 'Geographical Access Restrictions'
unknownWebsite: 'Unauthorized Domain Access'
notFoundLimit: '404 Frequency Limit'
headerDefense: 'Header Rules'
defaultUaBlack: 'User-Agent Rules'
methodWhite: 'HTTP Rules'
captcha: 'Captcha'
fiveSeconds: '5 Seconds Verification'
vulnCheck: 'Supplementary Rules'
acl: 'Custom Rules'
sql: 'SQL Injection'
cc: 'Access Frequency Limit'
defaultUrlBlack: 'URL Rules'
sqlInject: 'SQL Injection'


#license
ErrLicense: "License format error, please check and try again!"
Expand Down
36 changes: 36 additions & 0 deletions agent/i18n/lang/zh-Hant.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,42 @@ ErrGroupInUse: "IP 群組被黑/白名單使用,無法刪除"
ErrGroupExist: "IP 群組名稱已存在"
ErrIPRange: "IP 範圍錯誤"
ErrIPExist: "IP 已存在"
urlDefense: 'URL 規則'
urlHelper: '禁止訪問的 URL'
dirFilter: '目錄過濾'
xss: 'XSS'
phpExec: 'PHP 腳本執行'
oneWordTrojan: '一句話木馬'
appFilter: '應用危險目錄過濾'
webshell: 'Webshell'
args: '參數規則'
protocolFilter: '協議過濾'
javaFileter: 'Java 危險檔案過濾'
scannerFilter: '掃描器過濾'
escapeFilter: '轉義過濾'
customRule: '自定義規則'
httpMethod: 'HTTP 方法過濾'
fileExt: '檔案上傳限制'
defaultIpBlack: '惡意 IP 組'
cookie: 'Cookie 規則'
urlBlack: 'URL 黑名單'
uaBlack: 'User-Agent 黑名單'
attackCount: '攻擊頻率限制'
fileExtCheck: '檔案上傳限制'
geoRestrict: '地區訪問限制'
unknownWebsite: '未授權域名訪問'
notFoundLimit: '404 頻率限制'
headerDefense: 'Header 規則'
defaultUaBlack: 'User-Agent 規則'
methodWhite: 'HTTP 規則'
captcha: '人機驗證'
fiveSeconds: '5 秒驗證'
vulnCheck: '補充規則'
acl: '自定義規則'
sql: 'SQL 注入'
cc: '訪問頻率限制'
defaultUrlBlack: 'URL 規則'
sqlInject: 'SQL 注入'


#license
Expand Down
37 changes: 37 additions & 0 deletions agent/i18n/lang/zh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,43 @@ ErrGroupInUse: "IP 组被黑/白名单使用,无法删除"
ErrGroupExist: "IP 组名称已存在"
ErrIPRange: "IP 范围错误"
ErrIPExist: "IP 已存在"
urlDefense: 'URL 规则'
urlHelper: '禁止访问的 URL'
dirFilter: '目录过滤'
xss: 'XSS'
phpExec: 'PHP 脚本执行'
oneWordTrojan: '一句话木马'
appFilter: '应用危险目录过滤'
webshell: 'Webshell'
args: '参数规则'
protocolFilter: '协议过滤'
javaFileter: 'Java 危险文件过滤'
scannerFilter: '扫描器过滤'
escapeFilter: '转义过滤'
customRule: '自定义规则'
httpMethod: 'HTTP 方法过滤'
fileExt: '文件上传限制'
defaultIpBlack: '恶意 IP 组'
cookie: 'Cookie 规则'
urlBlack: 'URL 黑名单'
uaBlack: 'User-Agent 黑名单'
attackCount: '攻击频率限制'
fileExtCheck: '文件上传限制'
geoRestrict: '地区访问限制'
unknownWebsite: '未授权域名访问'
notFoundLimit: '404 频率限制'
headerDefense: 'Header 规则'
defaultUaBlack: 'User-Agent 规则'
methodWhite: 'HTTP 规则'
captcha: '人机验证'
fiveSeconds: '5 秒验证'
vulnCheck: '补充规则'
acl: '自定义规则'
sql: 'SQL 注入'
cc: '访问频率限制'
defaultUrlBlack: 'URL 规则'
sqlInject: 'SQL 注入'


#license
ErrLicense: "许可证格式错误,请检查后重试!"
Expand Down
Loading