syncable_cli/analyzer/tool_management/installers/
rust.rs1use super::common::InstallationUtils;
2use crate::analyzer::tool_management::ToolDetector;
3use crate::error::{AnalysisError, IaCGeneratorError, Result};
4use log::info;
5use std::collections::HashMap;
6
7pub fn install_cargo_audit(
9 tool_detector: &mut ToolDetector,
10 installed_tools: &mut HashMap<String, bool>,
11) -> Result<()> {
12 if tool_detector.detect_tool("cargo-audit").available {
13 return Ok(());
14 }
15
16 info!("🔧 Installing cargo-audit for Rust vulnerability scanning...");
17
18 let success = InstallationUtils::execute_command("cargo", &["install", "cargo-audit"])?;
19
20 if success {
21 info!("✅ cargo-audit installed successfully");
22 installed_tools.insert("cargo-audit".to_string(), true);
23 tool_detector.clear_cache(); } else {
25 return Err(IaCGeneratorError::Analysis(
26 AnalysisError::DependencyParsing {
27 file: "cargo-audit installation".to_string(),
28 reason: "Installation failed".to_string(),
29 },
30 ));
31 }
32
33 Ok(())
34}