refactor: streaming, security hardening, and MCP removal
Major overhaul of server architecture and security posture: - Streaming: Unified all I/O through PIPESIZE (8192-byte) buffers. POST bodies stream via MpscReader through the save pipeline. GET content streams from disk via decompression to client. Removed save_item_with_reader, get_item_content_info, ChannelReader. 413 responses keep partial items (nonfatal by design). - Security: XSS protection in all HTML pages via html_escape crate. Security headers middleware (nosniff, frame deny, referrer policy). CORS tightened to explicit headers. Input validation for tags (256 chars), metadata (128/4096), pagination (10k cap). Config file reads use from_utf8_lossy. Generic error messages in HTML. Diff endpoint has 10 MB per-item cap. max_body_size config option. - Panics eliminated: Path unwraps → proper error propagation. Mutex unwraps → map_err (registries) / expect with message (local). - MCP removed: Deleted all MCP code, rmcp dependency, mcp feature. - Docs: Updated README, DESIGN, AGENTS to reflect all changes.
This commit is contained in:
@@ -578,11 +578,15 @@ static META_PLUGIN_REGISTRY: Lazy<Mutex<HashMap<MetaPluginType, PluginConstructo
|
||||
///
|
||||
/// * `meta_plugin_type` - The type of the meta plugin to register.
|
||||
/// * `constructor` - The constructor function for creating plugin instances.
|
||||
pub fn register_meta_plugin(meta_plugin_type: MetaPluginType, constructor: PluginConstructor) {
|
||||
pub fn register_meta_plugin(
|
||||
meta_plugin_type: MetaPluginType,
|
||||
constructor: PluginConstructor,
|
||||
) -> anyhow::Result<()> {
|
||||
META_PLUGIN_REGISTRY
|
||||
.lock()
|
||||
.unwrap()
|
||||
.map_err(|e| anyhow::anyhow!("plugin registry poisoned: {e}"))?
|
||||
.insert(meta_plugin_type, constructor);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn get_meta_plugin(
|
||||
@@ -590,7 +594,9 @@ pub fn get_meta_plugin(
|
||||
options: Option<std::collections::HashMap<String, serde_yaml::Value>>,
|
||||
outputs: Option<std::collections::HashMap<String, serde_yaml::Value>>,
|
||||
) -> anyhow::Result<Box<dyn MetaPlugin>> {
|
||||
let registry = META_PLUGIN_REGISTRY.lock().unwrap();
|
||||
let registry = META_PLUGIN_REGISTRY
|
||||
.lock()
|
||||
.map_err(|e| anyhow::anyhow!("plugin registry poisoned: {e}"))?;
|
||||
if let Some(constructor) = registry.get(&meta_plugin_type) {
|
||||
return Ok(constructor(options, outputs));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user