mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-12-01 05:24:22 +01:00
better naming
This commit is contained in:
1 parent
a430e46a8e
commit
15d3d8e7de
4 files changed
+65
-117
No files matched your search
@@ -1,51 +1,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/nbutton23/zxcvbn-go"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// checkDiff operates on a single diff between to chronological commits
|
||||
func checkDiff(commit1 string, commit2 string, repoName string) []string {
|
||||
// var leakPrs bool
|
||||
// var leaks []string
|
||||
// _, seen := cache[commit1+commit2]
|
||||
// if seen {
|
||||
// fmt.Println("WE HAVE SEEN THIS")
|
||||
// return []string{}
|
||||
// }
|
||||
|
||||
if err := os.Chdir(fmt.Sprintf("%s/%s", appRoot, repoName)); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
cmd := exec.Command("git", "diff", commit1, commit2)
|
||||
_, err := cmd.Output()
|
||||
// fmt.Println(string(out))
|
||||
if err != nil {
|
||||
return []string{}
|
||||
}
|
||||
return []string{}
|
||||
|
||||
// cache[commit1+commit2] = true
|
||||
// lines := checkRegex(string(out))
|
||||
// if len(lines) == 0 {
|
||||
// return []string{}
|
||||
// }
|
||||
//
|
||||
// for _, line := range lines {
|
||||
// leakPrs = checkEntropy(line)
|
||||
// if leakPrs {
|
||||
// leaks = append(leaks, line)
|
||||
// }
|
||||
// }
|
||||
// return leaks
|
||||
}
|
||||
|
||||
// check each line of a diff and see if there are any potential secrets
|
||||
// [1] https://people.eecs.berkeley.edu/~rohanpadhye/files/key_leaks-msr15.pdf
|
||||
func checkRegex(diff string) []string {
|
||||
@@ -54,7 +13,7 @@ func checkRegex(diff string) []string {
|
||||
lines := strings.Split(diff, "\n")
|
||||
for _, line := range lines {
|
||||
// doubtful a leak would be on a line > 120 characters
|
||||
if len(line) == 0 || len(line) > 80 {
|
||||
if len(line) == 0 || len(line) > 120 {
|
||||
continue
|
||||
}
|
||||
for _, re := range regexes {
|
||||
@@ -85,7 +44,6 @@ func checkEntropy(target string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// entropy := shannonEntropy(target)
|
||||
entropy := zxcvbn.PasswordStrength(target, nil).Entropy
|
||||
|
||||
// tune this/make option
|
||||
|
||||
Reference in new issue
Block a user