mirror of
https://github.com/openappsec/attachment.git
synced 2026-01-17 16:00:26 +03:00
Fixed forward delcaration of NanoAttachment in nano_attachment_io fixed return from PopResponseVerdictFromQueue
This commit is contained in:
@@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#define CP_ASYNC_CTX_BUCKETS 2048 ///< Hash table buckets for better distribution
|
#define CP_ASYNC_CTX_BUCKETS 2048 ///< Hash table buckets for better distribution
|
||||||
|
|
||||||
|
typedef struct NanoAttachment NanoAttachment;
|
||||||
|
|
||||||
AttachmentVerdictResponse NanoAsyncFindResponse(NanoAttachment *attachment, SessionID session_id);
|
AttachmentVerdictResponse NanoAsyncFindResponse(NanoAttachment *attachment, SessionID session_id);
|
||||||
|
|
||||||
NanoCommunicationResult NanoAsyncAddResponse(NanoAttachment *attachment, SessionID session_id, AttachmentVerdictResponse *response);
|
NanoCommunicationResult NanoAsyncAddResponse(NanoAttachment *attachment, SessionID session_id, AttachmentVerdictResponse *response);
|
||||||
|
|||||||
@@ -1757,13 +1757,19 @@ PopResponseVerdictFromQueue(NanoAttachment *attachment)
|
|||||||
HttpReplyFromService *reply_p;
|
HttpReplyFromService *reply_p;
|
||||||
int pop_result;
|
int pop_result;
|
||||||
SessionID session_id = 0;
|
SessionID session_id = 0;
|
||||||
|
AttachmentVerdictResponse response = {
|
||||||
|
.verdict = ATTACHMENT_VERDICT_INSPECT,
|
||||||
|
.session_id = 0,
|
||||||
|
.web_response_data = NULL,
|
||||||
|
.modifications = NULL
|
||||||
|
};
|
||||||
|
|
||||||
if (attachment == NULL || attachment->nano_service_ipc == NULL) {
|
if (attachment == NULL || attachment->nano_service_ipc == NULL) {
|
||||||
return 0;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isDataAvailable(attachment->nano_service_ipc)) {
|
if (!isDataAvailable(attachment->nano_service_ipc)) {
|
||||||
return 0;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
pop_result = receiveData(attachment->nano_service_ipc, &reply_size, &reply_data);
|
pop_result = receiveData(attachment->nano_service_ipc, &reply_size, &reply_data);
|
||||||
@@ -1774,7 +1780,7 @@ PopResponseVerdictFromQueue(NanoAttachment *attachment)
|
|||||||
DBG_LEVEL_WARNING,
|
DBG_LEVEL_WARNING,
|
||||||
"Failed to receive data from queue"
|
"Failed to receive data from queue"
|
||||||
);
|
);
|
||||||
return 0;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
reply_p = (HttpReplyFromService *)reply_data;
|
reply_p = (HttpReplyFromService *)reply_data;
|
||||||
@@ -1787,10 +1793,35 @@ PopResponseVerdictFromQueue(NanoAttachment *attachment)
|
|||||||
DBG_LEVEL_WARNING,
|
DBG_LEVEL_WARNING,
|
||||||
"Failed to pop data from queue"
|
"Failed to pop data from queue"
|
||||||
);
|
);
|
||||||
return 0;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
response.verdict = reply_p->verdict;
|
// Convert ServiceVerdict to AttachmentVerdict
|
||||||
|
switch ((ServiceVerdict)reply_p->verdict) {
|
||||||
|
case TRAFFIC_VERDICT_INSPECT:
|
||||||
|
response.verdict = ATTACHMENT_VERDICT_INSPECT;
|
||||||
|
break;
|
||||||
|
case TRAFFIC_VERDICT_ACCEPT:
|
||||||
|
response.verdict = ATTACHMENT_VERDICT_ACCEPT;
|
||||||
|
break;
|
||||||
|
case TRAFFIC_VERDICT_DROP:
|
||||||
|
response.verdict = ATTACHMENT_VERDICT_DROP;
|
||||||
|
break;
|
||||||
|
case TRAFFIC_VERDICT_INJECT:
|
||||||
|
// Not yet supported
|
||||||
|
response.verdict = ATTACHMENT_VERDICT_INSPECT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
write_dbg(
|
||||||
|
attachment,
|
||||||
|
reply_p->session_id,
|
||||||
|
DBG_LEVEL_WARNING,
|
||||||
|
"Unknown verdict %d",
|
||||||
|
reply_p->verdict
|
||||||
|
);
|
||||||
|
response.verdict = ATTACHMENT_VERDICT_INSPECT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
response.session_id = reply_p->session_id;
|
response.session_id = reply_p->session_id;
|
||||||
|
|
||||||
// TODO: Deal with data leak.
|
// TODO: Deal with data leak.
|
||||||
|
|||||||
Reference in New Issue
Block a user