gqlprobe 1.0.0

Fast GraphQL security scanner - schema-aware introspection, injection, DoS, CSRF, auth bypass, SARIF
Documentation
//! Internal utility functions for gqlprobe.

/// Scrub potentially sensitive data from evidence strings before storage.
///
/// Redacts common credential patterns and email addresses
/// to prevent findings from leaking sensitive information.
///
/// Note: This is a best-effort heuristic scrubber. For production use
/// with strict data-protection requirements, consider a regex-based
/// approach or post-processing findings before export.
pub fn scrub_evidence(input: &str) -> String {
    let mut result = input.to_string();

    // Simple heuristic: redact lines that look like they contain credentials
    let lines: Vec<String> = result
        .lines()
        .map(|line| {
            let lower = line.to_lowercase();
            if lower.contains("authorization:")
                || lower.contains("bearer ")
                || lower.contains("token:")
                || lower.contains("api-key:")
                || lower.contains("password:")
                || lower.contains("secret:")
            {
                let pos = line
                    .find(':')
                    .unwrap_or(line.find(' ').unwrap_or(line.len()));
                format!("{}: [REDACTED]", &line[..pos])
            } else {
                line.to_string()
            }
        })
        .collect();

    result = lines.join("\n");

    // Redact email addresses (simple heuristic)
    let mut output = String::with_capacity(result.len());
    for word in result.split_whitespace() {
        if word.contains('@') && word.contains('.') {
            output.push_str("[EMAIL_REDACTED] ");
        } else {
            output.push_str(word);
            output.push(' ');
        }
    }

    output.trim_end().to_string()
}