mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-12 14:10:19 +08:00
feat(security): harden gateway request and runtime controls
This commit is contained in:
@@ -309,11 +309,14 @@ async fn parse_request_json<T>(request: Request) -> Result<T, ExecutionRuntimeAp
|
||||
where
|
||||
T: serde::de::DeserializeOwned,
|
||||
{
|
||||
let body = to_bytes(request.into_body(), usize::MAX)
|
||||
.await
|
||||
.map_err(|err| {
|
||||
ExecutionRuntimeAppError(ExecutionRuntimeServerError::RequestRead(err.to_string()))
|
||||
})?;
|
||||
let body = to_bytes(
|
||||
request.into_body(),
|
||||
usize::try_from(crate::headers::max_request_body_bytes()).unwrap_or(usize::MAX),
|
||||
)
|
||||
.await
|
||||
.map_err(|err| {
|
||||
ExecutionRuntimeAppError(ExecutionRuntimeServerError::RequestRead(err.to_string()))
|
||||
})?;
|
||||
serde_json::from_slice(&body).map_err(|err| {
|
||||
ExecutionRuntimeAppError(ExecutionRuntimeServerError::InvalidRequestJson(err))
|
||||
})
|
||||
|
||||
@@ -1534,7 +1534,12 @@ async fn openai_image_sync_json_heartbeat_final_bytes(
|
||||
result: Result<Option<Response<Body>>, GatewayError>,
|
||||
) -> Vec<u8> {
|
||||
match result {
|
||||
Ok(Some(response)) => match to_bytes(response.into_body(), usize::MAX).await {
|
||||
Ok(Some(response)) => match to_bytes(
|
||||
response.into_body(),
|
||||
crate::headers::max_internal_buffered_body_bytes(),
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(bytes) if !bytes.is_empty() => bytes.to_vec(),
|
||||
Ok(_) => openai_image_sync_json_heartbeat_error_body("empty sync image response"),
|
||||
Err(err) => openai_image_sync_json_heartbeat_error_body(&err.to_string()),
|
||||
|
||||
Reference in New Issue
Block a user