Skip to content

Conversation

@nikhilsinhaparseable
Copy link
Contributor

@nikhilsinhaparseable nikhilsinhaparseable commented Mar 22, 2025

New environment variable P_MASK_PII is added
if set to true, server masks the PII data as per below -

  1. emails are masked like [email protected] -> TXXX@XXX
  2. urls are sent as None
  3. strings are masked as all X

Summary by CodeRabbit

  • New Features

    • Introduced a configuration option that allows users to enable or disable masking of personally identifiable data.
    • Enhanced privacy by automatically obscuring sensitive information such as email details and URLs when masking is active.
  • Tests

    • Added comprehensive tests to ensure the new data masking functionality works as intended.

New environment variable `P_MASK_PII` is added
if set to true, server masks the PII data as per below -

1. emails are masked like `[email protected]` -> `TXXX@XXX`
2. urls are sent as None
3. strings are masked as all `X`
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 22, 2025

Walkthrough

The changes add a new command-line option to control PII masking and update the logic to mask sensitive data. In src/cli.rs, a boolean flag (mask_pii) is added to the application options with proper CLI parsing. In src/rbac/utils.rs, the PII masking logic is refactored: new functions (mask_pii_string, mask_string, and mask_pii_url) are introduced to process email and URL fields in the to_prism_user function. Additional tests verify the new masking behavior.

Changes

File(s) Change Summary
src/cli.rs Added a new public boolean field mask_pii to the Options struct, configured with clap to accept --mask-pii, use the environment variable P_MASK_PII, and a default value of "false".
src/rbac/utils.rs Introduced three new functions: mask_pii_string, mask_string, and mask_pii_url to encapsulate PII masking logic. Updated to_prism_user to process email and picture fields using these functions; added tests for various input scenarios.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Options
    participant to_prism_user
    participant Masking

    User->>CLI: Provide command with "--mask-pii" flag
    CLI->>Options: Parse options (mask_pii set)
    Options-->>to_prism_user: Pass configuration for processing
    to_prism_user->>Masking: Call mask_pii_string(email)
    Masking-->>to_prism_user: Return masked or original email
    to_prism_user->>Masking: Call mask_pii_url(pictureURL)
    Masking-->>to_prism_user: Return None (if masking enabled) or original URL
Loading

Poem

I'm a rabbit with a coding tale,
Hopping through changes without fail.
A flag to hide PII in every byte,
Transforming data with pure delight.
In lines and tests, our secrets conceal—
With each leap, our code feels real!
🐇💻

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/rbac/utils.rs (3)

60-66: Consider renaming function to better reflect conditional behavior

The function name mask_pii_string implies it always masks PII, but it only does so if the mask_pii flag is enabled. Consider renaming to maybe_mask_pii_string to make this clearer.


68-74: Consider renaming function to better reflect conditional behavior

Similar to the previous function, consider renaming to maybe_mask_pii_url to clarify that masking only occurs when the flag is enabled.


104-147: Consider adding tests for the conditional masking functions

The tests currently only test the mask_string function directly. Consider adding tests for mask_pii_string and mask_pii_url functions with both enabled and disabled masking to verify their conditional behavior.

For example:

#[test]
fn test_mask_pii_string_when_enabled() {
    // Mock PARSEABLE.options.mask_pii to be true
    // Verify that masking occurs
}

#[test]
fn test_mask_pii_string_when_disabled() {
    // Mock PARSEABLE.options.mask_pii to be false
    // Verify that no masking occurs
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8ac3105 and 116723b.

📒 Files selected for processing (2)
  • src/cli.rs (1 hunks)
  • src/rbac/utils.rs (2 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
src/rbac/utils.rs (1)
src/cli.rs (3) (3)
  • format (427-432)
  • format (441-446)
  • format (497-498)
⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: Quest Smoke and Load Tests for Standalone deployments
  • GitHub Check: Quest Smoke and Load Tests for Distributed deployments
  • GitHub Check: coverage
  • GitHub Check: Build Default aarch64-apple-darwin
  • GitHub Check: Build Default x86_64-pc-windows-msvc
  • GitHub Check: Build Kafka x86_64-unknown-linux-gnu
  • GitHub Check: Build Default x86_64-apple-darwin
  • GitHub Check: Build Default x86_64-unknown-linux-gnu
  • GitHub Check: Build Default aarch64-unknown-linux-gnu
  • GitHub Check: Build Kafka aarch64-apple-darwin
🔇 Additional comments (5)
src/cli.rs (1)

177-183: Implementation of PII masking flag looks good

The addition of the mask_pii flag is properly configured with command-line argument, environment variable, default value, and helpful description. This implementation matches the pattern used for other boolean options in the codebase.

src/rbac/utils.rs (4)

20-22: LGTM: Required imports for PII masking

The addition of these imports is necessary for the new PII masking functionality.


54-56: LGTM: Updated to_prism_user to use PII masking

The function now correctly applies PII masking to sensitive fields.


76-102: LGTM: PII masking implementation matches requirements

The implementation follows the specified requirements:

  1. Email addresses are masked with the first character of the username followed by X's, and @xxx
  2. Other strings are completely masked with X's

The function handles edge cases appropriately: None values, invalid email formats, and empty usernames.


108-146: LGTM: Comprehensive tests for masking functionality

The tests thoroughly cover the different scenarios: valid emails, invalid emails, empty strings, generic strings, and None values.

@nitisht nitisht merged commit 283aa21 into parseablehq:main Mar 22, 2025
14 checks passed
@nikhilsinhaparseable nikhilsinhaparseable deleted the pii-masking branch July 12, 2025 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants