Skip to content

DEV: add PipeSeparatedValue and EscapedJson support#42

Merged
prasanthkv merged 2 commits into
eBay:masterfrom
RandySun228:master
Jun 3, 2026
Merged

DEV: add PipeSeparatedValue and EscapedJson support#42
prasanthkv merged 2 commits into
eBay:masterfrom
RandySun228:master

Conversation

@RandySun228
Copy link
Copy Markdown
Contributor

@RandySun228 RandySun228 commented Jun 3, 2026

Motivation

The eBay payments (BES) accounting layer emits event payloads in two formats that EJMask could not previously mask:

  1. Escaped JSON — JSON serialized as a string value inside a containing JSON document, where every quote character appears as ". The existing JsonFullValuePatternBuilder cannot handle this because its regex does not account for the backslash before each quote delimiter.
  2. Pipe-separated key=value — a flat record format (e.g. the decodePayload field) where fields are delimited by |.

Proposed Changes

  • EscapedJsonFullValuePatternBuilder (new, ejmask-extensions/builder/json): fully masks field values in escaped JSON strings.
    • "cvv":"sensitiveData" → "cvv":"****"
  • PipeSeparatedValuePatternBuilder (new, ejmask-extensions/builder/string): fully masks field values in pipe-separated payloads.
    • userId=1083849182|type=SELLER → userId=****|type=SELLER
    • Value character class excludes " and \ so replacement is safe when the payload is embedded inside a JSON string.
  • Unit tests for both builders aligned with existing project conventions (parameterized @MethodSource, exact pattern/replacement assertions).
  • README updated with usage examples and builder table entries.

Test Plan

  • EscapedJsonFullValuePatternBuilderTest: 7 tests — normal masked, empty value (unchanged), non-sensitive field (unchanged), field name appearing in value only (unchanged), JSON-embedded payload.
  • PipeSeparatedValuePatternBuilderTest: 8 tests — value before pipe, value at end of string, multiple sensitive fields, adjacent field preserved, unrelated fields unchanged, JSON-embedded payload.
  • All 15 tests pass: mvn test -pl ejmask-extensions

Copilot AI review requested due to automatic review settings June 3, 2026 12:39
@RandySun228 RandySun228 enabled auto-merge (squash) June 3, 2026 12:39
@RandySun228 RandySun228 disabled auto-merge June 3, 2026 12:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds two new regex pattern builders to the ejmask-extensions module to support masking in (1) escaped-JSON strings and (2) pipe-separated key=value payloads, and documents/validates usage via new unit tests and README updates.

Changes:

  • Introduces EscapedJsonFullValuePatternBuilder for masking values inside escaped JSON (e.g., {\"cvv\":\"...\"}).
  • Introduces PipeSeparatedValuePatternBuilder for masking values in pipe-delimited key=value strings.
  • Updates README and adds JUnit tests covering the new builders’ regex + replacement behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
README.md Documents the two new builders and provides usage examples.
ejmask-extensions/src/main/java/com/ebay/ejmask/extenstion/builder/json/EscapedJsonFullValuePatternBuilder.java Adds a builder to mask values in escaped-JSON strings.
ejmask-extensions/src/main/java/com/ebay/ejmask/extenstion/builder/string/PipeSeparatedValuePatternBuilder.java Adds a builder to mask values in pipe-separated key=value payloads.
ejmask-extensions/src/test/java/com/ebay/ejmask/extenstion/builder/json/EscapedJsonFullValuePatternBuilderTest.java Adds unit tests for the escaped-JSON builder.
ejmask-extensions/src/test/java/com/ebay/ejmask/extenstion/builder/string/PipeSeparatedValuePatternBuilderTest.java Adds unit tests for the pipe-separated builder.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 3, 2026 12:49
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

@prasanthkv prasanthkv merged commit c2d9607 into eBay:master Jun 3, 2026
3 checks passed
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.

5 participants