crowdsecurity / cs-openresty-bouncer

CrowdSec bouncer for OpenResty
MIT License
11 stars 5 forks source link

logs spammed with errors regarding the use of variable ('err') #15

Closed LePresidente closed 2 years ago

LePresidente commented 2 years ago

Every request causes the following log line

writing a global Lua variable ('err') which may lead to race conditions between concurrent requests, so prefer the use of 'local' variables and a stacktrace


2022/02/18 02:00:18 [warn] 2181#2181: *3719 [lua] _G write guard:12: __newindex(): writing a global Lua variable ('err') which may lead to race conditions between concurrent requests, so prefer the use of 'local' variables
stack traceback:
        /var/lib/nginx/lualib/plugins/crowdsec/access.lua:1: in main chunk while sending to client, client: 172.17.0.1, server: emby.example.xyz, request: "GET /emby/users/c751cfdf26194bdda74277dccfbb8716/items?Recursive=True&IncludeItemTypes=Episode&Fields=ProviderIds&startIndex=6000&limit=100&IsVirtualItem=False HTTP/1.1", host: "emby.example.xyz"
2022/02/18 02:00:19 [warn] 2181#2181: *3719 [lua] _G write guard:12: __newindex(): writing a global Lua variable ('err') which may lead to race conditions between concurrent requests, so prefer the use of 'local' variables
stack traceback:
        /var/lib/nginx/lualib/plugins/crowdsec/access.lua:1: in main chunk while sending to client, client: 172.17.0.1, server: emby.example.xyz, request: "GET /emby/users/c751cfdf26194bdda74277dccfbb8716/items?Recursive=True&IncludeItemTypes=Episode&Fields=ProviderIds&startIndex=6100&limit=100&IsVirtualItem=False HTTP/1.1", host: "emby.example.xyz"
2022/02/18 02:00:19 [warn] 2181#2181: *3719 [lua] _G write guard:12: __newindex(): writing a global Lua variable ('err') which may lead to race conditions between concurrent requests, so prefer the use of 'local' variables
stack traceback:
        /var/lib/nginx/lualib/plugins/crowdsec/access.lua:1: in main chunk while sending to client, client: 172.17.0.1, server: emby.example.xyz, request: "GET /emby/users/c751cfdf26194bdda74277dccfbb8716/items?Recursive=True&IncludeItemTypes=Episode&Fields=ProviderIds&startIndex=6200&limit=100&IsVirtualItem=False HTTP/1.1", host: "emby.example.xyz"
2022/02/18 08:27:55 [alert] 2048#2048: *151 [lua] access.lua:6: [Crowdsec] denied '10.0.0.10' while sending to client, client: 10.0.0.10, server: emby.example.xyz, request: "GET /web/index.html HTTP/2.0", host: "emby.example.xyz"
2022/02/18 08:27:55 [warn] 2048#2048: *151 [lua] _G write guard:12: __newindex(): writing a global Lua variable ('err') which may lead to race conditions between concurrent requests, so prefer the use of 'local' variables
stack traceback:
        /var/lib/nginx/lualib/plugins/crowdsec/access.lua:1: in main chunk while sending to client, client: 10.0.0.10, server: emby.example.xyz, request: "GET /favicon.ico HTTP/2.0", host: "emby.example.xyz", referrer: "https://emby.example.xyz/web/index.html"
2022/02/18 08:27:55 [alert] 2048#2048: *151 [lua] access.lua:6: [Crowdsec] denied '10.0.0.10' while sending to client, client: 10.0.0.10, server: emby.example.xyz, request: "GET /favicon.ico HTTP/2.0", host: "emby.example.xyz", referrer: "https://emby.example.xyz/web/index.html"
2022/02/18 08:27:57 [warn] 2048#2048: *151 [lua] _G write guard:12: __newindex(): writing a global Lua variable ('err') which may lead to race conditions between concurrent requests, so prefer the use of 'local' variables
stack traceback:
        /var/lib/nginx/lualib/plugins/crowdsec/access.lua:1: in main chunk while sending to client, client: 10.0.0.10, server: emby.example.xyz, request: "GET /web/serviceworker.js HTTP/2.0", host: "emby.example.xyz", referrer: "https://emby.example.xyz/web/serviceworker.js"
2022/02/18 08:27:57 [alert] 2048#2048: *151 [lua] access.lua:6: [Crowdsec] denied '10.0.0.10' while sending to client, client: 10.0.0.10, server: emby.example.xyz, request: "GET /web/serviceworker.js HTTP/2.0", host: "emby.example.xyz", referrer: "https://emby.example.xyz/web/serviceworker.js"
2022/02/18 08:30:00 [warn] 2048#2048: *243 [lua] _G write guard:12: __newindex(): writing a global Lua variable ('err') which may lead to race conditions between concurrent requests, so prefer the use of 'local' variables
stack traceback:
        /var/lib/nginx/lualib/plugins/crowdsec/access.lua:1: in main chunk while sending to client, client: 172.17.0.1, server: emby.example.xyz, request: "GET /emby/users/c751cfdf26194bdda74277dccfbb8716/items?Recursive=True&IncludeItemTypes=Movie&Fields=ProviderIds%2CMediaStreams%2COverview&startIndex=0&limit=50&sortBy=DateCreated&SortOrder=Descending&IsVirtualItem=False HTTP/1.1", host: "emby.example.xyz"
 ''`
LePresidente commented 2 years ago

I see this is fixed in 0.1.1, is it safe to use?

baudneo commented 2 years ago

You can fix this in current versionl by using sed-patch 's|ok, err = require "crowdsec".allowIp(ngx.var.remote_addr)|local ok, err = require "crowdsec".allowIp(ngx.var.remote_addr)|' /PATH/TO/nginx/lualib/plugins/crowdsec/access.lua