Skip to content
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

feat: redact data from cloud #232

Merged
merged 1 commit into from
Jul 20, 2024
Merged

feat: redact data from cloud #232

merged 1 commit into from
Jul 20, 2024

Conversation

rokam
Copy link
Contributor

@rokam rokam commented Jul 18, 2024

Summary by CodeRabbit

  • New Features

    • Implemented automatic redaction of sensitive data in logs, including phone numbers, emails, and credit card information.
  • Chores

    • Updated dependencies to include commonregex.

Copy link
Contributor

coderabbitai bot commented Jul 18, 2024

Walkthrough

The changes introduce a mechanism to redact sensitive information such as phone numbers, emails, and credit card details from logs within the MideaCloud class. This is achieved through a new function _redact_data which utilizes regular expressions. Additionally, the _api_request function has been updated to incorporate this redaction feature. The requirements.txt file has been updated to include the commonregex library required for the new functionality.

Changes

File Change Summary
midealocal/cloud.py Added imports for re and CommonRegex. Introduced _redact_data function in the MideaCloud class to redact sensitive information from logs. Updated _api_request to use it.
requirements.txt Added the commonregex library to the list of dependencies.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MideaCloud
    participant Logger
    
    User->>MideaCloud: Call _api_request()
    MideaCloud->>Logger: Log request data
    MideaCloud->>MideaCloud: Execute API request
    MideaCloud->>Logger: Log response data
    MideaCloud->>MideaCloud: Call _redact_data() with response data
    MideaCloud-->>Logger: Log redacted data
    MideaCloud-->>User: Return response
Loading

Poem

In the cloud where secrets lie,
Redaction sweeps, none shall spy,
Emails, phones, and cards so bright,
Hidden safe from prying sight.
Code's embrace, a gentle sweep,
Logs now guard what they keep.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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.

@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 36.05%. Comparing base (8178e76) to head (6c8cd30).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #232      +/-   ##
==========================================
+ Coverage   35.95%   36.05%   +0.09%     
==========================================
  Files          81       81              
  Lines        7064     7075      +11     
==========================================
+ Hits         2540     2551      +11     
  Misses       4524     4524              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8178e76 and 6c8cd30.

Files selected for processing (2)
  • midealocal/cloud.py (4 hunks)
  • requirements.txt (1 hunks)
Additional comments not posted (3)
requirements.txt (1)

4-4: Dependency addition looks good.

The commonregex library is correctly added to the list of dependencies.

midealocal/cloud.py (2)

6-7: New imports are correctly added.

The imports for re and CommonRegex are necessary for the new redaction functionality.

Also applies to: 16-16


209-210: Redaction integration in _api_request looks good.

The redaction of sensitive data in the logs is correctly integrated and does not affect the functionality of the API request.

midealocal/cloud.py Show resolved Hide resolved
Copy link
Member

@chemelli74 chemelli74 left a comment

Choose a reason for hiding this comment

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

LGTM.
What about coderabbitai comment ?

@rokam
Copy link
Contributor Author

rokam commented Jul 19, 2024

Each will be used only once. It doesn't make sense to me to compile the regex.

@chemelli74
Copy link
Member

I still think is a good practice as in future it may be easily extended.
Anyway nothing really blocking

@rokam rokam merged commit c61991e into main Jul 20, 2024
10 checks passed
@rokam rokam deleted the feat/redact-cloud-data branch July 20, 2024 13:22
@rokam rokam mentioned this pull request Jul 20, 2024
rokam added a commit that referenced this pull request Jul 21, 2024
🤖 I have created a release *beep* *boop*
---


## [2.2.0](v2.1.1...v2.2.0)
(2024-07-20)


### Features

* redact data from cloud
([#232](#232))
([c61991e](c61991e))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Introduced functionality for users to redact data from the cloud,
enhancing data privacy management.
- **Version Update**
- Updated the software version to 2.2.0, indicating new features and
improvements.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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.

3 participants