allow to only set APPSEC_URL (#65)
This commit is contained in:
parent
cce2ea3946
commit
654bc2ce39
2 changed files with 22 additions and 0 deletions
|
@ -118,6 +118,14 @@ function csmod.init(configFile, userAgent)
|
|||
end
|
||||
end
|
||||
|
||||
if runtime.conf["API_URL"] == "" and runtime.conf["APPSEC_URL"] == "" then
|
||||
ngx.log(ngx.ERR, "Neither API_URL or APPSEC_URL are defined, remediation component will not do anything")
|
||||
end
|
||||
|
||||
if runtime.conf["API_URL"] == "" and runtime.conf["APPSEC_URL"] ~= "" then
|
||||
ngx.log(ngx.ERR, "Only APPSEC_URL is defined, local API decisions will be ignored")
|
||||
end
|
||||
|
||||
|
||||
|
||||
return true, nil
|
||||
|
@ -228,6 +236,9 @@ local function stream_query(premature)
|
|||
-- As this function is running inside coroutine (with ngx.timer.at),
|
||||
-- we need to raise error instead of returning them
|
||||
|
||||
if runtime.conf["API_URL"] == "" then
|
||||
return
|
||||
end
|
||||
|
||||
ngx.log(ngx.DEBUG, "running timers: " .. tostring(ngx.timer.running_count()) .. " | pending timers: " .. tostring(ngx.timer.pending_count()))
|
||||
|
||||
|
@ -360,6 +371,9 @@ local function stream_query(premature)
|
|||
end
|
||||
|
||||
local function live_query(ip)
|
||||
if runtime.conf["API_URL"] == "" then
|
||||
return true, nil, nil
|
||||
end
|
||||
local link = runtime.conf["API_URL"] .. "/v1/decisions?ip=" .. ip
|
||||
local res, err = get_remediation_http_request(link)
|
||||
if not res then
|
||||
|
@ -439,6 +453,9 @@ end
|
|||
|
||||
function csmod.SetupStream()
|
||||
-- if it stream mode and startup start timer
|
||||
if runtime.conf["API_URL"] == "" then
|
||||
return
|
||||
end
|
||||
ngx.log(ngx.DEBUG, "timer started: " .. tostring(runtime.timer_started) .. " in worker " .. tostring(ngx.worker.id()))
|
||||
if runtime.timer_started == false and runtime.conf["MODE"] == "stream" then
|
||||
local ok, err
|
||||
|
@ -456,6 +473,10 @@ function csmod.allowIp(ip)
|
|||
return true, nil, "Configuration is bad, cannot run properly"
|
||||
end
|
||||
|
||||
if runtime.conf["API_URL"] == "" then
|
||||
return true, nil, nil
|
||||
end
|
||||
|
||||
csmod.SetupStream()
|
||||
|
||||
local key = item_to_string(ip, "ip")
|
||||
|
|
|
@ -45,6 +45,7 @@ function config.loadConfig(file)
|
|||
local valid_truefalse_values = {'false', 'true'}
|
||||
local default_values = {
|
||||
['ENABLED'] = "true",
|
||||
['API_URL'] = "",
|
||||
['REQUEST_TIMEOUT'] = 500,
|
||||
['STREAM_REQUEST_TIMEOUT'] = 15000,
|
||||
['BOUNCING_ON_TYPE'] = "ban",
|
||||
|
|
Loading…
Add table
Reference in a new issue