diff --git a/compliance-agent/src/api/handlers/dast.rs b/compliance-agent/src/api/handlers/dast.rs index 9046770..e8e5839 100644 --- a/compliance-agent/src/api/handlers/dast.rs +++ b/compliance-agent/src/api/handlers/dast.rs @@ -103,8 +103,7 @@ pub async fn trigger_scan( Extension(agent): AgentExt, Path(id): Path, ) -> Result, StatusCode> { - let oid = - mongodb::bson::oid::ObjectId::parse_str(&id).map_err(|_| StatusCode::BAD_REQUEST)?; + let oid = mongodb::bson::oid::ObjectId::parse_str(&id).map_err(|_| StatusCode::BAD_REQUEST)?; let target = agent .db @@ -207,8 +206,7 @@ pub async fn get_finding( Extension(agent): AgentExt, Path(id): Path, ) -> Result>, StatusCode> { - let oid = - mongodb::bson::oid::ObjectId::parse_str(&id).map_err(|_| StatusCode::BAD_REQUEST)?; + let oid = mongodb::bson::oid::ObjectId::parse_str(&id).map_err(|_| StatusCode::BAD_REQUEST)?; let finding = agent .db diff --git a/compliance-agent/src/api/handlers/graph.rs b/compliance-agent/src/api/handlers/graph.rs index 75082d3..d84bd4b 100644 --- a/compliance-agent/src/api/handlers/graph.rs +++ b/compliance-agent/src/api/handlers/graph.rs @@ -235,12 +235,7 @@ pub async fn get_file_content( // Cap at 10,000 lines let truncated: String = content.lines().take(10_000).collect::>().join("\n"); - let language = params - .path - .rsplit('.') - .next() - .unwrap_or("") - .to_string(); + let language = params.path.rsplit('.').next().unwrap_or("").to_string(); Ok(Json(ApiResponse { data: FileContent { diff --git a/compliance-agent/src/pipeline/orchestrator.rs b/compliance-agent/src/pipeline/orchestrator.rs index 3abcecc..39923ca 100644 --- a/compliance-agent/src/pipeline/orchestrator.rs +++ b/compliance-agent/src/pipeline/orchestrator.rs @@ -185,7 +185,9 @@ impl PipelineOrchestrator { // Stage 4.5: Graph Building tracing::info!("[{repo_id}] Stage 4.5: Graph Building"); self.update_phase(scan_run_id, "graph_building").await; - let graph_context = match self.build_code_graph(&repo_path, &repo_id, &all_findings).await + let graph_context = match self + .build_code_graph(&repo_path, &repo_id, &all_findings) + .await { Ok(ctx) => Some(ctx), Err(e) => { @@ -296,9 +298,10 @@ impl PipelineOrchestrator { let graph_build_id = uuid::Uuid::new_v4().to_string(); let engine = compliance_graph::GraphEngine::new(50_000); - let (mut code_graph, build_run) = engine - .build_graph(repo_path, repo_id, &graph_build_id) - .map_err(|e| AgentError::Other(format!("Graph build error: {e}")))?; + let (mut code_graph, build_run) = + engine + .build_graph(repo_path, repo_id, &graph_build_id) + .map_err(|e| AgentError::Other(format!("Graph build error: {e}")))?; // Apply community detection compliance_graph::graph::community::apply_communities(&mut code_graph); @@ -348,15 +351,11 @@ impl PipelineOrchestrator { use futures_util::TryStreamExt; let filter = mongodb::bson::doc! { "repo_id": repo_id }; - let targets: Vec = match self - .db - .dast_targets() - .find(filter) - .await - { - Ok(cursor) => cursor.try_collect().await.unwrap_or_default(), - Err(_) => return, - }; + let targets: Vec = + match self.db.dast_targets().find(filter).await { + Ok(cursor) => cursor.try_collect().await.unwrap_or_default(), + Err(_) => return, + }; if targets.is_empty() { tracing::info!("[{repo_id}] No DAST targets configured, skipping"); @@ -379,10 +378,7 @@ impl PipelineOrchestrator { tracing::error!("Failed to store DAST finding: {e}"); } } - tracing::info!( - "DAST scan complete: {} findings", - findings.len() - ); + tracing::info!("DAST scan complete: {} findings", findings.len()); } Err(e) => { tracing::error!("DAST scan failed: {e}"); diff --git a/compliance-core/src/models/repository.rs b/compliance-core/src/models/repository.rs index e283afe..569a139 100644 --- a/compliance-core/src/models/repository.rs +++ b/compliance-core/src/models/repository.rs @@ -31,9 +31,15 @@ pub struct TrackedRepository { pub last_scanned_commit: Option, #[serde(default, deserialize_with = "deserialize_findings_count")] pub findings_count: u32, - #[serde(default = "chrono::Utc::now", deserialize_with = "deserialize_datetime")] + #[serde( + default = "chrono::Utc::now", + deserialize_with = "deserialize_datetime" + )] pub created_at: DateTime, - #[serde(default = "chrono::Utc::now", deserialize_with = "deserialize_datetime")] + #[serde( + default = "chrono::Utc::now", + deserialize_with = "deserialize_datetime" + )] pub updated_at: DateTime, } @@ -51,9 +57,7 @@ where let bson = bson::Bson::deserialize(deserializer)?; match bson { bson::Bson::DateTime(dt) => Ok(dt.into()), - bson::Bson::String(s) => s - .parse::>() - .map_err(serde::de::Error::custom), + bson::Bson::String(s) => s.parse::>().map_err(serde::de::Error::custom), other => Err(serde::de::Error::custom(format!( "expected DateTime or string, got: {other:?}" ))), diff --git a/compliance-dashboard/src/components/file_tree.rs b/compliance-dashboard/src/components/file_tree.rs index f1a57a1..b62c11d 100644 --- a/compliance-dashboard/src/components/file_tree.rs +++ b/compliance-dashboard/src/components/file_tree.rs @@ -47,17 +47,19 @@ fn insert_path( let name = parts[0].to_string(); let is_leaf = parts.len() == 1; - let entry = children.entry(name.clone()).or_insert_with(|| FileTreeNode { - name: name.clone(), - path: if is_leaf { - full_path.to_string() - } else { - String::new() - }, - is_dir: !is_leaf, - node_count: 0, - children: Vec::new(), - }); + let entry = children + .entry(name.clone()) + .or_insert_with(|| FileTreeNode { + name: name.clone(), + path: if is_leaf { + full_path.to_string() + } else { + String::new() + }, + is_dir: !is_leaf, + node_count: 0, + children: Vec::new(), + }); if is_leaf { entry.node_count = node_count; diff --git a/compliance-dashboard/src/components/toast.rs b/compliance-dashboard/src/components/toast.rs index 627ab0d..13a8f98 100644 --- a/compliance-dashboard/src/components/toast.rs +++ b/compliance-dashboard/src/components/toast.rs @@ -39,11 +39,11 @@ impl Toasts { #[cfg(feature = "web")] { - let mut items = self.items; - spawn(async move { - gloo_timers::future::TimeoutFuture::new(4_000).await; - items.write().retain(|t| t.id != id); - }); + let mut items = self.items; + spawn(async move { + gloo_timers::future::TimeoutFuture::new(4_000).await; + items.write().retain(|t| t.id != id); + }); } } diff --git a/compliance-dashboard/src/infrastructure/dast.rs b/compliance-dashboard/src/infrastructure/dast.rs index c042dd7..9b6fe50 100644 --- a/compliance-dashboard/src/infrastructure/dast.rs +++ b/compliance-dashboard/src/infrastructure/dast.rs @@ -87,10 +87,7 @@ pub async fn fetch_dast_finding_detail( } #[server] -pub async fn add_dast_target( - name: String, - base_url: String, -) -> Result<(), ServerFnError> { +pub async fn add_dast_target(name: String, base_url: String) -> Result<(), ServerFnError> { let state: super::server_state::ServerState = dioxus_fullstack::FullstackContext::extract().await?; let url = format!("{}/api/v1/dast/targets", state.agent_api_url); diff --git a/compliance-dashboard/src/infrastructure/graph.rs b/compliance-dashboard/src/infrastructure/graph.rs index 011c131..68a0d06 100644 --- a/compliance-dashboard/src/infrastructure/graph.rs +++ b/compliance-dashboard/src/infrastructure/graph.rs @@ -121,10 +121,7 @@ pub async fn fetch_file_content( } #[server] -pub async fn search_nodes( - repo_id: String, - query: String, -) -> Result { +pub async fn search_nodes(repo_id: String, query: String) -> Result { let state: super::server_state::ServerState = dioxus_fullstack::FullstackContext::extract().await?; let url = format!( diff --git a/compliance-dashboard/src/pages/findings.rs b/compliance-dashboard/src/pages/findings.rs index 2f06b8e..e6fd390 100644 --- a/compliance-dashboard/src/pages/findings.rs +++ b/compliance-dashboard/src/pages/findings.rs @@ -14,7 +14,9 @@ pub fn FindingsPage() -> Element { let mut repo_filter = use_signal(String::new); let repos = use_resource(|| async { - crate::infrastructure::repositories::fetch_repositories(1).await.ok() + crate::infrastructure::repositories::fetch_repositories(1) + .await + .ok() }); let findings = use_resource(move || { diff --git a/compliance-dast/src/agents/api_fuzzer.rs b/compliance-dast/src/agents/api_fuzzer.rs index e426288..91fa153 100644 --- a/compliance-dast/src/agents/api_fuzzer.rs +++ b/compliance-dast/src/agents/api_fuzzer.rs @@ -234,10 +234,7 @@ impl ApiFuzzerAgent { .ok()?; let headers = response.headers(); - let acao = headers - .get("access-control-allow-origin")? - .to_str() - .ok()?; + let acao = headers.get("access-control-allow-origin")?.to_str().ok()?; if acao == "*" || acao == "https://evil.com" { let acac = headers @@ -265,12 +262,9 @@ impl ApiFuzzerAgent { request_body: None, response_status: response.status().as_u16(), response_headers: Some( - [( - "Access-Control-Allow-Origin".to_string(), - acao.to_string(), - )] - .into_iter() - .collect(), + [("Access-Control-Allow-Origin".to_string(), acao.to_string())] + .into_iter() + .collect(), ), response_snippet: None, screenshot_path: None, diff --git a/compliance-dast/src/agents/auth_bypass.rs b/compliance-dast/src/agents/auth_bypass.rs index ba88fe3..5c48613 100644 --- a/compliance-dast/src/agents/auth_bypass.rs +++ b/compliance-dast/src/agents/auth_bypass.rs @@ -132,7 +132,10 @@ impl DastAgent for AuthBypassAgent { String::new(), target_id.clone(), DastVulnType::AuthBypass, - format!("HTTP method tampering: {} accepted on {}", method, endpoint.url), + format!( + "HTTP method tampering: {} accepted on {}", + method, endpoint.url + ), format!( "Endpoint {} accepts {} requests which may bypass access controls.", endpoint.url, method diff --git a/compliance-dast/src/agents/ssrf.rs b/compliance-dast/src/agents/ssrf.rs index 4cee538..216bca1 100644 --- a/compliance-dast/src/agents/ssrf.rs +++ b/compliance-dast/src/agents/ssrf.rs @@ -20,10 +20,7 @@ impl SsrfAgent { ("http://[::1]", "localhost IPv6"), ("http://0.0.0.0", "zero address"), ("http://169.254.169.254/latest/meta-data/", "AWS metadata"), - ( - "http://metadata.google.internal/", - "GCP metadata", - ), + ("http://metadata.google.internal/", "GCP metadata"), ("http://127.0.0.1:22", "SSH port probe"), ("http://127.0.0.1:3306", "MySQL port probe"), ("http://localhost/admin", "localhost admin"), @@ -91,10 +88,7 @@ impl DastAgent for SsrfAgent { .post(&endpoint.url) .form(&[(param.name.as_str(), payload)]) } else { - let test_url = format!( - "{}?{}={}", - endpoint.url, param.name, payload - ); + let test_url = format!("{}?{}={}", endpoint.url, param.name, payload); self.http.get(&test_url) }; @@ -133,10 +127,7 @@ impl DastAgent for SsrfAgent { String::new(), target_id.clone(), DastVulnType::Ssrf, - format!( - "SSRF ({technique}) via parameter '{}'", - param.name - ), + format!("SSRF ({technique}) via parameter '{}'", param.name), format!( "Server-side request forgery detected in parameter '{}' at {}. \ The application made a request to an internal resource ({}).", diff --git a/compliance-dast/src/agents/xss.rs b/compliance-dast/src/agents/xss.rs index 42e602c..af30649 100644 --- a/compliance-dast/src/agents/xss.rs +++ b/compliance-dast/src/agents/xss.rs @@ -17,26 +17,11 @@ impl XssAgent { fn payloads(&self) -> Vec<(&str, &str)> { vec![ ("", "basic script injection"), - ( - "", - "event handler injection", - ), - ( - "", - "svg event handler", - ), - ( - "javascript:alert(1)", - "javascript protocol", - ), - ( - "'\">", - "attribute breakout", - ), - ( - "", - "body event handler", - ), + ("", "event handler injection"), + ("", "svg event handler"), + ("javascript:alert(1)", "javascript protocol"), + ("'\">", "attribute breakout"), + ("", "body event handler"), ] } } @@ -65,10 +50,7 @@ impl DastAgent for XssAgent { for param in &endpoint.parameters { for (payload, technique) in self.payloads() { let test_url = if endpoint.method == "GET" { - format!( - "{}?{}={}", - endpoint.url, param.name, payload - ) + format!("{}?{}={}", endpoint.url, param.name, payload) } else { endpoint.url.clone() }; diff --git a/compliance-dast/src/crawler/mod.rs b/compliance-dast/src/crawler/mod.rs index 5cbb646..7bcf433 100644 --- a/compliance-dast/src/crawler/mod.rs +++ b/compliance-dast/src/crawler/mod.rs @@ -28,8 +28,8 @@ impl WebCrawler { base_url: &str, excluded_paths: &[String], ) -> Result, CoreError> { - let base = Url::parse(base_url) - .map_err(|e| CoreError::Dast(format!("Invalid base URL: {e}")))?; + let base = + Url::parse(base_url).map_err(|e| CoreError::Dast(format!("Invalid base URL: {e}")))?; let mut visited: HashSet = HashSet::new(); let mut endpoints: Vec = Vec::new(); @@ -95,12 +95,13 @@ impl WebCrawler { let document = Html::parse_document(&body); // Extract links - let link_selector = - Selector::parse("a[href]").unwrap_or_else(|_| Selector::parse("a").expect("valid selector")); + let link_selector = Selector::parse("a[href]") + .unwrap_or_else(|_| Selector::parse("a").expect("valid selector")); for element in document.select(&link_selector) { if let Some(href) = element.value().attr("href") { if let Some(absolute_url) = self.resolve_url(&base, &url, href) { - if self.is_same_origin(&base, &absolute_url) && !visited.contains(&absolute_url) + if self.is_same_origin(&base, &absolute_url) + && !visited.contains(&absolute_url) { queue.push((absolute_url, depth + 1)); } @@ -116,11 +117,7 @@ impl WebCrawler { for form in document.select(&form_selector) { let action = form.value().attr("action").unwrap_or(""); - let method = form - .value() - .attr("method") - .unwrap_or("GET") - .to_uppercase(); + let method = form.value().attr("method").unwrap_or("GET").to_uppercase(); let form_url = self .resolve_url(&base, &url, action) @@ -128,20 +125,12 @@ impl WebCrawler { let mut params = Vec::new(); for input in form.select(&input_selector) { - let name = input - .value() - .attr("name") - .unwrap_or("") - .to_string(); + let name = input.value().attr("name").unwrap_or("").to_string(); if name.is_empty() { continue; } - let input_type = input - .value() - .attr("type") - .unwrap_or("text") - .to_string(); + let input_type = input.value().attr("type").unwrap_or("text").to_string(); let location = if method == "GET" { "query".to_string() diff --git a/compliance-dast/src/orchestrator/state_machine.rs b/compliance-dast/src/orchestrator/state_machine.rs index d5c569f..63e5540 100644 --- a/compliance-dast/src/orchestrator/state_machine.rs +++ b/compliance-dast/src/orchestrator/state_machine.rs @@ -149,11 +149,8 @@ impl DastOrchestrator { let t2 = target.clone(); let c2 = context.clone(); let h2 = http.clone(); - let xss_handle = tokio::spawn(async move { - crate::agents::xss::XssAgent::new(h2) - .run(&t2, &c2) - .await - }); + let xss_handle = + tokio::spawn(async move { crate::agents::xss::XssAgent::new(h2).run(&t2, &c2).await }); let t3 = target.clone(); let c3 = context.clone(); @@ -167,11 +164,10 @@ impl DastOrchestrator { let t4 = target.clone(); let c4 = context.clone(); let h4 = http.clone(); - let ssrf_handle = tokio::spawn(async move { - crate::agents::ssrf::SsrfAgent::new(h4) - .run(&t4, &c4) - .await - }); + let ssrf_handle = + tokio::spawn( + async move { crate::agents::ssrf::SsrfAgent::new(h4).run(&t4, &c4).await }, + ); let t5 = target.clone(); let c5 = context.clone(); @@ -182,8 +178,13 @@ impl DastOrchestrator { .await }); - let handles: Vec, CoreError>>> = - vec![sqli_handle, xss_handle, auth_handle, ssrf_handle, api_handle]; + let handles: Vec, CoreError>>> = vec![ + sqli_handle, + xss_handle, + auth_handle, + ssrf_handle, + api_handle, + ]; let mut all_findings = Vec::new(); for handle in handles { diff --git a/compliance-dast/src/recon/mod.rs b/compliance-dast/src/recon/mod.rs index 68b7d4f..a08db6a 100644 --- a/compliance-dast/src/recon/mod.rs +++ b/compliance-dast/src/recon/mod.rs @@ -81,10 +81,9 @@ impl ReconAgent { ]; for header in &missing_security { if !headers.contains_key(*header) { - result.interesting_headers.insert( - format!("missing:{header}"), - "Not present".to_string(), - ); + result + .interesting_headers + .insert(format!("missing:{header}"), "Not present".to_string()); } } diff --git a/compliance-graph/src/graph/impact.rs b/compliance-graph/src/graph/impact.rs index de8eb22..bd14543 100644 --- a/compliance-graph/src/graph/impact.rs +++ b/compliance-graph/src/graph/impact.rs @@ -26,8 +26,11 @@ impl<'a> ImpactAnalyzer<'a> { file_path: &str, line_number: Option, ) -> ImpactAnalysis { - let mut analysis = - ImpactAnalysis::new(repo_id.to_string(), finding_id.to_string(), graph_build_id.to_string()); + let mut analysis = ImpactAnalysis::new( + repo_id.to_string(), + finding_id.to_string(), + graph_build_id.to_string(), + ); // Find the node containing the finding let target_node = self.find_node_at_location(file_path, line_number); @@ -97,7 +100,11 @@ impl<'a> ImpactAnalyzer<'a> { } /// Find the graph node at a given file/line location - fn find_node_at_location(&self, file_path: &str, line_number: Option) -> Option { + fn find_node_at_location( + &self, + file_path: &str, + line_number: Option, + ) -> Option { let mut best: Option<(NodeIndex, u32)> = None; // (index, line_span) for node in &self.code_graph.nodes { @@ -166,12 +173,7 @@ impl<'a> ImpactAnalyzer<'a> { } /// Find a path from source to target (BFS, limited depth) - fn find_path( - &self, - from: NodeIndex, - to: NodeIndex, - max_depth: usize, - ) -> Option> { + fn find_path(&self, from: NodeIndex, to: NodeIndex, max_depth: usize) -> Option> { let mut visited = HashSet::new(); let mut queue: VecDeque<(NodeIndex, Vec)> = VecDeque::new(); queue.push_back((from, vec![from])); @@ -209,7 +211,10 @@ impl<'a> ImpactAnalyzer<'a> { None } - fn get_node_by_index(&self, idx: NodeIndex) -> Option<&compliance_core::models::graph::CodeNode> { + fn get_node_by_index( + &self, + idx: NodeIndex, + ) -> Option<&compliance_core::models::graph::CodeNode> { let target_gi = idx.index() as u32; self.code_graph .nodes diff --git a/compliance-graph/src/graph/persistence.rs b/compliance-graph/src/graph/persistence.rs index 65c7b10..7ac2017 100644 --- a/compliance-graph/src/graph/persistence.rs +++ b/compliance-graph/src/graph/persistence.rs @@ -211,8 +211,6 @@ impl GraphStore { repo_id: &str, graph_build_id: &str, ) -> Result, CoreError> { - - let filter = doc! { "repo_id": repo_id, "graph_build_id": graph_build_id, diff --git a/compliance-graph/src/parsers/javascript.rs b/compliance-graph/src/parsers/javascript.rs index bfe66d8..0dae26e 100644 --- a/compliance-graph/src/parsers/javascript.rs +++ b/compliance-graph/src/parsers/javascript.rs @@ -51,7 +51,13 @@ impl JavaScriptParser { if let Some(body) = node.child_by_field_name("body") { self.extract_calls( - body, source, file_path, repo_id, graph_build_id, &qualified, output, + body, + source, + file_path, + repo_id, + graph_build_id, + &qualified, + output, ); } } @@ -97,7 +103,12 @@ impl JavaScriptParser { if let Some(body) = node.child_by_field_name("body") { self.walk_children( - body, source, file_path, repo_id, graph_build_id, Some(&qualified), + body, + source, + file_path, + repo_id, + graph_build_id, + Some(&qualified), output, ); } @@ -130,7 +141,13 @@ impl JavaScriptParser { if let Some(body) = node.child_by_field_name("body") { self.extract_calls( - body, source, file_path, repo_id, graph_build_id, &qualified, output, + body, + source, + file_path, + repo_id, + graph_build_id, + &qualified, + output, ); } } @@ -138,7 +155,13 @@ impl JavaScriptParser { // Arrow functions assigned to variables: const foo = () => {} "lexical_declaration" | "variable_declaration" => { self.extract_arrow_functions( - node, source, file_path, repo_id, graph_build_id, parent_qualified, output, + node, + source, + file_path, + repo_id, + graph_build_id, + parent_qualified, + output, ); } "import_statement" => { @@ -183,7 +206,13 @@ impl JavaScriptParser { let mut cursor = node.walk(); for child in node.children(&mut cursor) { self.walk_tree( - child, source, file_path, repo_id, graph_build_id, parent_qualified, output, + child, + source, + file_path, + repo_id, + graph_build_id, + parent_qualified, + output, ); } } @@ -217,7 +246,13 @@ impl JavaScriptParser { let mut cursor = node.walk(); for child in node.children(&mut cursor) { self.extract_calls( - child, source, file_path, repo_id, graph_build_id, caller_qualified, output, + child, + source, + file_path, + repo_id, + graph_build_id, + caller_qualified, + output, ); } } @@ -263,7 +298,12 @@ impl JavaScriptParser { if let Some(body) = value_n.child_by_field_name("body") { self.extract_calls( - body, source, file_path, repo_id, graph_build_id, &qualified, + body, + source, + file_path, + repo_id, + graph_build_id, + &qualified, output, ); } diff --git a/compliance-graph/src/parsers/registry.rs b/compliance-graph/src/parsers/registry.rs index d5f582c..7f3dcc7 100644 --- a/compliance-graph/src/parsers/registry.rs +++ b/compliance-graph/src/parsers/registry.rs @@ -57,10 +57,7 @@ impl ParserRegistry { repo_id: &str, graph_build_id: &str, ) -> Result, CoreError> { - let ext = file_path - .extension() - .and_then(|e| e.to_str()) - .unwrap_or(""); + let ext = file_path.extension().and_then(|e| e.to_str()).unwrap_or(""); let parser_idx = match self.extension_map.get(ext) { Some(idx) => *idx, @@ -89,7 +86,15 @@ impl ParserRegistry { let mut combined = ParseOutput::default(); let mut node_count: u32 = 0; - self.walk_directory(dir, dir, repo_id, graph_build_id, max_nodes, &mut node_count, &mut combined)?; + self.walk_directory( + dir, + dir, + repo_id, + graph_build_id, + max_nodes, + &mut node_count, + &mut combined, + )?; info!( nodes = combined.nodes.len(), @@ -162,8 +167,7 @@ impl ParserRegistry { Err(_) => continue, // Skip binary/unreadable files }; - if let Some(output) = self.parse_file(rel_path, &source, repo_id, graph_build_id)? - { + if let Some(output) = self.parse_file(rel_path, &source, repo_id, graph_build_id)? { *node_count += output.nodes.len() as u32; combined.nodes.extend(output.nodes); combined.edges.extend(output.edges); diff --git a/compliance-graph/src/parsers/rust_parser.rs b/compliance-graph/src/parsers/rust_parser.rs index 2aad595..f05c5c5 100644 --- a/compliance-graph/src/parsers/rust_parser.rs +++ b/compliance-graph/src/parsers/rust_parser.rs @@ -196,9 +196,7 @@ impl RustParser { id: None, repo_id: repo_id.to_string(), graph_build_id: graph_build_id.to_string(), - source: parent_qualified - .unwrap_or(file_path) - .to_string(), + source: parent_qualified.unwrap_or(file_path).to_string(), target: path, kind: CodeEdgeKind::Imports, file_path: file_path.to_string(), @@ -354,10 +352,7 @@ impl RustParser { fn extract_use_path(&self, use_text: &str) -> Option { // "use foo::bar::baz;" -> "foo::bar::baz" - let trimmed = use_text - .strip_prefix("use ")? - .trim_end_matches(';') - .trim(); + let trimmed = use_text.strip_prefix("use ")?.trim_end_matches(';').trim(); Some(trimmed.to_string()) } } diff --git a/compliance-graph/src/parsers/typescript.rs b/compliance-graph/src/parsers/typescript.rs index 2e3d0e9..8f3f15a 100644 --- a/compliance-graph/src/parsers/typescript.rs +++ b/compliance-graph/src/parsers/typescript.rs @@ -49,7 +49,13 @@ impl TypeScriptParser { if let Some(body) = node.child_by_field_name("body") { self.extract_calls( - body, source, file_path, repo_id, graph_build_id, &qualified, output, + body, + source, + file_path, + repo_id, + graph_build_id, + &qualified, + output, ); } } @@ -80,12 +86,23 @@ impl TypeScriptParser { // Heritage clause (extends/implements) self.extract_heritage( - &node, source, file_path, repo_id, graph_build_id, &qualified, output, + &node, + source, + file_path, + repo_id, + graph_build_id, + &qualified, + output, ); if let Some(body) = node.child_by_field_name("body") { self.walk_children( - body, source, file_path, repo_id, graph_build_id, Some(&qualified), + body, + source, + file_path, + repo_id, + graph_build_id, + Some(&qualified), output, ); } @@ -143,14 +160,26 @@ impl TypeScriptParser { if let Some(body) = node.child_by_field_name("body") { self.extract_calls( - body, source, file_path, repo_id, graph_build_id, &qualified, output, + body, + source, + file_path, + repo_id, + graph_build_id, + &qualified, + output, ); } } } "lexical_declaration" | "variable_declaration" => { self.extract_arrow_functions( - node, source, file_path, repo_id, graph_build_id, parent_qualified, output, + node, + source, + file_path, + repo_id, + graph_build_id, + parent_qualified, + output, ); } "import_statement" => { @@ -172,7 +201,13 @@ impl TypeScriptParser { } self.walk_children( - node, source, file_path, repo_id, graph_build_id, parent_qualified, output, + node, + source, + file_path, + repo_id, + graph_build_id, + parent_qualified, + output, ); } @@ -189,7 +224,13 @@ impl TypeScriptParser { let mut cursor = node.walk(); for child in node.children(&mut cursor) { self.walk_tree( - child, source, file_path, repo_id, graph_build_id, parent_qualified, output, + child, + source, + file_path, + repo_id, + graph_build_id, + parent_qualified, + output, ); } } @@ -223,7 +264,13 @@ impl TypeScriptParser { let mut cursor = node.walk(); for child in node.children(&mut cursor) { self.extract_calls( - child, source, file_path, repo_id, graph_build_id, caller_qualified, output, + child, + source, + file_path, + repo_id, + graph_build_id, + caller_qualified, + output, ); } } @@ -269,7 +316,12 @@ impl TypeScriptParser { if let Some(body) = value_n.child_by_field_name("body") { self.extract_calls( - body, source, file_path, repo_id, graph_build_id, &qualified, + body, + source, + file_path, + repo_id, + graph_build_id, + &qualified, output, ); } diff --git a/compliance-graph/src/search/index.rs b/compliance-graph/src/search/index.rs index 435685a..c5e6534 100644 --- a/compliance-graph/src/search/index.rs +++ b/compliance-graph/src/search/index.rs @@ -89,8 +89,10 @@ impl SymbolIndex { .map_err(|e| CoreError::Graph(format!("Failed to create reader: {e}")))?; let searcher = reader.searcher(); - let query_parser = - QueryParser::for_index(&self.index, vec![self.name_field, self.qualified_name_field]); + let query_parser = QueryParser::for_index( + &self.index, + vec![self.name_field, self.qualified_name_field], + ); let query = query_parser .parse_query(query_str)