Skip to content

Improve generic regex #778

@raro42

Description

@raro42

Describe the solution you'd like

I have the following secret in my secret.json file in a repo:
{
"client_id" : "0afae57f3ccfd9d7f5767067bc48b30f719e271ba470488056e37ab35d4b6506",
"client_secret" : "6da89121079f83b2eb6acccf8219ea982c3d79bccc3e9c6a85856480661f8fde",
"response_type" : "id_token"
}

I would like to recognize it with the default regex provided in your repo.

The following regex would do so:
(?i)((key|api|token|secret|password)[a-z0-9 .\-,]{0,25})(=|>|:=|||:|<=|=>|:|).{0,5}[\'\"]([0-9a-zA-Z-=]+)[\'\"]

What's the difference:
(=|>|:=|||:|<=|=>|:|) ... the last "|" makes null hits be positiv and continue on regex
([0-9a-zA-Z-=]+) ... the "+" ... makes the limit of 64 disappear. I am not sure if this is a good idea. As time flies by, I guess we will soon see longer secrets

Additional context
My questions:

  • is that something you would like to see as a contribution?
  • I did not understand how you are testing. Do you have testcases that the secret should be added to?
  • How could I test the new regex against existing testcases?

cc @zricethezav

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions