pub mod analyzer;
pub mod baseline;
pub mod hardware;
pub mod profiler;
pub mod security;
pub mod verifier;
pub use analyzer::{Analysis, WasmAnalyzer};
pub use baseline::{QualityAssessment, QualityBaseline, Violation};
pub use hardware::{CacheClass, CoreClass, HardwareClass};
pub use profiler::{AsyncProfiler, ShadowStack};
pub use security::{PatternDetector, VulnerabilityMatch, VulnerabilityPattern};
pub use verifier::{IncrementalVerifier, VerificationResult};
use anyhow::Result;
use serde::{Deserialize, Serialize};
pub async fn analyze_wasm_module(binary: &[u8]) -> Result<Analysis> {
let analyzer = WasmAnalyzer::new()?;
analyzer.analyze_streaming(binary)
}
pub fn verify_wasm_safety(binary: &[u8]) -> Result<VerificationResult> {
let verifier = IncrementalVerifier::new()?;
verifier.verify_module(binary)
}
pub async fn profile_wasm_module(binary: &[u8]) -> Result<ProfilingReport> {
let profiler = AsyncProfiler::new();
profiler.profile_module(binary).await
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProfilingReport {
pub instruction_mix: InstructionMix,
pub hot_functions: Vec<HotFunction>,
pub memory_usage: MemoryProfile,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct InstructionMix {
pub total_instructions: usize,
pub control_flow: usize,
pub memory_ops: usize,
pub arithmetic: usize,
pub calls: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HotFunction {
pub name: String,
pub samples: usize,
pub percentage: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MemoryProfile {
pub initial_pages: u32,
pub max_pages: Option<u32>,
pub growth_events: Vec<GrowthEvent>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GrowthEvent {
pub timestamp: u64,
pub pages_before: u32,
pub pages_after: u32,
}
#[cfg(test)]
mod property_tests {
use proptest::prelude::*;
proptest! {
#[test]
fn basic_property_stability(_input in ".*") {
prop_assert!(true);
}
#[test]
fn module_consistency_check(_x in 0u32..1000) {
prop_assert!(_x < 1001);
}
}
}