crowdsec appsec - access User-Agent header within hooks

Hello! We use hooks to evaluate requests and add exceptions, currently the documentation is rather slim on this area. Is the any way to access "User-Agent" header for evaluation? Example how we use it to check a request uri (appsec config)
- filter: IsInBand == true && Match("/example/*", req.RequestURI) || Match("//wp/api/test/*", req.RequestURI)
apply:
- RemoveInBandRuleByID(400000)
- filter: IsInBand == true && Match("/example/*", req.RequestURI) || Match("//wp/api/test/*", req.RequestURI)
apply:
- RemoveInBandRuleByID(400000)
3 Replies
CrowdSec
CrowdSec6mo ago
Important Information
This post has been marked as resolved. If this is a mistake please press the red button below or type /unresolve
© Created By WhyAydan for CrowdSec ❤️
vedtoto
vedtotoOP6mo ago
I was able to dig it out from the source code, if anyone else is interested this is a working solution. - filter: IsInBand == true && req.Header.Get("User-Agent") == "test"
CrowdSec
CrowdSec6mo ago
Resolving crowdsec appsec - access User-Agent header within hooks This has now been resolved. If you think this is a mistake please run /unresolve

Did you find this page helpful?