-
Notifications
You must be signed in to change notification settings - Fork 65
feat: add PII detetction #293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Summary of ChangesHello @e06084, 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 significant enhancement to data security by adding a new feature for detecting Personal Identifiable Information (PII) within text. The primary objective is to proactively identify and manage sensitive data like ID numbers, phone numbers, emails, and credit card details. This addition not only strengthens the system's ability to protect sensitive information but also provides mechanisms for validating and masking such data, aligning with modern data protection standards and improving overall data governance. Highlights
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a new rule for detecting Personally Identifiable Information (PII), which is a great addition for improving data security. The implementation is well-structured with regex patterns, validators, and masking logic. The test coverage is also quite comprehensive.
My review includes a few suggestions to improve the correctness and maintainability of the new rule:
- A high-severity fix for the credit card detection regex to support all valid card lengths.
- A correction for the email detection regex.
- Suggestions for refactoring the PII masking and result grouping logic for better efficiency and maintainability.
- A recommendation to expand test coverage for credit card numbers to include more lengths.
Overall, this is a solid contribution. Addressing these points will make the PII detection feature more robust and reliable.
dingo/model/rule/rule_common.py
Outdated
| high_severity = [item for item in detected_pii if item["severity"] == "high"] | ||
| medium_severity = [item for item in detected_pii if item["severity"] == "medium"] | ||
| low_severity = [item for item in detected_pii if item["severity"] == "low"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These three list comprehensions iterate over detected_pii three separate times. For better performance, you could iterate once and group the items by severity. Using collections.defaultdict would be an efficient way to achieve this.
Example:
from collections import defaultdict
pii_by_severity = defaultdict(list)
for item in detected_pii:
pii_by_severity[item["severity"]].append(item)
high_severity = pii_by_severity.get("high", [])
# ... and so on for other severitiesThis approach is more efficient and scales better if more severity levels are added in the future.
* feat: add PII detetction
No description provided.