mirror of
https://github.com/openappsec/attachment.git
synced 2026-01-02 14:44:42 +03:00
proper fini session
This commit is contained in:
@@ -204,6 +204,13 @@ function NanoHandler.body_filter(conf)
|
|||||||
ctx.body_filter_timeout = true
|
ctx.body_filter_timeout = true
|
||||||
ctx.failed_nano_send = true
|
ctx.failed_nano_send = true
|
||||||
kong.log.warn("body_filter timeout exceeded (2.5 minutes), failing open")
|
kong.log.warn("body_filter timeout exceeded (2.5 minutes), failing open")
|
||||||
|
|
||||||
|
-- Finalize session on timeout
|
||||||
|
if not ctx.session_finalized then
|
||||||
|
nano.fini_session(session_data)
|
||||||
|
nano.cleanup_all()
|
||||||
|
ctx.session_finalized = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -274,22 +281,19 @@ function NanoHandler.body_filter(conf)
|
|||||||
local modifications = result[3]
|
local modifications = result[3]
|
||||||
|
|
||||||
if modifications then
|
if modifications then
|
||||||
chunk = nano.handle_body_modifications(chunk, modifications, ctx.body_buffer_chunk - 1)
|
chunk = nano.handle_body_modifications(chunk, modifications, ctx.body_buffer_chunk)
|
||||||
|
ngx.arg[1] = chunk
|
||||||
end
|
end
|
||||||
|
|
||||||
if verdict == nano.AttachmentVerdict.DROP then
|
if verdict == nano.AttachmentVerdict.DROP then
|
||||||
nano.fini_session(session_data)
|
nano.fini_session(session_data)
|
||||||
ctx.session_finalized = true
|
ctx.session_finalized = true
|
||||||
ngx.arg[1] = nil
|
|
||||||
ngx.arg[2] = true
|
|
||||||
local custom_result = nano.handle_custom_response(session_data, response)
|
local custom_result = nano.handle_custom_response(session_data, response)
|
||||||
nano.cleanup_all()
|
nano.cleanup_all()
|
||||||
return custom_result
|
return custom_result
|
||||||
end
|
end
|
||||||
|
|
||||||
ngx.arg[1] = chunk
|
|
||||||
else
|
else
|
||||||
kong.log.warn("nano.send_body failed for chunk #", ctx.body_buffer_chunk + 1, ": ", result)
|
kong.log.warn("nano.send_body failed: ", result)
|
||||||
ctx.body_buffer_chunk = ctx.body_buffer_chunk + 1
|
ctx.body_buffer_chunk = ctx.body_buffer_chunk + 1
|
||||||
ctx.failed_nano_send = true
|
ctx.failed_nano_send = true
|
||||||
end
|
end
|
||||||
@@ -317,12 +321,12 @@ function NanoHandler.body_filter(conf)
|
|||||||
else
|
else
|
||||||
kong.log.warn("nano.end_inspection failed: ", result)
|
kong.log.warn("nano.end_inspection failed: ", result)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
nano.fini_session(session_data)
|
nano.fini_session(session_data)
|
||||||
nano.cleanup_all()
|
nano.cleanup_all()
|
||||||
ctx.session_finalized = true
|
ctx.session_finalized = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return NanoHandler
|
return NanoHandler
|
||||||
Reference in New Issue
Block a user