fix: optimize sensitive log parsing performance and reduce false positives#17
Conversation
…ence tiers, and sampling - Add anchor-based pre-filtering to skip ~91% of regex evaluations on normal log lines - Add confidence tiers (high/medium/low) to sensitive_patterns.json for all 200 patterns - Add Shannon entropy + character-class validation to reject false positives on low-confidence patterns - Add singleton pattern cache to share compiled regexes across all parsers (~14KB vs ~2.1MB per parser) - Replace bare bool parameter with SensitiveConfig struct (sampling rate, min confidence, max detections) - Add configurable sampling (1-in-N lines) and per-container detection cap
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a comprehensive set of enhancements to the sensitive log parsing mechanism. The primary goal is to drastically improve performance and accuracy by intelligently filtering log lines before full regex evaluation and by applying more robust validation to potential matches. These changes provide greater control over the detection process and ensure that the system is both efficient and reliable in identifying sensitive data. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces significant performance optimizations and accuracy improvements for sensitive data detection in logs. The changes include anchor-based pre-filtering, confidence levels for patterns, entropy-based validation, and a shared cache for compiled regexes. The implementation is solid and backed by extensive new benchmarks and tests. I've found a few areas for improvement, mainly related to test robustness and minor code cleanup, which I've detailed in the comments.
Summary
boolparameter withSensitiveConfigstruct supporting sampling rate, min confidence, and max detections capTest plan
go test ./...passesTestExtractAnchorsvalidates anchor extraction from regex patternsTestPrefilterEffectivenessconfirms ≥80% anchor coverageTestPrefilterSkipsNonMatchingconfirms ≥90% skip rate on normal linesTestLooksLikeSecretvalidates entropy-based FP rejectionTestDetectSensitiveData_LowConfidence_EntropyFilterconfirms real secrets detected, SQL table names rejectedTestParserSensitiveDisabledconfirms zero overhead when disabledTestParserSensitiveSamplingandTestParserSensitiveMaxDetectionsvalidate rate limitinggo test -bench=. -benchmemshows improvement over baseline