GSTT-CSC / project-template

Template for new projects
0 stars 0 forks source link

Add pre-commit hook #57

Closed AgatheZ closed 1 year ago

AgatheZ commented 1 year ago

This pull request introduces a pre-commit hook script that helps prevent accidental commits of sensitive data into the repository. The script scans for a set of forbidden patterns, which currently includes:

I detailed the setup of this hook in the README, there is a file with exceptions that the developer can populate. This script has several limitations/assumptions, the main one being that it is impossible to define a regex that only captures names. There will therefore be several false positives that can be ignored.

A screenshot of an example output:

image

@hshuaib90 I put you as a reviewer since you initiated the idea, I'm also sure you'll have suggestion to improve them!

EDIT: A few updates:

I have removed the Name regex after reaching the conclusion it would catch too many false positives.

AgatheZ commented 1 year ago

@GSTT-CSC/core It would be good to have anyone's feedback on it!

hshuaib90 commented 1 year ago

Thanks @AgatheZ , can you explain the role of .sensitive_exceptions?

AgatheZ commented 1 year ago

@hshuaib90 .sensitive_exceptions is a file you can populate to define exceptions, for instance if you want to include your name in all of your scripts, or if it catches instances it shouldn't have, without ignoring entire files.

hshuaib90 commented 1 year ago

In that case I suggest you commit an empty file or some default value and then in the documentation explain that you can use this file for exception but that it probably shouldn't be committed itself.

AgatheZ commented 1 year ago

@hshuaib90 sorry for the delay.

A few updates: