github.com/StackExchange/blackbox/v2@v2.0.1-0.20220331193400-d84e904973ab/bin/blackbox_shred_all_files (about) 1 #!/usr/bin/env bash 2 3 # 4 # blackbox_shred_all_files -- shred all decrypted versions of encrypted files 5 # 6 # Shred: To securely delete a file. 7 # 8 # Typical uses: 9 # After running blackbox_edit_start, deciding not to edit the file. 10 # A developer that wants to securely clean up a workspace before deleting it. 11 # An automated process that doesn't want to leave 12 # plaintext (unencrypted) files laying around. 13 # 14 # NOTE: The output lists files that were decrypted and are being 15 # shredded. For example, if you have many encrypted files but none 16 # have been decrypted for editing, you will see an empty list. 17 18 set -e 19 source "${0%/*}/_blackbox_common.sh" 20 21 change_to_vcs_root 22 23 echo '========== FILES BEING SHREDDED:' 24 25 exported_internal_shred_file() { 26 source "$1/_blackbox_common.sh" 27 #unencrypted_file=$(get_unencrypted_filename "$2") 28 unencrypted_file="$2" 29 if [[ -f "$unencrypted_file" ]]; then 30 echo " SHRED: $unencrypted_file" 31 shred_file "$unencrypted_file" 32 else 33 echo "NOT FOUND: $unencrypted_file" 34 fi 35 } 36 37 export -f exported_internal_shred_file 38 39 DEREFERENCED_BIN_DIR="${0%/*}" 40 MAX_PARALLEL_SHRED=10 41 42 bash_args= 43 if bash --help | grep import-functions >/dev/null 2>/dev/null; then 44 bash_args=--import-functions 45 fi 46 47 export IFS= 48 tr '\n' '\0' <"$BB_FILES" | xargs -0 -I{} -P $MAX_PARALLEL_SHRED bash $bash_args -c "exported_internal_shred_file $DEREFERENCED_BIN_DIR \"{}\"" $DEREFERENCED_BIN_DIR/fake 49 50 echo '========== DONE.'