thoughtworks / talisman

Using a pre-commit hook, Talisman validates the outgoing changeset for things that look suspicious — such as tokens, passwords, and private keys.
https://thoughtworks.github.io/talisman/
MIT License
1.87k stars 241 forks source link

Talisman fails silently if parts of the .talismanrc are not valid yaml #454

Open karlbrown-va opened 3 months ago

karlbrown-va commented 3 months ago

Describe the bug .talismanrc is supposed to be a yaml file. However, the filename does not end in .yaml, certain editors may not detect it and use yaml settings, and additionally, yaml linters will not detect it by default to find errors.

This can lead to silent failures - for example if a tab is added to one of the lines. Further lines in the file (such as custom_patterns) could be ignored, leading to password leakage.

To Reproduce Steps to reproduce the behavior:

  1. Create a new git repository and add a test file
  2. Add a custom pattern to .talismanrc:
    custom_patterns:
    - 'pwd_[a-z]{8,20}'
  3. Add a string matching this pattern to the file
  4. git add . and then talisman -l debug --githook pre-commit and confirm the secret is detected and the custom pattern was used
  5. Replace the spaces in .talismanrc with tabs
  6. git add . and then talisman -l debug --githook pre-commit and confirm the secret no longer detected

Expected behavior

Desktop (please complete the following information):