diff --git a/README.md b/README.md index 098ea4c..3a4dfa2 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/pass-update.1 b/pass-update.1 index 0a15efd..50be53c 100644 --- a/pass-update.1 +++ b/pass-update.1 @@ -9,10 +9,9 @@ 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. @@ -20,8 +19,8 @@ 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=\fP, \fI-l \fP] [ \fI--multiline\fP, \fI-m\fP ] [ \fI--edit\fP, \fI-e\fP ] - \fIpass-names...\fP + [\fI--length=\fP, \fI-l \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. @@ -29,7 +28,8 @@ 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. diff --git a/tests/00_update.sh b/tests/00_update.sh index 384194a..cdd370f 100644 --- a/tests/00_update.sh +++ b/tests/00_update.sh @@ -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 ' diff --git a/tests/setup b/tests/setup index c15a2c4..0c80f11 100644 --- a/tests/setup +++ b/tests/setup @@ -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" diff --git a/update.bash b/update.bash index 5d10d59..7d70e9a 100755 --- a/update.bash +++ b/update.bash @@ -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