Repository navigation
Expand file tree
/
Copy pathlib.rs
More file actions
70 lines (66 loc) · 2.3 KB
/
Copy pathlib.rs
File metadata and controls
70 lines (66 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//! ShellMind Guard (`smg`) root library wiring.
//!
//! Decomposed into focused modules (Phase 2 / Q111):
//! - `cli`: Clap CLI definitions and output/palette types
//! - `baseline`: v2 finding fingerprinting, inline `smg-ignore` & baseline suppressions
//! - `pipeline`: Multi-layer scan orchestration, persistence & verification wiring
//! - `render`: Terminal, JSON, SARIF, HTML & patch output formatters
//! - `hooks`: Git pre-commit hooks, Claude Code PreToolUse gate & `smg doctor`
//! - `commands`: Top-level CLI command dispatchers
//! - `mcp`: Read-only/hardened stdio MCP server
//! - `rules_catalog`: Canonical rule docs & shell completion renderer
//! - `smg_dynamic`: Re-exported network/dynamic/OCI/OSV engines
mod baseline;
mod cli;
mod commands;
mod hooks;
mod mcp;
mod pipeline;
mod render;
mod rules_catalog;
#[cfg(test)]
mod tests;
pub use commands::run_cli;
pub use smg_dynamic::{
cdp_engine, dast_audit, deps_sync, http_audit, idor_audit, live_verify, oci_image, oob_server,
proxy, proxy_mitm, safe_http, sqli_audit, templates_audit, tls_audit,
};
/// Runs the CLI on a dedicated 16 MiB stack thread (preventing 1 MiB main-thread stack overflows
/// on Windows builds) and maps runtime/IO/config errors to POSIX exit code `2` (`Q126`:
/// `0` = clean, `1` = policy findings, `2` = CLI/config/IO error).
pub fn run_cli_entry() -> std::process::ExitCode {
const CLI_STACK_BYTES: usize = 16 * 1024 * 1024;
let res = match std::thread::Builder::new()
.name("smg-main".into())
.stack_size(CLI_STACK_BYTES)
.spawn(run_cli)
{
Ok(handle) => match handle.join() {
Ok(inner) => inner,
Err(_) => {
eprintln!("Error: smg main thread panicked unexpectedly");
return std::process::ExitCode::from(2);
}
},
Err(_) => run_cli(),
};
match res {
Ok(code) => code,
Err(err) => {
eprintln!("Error: {err:#}");
std::process::ExitCode::from(2)
}
}
}
#[allow(unused_imports)]
pub(crate) use baseline::*;
#[allow(unused_imports)]
pub(crate) use cli::*;
#[allow(unused_imports)]
pub(crate) use commands::*;
#[allow(unused_imports)]
pub(crate) use hooks::*;
#[allow(unused_imports)]
pub(crate) use pipeline::*;
#[allow(unused_imports)]
pub(crate) use render::*;