mirror of
https://github.com/elicpeter/nyx.git
synced 2026-06-21 20:18:06 +02:00
53 lines
1.6 KiB
Rust
53 lines
1.6 KiB
Rust
|
|
use crate::cli::OutputFormat;
|
||
|
|
use crate::utils::project::get_project_info;
|
||
|
|
use std::path::Path;
|
||
|
|
use crate::utils::config::Config;
|
||
|
|
|
||
|
|
pub fn handle(
|
||
|
|
path: &str,
|
||
|
|
no_index: bool,
|
||
|
|
rebuild_index: bool,
|
||
|
|
format: OutputFormat,
|
||
|
|
high_only: bool,
|
||
|
|
database_dir: &Path,
|
||
|
|
config: &Config,
|
||
|
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||
|
|
let scan_path = Path::new(path).canonicalize()?;
|
||
|
|
let (project_name, db_path) = get_project_info(&scan_path, database_dir)?;
|
||
|
|
|
||
|
|
tracing::info!("Config: {:?}", config);
|
||
|
|
tracing::info!("Scanning project: {}", project_name);
|
||
|
|
tracing::info!("Scan path: {}", scan_path.display());
|
||
|
|
|
||
|
|
if no_index {
|
||
|
|
tracing::info!("Scanning without index...");
|
||
|
|
scan_filesystem(&scan_path)?;
|
||
|
|
} else {
|
||
|
|
if rebuild_index || !db_path.exists() {
|
||
|
|
tracing::info!("Building/updating index...");
|
||
|
|
crate::commands::index::build_index(&scan_path, &db_path)?;
|
||
|
|
}
|
||
|
|
|
||
|
|
tracing::info!("Using index: {}", db_path.display());
|
||
|
|
scan_with_index(&db_path)?;
|
||
|
|
}
|
||
|
|
|
||
|
|
tracing::info!("Output format: {:?}", format);
|
||
|
|
if high_only {
|
||
|
|
tracing::info!("Filtering: High severity only");
|
||
|
|
}
|
||
|
|
|
||
|
|
Ok(())
|
||
|
|
}
|
||
|
|
|
||
|
|
fn scan_filesystem(path: &Path) -> Result<(), Box<dyn std::error::Error>> {
|
||
|
|
// TODO: Implement direct filesystem scanning
|
||
|
|
tracing::info!("Direct filesystem scan of: {}", path.display());
|
||
|
|
Ok(())
|
||
|
|
}
|
||
|
|
|
||
|
|
fn scan_with_index(db_path: &Path) -> Result<(), Box<dyn std::error::Error>> {
|
||
|
|
// TODO: Implement index-based scanning
|
||
|
|
tracing::info!("Index-based scan using: {}", db_path.display());
|
||
|
|
Ok(())
|
||
|
|
}
|