-
-
Notifications
You must be signed in to change notification settings - Fork 7
Introduce category methods #90
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
base: main
Are you sure you want to change the base?
Conversation
4c5b543 to
2deb1cf
Compare
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.
Pull Request Overview
This pull request adds dynamic categorization functionality to the TopSecret::Mapping module, enabling results to be queried by sensitive data types through dynamically generated accessor methods. The changes introduce a flexible method-missing-based approach to access categorized sensitive information.
- Introduces dynamic method generation for accessing sensitive data by category (e.g.,
emails,credit_cards,people) - Adds a
LABEL_DELIMITERconstant and updates label generation to use it consistently - Extends test coverage with comprehensive tests for categorization features
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/top_secret/constants.rb | Adds LABEL_DELIMITER constant for consistent label formatting |
| lib/top_secret/text/global_mapping.rb | Updates label generation to use the new LABEL_DELIMITER constant |
| lib/top_secret/mapping.rb | Implements dynamic method generation via method_missing for categorization accessors, predicates, and mapping methods |
| spec/top_secret/text_spec.rb | Adds comprehensive tests for categorization features in both .filter and .filter_all methods |
| spec/top_secret/result_spec.rb | Adds tests for categorization behavior and dynamic method responses |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| PERSON_1: "Ralph", | ||
| IP_ADDRESS_1: "192.168.1.1", | ||
| CREDIT_CARD_NUMBER_1: "4242424242424242", | ||
| NETWORK_MAPPING_1: "10.0.1.0/24 -> 192.168.1.0/24" |
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.
I should test something like {WORD}_MAPPING_{WORD}_{N} to ensure that works too.
README.md
Outdated
| result.email_mapping # => {} | ||
| ``` | ||
|
|
||
| When using custom labels, methods are generated based on the label name: |
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.
Also highlight that emails works too.
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.
This needs some work. It's actually a false-positive that it was returning data before. I think that's because they both started with EMAIL_.
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.
Also, what should we do if we disable a filter? Should those methods still exist?
2deb1cf to
76021bd
Compare
Follow-up to #89. Now that we enforce a specific label format, we can dynamically generate methods based on the types of data that was filtered. ```ruby result = TopSecret::Text.filter("Ralph can be reached at ralph@example.com") result.emails? => true result.emails => ["ralph@example.com"] result.email_mapping => {EMAIL_1 => "ralph@example.com"} result.people? => true result.people => ["Ralph"] result.email_mapping => {PERSON_1 => "Ralph"} result.credit_cards? => false result.credit_cards => [] result.credit_card_mapping => {} ```
76021bd to
69b1f8c
Compare
|
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
|
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days. |
Follow-up to #89.
Now that we enforce a specific label format, we can dynamically generate
methods based on the types of data that was filtered.