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: add config for hash to bingads offline conversions #1843

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

ItsSudip
Copy link
Member

@ItsSudip ItsSudip commented Dec 13, 2024

What are the changes introduced in this PR?

We are adding a new configuration to enable hashing of email and phone.

What is the related Linear task?

Resolves INT-3019

Please explain the objectives of your changes below

Put down any required details on the broader aspect of your changes. If there are any dependent changes, mandatorily mention them here

Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?

N/A

Any new dependencies introduced with this change?

N/A

Any new checks got introduced or modified in test suites. Please explain the changes.

N/A


Developer checklist

  • My code follows the style guidelines of this project

  • No breaking changes are being introduced.

  • All related docs linked with the PR?

  • All changes manually tested?

  • Any documentation changes needed with this change?

  • I have executed schemaGenerator tests and updated schema if needed

  • Are sensitive fields marked as secret in definition config?

  • My test cases and placeholders use only masked/sample values for sensitive fields

  • Is the PR limited to 10 file changes & one task?

Reviewer checklist

  • Is the type of change in the PR title appropriate as per the changes?

  • Verified that there are no credentials or confidential data exposed with the changes.

Summary by CodeRabbit

  • New Features

    • Added a new configuration option, "isHashRequired," for Bing Ads Offline Conversions.
    • Introduced a new section in the UI for advanced destination settings, including a checkbox for enabling hashed data options.
  • Bug Fixes

    • Enhanced validation logic for configuration settings, ensuring stricter adherence to expected formats and types.

Copy link

coderabbitai bot commented Dec 13, 2024

Walkthrough

The pull request introduces modifications to the configuration files for the Bing Ads Offline Conversions destination. Key changes include the addition of a new property, "isHashRequired", to the JSON configuration, schema, and UI configuration files. This property is a boolean indicating whether hashing is required. The validation logic has also been updated to incorporate this new field, ensuring stricter adherence to expected formats. Overall, the changes enhance configuration management related to hashing settings without altering existing properties or structures.

Changes

File Path Change Summary
src/configurations/destinations/bingads_offline_conversions/db-config.json Added "isHashRequired" to "defaultConfig"; reordered keys in "destConfig" object.
src/configurations/destinations/bingads_offline_conversions/schema.json Introduced isHashRequired property as a boolean with a default value of false.
src/configurations/destinations/bingads_offline_conversions/ui-config.json Added new section "Destination settings" with a checkbox for isHashRequired and related documentation note.
test/data/validation/destinations/bingads_offline_conversions.json Added isHashRequired field to validation objects and refined validation rules for existing properties.

Possibly related PRs

Suggested reviewers

  • lvrach
  • am6010
  • krishna2020
  • ssbeefeater
  • debanjan97
  • cisse21
  • ruchiramoitra
  • shrouti1507
  • 1abhishekpandey
  • sandeepdsvs

🐰 In fields of code, we hop and play,
With "isHashRequired", we pave the way.
New settings bloom, like flowers in spring,
Configurations dance, hear the changes sing!
A checkbox here, a schema there,
In the world of data, we show we care! 🌼


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>, 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. (Experiment)
  • @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

codecov bot commented Dec 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (2c683fe) to head (e57492a).

Additional details and impacted files
@@            Coverage Diff            @@
##           develop     #1843   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines           53        53           
  Branches         7         7           
=========================================
  Hits            53        53           

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

Copy link

@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

🧹 Outside diff range and nitpick comments (5)
src/configurations/destinations/bingads_offline_conversions/schema.json (1)

15-18: Consider adding validation for PII fields when hashing is enabled

While the schema definition for isHashRequired is correct, consider adding validation rules for email and phone fields when hashing is enabled to ensure they meet the Microsoft Advertising requirements for hashed values.

Add validation patterns for hashed values:

 "isHashRequired": {
   "type": "boolean",
   "default": false
-  }
+  },
+  "allOf": [
+    {
+      "if": {
+        "properties": {
+          "isHashRequired": { "const": true }
+        }
+      },
+      "then": {
+        "properties": {
+          "email": {
+            "pattern": "^[a-fA-F0-9]{64}$"  // SHA256 hash pattern
+          },
+          "phone": {
+            "pattern": "^[a-fA-F0-9]{64}$"  // SHA256 hash pattern
+          }
+        }
+      }
+    }
+  ]
src/configurations/destinations/bingads_offline_conversions/ui-config.json (2)

71-72: Improve checkbox label clarity

The current label "Enable it, if you are not sending hashed data" could be clearer. Consider rewording to better explain the action and its consequence.

Suggested label change:

-    "label": "Enable it, if you are not sending hashed data.",
+    "label": "Automatically hash email and phone data before sending",

61-92: Consider additional security measures for PII handling

While adding hashing capability is good, consider these additional security measures:

  1. Add a warning in the UI about sending unhashed PII data
  2. Consider implementing server-side validation to prevent accidental PII exposure
  3. Add logging/monitoring for when unhashed data is detected
test/data/validation/destinations/bingads_offline_conversions.json (2)

218-218: Add more test cases for isHashRequired.

While the current test cases cover valid boolean and invalid string scenarios, consider adding tests for:

  • Missing isHashRequired field (default behavior)
  • isHashRequired: false value
  • isHashRequired: null value
  • isHashRequired: undefined value

This ensures comprehensive validation coverage for all possible scenarios.

Here's a suggested test case to add:

[
  {
    "config": {
      "customerAccountId": "434342324",
      "customerId": "447477473",
      "isHashRequired": false
    },
    "result": true
  },
+ {
+   "config": {
+     "customerAccountId": "434342324",
+     "customerId": "447477473",
+     "isHashRequired": null
+   },
+   "result": false,
+   "err": ["isHashRequired must be boolean"]
+ }
]

Line range hint 185-243: Consider adding validation for hashed data format.

The PR objective mentions this feature is for hashing email and phone data, but the current validation only checks if isHashRequired is a boolean. Consider adding validation to ensure that when isHashRequired is true, the relevant fields actually contain hashed values (e.g., checking for common hash formats like SHA-256).

This would prevent accidental PII exposure by ensuring the data is actually hashed when required.

Example validation patterns for common hash formats:

  • MD5: 32 hexadecimal characters
  • SHA-256: 64 hexadecimal characters
  • SHA-512: 128 hexadecimal characters

Would you like me to propose additional test cases that validate the hash format?

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1f4e1c5 and 28f6e68.

📒 Files selected for processing (4)
  • src/configurations/destinations/bingads_offline_conversions/db-config.json (1 hunks)
  • src/configurations/destinations/bingads_offline_conversions/schema.json (1 hunks)
  • src/configurations/destinations/bingads_offline_conversions/ui-config.json (1 hunks)
  • test/data/validation/destinations/bingads_offline_conversions.json (3 hunks)
🔇 Additional comments (4)
src/configurations/destinations/bingads_offline_conversions/db-config.json (1)

28-29: LGTM! Verify configuration consistency

The addition of isHashRequired to defaultConfig is appropriate and follows the existing pattern.

Let's verify that this configuration key is consistently used across all related files:

✅ Verification successful

Let me check the content of these files to ensure the configuration is consistent across them.


Configuration is consistent across all files

The isHashRequired configuration is properly defined and consistent across all related files:

  • In db-config.json: Added to defaultConfig array
  • In ui-config.json: Defined as a config key with default value false
  • In schema.json: Properly typed as boolean with default value false
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for isHashRequired usage across configuration files
rg "isHashRequired" src/configurations/destinations/bingads_offline_conversions/

Length of output: 475


Script:

#!/bin/bash
# Check the content of the files to verify configuration consistency
echo "=== ui-config.json ==="
cat src/configurations/destinations/bingads_offline_conversions/ui-config.json | grep -A 5 -B 5 "isHashRequired"

echo -e "\n=== schema.json ==="
cat src/configurations/destinations/bingads_offline_conversions/schema.json | grep -A 5 -B 1 "isHashRequired"

Length of output: 951

src/configurations/destinations/bingads_offline_conversions/ui-config.json (1)

73-85: LGTM! Well-documented feature

Excellent inclusion of relevant documentation links to Microsoft's official documentation for both hashed email and phone number requirements.

test/data/validation/destinations/bingads_offline_conversions.json (2)

185-185: LGTM! Good test case for invalid type.

The test case correctly validates that isHashRequired must be a boolean and not a string "true". This helps prevent type-related bugs in production.

Also applies to: 209-209


Line range hint 185-209: Verify PII handling in validation tests.

Given that this feature is specifically for hashing email and phone data (as per PR objectives), we should verify that the test data doesn't contain any actual PII.

Also applies to: 218-243

✅ Verification successful

Let me check the specific file under review for any PII patterns.


Let me check the actual content of the file to verify the test data.


No PII data found in test cases

After reviewing the test file content, I can confirm that it only contains:

  • Mock account IDs (e.g., "434342324", "447477473")
  • Test validation scenarios with dummy data
  • Configuration validation patterns
  • No actual email addresses, phone numbers, or other PII

The test data appropriately uses non-sensitive information to validate the schema and functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for potential PII patterns in test files
rg -i '(\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b)|(\b\d{3}[-.]?\d{3}[-.]?\d{4}\b)' test/data/validation/destinations/

Length of output: 14693


Script:

#!/bin/bash
# Check the specific file for PII patterns
rg -i '(\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b)|(\b\d{3}[-.]?\d{3}[-.]?\d{4}\b)' test/data/validation/destinations/bingads_offline_conversions.json

Length of output: 162


Script:

#!/bin/bash
# View the content of the specific file
cat test/data/validation/destinations/bingads_offline_conversions.json

Length of output: 7053

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.

1 participant