Skip to main content

sdkt_audit/
lib.rs

1//! `sdkt-audit` — static security analysis for Soroban contracts (Gap C).
2//!
3//! Offline, source-based heuristics for Soroban-specific logic/security bugs
4//! the Rust compiler does not catch (missing auth, unauthenticated cross-contract
5//! calls, unguarded initialize, suspicious move-after-use). No networking.
6//!
7//! ## Plugin authoring
8//!
9//! Implement [`AuditRule`], then register your rule with [`register_rule`] (or the
10//! [`register_rule!`](crate::register_rule) macro). Built-in rules register
11//! through the same [`RuleRegistry`]. See `docs/plugin-authoring.md`.
12
13pub mod audit;
14pub mod error;
15pub mod plugin_abi;
16pub mod plugin_doctor;
17pub mod plugin_store;
18pub mod registry;
19pub mod rules;
20pub mod sarif;
21pub mod types;
22
23#[cfg(feature = "plugins")]
24pub mod plugin_loader;
25
26#[cfg(feature = "wasm-plugins")]
27pub mod plugin_abi_wasm;
28#[cfg(feature = "wasm-plugins")]
29pub mod plugin_loader_wasm;
30
31pub use audit::{
32    all_rules, audit_source, audit_source_with, audit_source_with_registry, audit_source_with_spec,
33    scan_all_functions, scan_all_functions_str, AuditContext, AuditRule, FnScan,
34};
35pub use error::AuditError;
36pub use plugin_doctor::{
37    doctor, doctor_installed, doctor_installed_with_root, doctor_with_root, DoctorReport,
38    DoctorStage, DoctorStageStatus, DOCTOR_SAMPLE_CONTRACT,
39};
40pub use plugin_store::{
41    install_bundle, install_bundle_with_key, pack_bundle, verify_bundle, BundleVerification,
42    InstallOpts, PluginMeta, StoreError,
43};
44pub use registry::{
45    register_builtin_rules, register_rule, run_registered, BoxedRule, RuleRegistry,
46};
47pub use rules::{Auth001, Auth002, Auth003, Auth004, Move001};
48pub use sarif::{
49    report_to_sarif_string, report_to_sarif_string_multi_file, to_sarif, to_sarif_multi_file,
50    SarifLog,
51};
52pub use types::{AuditReport, AuditSummary, Finding, RuleInfo, Severity};
53
54#[cfg(feature = "plugins")]
55pub use plugin_loader::{load_and_register, PluginLoadError, PluginRule};
56
57#[cfg(feature = "wasm-plugins")]
58pub use plugin_loader_wasm::{load_and_register_wasm, WasmPluginLoadError, WasmPluginRule};
59
60/// Register a rule into the process-wide [`RuleRegistry`].
61///
62/// # Example
63/// ```ignore
64/// sdkt_audit::register_rule!(MyRule);
65/// ```
66#[macro_export]
67macro_rules! register_rule {
68    ($rule:expr) => {
69        $crate::registry::register_rule(::std::boxed::Box::new($rule))
70    };
71}