mirror of
https://github.com/openappsec/attachment.git
synced 2026-01-02 06:34:42 +03:00
fix wrong close statement
This commit is contained in:
@@ -93,6 +93,7 @@ function NanoHandler.access(conf)
|
|||||||
local result = nano.handle_custom_response(session_data, response)
|
local result = nano.handle_custom_response(session_data, response)
|
||||||
nano.cleanup_all()
|
nano.cleanup_all()
|
||||||
return result
|
return result
|
||||||
|
end
|
||||||
else
|
else
|
||||||
kong.log.err("Request body not in memory, attempting to read from buffer/file")
|
kong.log.err("Request body not in memory, attempting to read from buffer/file")
|
||||||
|
|
||||||
@@ -104,6 +105,7 @@ function NanoHandler.access(conf)
|
|||||||
nano.fini_session(session_data)
|
nano.fini_session(session_data)
|
||||||
kong.ctx.plugin.blocked = true
|
kong.ctx.plugin.blocked = true
|
||||||
return nano.handle_custom_response(session_data, response)
|
return nano.handle_custom_response(session_data, response)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
local body_file = ngx.var.request_body_file
|
local body_file = ngx.var.request_body_file
|
||||||
if body_file then
|
if body_file then
|
||||||
@@ -132,23 +134,25 @@ function NanoHandler.access(conf)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local ok, verdict, response = pcall(function()
|
local ok, verdict, response = pcall(function()
|
||||||
return nano.end_inspection(session_id, session_data, nano.HttpChunkType.HTTP_REQUEST_END)
|
return nano.end_inspection(session_id, session_data, nano.HttpChunkType.HTTP_REQUEST_END)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if not ok then
|
if not ok then
|
||||||
kong.log.err("Error ending request inspection: ", verdict, " - failing open")
|
kong.log.err("Error ending request inspection: ", verdict, " - failing open")
|
||||||
nano.fini_session(session_data)
|
nano.fini_session(session_data)
|
||||||
nano.cleanup_all()
|
nano.cleanup_all()
|
||||||
return
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
if verdict == nano.AttachmentVerdict.DROP then
|
||||||
|
nano.fini_session(session_data)
|
||||||
|
kong.ctx.plugin.blocked = true
|
||||||
|
local result = nano.handle_custom_response(session_data, response)
|
||||||
|
nano.cleanup_all()
|
||||||
|
return result
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if verdict == nano.AttachmentVerdict.DROP then
|
|
||||||
nano.fini_session(session_data)
|
|
||||||
kong.ctx.plugin.blocked = true
|
|
||||||
local result = nano.handle_custom_response(session_data, response)
|
|
||||||
nano.cleanup_all()
|
|
||||||
return result
|
|
||||||
else
|
else
|
||||||
local ok, verdict, response = pcall(function()
|
local ok, verdict, response = pcall(function()
|
||||||
return nano.end_inspection(session_id, session_data, nano.HttpChunkType.HTTP_REQUEST_END)
|
return nano.end_inspection(session_id, session_data, nano.HttpChunkType.HTTP_REQUEST_END)
|
||||||
@@ -296,12 +300,13 @@ function NanoHandler.body_filter(conf)
|
|||||||
ctx.session_data = nil
|
ctx.session_data = nil
|
||||||
return custom_result
|
return custom_result
|
||||||
else
|
else
|
||||||
kong.log.err("nano.send_body failed, failing open: ", tostring(result))
|
kong.log.err("nano.send_body failed, failing open: ", tostring(result))
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- Inspection already complete - just count the chunk and pass through
|
||||||
|
kong.log.err("CHUNK #", ctx.body_buffer_chunk, " - skipping nano.send_body (inspection complete)")
|
||||||
|
ctx.body_buffer_chunk = ctx.body_buffer_chunk + 1
|
||||||
end
|
end
|
||||||
else
|
|
||||||
-- Inspection already complete - just count the chunk and pass through
|
|
||||||
kong.log.err("CHUNK #", ctx.body_buffer_chunk, " - skipping nano.send_body (inspection complete)")
|
|
||||||
ctx.body_buffer_chunk = ctx.body_buffer_chunk + 1
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user