Are there any open source tools that scans the code and detects such gaffes
You install their Github app and give them access to your Github repo (private repos are ok too) and they run a Github workflow when each PR is submitted scanning for secrets that should not be in the code. Really happy with how their product works.
I worked for them a little bit and their product is really impressive and works great.