(req requests.Request, rawResp *http.Response, writer http.ResponseWriter)
| 311 | } |
| 312 | |
| 313 | func (this *WAF) MatchResponse(req requests.Request, rawResp *http.Response, writer http.ResponseWriter) (result MatchResult, err error) { |
| 314 | if !this.hasOutboundRules { |
| 315 | return MatchResult{ |
| 316 | GoNext: true, |
| 317 | }, nil |
| 318 | } |
| 319 | var hasRequestBody bool |
| 320 | var resp = requests.NewResponse(rawResp) |
| 321 | for _, group := range this.Outbound { |
| 322 | if !group.IsOn { |
| 323 | continue |
| 324 | } |
| 325 | b, hasCheckedRequestBody, set, matchErr := group.MatchResponse(req, resp) |
| 326 | if hasCheckedRequestBody { |
| 327 | hasRequestBody = true |
| 328 | } |
| 329 | if matchErr != nil { |
| 330 | return MatchResult{ |
| 331 | GoNext: true, |
| 332 | HasRequestBody: hasRequestBody, |
| 333 | }, matchErr |
| 334 | } |
| 335 | if b { |
| 336 | var performResult = set.PerformActions(this, group, req, writer) |
| 337 | if !performResult.GoNextSet { |
| 338 | if performResult.GoNextGroup { |
| 339 | continue |
| 340 | } |
| 341 | return MatchResult{ |
| 342 | GoNext: performResult.ContinueRequest, |
| 343 | HasRequestBody: hasRequestBody, |
| 344 | Group: group, |
| 345 | Set: set, |
| 346 | IsAllowed: performResult.IsAllowed, |
| 347 | AllowScope: performResult.AllowScope, |
| 348 | }, nil |
| 349 | } |
| 350 | } |
| 351 | } |
| 352 | return MatchResult{ |
| 353 | GoNext: true, |
| 354 | HasRequestBody: hasRequestBody, |
| 355 | }, nil |
| 356 | } |
| 357 | |
| 358 | // Save to file path |
| 359 | func (this *WAF) Save(path string) error { |
no test coverage detected