mirror of
https://github.com/trufflesecurity/trufflehog.git
synced 2024-11-10 07:04:24 +00:00
[chore] - update docs for pre-commit (#2280)
* update docs for pre-commit * fix spacing
This commit is contained in:
parent
24a09bc37d
commit
b2c0d50ba8
2 changed files with 8 additions and 2 deletions
|
@ -421,6 +421,12 @@ If you'd like to specify specific `base` and `head` refs, you can use the `base`
|
||||||
## Pre-commit Hook
|
## Pre-commit Hook
|
||||||
|
|
||||||
Trufflehog can be used in a pre-commit hook to prevent credentials from leaking before they ever leave your computer.
|
Trufflehog can be used in a pre-commit hook to prevent credentials from leaking before they ever leave your computer.
|
||||||
|
|
||||||
|
**Key Usage Note:**
|
||||||
|
|
||||||
|
- **For optimal hook efficacy, execute `git add` followed by `git commit` separately.** This ensures Trufflehog analyzes all intended changes.
|
||||||
|
- **Avoid using `git commit -am`, as it might bypass pre-commit hook execution for unstaged modifications.**
|
||||||
|
|
||||||
An example `.pre-commit-config.yaml` is provided (see [pre-commit.com](https://pre-commit.com/) for installation).
|
An example `.pre-commit-config.yaml` is provided (see [pre-commit.com](https://pre-commit.com/) for installation).
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
|
|
@ -120,7 +120,7 @@ func NormalizeOrgRepoURL(provider provider, repoURL string) (string, error) {
|
||||||
func GenerateLink(repo, commit, file string, line int64) string {
|
func GenerateLink(repo, commit, file string, line int64) string {
|
||||||
// Some paths contain '%' which breaks |url.Parse| if not encoded.
|
// Some paths contain '%' which breaks |url.Parse| if not encoded.
|
||||||
// https://developer.mozilla.org/en-US/docs/Glossary/Percent-encoding
|
// https://developer.mozilla.org/en-US/docs/Glossary/Percent-encoding
|
||||||
file = strings.Replace(file, "%", "%25", -1)
|
file = strings.ReplaceAll(file, "%", "%25")
|
||||||
|
|
||||||
switch determineProvider(repo) {
|
switch determineProvider(repo) {
|
||||||
case providerBitbucket:
|
case providerBitbucket:
|
||||||
|
@ -140,7 +140,7 @@ func GenerateLink(repo, commit, file string, line int64) string {
|
||||||
default:
|
default:
|
||||||
var baseLink string
|
var baseLink string
|
||||||
|
|
||||||
//Gist links are formatted differently
|
// Gist links are formatted differently
|
||||||
if strings.HasPrefix(repo, "https://gist.github.com") {
|
if strings.HasPrefix(repo, "https://gist.github.com") {
|
||||||
baseLink = repo[:len(repo)-4] + "/"
|
baseLink = repo[:len(repo)-4] + "/"
|
||||||
if commit != "" {
|
if commit != "" {
|
||||||
|
|
Loading…
Reference in a new issue