Skip to content

Commit

Permalink
Add support for wildcard update. See #3
Browse files Browse the repository at this point in the history
  • Loading branch information
roddhjav committed Sep 16, 2017
1 parent f0bde7b commit 6f5361f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 13 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ A [pass][pass] extension that provides an easy flow for updating passwords.

## Description
`pass update` extends the pass utility with an update command providing
an easy flow for updating passwords. It allows you to update all the passwords
in a folder or to provide the extact list of password to update. Moreover, you
can select how to update your passwords by automaticaly generating new passwords
or manually setting your own.
an easy flow for updating passwords. It supports path, directory and wildcard
update. Moreover, you can select how to update your passwords by automaticaly
generating new passwords or manually setting your own.

By default `pass update` prints the old password and wait for the user before
generating a new one. This behavior can be changed using the provided options.
Expand Down
14 changes: 7 additions & 7 deletions pass-update.1
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ passwords.

.SH DESCRIPTION
\fBpass update\fP extends the pass utility with an update command providing
an easy flow for updating passwords. It allows you to update all the passwords
in a folder or to provide the extact list of password to update. Moreover, you
can select how to update your passwords by automaticaly generating new passwords
or manually setting your own.
an easy flow for updating passwords. It supports path, directory and wildcard
update. Moreover, you can select how to update your passwords by automaticaly
generating new passwords or manually setting your own.

By default \fBpass update\fP prints the old password and wait for the user before
generating a new one. This behavior can be changed using the provided options.

.SH COMMAND
.TP
\fBpass update\fP [ \fI--clip\fP, \fI-c\fP ] [ \fI--no-symbols\fP, \fI-n\fP ] [ \fI--provide\fP, \fI-p\fP ]
[\fI--length=<size>\fP, \fI-l <size>\fP] [ \fI--multiline\fP, \fI-m\fP ] [ \fI--edit\fP, \fI-e\fP ]
\fIpass-names...\fP
[\fI--length=<size>\fP, \fI-l <size>\fP] [ \fI--edit\fP, \fI-e\fP ]
[ \fI--multiline\fP, \fI-m\fP ] \fIpass-names...\fP

Update the password provided: print the password and wait for the user to
generate a new one.

.I pass-names
can refer either to password store path(s) or to directory. Both path and
directory can be given in the same command. When updating a directory, all the
password in this directory are updated.
password in this directory are updated. Wildcard update are supported by quoting
\fI'*'\fP sign.

Both old and newly generated password can optionally be written on the clipboard
using the \fI--clip\fP or \fI-c\fP option.
Expand Down
5 changes: 5 additions & 0 deletions tests/00_update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ test_expect_success 'Updating multiple password' '
_pass update --force Email/
'

test_expect_success "Testing bulkd update" "
_pass update --force Email/ &&
_pass update --force 'Business/*/login'
"

test_expect_success 'Updating password with specific length' '
_pass update --force --length=50 France/bank
'
Expand Down
6 changes: 6 additions & 0 deletions tests/setup
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ test_pass_populate() {
pass init "$KEY1"
pass_insert "Business/site.com" "$RANDOM"
pass_insert "Business/site.eu" "$RANDOM"
pass_insert "Business/bitcoin/login" "$RANDOM"
pass_insert "Business/bitcoin/username" "$RANDOM"
pass_insert "Business/a space/login" "$RANDOM"
pass_insert "Business/a space/username" "$RANDOM"
pass_insert "Business/euro/login" "$RANDOM"
pass_insert "Business/euro/username" "$RANDOM"
pass_insert "Email/donenfeld.com" "$RANDOM"
pass_insert "Email/zx2c4.com" "$RANDOM"
pass_insert "France/bank" "$RANDOM"
Expand Down
11 changes: 9 additions & 2 deletions update.bash
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,19 @@ cmd_update() {

# Get a curated list of path to update
typeset -a paths=() passfiles=()
local path passfile passdir file
local path passfile passdir file tmpfile
for path in "$@"; do
check_sneaky_paths "$path"
passfile="$PREFIX/${path%/}.gpg"
passdir="$PREFIX/${path%/}"
if [[ -d "$passdir" ]]; then
if [[ $path =~ [*] ]]; then
for file in $PREFIX/$path.gpg; do
if [[ -f $file ]]; then
tmpfile="${file#$PREFIX/}"
paths+=("${tmpfile%.gpg}")
fi
done
elif [[ -d "$passdir" ]]; then
passfiles=($(find "$passdir" -type f -iname '*.gpg' -printf "$path/%P\n"))
for file in "${passfiles[@]}"; do paths+=("${file%.gpg}") ; done
else
Expand Down

0 comments on commit 6f5361f

Please sign in to comment.