Automate Privacy Leak Detection for Your Projects — Weekly Security Scan in 15 Minutes

Difficulty: IntermediateTime: 15 minutes setup, then fully automated

The Problem

You have projects with dozens of files: markdown articles, JSON workflow exports, Python scripts, config files. Any one of them can accidentally contain:

  • A real email address in a test workflow JSON
  • A pipeline token hardcoded in an importable file
  • A client or company name in a project description
  • An API key left in a committed config
  • A server IP address in infrastructure docs
  • The problem isn't that these leaks happen — it's that you won't know until someone finds them. A leaked credential in a public repo or dashboard can cost $5,000 to $50,000+ in damages, depending on the exposure.

    Manual audits don't work. You forget. You get busy. And the one time you skip it is the one time something slips through.

    This workflow gives you a fully automated privacy scanner that runs weekly, alerts you immediately if anything changes, and costs exactly $0.


    The Stack

    ToolWhat It DoesCost
    bash + grepPattern matching for emails, phones, keys, IPsFree
    Python 3JSON parsing for credential references in n8n workflowsFree
    cronWeekly automated schedule (Sundays at 3am)Free
    n8n (self-hosted)Webhook-triggered on-demand scans + email alertsFree
    systemdKeeps the webhook server runningFree

    Total cost: $0 — all tools are built-in or free.


    Step 1: Understand What You're Scanning For

    Before building the scanner, here are the categories of private data to detect:

    CategoryWhat It CatchesExample
    📧 Non-Project EmailsExternal email addresses in files`service@client.com` in a workflow JSON
    📞 Phone NumbersUS/International phone formats`555-123-4567` in a config file
    🔑 API Keys / TokensKnown key formats (sk-, AKIA, ghp_, xox-)`sk-proj-abc123...` in a script
    🆔 n8n Credential IDsCredential references in JSON exports`credential ID "2"` in a workflow file
    🔐 Passwords / Secrets`password=`, `secret=`, `token=` assignments`password=supersecret123` in a .env
    🌐 Embedded URL CredsURLs containing `user:pass@``https://admin:pass@api.example.com`
    🏢 Company / Client Names`client:`, `company:` fields with real names`company: ALSEC` in a dashboard
    🌍 Public IP AddressesNon-private IPs in infrastructure docsServer IPs, API endpoint IPs

    Each category gets its own scan function, making the system modular and easy to extend.


    Step 2: Build the Scanner Script

    **[📸 SCREENSHOT: Terminal showing the check-priv script output with colored sections]**

    Create a single bash script called `check-privacy.sh` that runs all scans and generates a markdown report.

    Scan Functions

    Each scan uses `find` + `grep` with smart exclusions:

    
    # Scan for emails (excludes project-owned domains and placeholders)
    
    check_emails() {
    
      find "$TARGET" -type f \( -name '*.md' -o -name '*.json' -o -name '*.py' ... \) \
    
        ! -path '*/node_modules/*' ! -path '*/.git/*' \
    
        -exec grep -HnoE '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}' {} + \
    
        | grep -vi 'example\.com\|your@\|test@\|@domain\|flowforge@toolyft.com'
    
    }
    
    

    The key patterns:

    Data TypeRegex Pattern
    Email`[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}`
    Phone`\b[0-9]{3}[-.][0-9]{3}[-.][0-9]{4}\b`
    API Key`sk-[A-Za-z0-9]{10,}` or `AKIA[0-9A-Z]{16}`
    IP Address`\b([0-9]{1,3}\.){3}[0-9]{1,3}\b`
    URL Creds`https?://[^:]+:[^@]+@`
    Company Name`(client\company\vendor)\s[:=]\s[A-Z][A-Za-z]+`

    Exclusion Lists

    Equally important is what not to flag:

  • Own project emails — `flowforge@toolyft.com`, `briefs@flowforge.toolyft.com`
  • Private IPs — `10.x`, `192.168.x`, `172.16-31.x`, `127.0.0.1`
  • Your server IP — Add your public IP to the exclusion list
  • Placeholder values — `example.com`, `test@`, `your_`, `NEW_SHEET`
  • n8n UUIDs — Node IDs and credential UUIDs (not real secrets)
  • The scanner script itself — It contains regex patterns that look like credentials
  • Report Format

    The script generates a timestamped markdown report:

    
    # Privacy Scan Report — 2026-06-20 02:16
    
    Target: /home/user/projects
    
    
    
    ## 📧 Non-Project Emails
    
    ✅ None found
    
    
    
    ## 🏢 Company / Client Names
    
    ✅ None found
    
    
    
    ---
    
    
    
    ✅ Result: CLEAN — no privacy issues detected
    
    

    Reports are saved to `~/project-privacy-reports/report-YYYY-MM-DD.md` for historical tracking.

    Quiet Mode for Automation

    A `--quiet` flag makes the script return exit codes only — 0 for clean, 1+ for issues found. This is what cron and n8n use:

    
    check-priv --quiet && echo "Clean" || echo "Issues found"
    
    

    Step 3: Install and Run Your First Scan

    
    # Make executable
    
    chmod +x scripts/check-privacy.sh
    
    
    
    # Install as global command
    
    sudo ln -sf $(pwd)/scripts/check-privacy.sh /usr/local/bin/check-priv
    
    
    
    # Run your first scan
    
    check-priv
    
    
    
    # Quick check only
    
    check-priv --quiet; echo "Exit: $?"
    
    
    
    # View last report
    
    check-priv --report
    
    

    On first run, expect some false positives — that's normal. Add exclusions for:

  • Your project's own domain emails
  • Your server's public IP (it's in DNS anyway)
  • n8n credential IDs that are database references, not secrets
  • Tune the exclusion lists in the script until `--quiet` returns 0. Then automation begins.


    Step 4: Automate with cron

    **[📸 SCREENSHOT: crontab -l showing the weekly schedule]**

    Add a weekly cron job to scan every Sunday at 3am:

    
    # Open crontab
    
    crontab -e
    
    
    
    # Add this line:
    
    0 3 * * 0 /usr/local/bin/check-priv --quiet && \
    
      echo "[$(date)] ✅ Clean" >> /tmp/check-priv-history.log || \
    
      echo "[$(date)] ⚠️ Issues found" >> /tmp/check-priv-history.log
    
    

    The log file accumulates a running history:

    
    [Sat Jun 20 03:00:01 UTC 2026] ✅ Clean
    
    [Sat Jun 27 03:00:01 UTC 2026] ✅ Clean
    
    [Sat Jul 4 03:00:01 UTC 2026] ⚠️ Issues found
    
    

    No mail server needed. No external services. Just a log file you check when you remember — or better yet, integrate with n8n for alerts.


    Step 5: n8n Integration — Webhook-Triggered Scans with Email Alerts

    **[📸 SCREENSHOT: n8n workflow showing the privacy scan webhook → HTTP request → email flow]**

    The weekly cron log is passive. Active alerts require a webhook that n8n can call, which then emails you when issues are found.

    Architecture

    
    n8n (Docker container)
    
      → POST to host webhook server (port 9199)
    
        → check-priv runs on the host
    
          → Returns report JSON to n8n
    
            → If issues found: send email alert
    
    

    Setting Up the Webhook Server

    If you already have a pipeline webhook server running (like the FlowForge publish pipeline), add a new endpoint:

    
    # In your pipeline-webhook-server.py — add this handler
    
    elif parsed.path == "/webhook/check-priv":
    
        result = self._run_check_priv()
    
        self._send_json(200, result)
    
    

    The `_run_check_priv` method executes `/usr/local/bin/check-priv` and captures its output:

    
    def _run_check_priv(self):
    
        result = subprocess.run(
    
            ["/usr/local/bin/check-priv"],
    
            capture_output=True, text=True, timeout=120
    
        )
    
        return {
    
            "clean": result.returncode == 0,
    
            "exit_code": result.returncode,
    
            "report": result.stdout
    
        }
    
    

    The n8n Workflow

    The workflow has 4 nodes:

  • Webhook Trigger — Accepts POST at `/webhook/check-priv`
  • HTTP Request — Calls the host webhook server with auth token
  • IF Node — Checks if `clean` is false (issues found)
  • Email (SMTP) — Sends alert with report summary
  • The HTTP Request node configuration:

    
    URL: http://172.18.0.1:9199/webhook/check-priv
    
    Method: POST
    
    Headers:
    
      X-Pipeline-Token: {{ $env.PIPELINE_TOKEN }}
    
    

    When the scan finds issues, the email alert looks like:

    
    Subject: ⚠️ Privacy Scan Alert — Issues Found
    
    Body:
    
      Privacy scan detected potential leaks in your project.
    
      Run 'check-priv --report' on the server for full details.
    
      
    
      Summary:
    
      - 1 company/client name(s) flagged
    
      - 1 credential reference(s) found
    
    

    Step 6: Interpreting Results

    When the scanner reports issues, here's how to evaluate each category:

    CategoryFalse Positive?Real Issue?
    Email`flowforge@toolyft.com` (your own domain)`user@gmail.com` (personal email in a workflow)
    API Key`sk-test-abc...` (test key in example code)`sk-live-xyz...` (production key in a script)
    Company Name`company: Google` (public company in an article)`company: ALSEC` (private client name in a dashboard)
    n8n Cred IDUUID like `abc123-...` (node reference)Numeric ID like `"2"` (direct DB reference)
    IP Address`192.168.1.1` (private IP)`203.0.113.5` (public server IP in docs)

    Recommended action by severity:

    🔴 Critical — API keys, passwords, embedded URL creds → Rotate immediately, scrub from git history

    🟡 High — Real emails, phone numbers, company names → Remove from public files, update dashboards

    🟢 Low — n8n credential IDs, public IPs, false positives → Document and exclude from future scans


    Variations

    Variation 1: Multi-Project Workspace (30 min setup)

    If you have multiple projects in a workspace directory, run the scanner from the parent:

    
    check-priv /home/user/workspace
    
    

    Or create a wrapper that scans each project individually and aggregates results:

    
    for dir in /home/user/workspace/*/; do
    
      check-priv "$dir" --quiet || echo "⚠️ Issues in $(basename $dir)"
    
    done
    
    

    Variation 2: CI/CD Integration (1 hour setup)

    Run the scanner as part of your deployment pipeline:

    
    # Before deploy
    
    if ! check-priv --quiet; then
    
      echo "❌ Privacy scan failed — deploy blocked"
    
      check-priv --report | mail -s "Privacy Blocked Deploy" team@project.com
    
      exit 1
    
    fi
    
    

    This prevents any file with potential leaks from reaching production.

    Variation 3: Slack/Teams Alert (30 min setup)

    Replace the email node in n8n with a Slack webhook node or Microsoft Teams connector. Instead of email, the alert goes directly to your team chat:

    
    n8n → IF (issues found) → Slack Webhook → #security-alerts
    
    

    Your whole team sees the alert in seconds.


    Troubleshooting

    "The scanner flags my own email address"

    Add it to the exclusion list in the `check_emails` function:

    
    | grep -vi 'you@yourproject.com\|admin@yourdomain.com'
    
    

    "Too many false positives from n8n JSONs"

    The credential UUIDs in n8n workflows look like secrets but are just database row identifiers. The scanner already filters UUID patterns. If you still see false positives, add the specific credential IDs to the exclusion filter.

    "cron doesn't run the scan"

    Check the cron log:

    
    grep -i "check-priv" /var/log/syslog
    
    

    Common issues:

  • The script path in cron must be absolute: `/usr/local/bin/check-priv` not `check-priv`
  • cron has a limited PATH — use full paths or set PATH in the crontab
  • The user running cron must have read access to the scanned directories
  • "n8n workflow returns 403"

    The webhook server requires the auth token. Make sure the `X-Pipeline-Token` header matches what's configured in your systemd service file:

    
    sudo grep PIPELINE_TOKEN /etc/systemd/system/flowforge-pipeline-webhook.service
    
    

    "The scan takes too long"

    Limit the file types or directories scanned. The biggest slowdown is usually `node_modules` — the script already excludes it. If scanning a very large repo, narrow the `find` scope:

    
    # Only scan specific directories
    
    find articles/ scripts/ n8n-workflows/ ...
    
    

    Why This Workflow Wins

    Before automated scanning, privacy was a manual checklist you'd forget. You'd do a quick grep before a big launch, find nothing obvious, and call it done. The one time you missed something was the one time it mattered.

    After automated scanning, privacy is a continuous process. Every Sunday at 3am, the scanner runs. If clean, you never hear about it. If not, you get an alert within seconds. The report archive gives you a paper trail. The n8n integration gives you active alerts.

    BeforeAfter
    Manual audit before launchesContinuous weekly scanning
    Forget to check for monthsAutomated Sunday 3am schedule
    No alert when leaks happenEmail/Slack alert within seconds
    No historical recordDate-stamped report archive
    One regex search, hope for the best8 specialized scan categories
    No integration with automationn8n webhook for CI/CD pipeline
    Takes 2-3 hours per audit15 minutes setup, $0/mo forever

    Set it up once. Tune it for a week. Then forget about it — until the day it catches something that would have cost you thousands.


    Related Workflows

  • [Claude Code vs Cursor vs GitHub Copilot: The 2026 AI Coding Assistant Face-Off](/articles/en/04-claude-code-vs-cursor-vs-copilot) — The definitive comparison for developers. Which tool for autocomplete, refactoring, debugging, and code review — tested on real tasks.
  • [How a Solo Accountant Can Automate 80% of Bookkeeping with AI](/articles/en/02-solo-accountant) — Accountants handle sensitive financial data. This workflow shows how to automate bookkeeping while maintaining data privacy and compliance.
  • [The Non-Technical Founder's AI Stack](/articles/en/03-non-technical-founder) — If you're running a startup, privacy isn't optional. This stack covers the business tools you need alongside security best practices.
  • [The AI-Powered Freelance Designer](/articles/en/01-freelance-designer) — Designers handle client assets and brand materials. Apply the same security scanning practices to your design files and client data.
  • [Scale Your Design Workflow: From Freelancer to Agency](/articles/en/07-scale-your-design-workflow) — As you scale, security becomes critical. This guide shows how to build automated checks into your pipeline.

  • Download n8n Workflow

    Get the full client intake pipeline — free, no credit card.

    By downloading, you agree to our Privacy Policy. We'll send workflow updates — unsubscribe anytime.