All Toolsโ€บAI Privacy Audit
๐Ÿ”ง AI Model Privacy LeaksJuly 8, 2026โœ… Tests passing

AI Privacy Audit

A CLI library that scans AI system logs or outputs for sensitive data exposure, including private user data or confidential information. It performs advanced pattern matching and semantic checks to identify leaks that generic tools might miss.

What It Does

The AI Privacy Audit Tool scans AI system logs or outputs for sensitive data exposure, including private user data or confidential information. It performs advanced pattern matching and semantic checks to identify leaks that generic tools might miss.

Installation

1. Install the required Python packages:

pip install regex spacy

2. Download the spaCy language model:

python -m spacy download en_core_web_sm

Usage

Run the tool from the command line:

python ai_privacy_audit.py --logfile <path_to_log_file> --pii-check

Arguments

  • --logfile: Path to the log file to scan.
  • --pii-check: Enable PII detection.

Source Code

import argparse
import regex as re
import spacy
import sys

def load_spacy_model():
    try:
        return spacy.load("en_core_web_sm")
    except Exception as e:
        raise RuntimeError("Failed to load spaCy model. Ensure 'en_core_web_sm' is installed.")

def detect_pii(text, nlp):
    sensitive_patterns = {
        "email": r"[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+",
        "phone": r"\b\d{10}\b|\b\d{3}-\d{3}-\d{4}\b",
        "credit_card": r"\b\d{4}-\d{4}-\d{4}-\d{4}\b|\b\d{16}\b"
    }

    flagged_items = []

    for label, pattern in sensitive_patterns.items():
        matches = re.findall(pattern, text)
        flagged_items.extend([(label, match.strip().rstrip('.')) for match in matches])

    doc = nlp(text)
    for ent in doc.ents:
        if ent.label_ in ["PERSON", "ORG", "GPE"]:
            flagged_items.append((ent.label_, ent.text.strip()))

    return flagged_items

def scan_file(file_path, pii_check):
    try:
        with open(file_path, "r", encoding="utf-8") as f:
            content = f.read()
    except FileNotFoundError:
        raise FileNotFoundError(f"File not found: {file_path}")

    nlp = load_spacy_model()
    if pii_check:
        return detect_pii(content, nlp)
    return []

def main():
    parser = argparse.ArgumentParser(description="AI Privacy Audit Tool")
    parser.add_argument("--logfile", type=str, help="Path to the log file to scan.")
    parser.add_argument("--pii-check", action="store_true", help="Enable PII detection.")

    args = parser.parse_args()

    if not args.logfile:
        print("Error: --logfile argument is required.", file=sys.stderr)
        sys.exit(1)

    try:
        results = scan_file(args.logfile, args.pii_check)
        if results:
            print("Sensitive data found:")
            for label, item in results:
                print(f"- {label}: {item}")
        else:
            print("No sensitive data found.")
    except Exception as e:
        print(f"Error: {e}", file=sys.stderr)
        sys.exit(1)

if __name__ == "__main__":
    main()

Community

Downloads

ยทยทยท

Rate this tool

No ratings yet โ€” be the first!

Details

Tool Name
ai_privacy_audit
Category
AI Model Privacy Leaks
Generated
July 8, 2026
Tests
Passing โœ…
Fix Loops
4

Quick Install

Clone just this tool:

git clone --depth 1 --filter=blob:none --sparse \
  https://github.com/ptulin/autoaiforge.git
cd autoaiforge
git sparse-checkout set generated_tools/2026-07-08/ai_privacy_audit
cd generated_tools/2026-07-08/ai_privacy_audit
pip install -r requirements.txt 2>/dev/null || true
python ai_privacy_audit.py
AI Privacy Audit โ€” AI Tools by AutoAIForge