Skip to content

XML Regex is not working in Gitleaks #1637

@meenasubr

Description

@meenasubr

Describe the bug
I am trying to add regex to capture secrets from jmeter files. the regex is working in online golang tool. but when i try i with gitleaks it is not working

To Reproduce

  1. use below custom rule
    [[rules]]
    description = "JMX API Key"
    id = "jmx-api-key"
    regex = '''^\s*<elementProp name="(?:client_secret)"[^>]+>\n(.* name="Argument.name".\n). name="Argument.value">([a-zA-Z0-9]{8,})<[/][^>]+>\n'''
    [rules.allowlist]
    paths = [
    '''(?i)\b\wlnp\w.jmx''',
    ]

  2. Test data used:
    <elementProp name="client_secret" elementType="Argument"> <stringProp name="Argument.name">client_id</stringProp> <stringProp name="Argument.va1ddlue">${client_id}</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> <elementProp name="client_secret" elementType="Argument"> <stringProp name="Argument.name">client_secret</stringProp> <stringProp name="Argument.value">UiI6S2TNzIelSDXA</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp> <elementProp name="scope_op6" elementType="Argument"> <stringProp name="Argument.name">scope_op6</stringProp> <stringProp name="Argument.value">PARTNER_PAYMENT_HAS_PAYMENT_METHOD_OIC</stringProp> <stringProp name="Argument.desc">USER_PAYMENT_METHODS_MANAGE</stringProp> <stringProp name="Argument.metadata">=</stringProp> </elementProp>

Expected behavior
This should match hardcoded client_secret in jmx file

Screenshots
working screenshot from online tool.
https://www.akto.io/tools/go-regex-tester
image

Basic Info (please complete the following information):

  • OS: windows
  • Gitleaks Version: 8.18.4

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions