Skip to content

Commit e0e54d1

Browse files
committed
feat(plugins): add remote registry discovery and plugin signing
- Add RemoteRegistry and PluginIndexEntry types for remote plugin discovery - Add PluginSigner for ed25519 signature verification - Add checksum (SHA256) verification for downloaded plugins - Add registry methods: fetch_remote_index, search, check_updates, download_plugin - Add SignatureError, NetworkError, ChecksumMismatch, RegistryError to PluginError - Export new types from lib.rs
1 parent 3f6436d commit e0e54d1

6 files changed

Lines changed: 984 additions & 1 deletion

File tree

Cargo.lock

Lines changed: 105 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cortex-plugins/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ reqwest = { workspace = true }
4545
# URL parsing
4646
url = { workspace = true }
4747

48+
# Cryptographic signing
49+
ed25519-dalek = "2.1"
50+
51+
# Checksums
52+
sha2 = { workspace = true }
53+
hex = { workspace = true }
54+
4855

4956

5057
[dev-dependencies]

src/cortex-plugins/src/error.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,26 @@ pub enum PluginError {
8484
/// Plugin is disabled.
8585
#[error("Plugin is disabled: {0}")]
8686
Disabled(String),
87+
88+
/// Signature verification error.
89+
#[error("Signature error: {0}")]
90+
SignatureError(String),
91+
92+
/// Network/HTTP error.
93+
#[error("Network error: {0}")]
94+
NetworkError(String),
95+
96+
/// Checksum verification error.
97+
#[error("Checksum mismatch for plugin '{plugin}': expected {expected}, got {actual}")]
98+
ChecksumMismatch {
99+
plugin: String,
100+
expected: String,
101+
actual: String,
102+
},
103+
104+
/// Registry error.
105+
#[error("Registry error: {0}")]
106+
RegistryError(String),
87107
}
88108

89109
impl PluginError {
@@ -142,6 +162,19 @@ impl PluginError {
142162
message: message.into(),
143163
}
144164
}
165+
166+
/// Create a checksum mismatch error.
167+
pub fn checksum_mismatch(
168+
plugin: impl Into<String>,
169+
expected: impl Into<String>,
170+
actual: impl Into<String>,
171+
) -> Self {
172+
Self::ChecksumMismatch {
173+
plugin: plugin.into(),
174+
expected: expected.into(),
175+
actual: actual.into(),
176+
}
177+
}
145178
}
146179

147180
impl From<toml::de::Error> for PluginError {
@@ -162,6 +195,12 @@ impl From<wasmtime::Error> for PluginError {
162195
}
163196
}
164197

198+
impl From<reqwest::Error> for PluginError {
199+
fn from(err: reqwest::Error) -> Self {
200+
Self::NetworkError(err.to_string())
201+
}
202+
}
203+
165204
/// Result type alias for plugin operations.
166205
pub type Result<T> = std::result::Result<T, PluginError>;
167206

src/cortex-plugins/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pub mod plugin;
6060
pub mod registry;
6161
pub mod runtime;
6262
pub mod sdk;
63+
pub mod signing;
6364

6465
// Re-exports for convenience
6566
pub use api::{PluginApi, PluginContext, PluginHostFunctions};
@@ -273,7 +274,8 @@ pub use manifest::{
273274
PluginManifest, PluginPermission,
274275
};
275276
pub use plugin::{Plugin, PluginInfo, PluginState, PluginStatus};
276-
pub use registry::PluginRegistry;
277+
pub use registry::{PluginIndex, PluginIndexEntry, PluginRegistry, RemoteRegistry};
278+
pub use signing::PluginSigner;
277279
pub use runtime::{PluginStoreState, WasmPlugin, WasmRuntime};
278280

279281
// Host function re-exports

0 commit comments

Comments
 (0)