Skip to content

Commit 3dad87c

Browse files
committed
fix(pegboard-envoy): validate remote sqlite requests
1 parent 6ddb158 commit 3dad87c

6 files changed

Lines changed: 582 additions & 153 deletions

File tree

engine/packages/depot-client/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,19 @@ tracing.workspace = true
1919
getrandom = "0.2"
2020
rivet-envoy-protocol.workspace = true
2121
depot-client-types.workspace = true
22+
depot.workspace = true
2223
moka = { version = "0.12", default-features = false, features = ["sync"] }
2324
parking_lot.workspace = true
2425

2526
[dev-dependencies]
2627
async-trait.workspace = true
28+
depot = { workspace = true, features = ["test-faults"] }
2729
futures-util.workspace = true
2830
gas.workspace = true
2931
rivet-config.workspace = true
3032
rivet-pools.workspace = true
3133
rivet-test-deps.workspace = true
3234
scc.workspace = true
33-
depot = { workspace = true, features = ["test-faults"] }
3435
sha2.workspace = true
3536
tempfile.workspace = true
3637
universaldb.workspace = true

engine/packages/depot-client/src/database.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,36 @@ pub async fn open_database_from_envoy(
6262
Ok(native_db)
6363
}
6464

65+
pub async fn open_database_from_conveyer(
66+
db: Arc<depot::conveyer::Db>,
67+
actor_id: String,
68+
generation: u64,
69+
rt_handle: Handle,
70+
metrics: Option<Arc<dyn SqliteVfsMetrics>>,
71+
) -> Result<NativeDatabaseHandle> {
72+
let vfs_name = vfs_name_for_actor_database(&actor_id, generation);
73+
let vfs = Arc::new(
74+
SqliteVfs::register_with_transport(
75+
&vfs_name,
76+
crate::vfs::SqliteTransport::from_conveyer(db),
77+
actor_id.clone(),
78+
rt_handle,
79+
VfsConfig::default(),
80+
metrics.clone(),
81+
)
82+
.map_err(|e| anyhow!("failed to register sqlite VFS: {e}"))?,
83+
);
84+
85+
let native_db = NativeDatabaseHandle::new_with_metrics(
86+
vfs,
87+
actor_id,
88+
NativeConnectionManagerConfig::from_optimization_flags(*sqlite_optimization_flags()),
89+
metrics,
90+
);
91+
native_db.initialize().await?;
92+
Ok(native_db)
93+
}
94+
6595
impl NativeDatabaseHandle {
6696
pub fn new(
6797
vfs: NativeVfsHandle,

0 commit comments

Comments
 (0)