Skip to content

Match by regex #14

@clemlesne

Description

@clemlesne

It would be useful to hide secret by testing case-insensitive regex rules than today.

A false positive is better than a pawn :)

Integration proposal

Today, code implements a strict includes test (see https://github.com/eashi/hide-my-secrets/blob/7950e37817c710e791ad2fd337d2f5f603e3454c/src/extension.ts#L82C4-L82C40).

This new impleemntation could be achieved by using RegExp class:

let test = new RegExp(keyValue, 'i');  // Case insensitive match on purpose

if (test.test(secretKeys)) {
    // ...
}

Plus, the default configuration can be updated to:

"hide-my-secrets.secretKeys": [
    "(secret|password|token|key)"
],

Optionally, regex rules can be compiled and cached.

Issue example

Config extract:

"hide-my-secrets.secretKeys": [
    "password"
],

My secret config;

env:
    COSIGN_PASSWORD: xxx. # This is visible
    password: xxx  # This is hidden

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions