`gopass audit` now also detects dupe/shared passwords
@@ -4,6 +4,7 @@ import (
"fmt"
"io"
"os"
+ "strings"
"github.com/muesli/crunchy"
"github.com/urfave/cli"
@@ -20,6 +21,7 @@ func (s *Action) Audit(c *cli.Context) error {
var out io.Writer
out = os.Stdout
+ dupes := make(map[string][]string)
foundWeakPasswords := false
for _, secret := range t.List(0) {
content, err := s.Store.Get(secret)
@@ -27,15 +29,23 @@ func (s *Action) Audit(c *cli.Context) error {
return err
}
- if err = validator.Check(string(content)); err != nil {
+ pw := string(content)
+ if err = validator.Check(pw); err != nil {
foundWeakPasswords = true
fmt.Fprintf(out, "Detected weak password for %s: %v\n", secret, err)
}
+
+ dupes[pw] = append(dupes[pw], secret)
}
if !foundWeakPasswords {
fmt.Fprintln(out, "No weak passwords detected.")
}
+ for _, dupe := range dupes {
+ if len(dupe) > 1 {
+ fmt.Fprintf(out, "Detected a shared password for %s\n", strings.Join(dupe, ", "))
+ }
+ }
return nil
}
