MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / MatchRequest

Method MatchRequest

internal/waf/waf.go:250–311  ·  view source on GitHub ↗
(req requests.Request, writer http.ResponseWriter, defaultCaptchaType firewallconfigs.ServerCaptchaType)

Source from the content-addressed store, hash-verified

248}
249
250func (this *WAF) MatchRequest(req requests.Request, writer http.ResponseWriter, defaultCaptchaType firewallconfigs.ServerCaptchaType) (result MatchResult, err error) {
251 if !this.hasInboundRules {
252 return MatchResult{
253 GoNext: true,
254 }, nil
255 }
256
257 // validate captcha
258 var rawPath = req.WAFRaw().URL.Path
259 if rawPath == CaptchaPath {
260 req.DisableAccessLog()
261 req.DisableStat()
262 captchaValidator.Run(req, writer, defaultCaptchaType)
263 return
264 }
265
266 // Get 302验证
267 if rawPath == Get302Path {
268 req.DisableAccessLog()
269 req.DisableStat()
270 get302Validator.Run(req, writer)
271 return
272 }
273
274 // match rules
275 var hasRequestBody bool
276 for _, group := range this.Inbound {
277 if !group.IsOn {
278 continue
279 }
280 b, hasCheckedRequestBody, set, matchErr := group.MatchRequest(req)
281 if hasCheckedRequestBody {
282 hasRequestBody = true
283 }
284 if matchErr != nil {
285 return MatchResult{
286 GoNext: true,
287 HasRequestBody: hasRequestBody,
288 }, matchErr
289 }
290 if b {
291 var performResult = set.PerformActions(this, group, req, writer)
292 if !performResult.GoNextSet {
293 if performResult.GoNextGroup {
294 continue
295 }
296 return MatchResult{
297 GoNext: performResult.ContinueRequest,
298 HasRequestBody: hasRequestBody,
299 Group: group,
300 Set: set,
301 IsAllowed: performResult.IsAllowed,
302 AllowScope: performResult.AllowScope,
303 }, nil
304 }
305 }
306 }
307 return MatchResult{

Callers 15

configureWebMethod · 0.45
doAuthMethod · 0.45
doHostRedirectMethod · 0.45
doCacheReadMethod · 0.45
checkWAFRequestMethod · 0.45
PerformMethod · 0.45
PerformMethod · 0.45
TestRuleSet_MatchRequestFunction · 0.45

Calls 5

PerformActionsMethod · 0.80
WAFRawMethod · 0.65
DisableAccessLogMethod · 0.65
DisableStatMethod · 0.65
RunMethod · 0.45

Tested by 15

TestRuleSet_MatchRequestFunction · 0.36
Test_Template2Function · 0.36
BenchmarkTemplateFunction · 0.36
testTemplate1010Function · 0.36
testTemplate2001Function · 0.36
testTemplate3001Function · 0.36
testTemplate4001Function · 0.36
testTemplate5001Function · 0.36