forked from gopasspw/gopass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
audit.go
37 lines (29 loc) · 796 Bytes
/
audit.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package action
import (
"context"
"github.com/justwatchcom/gopass/pkg/audit"
"github.com/justwatchcom/gopass/pkg/out"
"github.com/urfave/cli"
)
// Audit validates passwords against common flaws
func (s *Action) Audit(ctx context.Context, c *cli.Context) error {
filter := c.Args().First()
out.Print(ctx, "Auditing passwords for common flaws ...")
t, err := s.Store.Tree(ctx)
if err != nil {
return ExitError(ctx, ExitList, err, "failed to get store tree: %s", err)
}
if filter != "" {
subtree, err := t.FindFolder(filter)
if err != nil {
return ExitError(ctx, ExitUnknown, err, "failed to find subtree: %s", err)
}
t = subtree
}
list := t.List(0)
if len(list) < 1 {
out.Yellow(ctx, "No secrets found")
return nil
}
return audit.Batch(ctx, list, s.Store)
}