mirror of
https://github.com/openappsec/attachment.git
synced 2025-12-31 13:49:09 +03:00
returning to last working version ...
This commit is contained in:
@@ -247,12 +247,6 @@ function NanoHandler.body_filter(conf)
|
|||||||
collectgarbage("step", 100)
|
collectgarbage("step", 100)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check if session is already finalized (like Envoy/nginx do)
|
|
||||||
if nano.is_session_finalized(ctx.session_data) then
|
|
||||||
kong.log.debug("Skipping already inspected session")
|
|
||||||
return -- Let remaining data pass through
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Initialize timeout tracking on first chunk
|
-- Initialize timeout tracking on first chunk
|
||||||
if not ctx.body_filter_start_time then
|
if not ctx.body_filter_start_time then
|
||||||
@@ -319,29 +313,26 @@ function NanoHandler.body_filter(conf)
|
|||||||
|
|
||||||
-- Process EOF
|
-- Process EOF
|
||||||
if eof then
|
if eof then
|
||||||
-- Only send end_inspection if session not already finalized
|
local ok, result = pcall(function()
|
||||||
if not nano.is_session_finalized(ctx.session_data) then
|
return {nano.end_inspection(ctx.session_id, ctx.session_data, nano.HttpChunkType.HTTP_RESPONSE_END)}
|
||||||
local ok, result = pcall(function()
|
end)
|
||||||
return {nano.end_inspection(ctx.session_id, ctx.session_data, nano.HttpChunkType.HTTP_RESPONSE_END)}
|
|
||||||
end)
|
|
||||||
|
|
||||||
if ok then
|
if ok then
|
||||||
local verdict = result[1]
|
local verdict = result[1]
|
||||||
local response = result[2]
|
local response = result[2]
|
||||||
|
|
||||||
if verdict == nano.AttachmentVerdict.DROP then
|
if verdict == nano.AttachmentVerdict.DROP then
|
||||||
ctx.blocked = true
|
ctx.blocked = true
|
||||||
ctx.inspection_complete = true
|
ctx.inspection_complete = true
|
||||||
local result = nano.handle_custom_response(ctx.session_data, response)
|
local result = nano.handle_custom_response(ctx.session_data, response)
|
||||||
nano.fini_session(ctx.session_data)
|
nano.fini_session(ctx.session_data)
|
||||||
collectgarbage("collect")
|
collectgarbage("collect")
|
||||||
ctx.session_id = nil
|
ctx.session_id = nil
|
||||||
ctx.session_data = nil
|
ctx.session_data = nil
|
||||||
return result
|
return result
|
||||||
end
|
|
||||||
else
|
|
||||||
kong.log.err("nano.end_inspection failed: ", tostring(result), " - cleaning up session")
|
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
kong.log.err("nano.end_inspection failed: ", tostring(result), " - cleaning up session")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Clean up session at EOF
|
-- Clean up session at EOF
|
||||||
|
|||||||
Reference in New Issue
Block a user