From: Steven Baltakatei Sandoval Date: Sat, 4 Jul 2020 22:11:45 +0000 (+0000) Subject: Merge branch 'feature/location-logging/EVA-2020-02' into develop X-Git-Url: https://zdv2.bktei.com/gitweb/EVA-2020-02.git/commitdiff_plain/0b923d462ecb33b04d1fdd7e45ecbd4ed79c1509?hp=be7d63ee8c19b5109c5f25deb3c1ed8dc05ace41 Merge branch 'feature/location-logging/EVA-2020-02' into develop --- diff --git a/exec/bkgpslog b/exec/bkgpslog index 9dba7bc..84a74b0 100755 --- a/exec/bkgpslog +++ b/exec/bkgpslog @@ -819,6 +819,42 @@ appendFileTar(){ try tar --append --directory="$TMP_DIR" --file="$TAR_PATH" "$FILENAME"; #yell "DEBUG:STATUS:$FN:Finished appendFileTar()." } # Append file to Tar archive +validateInput() { + # Desc: Validates Input + # Usage: validateInput [str input] [str input type] + # Version: 0.2.1 + # Input: arg1: string to validate + # arg2: string specifying input type (ex:"ssh_pubkey") + # Output: return code 0: if input string matched specified string type + # Depends: bash 5, yell + + # Save function name + local FN="${FUNCNAME[0]}"; + + # Process arguments + argInput="$1"; + argType="$2"; + if [[ $# -gt 2 ]]; then yell "ERROR:$0:$FN:Too many arguments."; exit 1; fi; + + # Check for blank + if [[ -z "$argInput" ]]; then return 1; fi + + # Define input types + ## ssh_pubkey + ### Check for alnum/dash base64 (ex: "ssh-rsa AAAAB3NzaC1yc2EAAA") + if [[ "$argType" = "ssh_pubkey" ]]; then + if [[ "$argInput" =~ ^[[:alnum:]-]*[\ ]*[[:alnum:]+/=]*$ ]]; then + return 0; fi; fi; + + ## age_pubkey + ### Check for age1[:bech32:] + if [[ "$argType" = "age_pubkey" ]]; then + if [[ "$argInput" =~ ^age1[qpzry9x8gf2tvdw0s3jn54khce6mua7l]*$ ]]; then + return 0; fi; fi + + # Return error if no condition matched. + return 1; +} # Validates strings magicWriteVersion() { # Desc: Appends time-stamped VERSION to PATHOUT_TAR # Usage: magicWriteVersion @@ -935,7 +971,8 @@ main() { if checkapp age; then # Check that age is available. for pubkey in "${recPubKeys[@]}"; do # Validate recipient pubkey strings by forming test message vbm "DEBUG:Testing pubkey string:$pubkey"; - if echo "butts" | age -a -r "$pubkey" 1>/dev/null; then + if echo "butts" | age -a -r "$pubkey" 1>/dev/null && + ( validateInput "$pubkey" "ssh_pubkey" || validateInput "$pubkey" "age_pubkey"); then #### Form age recipient string recipients="$recipients""-r '$pubkey' "; vbm "STATUS:Added pubkey for forming age recipient string:""$pubkey";