-
-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
`gopass audit` validates known passwords against common flaws, like being too short or systematic. This uses my own Golang implementation of cracklib: https://github.com/muesli/crunchy
- Loading branch information
1 parent
916ab24
commit a5938cb
Showing
17 changed files
with
935 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package action | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"os" | ||
|
||
"github.com/muesli/crunchy" | ||
"github.com/urfave/cli" | ||
) | ||
|
||
// Audit validates passwords against common flaws | ||
func (s *Action) Audit(c *cli.Context) error { | ||
t, err := s.Store.Tree() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
validator := crunchy.NewValidator() | ||
var out io.Writer | ||
out = os.Stdout | ||
|
||
foundWeakPasswords := false | ||
for _, secret := range t.List(0) { | ||
content, err := s.Store.Get(secret) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err = validator.Check(string(content)); err != nil { | ||
foundWeakPasswords = true | ||
fmt.Fprintf(out, "Detected weak password for %s: %v\n", secret, err) | ||
} | ||
} | ||
|
||
if !foundWeakPasswords { | ||
fmt.Fprintln(out, "No weak passwords detected.") | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package tests | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestAudit(t *testing.T) { | ||
ts := newTester(t) | ||
defer ts.teardown() | ||
|
||
ts.initStore() | ||
ts.initSecrets("") | ||
|
||
list := `Detected weak password for fixed/secret: Password is too short` | ||
out, err := ts.run("audit") | ||
assert.NoError(t, err) | ||
assert.Equal(t, strings.TrimSpace(list), out) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.