It will be annoying when scan code in Git, especially because Gitlab does not support code snippet search in CE version. This script will be helpful.
In some scenarios, we need to check the leaked credentials in maultiple Git repos. It will be annoying to scan code in Git when there are many projects, especially because Gitlab does not support code snippet search in CE version.
This script iterator with *.git directories, and check each Git repo with git command, let’s explain it in details.
Get the files in Git repo
git ls-tree will display the file paths in branch
git show HEAD:file-path will show the file content of a tracking file, with a gripe to filter with keyword.
Find the related user
If we want to do some fix, we need to find the latest author for review the fix.
git log will display the author:
Code scan snippet in git Repos
Combine the commands into final check scripts.
For more study please refer to: Version Control with Git: Powerful tools and techniques for collaborative software development
Join my Email List for more helpful insights, It's Free!😋