gqlprobe 1.0.0

Fast GraphQL security scanner - schema-aware introspection, injection, DoS, CSRF, auth bypass, SARIF
Documentation
//! # gqlprobe
//!
//! GraphQL security scanner - detect introspection, query depth `DoS`,
//! batching abuse, field suggestion enumeration, directive abuse,
//! injection vulnerabilities, CSRF, subscription abuse, information
//! disclosure, and authentication bypass.
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use gqlprobe::Scanner;
//!
//! # async fn example() -> anyhow::Result<()> {
//! let scanner = Scanner::new("https://api.example.com/graphql")?;
//! let findings = scanner.scan().await?;
//! for finding in &findings {
//!     println!("{}", finding.title());
//! }
//! # Ok(())
//! # }
//! ```
//!
//! ## Safe defaults
//!
//! gqlprobe ships with conservative defaults designed to avoid
//! accidentally overwhelming targets or leaking data:
//!
//! - **Input size:** No hardcoded response-body cap in gqlprobe itself.
//!   `serde_json` enforces its own recursion limit (~128 levels); deeply
//!   nested payloads beyond that fall back to the iterative
//!   `compute_depth_nonrecursive` parser, which reads the body character by
//!   character without allocating the full parse tree. Request bodies sent
//!   by gqlprobe are small, bounded GraphQL queries generated internally.
//! - **Recursion depth:** All JSON depth calculations use an explicit
//!   stack (`max_depth`) or a character-scan loop (`compute_depth_nonrecursive`).
//!   There is no recursive descent that could overflow the call stack on
//!   adversarial input.
//! - **Outbound network:** Connections are made exclusively to the single
//!   target URL supplied by the caller. No callbacks, no second-party
//!   lookups, no DNS rebinding. TLS certificate verification is enabled by
//!   default; pass `--insecure` / `http_config.accept_invalid_certs` only
//!   for lab use.
//! - **Process spawning:** None. The `std::process` import in `main.rs`
//!   is used solely for `process::exit()`; no `Command::new()` or
//!   shell execution occurs anywhere in the codebase.
//! - **Filesystem writes:** None. All output (human / JSON / JSONL / SARIF)
//!   is written to stdout. No temporary files, no log files, no on-disk state.
//! - **Credential exposure:** The `scrub_evidence` utility redacts lines
//!   containing `Authorization:`, `Bearer `, `token:`, `api-key:`,
//!   `password:`, or `secret:`, and masks email addresses, before they
//!   are embedded in finding evidence strings.
//!
//! Use [`ScannerBuilder`] or CLI flags to override the scan-timing defaults
//! (global timeout 300 s, module timeout 60 s, max concurrency 5).

#![forbid(unsafe_code)]
#![warn(missing_docs)]
#![warn(clippy::pedantic)]
#![cfg_attr(
    not(test),
    deny(
        clippy::unwrap_used,
        clippy::expect_used,
        clippy::todo,
        clippy::unimplemented,
        clippy::panic
    )
)]
#![allow(
    clippy::module_name_repetitions,
    clippy::must_use_candidate,
    clippy::missing_errors_doc,
    clippy::missing_panics_doc
)]

pub mod baseline;
pub mod cli;
pub mod context;
pub mod modules;
pub mod parsers;
pub mod scanner;
pub mod schema;
pub(crate) mod util;

#[doc(hidden)]
pub use util::scrub_evidence;

/// Re-export commonly used types.
pub use baseline::EndpointBaseline;
pub use context::ScanContext;
pub use scanner::{ScanConfig, Scanner, ScannerBuilder};
pub use schema::SchemaGraph;

/// Prelude module for convenient imports.
pub mod prelude {
    /// Re-export scanner types.
    pub use crate::scanner::{Scanner, ScannerBuilder};
}