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

Method MatchRequest

internal/waf/rule_set.go:225–278  ·  view source on GitHub ↗
(req requests.Request)

Source from the content-addressed store, hash-verified

223}
224
225func (this *RuleSet) MatchRequest(req requests.Request) (b bool, hasRequestBody bool, err error) {
226 // 是否忽略局域网IP
227 if this.IgnoreLocal && utils.IsLocalIP(req.WAFRemoteIP()) {
228 return false, hasRequestBody, nil
229 }
230
231 if !this.hasRules {
232 return false, hasRequestBody, nil
233 }
234 switch this.Connector {
235 case RuleConnectorAnd:
236 for _, rule := range this.Rules {
237 b1, hasCheckRequestBody, err1 := rule.MatchRequest(req)
238 if hasCheckRequestBody {
239 hasRequestBody = true
240 }
241 if err1 != nil {
242 return false, hasRequestBody, err1
243 }
244 if !b1 {
245 return false, hasRequestBody, nil
246 }
247 }
248 return true, hasRequestBody, nil
249 case RuleConnectorOr:
250 for _, rule := range this.Rules {
251 b1, hasCheckRequestBody, err1 := rule.MatchRequest(req)
252 if hasCheckRequestBody {
253 hasRequestBody = true
254 }
255 if err1 != nil {
256 return false, hasRequestBody, err1
257 }
258 if b1 {
259 return true, hasRequestBody, nil
260 }
261 }
262 default: // same as And
263 for _, rule := range this.Rules {
264 b1, hasCheckRequestBody, err1 := rule.MatchRequest(req)
265 if hasCheckRequestBody {
266 hasRequestBody = true
267 }
268 if err1 != nil {
269 return false, hasRequestBody, err1
270 }
271 if !b1 {
272 return false, hasRequestBody, nil
273 }
274 }
275 return true, hasRequestBody, nil
276 }
277 return
278}
279
280func (this *RuleSet) MatchResponse(req requests.Request, resp *requests.Response) (b bool, hasRequestBody bool, err error) {
281 if !this.hasRules {

Callers

nothing calls this directly

Calls 2

IsLocalIPFunction · 0.92
WAFRemoteIPMethod · 0.65

Tested by

no test coverage detected