ai_agent/utils/plugins/
plugin_installation_helpers.rs1#![allow(dead_code)]
3
4use super::schemas::{PluginMarketplaceEntry, PluginScope};
5
6pub fn get_current_timestamp() -> String {
8 chrono::Utc::now().to_rfc3339()
9}
10
11pub fn _validate_path_within_base(
13 base_path: &str,
14 relative_path: &str,
15) -> Result<String, Box<dyn std::error::Error + Send + Sync>> {
16 let base = std::fs::canonicalize(base_path)?;
17 let resolved = std::fs::canonicalize(std::path::Path::new(base_path).join(relative_path))?;
18
19 let normalized_base = base.to_string_lossy();
20 let normalized_base_with_sep = format!("{}{}", normalized_base, std::path::MAIN_SEPARATOR);
21
22 if !resolved.starts_with(&normalized_base_with_sep) && resolved != base {
23 return Err(format!(
24 "Path traversal detected: \"{}\" would escape the base directory",
25 relative_path
26 )
27 .into());
28 }
29
30 Ok(resolved.to_string_lossy().to_string())
31}
32
33pub async fn cache_and_register_plugin(
35 _plugin_id: &str,
36 _entry: &PluginMarketplaceEntry,
37 _scope: PluginScope,
38 _project_path: Option<&str>,
39 _local_source_path: Option<&str>,
40) -> Result<String, Box<dyn std::error::Error + Send + Sync>> {
41 Err("cache_and_register_plugin not fully implemented".into())
43}
44
45pub fn _register_plugin_installation(
47 _plugin_id: &str,
48 _install_path: &str,
49 _version: Option<&str>,
50 _scope: PluginScope,
51 _project_path: Option<&str>,
52) {
53 }
55
56pub fn _format_resolution_error(_r: &super::dependency_resolver::ResolutionResult) -> String {
58 "Unknown resolution error".to_string()
59}