-2

When sending logs, I want to replace the id and pw values as in:

https://m.xxxxx.com/yyyy.xxxx?id=aaaa&pw=cccc
https://m.xxxxx.com/aaaa.xxxx?id=aaaa&pass=cccc

with different values such as:

https://m.xxxxx.com/yyyy.xxxx?id=*&pw=****
https://m.xxxxx.com/aaaa.xxxx?id=*&pass=****

It is difficult to create a plugin. Is it possible to transfer by converting the id = aaaa value to id = **** using existing filter_record_transformer or grep? Is it impossible to use gsub of filter_record_transformer?

sawa
  • 165,429
  • 45
  • 277
  • 381
monouser
  • 11
  • 2

1 Answers1

-1
"https://m.xxxxx.com/yyyy.xxxx?id=aaaa&pw=cccc".
  gsub(/(?<=id=)[^&]+|(?<=pw=)[^&]+/) { |m| '*' * m.length }
#⇒ "https://m.xxxxx.com/yyyy.xxxx?id=****&pw=****"

We use positive lookbehind here to match exactly id and pw parts of the query.

Aleksei Matiushkin
  • 119,336
  • 10
  • 100
  • 160