bw - fix is_whitelisted function and fix typo in country core

This commit is contained in:
florian 2023-12-30 17:57:32 +01:00
parent a4f72f1c1e
commit af8fa60e28
No known key found for this signature in database
GPG key ID: 93EE47CC3D061500
6 changed files with 75 additions and 6 deletions

View file

@ -321,7 +321,7 @@ end
utils.is_whitelisted = function(ctx)
-- ngx.ctx
if ctx and ctx.bw and ctx.bw.is_whitelisted then
return ctx.bw.is_whitelisted
return ctx.bw.is_whitelisted == "yes"
end
-- ngx.var
if var.is_whitelisted and var.is_whitelisted == "yes" then

View file

@ -6,9 +6,10 @@ local utils = require "bunkerweb.utils"
local country = class("country", plugin)
local ngx = ngx
local get_country = utils.get_country
local get_deny_status = utils.get_deny_status
local decode = cjson.decode
local get_country = cjson.get_country
local encode = cjson.encode
function country:initialize(ctx)
-- Call parent initialize
@ -130,7 +131,7 @@ end
function country:add_to_cache(ip, country_data, result)
local ok, err = self.cachestore:set(
"plugin_country_" .. self.ctx.bw.server_name .. ip,
encode { country = country_data, result = result },
encode({ country = country_data, result = result }),
86400
)
if not ok then

View file

@ -76,6 +76,60 @@
"label": "Redis keepalive pool",
"regex": "^[0-9]+$",
"type": "text"
},
"REDIS_USERNAME": {
"context": "global",
"default": "",
"help": "Redis username used in AUTH command.",
"id": "redis-username",
"label": "Redis username",
"regex": "^.*$",
"type": "text"
},
"REDIS_PASSWORD": {
"context": "global",
"default": "",
"help": "Redis password used in AUTH command.",
"id": "redis-password",
"label": "Redis password",
"regex": "^.*$",
"type": "password"
},
"REDIS_SENTINEL_HOSTS": {
"context": "global",
"default": "",
"help": "Redis sentinel hosts with format host:[port] separated with spaces.",
"id": "redis-sentinel-hosts",
"label": "Redis sentinel hosts",
"regex": "^.*$",
"type": "text"
},
"REDIS_SENTINEL_USERNAME": {
"context": "global",
"default": "",
"help": "Redis sentinel username.",
"id": "redis-sentinel-username",
"label": "Redis sentinel username",
"regex": "^.*$",
"type": "text"
},
"REDIS_SENTINEL_PASSWORD": {
"context": "global",
"default": "",
"help": "Redis sentinel password.",
"id": "redis-sentinel-password",
"label": "Redis sentinel password",
"regex": "^.*$",
"type": "password"
},
"REDIS_SENTINEL_MASTER": {
"context": "global",
"default": "",
"help": "Redis sentinel master name.",
"id": "redis-sentinel-master",
"label": "Redis sentinel master",
"regex": "^.*$",
"type": "text"
}
}
}

View file

@ -234,6 +234,12 @@
"name": "zlib v1.3",
"url": "https://github.com/madler/zlib.git",
"commit": "09155eaa2f9270dc4ed1fa13e2b4b2613e6e4851"
},
{
"id": "lua-resty-redis-connector",
"name": "lua-resty-redis-connector v0.11.0",
"url": "https://github.com/ledgetech/lua-resty-redis-connector.git",
"commit": "02a29f93253d1f6ad392c5ac2b643c57e62b5979"
}
]
}

View file

@ -43,22 +43,24 @@ do
url="$(echo "$repo" | jq -r .url)"
commit="$(echo "$repo" | jq -r .commit)"
post_install="$(echo "$repo" | jq -r .post_install)"
post="no"
echo " Clone ${name} from $url at commit/version $commit"
if [ ! -d "src/deps/src/$id" ] ; then
do_and_check_cmd git subtree add --prefix "src/deps/src/$id" "$url" "$commit" --squash
post="yes"
else
echo "⚠️ Skipping clone of $url because target directory is already present"
echo " Updating ${name} from $url at commit/version $commit"
do_and_check_cmd git subtree pull --prefix "src/deps/src/$id" "$url" "$commit" --squash
# echo " Updating ${name} from $url at commit/version $commit"
# do_and_check_cmd git subtree pull --prefix "src/deps/src/$id" "$url" "$commit" --squash
fi
if [ -d "src/deps/src/$id/.git" ] ; then
do_and_check_cmd rm -rf "src/deps/src/$id/.git"
fi
if [ "$post_install" != "null" ] ; then
if [ "$post_install" != "null" ] && [ "$post" != "no" ]; then
echo " Running post install script for ${name}"
bash -c "$post_install"
fi

View file

@ -183,6 +183,12 @@ export CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-signal"
do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps -j "$NTASK"
do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps LUA_LIB_DIR=/usr/share/bunkerweb/deps/lib/lua install
# Installing lua-resty-redis-connector
echo " Installing lua-resty-redis-connector"
export CHANGE_DIR="/tmp/bunkerweb/deps/src/lua-resty-redis-connector"
do_and_check_cmd make PREFIX=/usr/share/bunkerweb/deps LUA_LIB_DIR=/usr/share/bunkerweb/deps/lib/lua install
# Patch modsec module
export CHANGE_DIR="/tmp/bunkerweb/deps/misc"
do_and_check_cmd bash -c "mv ngx_http_modsecurity_access.c /tmp/bunkerweb/deps/src/modsecurity-nginx/src/"