-
Notifications
You must be signed in to change notification settings - Fork 29
Open
Description
First try pre-commit + gitleaks
Using gitleaks : https://github.com/zricethezav/gitleaks
And pre-commit: https://pre-commit.com/#install
Example script:
"postinstall": "test -n \"$SKIP_PRE_COMMIT_INSTALL\" && echo 'Skipping pre-commit install' || pre-commit install # Please see 'https://pre-commit.com/#install'",
This needs Python to install "pre-commit" and "go" to run gitleaks. Therefore, a more appropriate alternative would be using Husky + the Docker version of gitleaks, similarly to what we do to run Mongo.
Second try with Husky + Docker
In package.json:
"prepare": "husky install || echo 'Husky command not installed or not working, are you running in production? You won't be protected when committing code",
"pre-commit:gitleaks": "docker run -v $(pwd):/path zricethezav/gitleaks:latest detect --source=\"/path\" --report-format json",
"pre-commit": "# Automatically run by husky on commit",With husky set to run "npm run pre-commit"
=> very slow, gives false positive
3rd try With protect command
It seems that the command we need is protect. Will test and finish this issue when the commands are ok.
Not sure if it actually catches leak yet, to be tested more extensively:
"prepare": "husky install || echo 'Husky command not installed or not working, are you running in production? You won't be protected when committing code",
"detect-leaks": "docker run -v $(pwd):/path zricethezav/gitleaks:latest detect -v --source=\"/path\"",
"pre-commit:gitleaks": "docker run -v $(pwd):/path zricethezav/gitleaks:latest protect -v --source=\"/path\" --staged",
"pre-commit": "echo 'Running yarn pre-commit command' && yarn run pre-commit:gitleaks # Automatically run by husky on commit",Metadata
Metadata
Assignees
Labels
No labels