title: Regex for detecting keys in the yaml file
body: <p>I am writing a regex to detect the exposed passwords/secrets/keys in a yaml file.  Below is the example of the yaml file. The <code>data</code> key is common to all my yaml files. subkeys under the <code>data</code> key will vary for each file.</p>
  <p><strong>Scenario 1:</strong></p>
  <pre><code>apiVersion: v1
  data:
      PASSWORD: mypass123
      USER: {$USER_NAME}
  metadata:
      Timestamp: 2021-03-31T14:29:09Z
  </code></pre>
  <p><strong>Scenario 2:</strong></p>
  <pre><code>apiVersion: v1
  data:
      DATABASE: {$DATABASE_NAME}
      USER: {$USER_NAME}
      API_KEY: mykey456=
  metadata:
      Timestamp: 2021-03-31T14:29:09Z
  </code></pre>
  <p>As you can see above sensitive information is exposed for the keys <code>PASSWORD</code> &amp; <code>API_KEY</code>. I need a regex to match the <code>data</code> key &amp; exposed values of sensitive information.</p>
  <pre><code>import re
  import sys
  from ruamel.yaml import YAML
  
  yaml_str = &quot;&quot;&quot;\
  apiVersion: v1
  data:
      PASSWORD: mypass123
      USER: {$USER_NAME}
  metadata:
      Timestamp: 2021-03-31T14:29:09Z
  &quot;&quot;&quot;
  
  regex = r'data:\s*-\s*\b[a-z0-9_ .\-,]:([a-z0-9=_\-]{1,4096})'
  </code></pre>
  <p>I have tried the above regex but it is not working. Any help is appreciated.</p>