Skip to content

Commit 6448e11

Browse files
Copilotlarp0
andcommitted
Fix cargo fmt and clippy formatting issues
Co-authored-by: larp0 <[email protected]>
1 parent 8a03584 commit 6448e11

File tree

4 files changed

+72
-21
lines changed

4 files changed

+72
-21
lines changed

src/services/audit_service.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,10 @@ impl AuditService {
299299
self.coordinator
300300
.generate_markdown_summary(&report, &markdown_path)
301301
.map_err(|e| {
302-
AuditError::OutputError(format!("Failed to generate Markdown summary: {}", e))
302+
AuditError::OutputError(format!(
303+
"Failed to generate Markdown summary: {}",
304+
e
305+
))
303306
})?;
304307

305308
if request.verbose > 0 {

src/utils/audit.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,15 +1276,24 @@ impl AuditCoordinator {
12761276
ai_successes,
12771277
ai_failures
12781278
);
1279-
1279+
12801280
// Provide user-facing feedback about AI analysis status
12811281
if ai_failures > ai_successes {
1282-
println!("⚠️ AI analysis partially unavailable ({} failures, {} successes)", ai_failures, ai_successes);
1282+
println!(
1283+
"⚠️ AI analysis partially unavailable ({} failures, {} successes)",
1284+
ai_failures, ai_successes
1285+
);
12831286
println!(" Manual review is recommended for enhanced security insights");
12841287
} else if ai_failures > 0 {
1285-
println!("ℹ️ AI analysis completed with some failures ({} failures, {} successes)", ai_failures, ai_successes);
1288+
println!(
1289+
"ℹ️ AI analysis completed with some failures ({} failures, {} successes)",
1290+
ai_failures, ai_successes
1291+
);
12861292
} else {
1287-
println!("✅ AI analysis completed successfully for {} findings", ai_successes);
1293+
println!(
1294+
"✅ AI analysis completed successfully for {} findings",
1295+
ai_successes
1296+
);
12881297
}
12891298
}
12901299

@@ -5787,7 +5796,11 @@ impl AuditCoordinator {
57875796
}
57885797

57895798
/// Generate Markdown summary using template system
5790-
pub fn generate_markdown_summary(&self, report: &AuditReport, output_path: &Path) -> Result<()> {
5799+
pub fn generate_markdown_summary(
5800+
&self,
5801+
report: &AuditReport,
5802+
output_path: &Path,
5803+
) -> Result<()> {
57915804
self.template_generator
57925805
.generate_markdown_summary(report, output_path)
57935806
}

src/utils/audit_modular.rs

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,9 @@ impl FindingIdAllocator {
165165
.as_nanos()
166166
.hash(&mut hasher);
167167
std::thread::current().id().hash(&mut hasher);
168-
FINDING_ID_COUNTER.fetch_add(1, Ordering::SeqCst).hash(&mut hasher);
168+
FINDING_ID_COUNTER
169+
.fetch_add(1, Ordering::SeqCst)
170+
.hash(&mut hasher);
169171
category.hash(&mut hasher);
170172

171173
let hash = hasher.finish();
@@ -191,7 +193,9 @@ impl FindingIdAllocator {
191193
.as_nanos()
192194
.hash(&mut hasher);
193195
std::thread::current().id().hash(&mut hasher);
194-
FINDING_ID_COUNTER.fetch_add(1, Ordering::SeqCst).hash(&mut hasher);
196+
FINDING_ID_COUNTER
197+
.fetch_add(1, Ordering::SeqCst)
198+
.hash(&mut hasher);
195199

196200
let hash = hasher.finish();
197201
format!("OSVM-{:016x}", hash)
@@ -572,10 +576,21 @@ impl SolanaSecurityCheck {
572576
fn is_likely_solana_key(&self, value: &str, context: &str) -> bool {
573577
// Skip common false positives
574578
let false_positive_indicators = [
575-
"test", "mock", "example", "dummy", "placeholder", "lorem", "ipsum",
576-
"comment", "doc", "readme", "license", "copyright", "author"
579+
"test",
580+
"mock",
581+
"example",
582+
"dummy",
583+
"placeholder",
584+
"lorem",
585+
"ipsum",
586+
"comment",
587+
"doc",
588+
"readme",
589+
"license",
590+
"copyright",
591+
"author",
577592
];
578-
593+
579594
let context_lower = context.to_lowercase();
580595
for indicator in &false_positive_indicators {
581596
if context_lower.contains(indicator) {
@@ -585,11 +600,26 @@ impl SolanaSecurityCheck {
585600

586601
// Look for Solana-specific context clues
587602
let solana_indicators = [
588-
"pubkey", "program_id", "account", "signer", "authority", "mint",
589-
"token", "pda", "system_program", "spl_token", "metaplex", "anchor",
590-
"lamports", "rent", "solana", "devnet", "mainnet", "testnet"
603+
"pubkey",
604+
"program_id",
605+
"account",
606+
"signer",
607+
"authority",
608+
"mint",
609+
"token",
610+
"pda",
611+
"system_program",
612+
"spl_token",
613+
"metaplex",
614+
"anchor",
615+
"lamports",
616+
"rent",
617+
"solana",
618+
"devnet",
619+
"mainnet",
620+
"testnet",
591621
];
592-
622+
593623
for indicator in &solana_indicators {
594624
if context_lower.contains(indicator) {
595625
return true;
@@ -613,8 +643,9 @@ impl SolanaSecurityCheck {
613643
// Check for potential base58 encoded Solana public keys
614644
if Self::is_valid_base58_pubkey(&string_lit.value) {
615645
// Reduce false positives by checking context
616-
let is_likely_key = self.is_likely_solana_key(&string_lit.value, &string_lit.context);
617-
646+
let is_likely_key =
647+
self.is_likely_solana_key(&string_lit.value, &string_lit.context);
648+
618649
if is_likely_key {
619650
findings.push(AuditFinding {
620651
id: FindingIdAllocator::next_category_id("solana"),
@@ -1168,7 +1199,7 @@ mod tests {
11681199
assert!(id1.starts_with("OSVM-") && id1.len() == 21); // OSVM- + 16 hex chars
11691200
assert!(id2.starts_with("OSVM-") && id2.len() == 21);
11701201
assert!(id3.starts_with("OSVM-SOL-") && id3.len() == 25); // OSVM-SOL- + 16 hex chars
1171-
1202+
11721203
// IDs should be different
11731204
assert_ne!(id1, id2);
11741205
assert_ne!(id1, id3);

src/utils/audit_templates.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ impl EnhancedAIErrorHandler {
232232
pub fn new() -> Self {
233233
Self {
234234
last_error_log: std::sync::Arc::new(std::sync::Mutex::new(
235-
std::time::Instant::now() - std::time::Duration::from_secs(60)
235+
std::time::Instant::now() - std::time::Duration::from_secs(60),
236236
)),
237237
error_log_threshold: std::time::Duration::from_secs(30), // Log at most once every 30 seconds
238238
}
@@ -254,12 +254,16 @@ impl EnhancedAIErrorHandler {
254254
}
255255

256256
/// Handle AI analysis error with comprehensive but rate-limited logging
257-
pub fn handle_ai_error_with_context(&self, error: &anyhow::Error, context: &str) -> Option<String> {
257+
pub fn handle_ai_error_with_context(
258+
&self,
259+
error: &anyhow::Error,
260+
context: &str,
261+
) -> Option<String> {
258262
// Always log the first occurrence or after the threshold period
259263
if self.should_log_error() {
260264
log::error!("AI Analysis Error in {}: {}", context, error);
261265
log::warn!("AI error logging rate-limited to prevent log flooding");
262-
266+
263267
// Log the full error chain for detailed diagnostics
264268
let mut current_error = error.source();
265269
let mut error_level = 1;

0 commit comments

Comments
 (0)