(actionConfig *CaptchaAction, policyId int64, groupId int64, setId int64, originURL string, req requests.Request, writer http.ResponseWriter, useLocalFirewall bool)
| 714 | } |
| 715 | |
| 716 | func (this *CaptchaValidator) validateSlideForm(actionConfig *CaptchaAction, policyId int64, groupId int64, setId int64, originURL string, req requests.Request, writer http.ResponseWriter, useLocalFirewall bool) (allow bool) { |
| 717 | var captchaId = req.WAFRaw().FormValue(captchaIdName) |
| 718 | var nonce = req.WAFRaw().FormValue("nonce") |
| 719 | if len(captchaId) > 0 { |
| 720 | var key = "WAF_CAPTCHA:" + captchaId |
| 721 | var cacheItem = ttlcache.SharedInt64Cache.Read(key) |
| 722 | ttlcache.SharedInt64Cache.Delete(key) |
| 723 | if cacheItem != nil { |
| 724 | // 清除计数 |
| 725 | CaptchaDeleteCacheKey(req) |
| 726 | |
| 727 | if cacheItem.Value == types.Int64(nonce) { |
| 728 | var life = CaptchaSeconds |
| 729 | if actionConfig.Life > 0 { |
| 730 | life = types.Int(actionConfig.Life) |
| 731 | } |
| 732 | |
| 733 | // 加入到白名单 |
| 734 | SharedIPWhiteList.RecordIP(wafutils.ComposeIPType(setId, req), actionConfig.Scope, req.WAFServerId(), req.WAFRemoteIP(), time.Now().Unix()+int64(life), policyId, false, groupId, setId, "") |
| 735 | |
| 736 | req.ProcessResponseHeaders(writer.Header(), http.StatusSeeOther) |
| 737 | |
| 738 | // 记录到Cookie |
| 739 | this.setCookie(writer, setId, life) |
| 740 | |
| 741 | http.Redirect(writer, req.WAFRaw(), originURL, http.StatusSeeOther) |
| 742 | |
| 743 | return false |
| 744 | } |
| 745 | } else { |
| 746 | // 增加计数 |
| 747 | if !CaptchaIncreaseFails(req, actionConfig, policyId, groupId, setId, CaptchaPageCodeSubmit, useLocalFirewall) { |
| 748 | return false |
| 749 | } |
| 750 | |
| 751 | req.ProcessResponseHeaders(writer.Header(), http.StatusSeeOther) |
| 752 | http.Redirect(writer, req.WAFRaw(), req.WAFRaw().URL.String(), http.StatusSeeOther) |
| 753 | } |
| 754 | } |
| 755 | |
| 756 | return true |
| 757 | } |
| 758 | |
| 759 | func (this *CaptchaValidator) validateGeeTestForm(actionConfig *CaptchaAction, policyId int64, groupId int64, setId int64, originURL string, req requests.Request, writer http.ResponseWriter, useLocalFirewall bool) (allow bool) { |
| 760 | var geeTestConfig = actionConfig.GeeTestConfig |
no test coverage detected