diff --git a/object/site.go b/object/site.go
index 9ee9e33..4362001 100644
--- a/object/site.go
+++ b/object/site.go
@@ -43,23 +43,24 @@ type Site struct {
UpdatedTime string `xorm:"varchar(100)" json:"updatedTime"`
DisplayName string `xorm:"varchar(100)" json:"displayName"`
- Tag string `xorm:"varchar(100)" json:"tag"`
- Domain string `xorm:"varchar(100)" json:"domain"`
- OtherDomains []string `xorm:"varchar(500)" json:"otherDomains"`
- NeedRedirect bool `json:"needRedirect"`
- EnableWaf bool `json:"enableWaf"`
- Rules []string `xorm:"varchar(500)" json:"wafRuleIds"`
- Challenges []string `xorm:"mediumtext" json:"challenges"`
- Host string `xorm:"varchar(100)" json:"host"`
- Port int `json:"port"`
- Hosts []string `xorm:"varchar(1000)" json:"hosts"`
- SslMode string `xorm:"varchar(100)" json:"sslMode"`
- SslCert string `xorm:"-" json:"sslCert"`
- PublicIp string `xorm:"varchar(100)" json:"publicIp"`
- Node string `xorm:"varchar(100)" json:"node"`
- IsSelf bool `json:"isSelf"`
- Status string `xorm:"varchar(100)" json:"status"`
- Nodes []*Node `xorm:"mediumtext" json:"nodes"`
+ Tag string `xorm:"varchar(100)" json:"tag"`
+ Domain string `xorm:"varchar(100)" json:"domain"`
+ OtherDomains []string `xorm:"varchar(500)" json:"otherDomains"`
+ NeedRedirect bool `json:"needRedirect"`
+ EnableWaf bool `json:"enableWaf"`
+ DisableVerbose bool `json:"disableVerbose"`
+ Rules []string `xorm:"varchar(500)" json:"wafRuleIds"`
+ Challenges []string `xorm:"mediumtext" json:"challenges"`
+ Host string `xorm:"varchar(100)" json:"host"`
+ Port int `json:"port"`
+ Hosts []string `xorm:"varchar(1000)" json:"hosts"`
+ SslMode string `xorm:"varchar(100)" json:"sslMode"`
+ SslCert string `xorm:"-" json:"sslCert"`
+ PublicIp string `xorm:"varchar(100)" json:"publicIp"`
+ Node string `xorm:"varchar(100)" json:"node"`
+ IsSelf bool `json:"isSelf"`
+ Status string `xorm:"varchar(100)" json:"status"`
+ Nodes []*Node `xorm:"mediumtext" json:"nodes"`
CasdoorApplication string `xorm:"varchar(100)" json:"casdoorApplication"`
ApplicationObj *casdoorsdk.Application `xorm:"-" json:"applicationObj"`
diff --git a/rule/rule.go b/rule/rule.go
index 0d53990..cb764a0 100644
--- a/rule/rule.go
+++ b/rule/rule.go
@@ -25,9 +25,9 @@ type Rule interface {
checkRule(expressions []*object.Expression, req *http.Request) (bool, string, string, error)
}
-func CheckRules(wafRuleIds []string, r *http.Request) (string, string, error) {
- rules := object.GetRulesByRuleIds(wafRuleIds)
- for _, rule := range rules {
+func CheckRules(ruleIds []string, r *http.Request) (string, string, error) {
+ rules := object.GetRulesByRuleIds(ruleIds)
+ for i, rule := range rules {
var ruleObj Rule
switch rule.Type {
case "User-Agent":
@@ -51,6 +51,8 @@ func CheckRules(wafRuleIds []string, r *http.Request) (string, string, error) {
if action == "Block" || action == "Drop" {
if rule.Reason != "" {
reason = rule.Reason
+ } else {
+ reason = fmt.Sprintf("hit rule %s: %s", ruleIds[i], reason)
}
return action, reason, nil
} else if action == "Allow" {
diff --git a/service/proxy.go b/service/proxy.go
index 5fe2a5d..33ceb3b 100644
--- a/service/proxy.go
+++ b/service/proxy.go
@@ -201,6 +201,10 @@ func handleRequest(w http.ResponseWriter, r *http.Request) {
return
}
+ if site.DisableVerbose {
+ reason = "illegal request"
+ }
+
switch action {
case "", "Allow":
w.WriteHeader(http.StatusOK)
diff --git a/web/src/SiteEditPage.js b/web/src/SiteEditPage.js
index d36222d..d9c90fa 100644
--- a/web/src/SiteEditPage.js
+++ b/web/src/SiteEditPage.js
@@ -179,6 +179,16 @@ class SiteEditPage extends React.Component {
}} />
+
+
+ {i18next.t("site:Disable Verbose")}:
+
+
+ {
+ this.updateSiteField("disableVerbose", checked);
+ }} />
+
+
{i18next.t("site:Challenges")}: