Обновить зависимости проекта
CI / Rust Checks (pull_request) Failing after 3s
CI / UI Checks (pull_request) Has been skipped
CI / Frontend E2E (pull_request) Has been skipped
CI / Deployment Manifests (pull_request) Has been skipped
CI / Deploy (pull_request) Has been skipped

This commit is contained in:
2026-07-06 22:47:24 +03:00
parent c7e5efa976
commit fd8571ad10
20 changed files with 773 additions and 1073 deletions
@@ -1,7 +1,7 @@
use axum_extra::extract::cookie::{Cookie, CookieJar, SameSite};
use base64::{Engine as _, engine::general_purpose::URL_SAFE_NO_PAD};
use crank_core::UserSessionId;
use rand::RngCore;
use rand::RngExt;
use sha2::{Digest, Sha256};
use time::{Duration, OffsetDateTime};
@@ -23,7 +23,7 @@ pub enum SessionCookieError {
pub fn create_session_cookie(session_ttl_hours: i64) -> Result<SessionCookie, SessionCookieError> {
let session_id = UserSessionId::new(format!("sess_{}", uuid::Uuid::now_v7().simple()));
let mut secret_bytes = [0_u8; 32];
rand::thread_rng().fill_bytes(&mut secret_bytes);
rand::rng().fill(&mut secret_bytes);
let secret = URL_SAFE_NO_PAD.encode(secret_bytes);
let expires_at = OffsetDateTime::now_utc()
.checked_add(Duration::hours(session_ttl_hours))
+16 -17
View File
@@ -641,24 +641,23 @@ async fn mcp_post(
);
}
if let Some(session_id) = headers.get(HEADER_MCP_SESSION_ID) {
if let Ok(session_id) = session_id.to_str() {
let session = match state.sessions.get(session_id).await {
Ok(session) => session,
Err(_) => {
return with_request_id_header(
StatusCode::INTERNAL_SERVER_ERROR.into_response(),
&transport_request_id,
);
}
};
if let Some(session) = session {
if let Err(status) =
validate_session_protocol_version(&headers, &session.protocol_version)
{
return with_request_id_header(status.into_response(), &transport_request_id);
}
if let Some(session_id) = headers.get(HEADER_MCP_SESSION_ID)
&& let Ok(session_id) = session_id.to_str()
{
let session = match state.sessions.get(session_id).await {
Ok(session) => session,
Err(_) => {
return with_request_id_header(
StatusCode::INTERNAL_SERVER_ERROR.into_response(),
&transport_request_id,
);
}
};
if let Some(session) = session
&& let Err(status) =
validate_session_protocol_version(&headers, &session.protocol_version)
{
return with_request_id_header(status.into_response(), &transport_request_id);
}
}
+2 -7
View File
@@ -14,18 +14,13 @@ pub enum MachineAccessMode {
StaticAgentKey,
}
#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum OperationSecurityLevel {
#[default]
Standard,
}
impl Default for OperationSecurityLevel {
fn default() -> Self {
Self::Standard
}
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct EditionLimits {
pub max_workspaces: Option<u32>,
+4 -4
View File
@@ -193,10 +193,10 @@ fn text(value: &Value, key: &str) -> Option<String> {
fn collapse_composition(value: &Value) -> Value {
for key in ["allOf", "oneOf", "anyOf"] {
if let Some(items) = value.get(key).and_then(Value::as_array) {
if let Some(first) = items.first() {
return first.clone();
}
if let Some(items) = value.get(key).and_then(Value::as_array)
&& let Some(first) = items.first()
{
return first.clone();
}
}
value.clone()
@@ -1,7 +1,7 @@
use std::time::Duration;
use sqlx::{
PgPool,
AssertSqlSafe, PgPool,
postgres::{PgConnectOptions, PgPoolOptions},
};
@@ -58,7 +58,7 @@ impl PostgresRegistry {
.await?;
if let Some(schema) = schema {
sqlx::query(&format!("set search_path to {schema}"))
sqlx::query(AssertSqlSafe(format!("set search_path to {schema}")))
.execute(&pool)
.await?;
}
@@ -239,7 +239,7 @@ impl PostgresRegistry {
group by 1
order by 1 asc"
);
let rows = sqlx::query(&sql)
let rows = sqlx::query(sqlx::AssertSqlSafe(sql))
.bind(query.workspace_id.as_str())
.bind(query.created_after)
.bind(
@@ -245,7 +245,9 @@ impl TestDatabase {
let schema = crank_test_support::unique_schema_name("test_registry");
admin_pool
.execute(sqlx::query(&format!("create schema {schema}")))
.execute(sqlx::query(sqlx::AssertSqlSafe(format!(
"create schema {schema}"
))))
.await
.unwrap();
@@ -267,10 +269,10 @@ impl TestDatabase {
pub(super) async fn cleanup(&self) {
self.admin_pool
.execute(sqlx::query(&format!(
.execute(sqlx::query(sqlx::AssertSqlSafe(format!(
"drop schema if exists {} cascade",
self.schema
)))
))))
.await
.unwrap();
}
+2 -3
View File
@@ -85,10 +85,9 @@ fn key_from_policy(
.header_name
.as_deref()
.filter(|value| !value.is_empty())
&& let Some(value) = prepared_request.headers.get(header_name)
{
if let Some(value) = prepared_request.headers.get(header_name) {
return Some(value.clone());
}
return Some(value.clone());
}
let field_name = policy.input_field.as_deref()?.trim();
+3 -1
View File
@@ -28,7 +28,9 @@ pub async fn postgres_schema_url(prefix: &str) -> String {
let mut connection = connect_admin_with_retry(database_url).await;
connection
.execute(sqlx::query(&format!("create schema {schema}")))
.execute(sqlx::query(sqlx::AssertSqlSafe(format!(
"create schema {schema}"
))))
.await
.expect("test PostgreSQL schema must be created");