惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
Engineering at Meta
Engineering at Meta
D
DataBreaches.Net
月光博客
月光博客
Recent Announcements
Recent Announcements
Google DeepMind News
Google DeepMind News
U
Unit 42
腾讯CDC
爱范儿
爱范儿
J
Java Code Geeks
有赞技术团队
有赞技术团队
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
B
Blog
Stack Overflow Blog
Stack Overflow Blog
GbyAI
GbyAI
T
The Blog of Author Tim Ferriss
小众软件
小众软件
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Y
Y Combinator Blog
大猫的无限游戏
大猫的无限游戏
Microsoft Azure Blog
Microsoft Azure Blog
T
Tailwind CSS Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Before You Send Logs to Gemini — Strip the PII First
hiyoyo · 2026-05-01 · via DEV Community
Cover image for Before You Send Logs to Gemini — Strip the PII First

hiyoyo

All tests run on an 8-year-old MacBook Air.

Android logs contain more than stack traces.

User IDs. Email addresses. IP addresses. Phone numbers. Auth tokens that slipped into a debug log. Device identifiers.

Before you send logcat output to any AI API — including Gemini — strip the sensitive data. Here's the filter I built into HiyokoLogcat.


What logcat actually leaks

Real examples from production apps I've debugged:

D/Network: Connecting to 192.168.1.105:8080
I/Auth: User token: eyJhbGciOiJIUzI1NiJ9...
D/User: Loading profile for user@example.com
I/Device: Serial: R58M123ABCD

Enter fullscreen mode Exit fullscreen mode

None of this should go to an external API. Especially not to a free-tier API where the terms say data may be used for training.


The filter

A regex pass over each line before it leaves the device:

use regex::Regex;
use once_cell::sync::Lazy;

static IP_RE: Lazy = Lazy::new(||
    Regex::new(r"\b(?:\d{1,3}\.){3}\d{1,3}\b").unwrap()
);
static EMAIL_RE: Lazy = Lazy::new(||
    Regex::new(r"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b").unwrap()
);
static TOKEN_RE: Lazy = Lazy::new(||
    Regex::new(r"\b[A-Za-z0-9+/]{20,}={0,2}\b").unwrap()
);
static PHONE_RE: Lazy = Lazy::new(||
    Regex::new(r"\b\d{2,4}[-\s]?\d{2,4}[-\s]?\d{4}\b").unwrap()
);

pub fn mask_pii(line: &str) -> String {
    let line = IP_RE.replace_all(line, "[IP]");
    let line = EMAIL_RE.replace_all(&line, "[EMAIL]");
    let line = TOKEN_RE.replace_all(&line, "[TOKEN]");
    let line = PHONE_RE.replace_all(&line, "[PHONE]");
    line.to_string()
}

Enter fullscreen mode Exit fullscreen mode

After masking:

D/Network: Connecting to [IP]:8080
I/Auth: User token: [TOKEN]
D/User: Loading profile for [EMAIL]

Enter fullscreen mode Exit fullscreen mode

The stack trace and error context survive. The sensitive data doesn't reach Gemini.


Tell users what you're doing

Even with masking, users should know their logs are being sent externally. HiyokoLogcat shows a disclaimer in settings:

"The free Gemini API may use submitted data for model training. Log lines are automatically masked for common PII before sending, but review your logs before using AI diagnosis on sensitive apps."

Transparency matters. Especially for developer tools where the logs might contain production data.


The token regex caveat

Base64-like strings appear everywhere in logs — not just auth tokens. The token regex will also mask things like encoded image previews, checksums, and random IDs.

That's acceptable. A masked checksum doesn't break the diagnosis. A leaked auth token is a much bigger problem.

When in doubt, mask more.


HiyokoLogcat is free and open source → github.com/hiyoyok/HiyokoLogcat
X → @hiyoyok