This self-paced course will help you prepare for the Azure Developer certification exam AZ-204: Developing Solutions for Microsoft Azure.
Prevents you from committing passwords and other sensitive information to a git repository.
git-secrets scans commits, commit messages, and
--no-ff merges to prevent adding secrets into your git repositories. If a commit, commit message, or any commit in a
--no-ff merge history matches one of your configured prohibited regular expression patterns, then the commit is rejected.
git-secrets must be placed somewhere in your PATH so that it is picked up by
git when running
You can use the install target of the provided Makefile to install git secrets and the man page. You can customize the install path using the PREFIX and MANPREFIX variables.
Windows OS :
Run the provided install.ps1 powershell script. This will copy the needed files to an installation directory (%USERPROFILE%/.git-secrets by default) and add the directory to the current user PATH.
PS > ./install.ps1
Run the below command to install the git secrets on the mac machine .
brew install git-secrets
--install :Installs git hooks for a repository. Once the hooks are installed for a git repository, commits and non-fast-forward merges for that repository will be prevented from committing secrets.
--scan : Scans one or more files for secrets. When a file contains a secret, the matched text from the file being scanned will be written to stdout and the script will exit with a non-zero status. If no files are provided, all files returned by
git ls-files are scanned.
--scan-history: Scans repository including all revisions. When a file contains a secret, the matched text from the file being scanned will be written to stdout and the script will exit with a non-zero status.
--list: Lists the
git-secrets configuration for the current repo or in the global git config.
--add :Adds a prohibited or allowed pattern.
--add-provider: Registers a secret provider. Secret providers are executables that when invoked output prohibited patterns that
git-secrets should treat as prohibited.
--register-aws:Adds common AWS patterns to the git config and ensures that keys present in
~/.aws/credentials are not found in any commit.
--register-azure:Adds common AZURE patterns to the git config and ensures that keys present in
~/.azure/credentials are not found in any commit.
-f, --force: Overwrites existing hooks if present while installation of git secrets.
-r, --recursive :Scans the given files recursively. If a directory is encountered, the directory will be scanned. If
-r is not provided, directories will be ignored.
--cached:Searches blobs registered in the index file.
--no-index :Searches files in the current directory that is not managed by git.
--untracked :In addition to searching in the tracked files in the working tree.
2. Once after the installation is completed , then we need to start the scanning of our repository before we checkin the code .
Depending upon the secrets it will throw us the error , if we did not get any error then we can commit it accordingly.
3. By this way we can even add it as part of our CICD pipeline so that even during our code build it scans and then shows us the error .
We also have a lot of code scanning tools like this to detect the secrets in our code such as :
Repo Security Scanner
In our next topic , we will see the same secrets scanning using Truffle Hog .