mirror of
https://github.com/openappsec/attachment.git
synced 2026-01-17 16:00:26 +03:00
Added Hold verdict
This commit is contained in:
@@ -97,7 +97,8 @@ public:
|
|||||||
NanoAttachment *attachment,
|
NanoAttachment *attachment,
|
||||||
HttpEventThreadCtx *ctx,
|
HttpEventThreadCtx *ctx,
|
||||||
SessionID cur_request_id,
|
SessionID cur_request_id,
|
||||||
unsigned int *num_messages_sent
|
unsigned int *num_messages_sent,
|
||||||
|
bool is_verdict_requested
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -200,7 +201,8 @@ CMOCK_MOCK_FUNCTION4(
|
|||||||
NanoAttachment *attachment,
|
NanoAttachment *attachment,
|
||||||
HttpEventThreadCtx *ctx,
|
HttpEventThreadCtx *ctx,
|
||||||
SessionID cur_request_id,
|
SessionID cur_request_id,
|
||||||
unsigned int *num_messages_sent
|
unsigned int *num_messages_sent,
|
||||||
|
bool is_verdict_requested
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -265,6 +265,9 @@ SendDataNanoAttachmentAsync(NanoAttachment *attachment, AttachmentData *data)
|
|||||||
case HTTP_RESPONSE_END: {
|
case HTTP_RESPONSE_END: {
|
||||||
return SendResponseEndAsync(attachment, data);
|
return SendResponseEndAsync(attachment, data);
|
||||||
}
|
}
|
||||||
|
case HOLD_DATA: {
|
||||||
|
return SendHoldDataAsync(attachment, data);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1703,7 +1703,8 @@ nano_request_delayed_verdict(
|
|||||||
NanoAttachment *attachment,
|
NanoAttachment *attachment,
|
||||||
HttpEventThreadCtx *ctx,
|
HttpEventThreadCtx *ctx,
|
||||||
SessionID cur_request_id,
|
SessionID cur_request_id,
|
||||||
unsigned int *num_messages_sent
|
unsigned int *num_messages_sent,
|
||||||
|
bool is_verdict_requested
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
char *fragments[DELAYED_VERDICT_DATA_COUNT];
|
char *fragments[DELAYED_VERDICT_DATA_COUNT];
|
||||||
@@ -1740,6 +1741,7 @@ nano_request_delayed_verdict(
|
|||||||
|
|
||||||
*num_messages_sent += 1;
|
*num_messages_sent += 1;
|
||||||
|
|
||||||
|
if (is_verdict_requested) {
|
||||||
ctx->res = service_reply_receiver(
|
ctx->res = service_reply_receiver(
|
||||||
attachment,
|
attachment,
|
||||||
ctx->session_data_p,
|
ctx->session_data_p,
|
||||||
@@ -1747,6 +1749,9 @@ nano_request_delayed_verdict(
|
|||||||
&ctx->modifications,
|
&ctx->modifications,
|
||||||
wait_transaction_type
|
wait_transaction_type
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
ctx->res = NANO_OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AttachmentVerdictResponse
|
AttachmentVerdictResponse
|
||||||
@@ -1796,6 +1801,8 @@ PopResponseVerdictFromQueue(NanoAttachment *attachment)
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
response.session_id = reply_p->session_id;
|
||||||
|
|
||||||
// Convert ServiceVerdict to AttachmentVerdict
|
// Convert ServiceVerdict to AttachmentVerdict
|
||||||
switch ((ServiceVerdict)reply_p->verdict) {
|
switch ((ServiceVerdict)reply_p->verdict) {
|
||||||
case TRAFFIC_VERDICT_INSPECT:
|
case TRAFFIC_VERDICT_INSPECT:
|
||||||
@@ -1814,15 +1821,23 @@ PopResponseVerdictFromQueue(NanoAttachment *attachment)
|
|||||||
case TRAFFIC_VERDICT_RECONF:
|
case TRAFFIC_VERDICT_RECONF:
|
||||||
write_dbg(
|
write_dbg(
|
||||||
attachment,
|
attachment,
|
||||||
reply_p->session_id,
|
0,
|
||||||
DBG_LEVEL_TRACE,
|
DBG_LEVEL_TRACE,
|
||||||
"Verdict reconf received from the nano service"
|
"Verdict reconf received from the nano service"
|
||||||
);
|
);
|
||||||
reset_attachment_config(attachment);
|
reset_attachment_config(attachment);
|
||||||
response.verdict = ATTACHMENT_VERDICT_INSPECT;
|
response.verdict = ATTACHMENT_VERDICT_INSPECT;
|
||||||
|
response.session_id = 0;
|
||||||
break;
|
break;
|
||||||
case TRAFFIC_VERDICT_DELAYED:
|
case TRAFFIC_VERDICT_DELAYED:
|
||||||
response.verdict = ATTACHMENT_VERDICT_INSPECT;
|
write_dbg(
|
||||||
|
attachment,
|
||||||
|
reply_p->session_id,
|
||||||
|
DBG_LEVEL_TRACE,
|
||||||
|
"Verdict delayed received from the nano service"
|
||||||
|
);
|
||||||
|
|
||||||
|
response.verdict = ATTACHMENT_VERDICT_DELAYED;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
write_dbg(
|
write_dbg(
|
||||||
@@ -1835,7 +1850,6 @@ PopResponseVerdictFromQueue(NanoAttachment *attachment)
|
|||||||
response.verdict = ATTACHMENT_VERDICT_INSPECT;
|
response.verdict = ATTACHMENT_VERDICT_INSPECT;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
response.session_id = reply_p->session_id;
|
|
||||||
|
|
||||||
// TODO: Deal with data leak.
|
// TODO: Deal with data leak.
|
||||||
response.web_response_data = NULL;
|
response.web_response_data = NULL;
|
||||||
|
|||||||
@@ -220,7 +220,8 @@ nano_request_delayed_verdict(
|
|||||||
NanoAttachment *attachment,
|
NanoAttachment *attachment,
|
||||||
HttpEventThreadCtx *ctx,
|
HttpEventThreadCtx *ctx,
|
||||||
SessionID cur_request_id,
|
SessionID cur_request_id,
|
||||||
unsigned int *num_messages_sent
|
unsigned int *num_messages_sent,
|
||||||
|
bool is_verdict_requested
|
||||||
);
|
);
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -1138,6 +1138,42 @@ SendResponseEndAsync(NanoAttachment *attachment, AttachmentData *data)
|
|||||||
return SendResponseEndAsyncImpl(attachment, session_data_p);
|
return SendResponseEndAsyncImpl(attachment, session_data_p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NanoCommunicationResult
|
||||||
|
SendHoldDataAsync(NanoAttachment *attachment, AttachmentData *data)
|
||||||
|
{
|
||||||
|
if (attachment == NULL || data == NULL) {
|
||||||
|
return NANO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpSessionData *session_data_p = data->session_data;
|
||||||
|
if (session_data_p == NULL) {
|
||||||
|
return NANO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
SessionID session_id = session_data_p->session_id;
|
||||||
|
|
||||||
|
write_dbg(
|
||||||
|
attachment,
|
||||||
|
session_id,
|
||||||
|
DBG_LEVEL_DEBUG,
|
||||||
|
"Hold data handling session ID: %d",
|
||||||
|
session_id
|
||||||
|
);
|
||||||
|
|
||||||
|
if (handle_shmem_corruption(attachment) == NANO_ERROR) {
|
||||||
|
write_dbg(
|
||||||
|
attachment,
|
||||||
|
session_id,
|
||||||
|
DBG_LEVEL_WARNING,
|
||||||
|
"Failed to handle shmem corruption in session ID: %d",
|
||||||
|
session_id
|
||||||
|
);
|
||||||
|
return NANO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SendHoldDataAsyncImpl(attachment, session_data_p);
|
||||||
|
}
|
||||||
|
|
||||||
NanoCommunicationResult
|
NanoCommunicationResult
|
||||||
SendMetricData(NanoAttachment *attachment)
|
SendMetricData(NanoAttachment *attachment)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -204,6 +204,19 @@ NanoCommunicationResult SendRequestEndAsync(NanoAttachment *attachment, Attachme
|
|||||||
///
|
///
|
||||||
NanoCommunicationResult SendResponseEndAsync(NanoAttachment *attachment, AttachmentData *data);
|
NanoCommunicationResult SendResponseEndAsync(NanoAttachment *attachment, AttachmentData *data);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief Sends a delayed verdict signal to the agent asynchronously.
|
||||||
|
///
|
||||||
|
/// This function sends a delayed verdict signal to the agent service, requesting an updated
|
||||||
|
/// verdict for a session that is currently in a delayed state.
|
||||||
|
///
|
||||||
|
/// @param attachment A pointer to the NanoAttachment structure.
|
||||||
|
/// @param data A pointer to AttachmentData structure containing the session data.
|
||||||
|
///
|
||||||
|
/// @return A NanoCommunicationResult indicating the outcome of the operation.
|
||||||
|
///
|
||||||
|
NanoCommunicationResult SendHoldDataAsync(NanoAttachment *attachment, AttachmentData *data);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// @brief Sends metric data to the nano service and resets it on the attachment.
|
/// @brief Sends metric data to the nano service and resets it on the attachment.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -249,6 +249,36 @@ SendDelayedVerdictRequestAsyncImpl(
|
|||||||
return NANO_OK;
|
return NANO_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NanoCommunicationResult
|
||||||
|
SendHoldDataAsyncImpl(
|
||||||
|
NanoAttachment *attachment,
|
||||||
|
HttpSessionData *session_data_p
|
||||||
|
)
|
||||||
|
{
|
||||||
|
HttpEventThreadCtx ctx;
|
||||||
|
|
||||||
|
if (attachment == NULL || session_data_p == NULL) {
|
||||||
|
return NANO_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.attachment = attachment;
|
||||||
|
ctx.data = NULL;
|
||||||
|
ctx.session_data_p = session_data_p;
|
||||||
|
ctx.res = NANO_OK;
|
||||||
|
ctx.web_response_data = NULL;
|
||||||
|
ctx.modifications = NULL;
|
||||||
|
|
||||||
|
nano_request_delayed_verdict(
|
||||||
|
attachment,
|
||||||
|
&ctx,
|
||||||
|
session_data_p->session_id,
|
||||||
|
&session_data_p->remaining_messages_to_reply,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
return ctx.res;
|
||||||
|
}
|
||||||
|
|
||||||
NanoCommunicationResult
|
NanoCommunicationResult
|
||||||
SendMetricToServiceAsyncImpl(
|
SendMetricToServiceAsyncImpl(
|
||||||
NanoAttachment *attachment,
|
NanoAttachment *attachment,
|
||||||
|
|||||||
@@ -321,7 +321,8 @@ SendDelayedVerdictRequestThread(void *_ctx)
|
|||||||
attachment,
|
attachment,
|
||||||
ctx,
|
ctx,
|
||||||
session_data_p->session_id,
|
session_data_p->session_id,
|
||||||
&session_data_p->remaining_messages_to_reply
|
&session_data_p->remaining_messages_to_reply,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -241,7 +241,8 @@ typedef enum AttachmentVerdict
|
|||||||
ATTACHMENT_VERDICT_INSPECT,
|
ATTACHMENT_VERDICT_INSPECT,
|
||||||
ATTACHMENT_VERDICT_ACCEPT,
|
ATTACHMENT_VERDICT_ACCEPT,
|
||||||
ATTACHMENT_VERDICT_DROP,
|
ATTACHMENT_VERDICT_DROP,
|
||||||
ATTACHMENT_VERDICT_INJECT
|
ATTACHMENT_VERDICT_INJECT,
|
||||||
|
ATTACHMENT_VERDICT_DELAYED
|
||||||
} AttachmentVerdict;
|
} AttachmentVerdict;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
Reference in New Issue
Block a user