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

feature: Add ability to define custom masker function for @masked annotation #1244

Merged
merged 1 commit into from
Apr 23, 2024

Conversation

NarekDW
Copy link
Contributor

@NarekDW NarekDW commented Apr 18, 2024

I'd like to propose an important feature - ability to define a custom masker function for fields.
Let's say I'd like to mask different fields - differently. Like this:

@derive(loggable)
case class MaskedCustom(
      @masked sensitiveField: String, // this should be replaced with "*"
      @masked firstName: Option[String], // this should be replaced with "J***"
      @masked age: Int // this should be replaced with "**"
  )

Or in Scala 3:

case class MaskedCustom(
      @masked sensitiveField: String, // this should be replaced with "*"
      @masked firstName: Option[String], // this should be replaced with "J***"
      @masked age: Int // this should be replaced with "**"
  ) derives Loggable

With that purpose - I'm proposing to define a new MaskMode

  /** Allows to define a custom masker function */
  case class Custom(f: String => String) extends MaskMode

with high order custom function

Copy link
Collaborator

@dos65 dos65 left a comment

Choose a reason for hiding this comment

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

LGTM!

@dos65 dos65 merged commit bac92d6 into tofu-tf:master Apr 23, 2024
9 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.

None yet

2 participants