nabla_cli/binary/
mod.rs

1// src/binary/mod.rs
2pub mod binary_analysis;
3pub mod metadata_extractor;
4pub mod scanner;
5
6pub use self::binary_analysis::analyze_binary;
7pub use self::metadata_extractor::{
8    LicenseInfo, VersionInfo, extract_license_info, extract_version_info,
9};
10pub use self::scanner::{ScanResult, enterprise_scan_binary, scan_binary};
11
12use chrono::{DateTime, Utc};
13use serde::{Deserialize, Serialize};
14use uuid::Uuid;
15
16#[derive(Debug, Serialize, Deserialize, Clone)]
17pub struct CodeSection {
18    pub name: String,
19    pub start_address: u64,
20    pub end_address: u64,
21    pub size: u64,
22    pub permissions: String, // e.g., "r-x", "rw-", etc.
23    pub section_type: CodeSectionType,
24}
25
26#[derive(Debug, Serialize, Deserialize, Clone)]
27pub enum CodeSectionType {
28    Text,   // Executable code
29    Data,   // Initialized data
30    Bss,    // Uninitialized data
31    Rodata, // Read-only data
32    Other(String),
33}
34
35#[derive(Debug, Serialize, Deserialize, Clone)]
36pub struct BinaryAnalysis {
37    pub id: Uuid,
38    pub file_name: String,
39    pub format: String,
40    pub architecture: String,
41    pub languages: Vec<String>,
42    pub detected_symbols: Vec<String>,
43    pub embedded_strings: Vec<String>,
44    pub suspected_secrets: Vec<String>,
45    pub imports: Vec<String>,
46    pub exports: Vec<String>,
47    pub hash_sha256: String,
48    pub hash_blake3: Option<String>,
49    pub size_bytes: u64,
50    pub linked_libraries: Vec<String>,
51    pub static_linked: bool,
52    pub version_info: Option<VersionInfo>,
53    pub license_info: Option<LicenseInfo>,
54    pub metadata: serde_json::Value,
55    pub created_at: DateTime<Utc>,
56    pub sbom: Option<serde_json::Value>,
57    // Binary data for advanced analysis (CFG, disassembly, etc.)
58    // Note: This field is marked with serde(skip) to avoid serialization overhead
59    #[serde(skip)]
60    pub binary_data: Option<Vec<u8>>,
61    // Entry point information for CFG construction
62    pub entry_point: Option<String>,
63    // Code sections for targeted analysis
64    pub code_sections: Vec<CodeSection>,
65}