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

Method MatchResponse

internal/waf/rule.go:290–383  ·  view source on GitHub ↗
(req requests.Request, resp *requests.Response)

Source from the content-addressed store, hash-verified

288}
289
290func (this *Rule) MatchResponse(req requests.Request, resp *requests.Response) (b bool, hasRequestBody bool, err error) {
291 if this.singleCheckpoint != nil {
292 // if is request param
293 if this.singleCheckpoint.IsRequest() {
294 value, hasCheckRequestBody, err, _ := this.singleCheckpoint.RequestValue(req, this.singleParam, this.CheckpointOptions, this.Id)
295 if hasCheckRequestBody {
296 hasRequestBody = true
297 }
298 if err != nil {
299 return false, hasRequestBody, err
300 }
301
302 // execute filters
303 if len(this.ParamFilters) > 0 {
304 value = this.execFilter(value)
305 }
306
307 return this.Test(value), hasRequestBody, nil
308 }
309
310 // response param
311 value, hasCheckRequestBody, err, _ := this.singleCheckpoint.ResponseValue(req, resp, this.singleParam, this.CheckpointOptions, this.Id)
312 if hasCheckRequestBody {
313 hasRequestBody = true
314 }
315 if err != nil {
316 return false, hasRequestBody, err
317 }
318
319 // if is composed checkpoint, we just returns true or false
320 if this.singleCheckpoint.IsComposed() {
321 return types.Bool(value), hasRequestBody, nil
322 }
323
324 return this.Test(value), hasRequestBody, nil
325 }
326
327 var value = configutils.ParseVariables(this.Param, func(varName string) (value string) {
328 var pieces = strings.SplitN(varName, ".", 2)
329 var prefix = pieces[0]
330 point, ok := this.multipleCheckpoints[prefix]
331 if !ok {
332 return ""
333 }
334
335 if len(pieces) == 1 {
336 if point.IsRequest() {
337 value1, hasCheckRequestBody, err1, _ := point.RequestValue(req, "", this.CheckpointOptions, this.Id)
338 if hasCheckRequestBody {
339 hasRequestBody = true
340 }
341 if err1 != nil {
342 err = err1
343 }
344 return this.stringifyValue(value1)
345 } else {
346 value1, hasCheckRequestBody, err1, _ := point.ResponseValue(req, resp, "", this.CheckpointOptions, this.Id)
347 if hasCheckRequestBody {

Callers

nothing calls this directly

Calls 7

execFilterMethod · 0.95
TestMethod · 0.95
stringifyValueMethod · 0.95
IsRequestMethod · 0.65
RequestValueMethod · 0.65
ResponseValueMethod · 0.65
IsComposedMethod · 0.65

Tested by

no test coverage detected