From 040d7baf997131d12b151f2a770061ebcf4cdba2 Mon Sep 17 00:00:00 2001 From: "Carlos A. Parra F" Date: Wed, 24 Mar 2021 11:29:50 +0100 Subject: [PATCH] Replaced legacy `..` with equivalent $(..). --- src/alert_methods/SCP/alert | 12 ++++++------ src/alert_methods/TippingPoint/alert | 10 +++++----- src/alert_methods/vFire/alert | 2 +- tools/create-gvm-migrate-config | 2 +- tools/greenbone-feed-sync.in | 16 ++++++++-------- tools/gvm-export-config | 8 ++++---- tools/gvm-manage-certs.in | 2 +- tools/gvm-migrate-config | 2 +- 8 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/alert_methods/SCP/alert b/src/alert_methods/SCP/alert index a75563ab65..24b0d871bb 100755 --- a/src/alert_methods/SCP/alert +++ b/src/alert_methods/SCP/alert @@ -26,15 +26,15 @@ PRIVATE_KEY_FILE=$5 PASSWORD_FILE=$6 REPORT_FILE=$7 -KNOWN_HOSTS_FILE=`mktemp` || exit 1 +KNOWN_HOSTS_FILE=$(mktemp) || exit 1 echo $KNOWN_HOSTS > $KNOWN_HOSTS_FILE -ERROR_FILE=`mktemp` || exit 1 +ERROR_FILE=$(mktemp) || exit 1 log_error() { # remove \r used in line feed by scp or sshpass (\r\n) # which can make journalctl interpret the output as blob data - MESSAGE=`echo "$1" | tr -d '\r'` + MESSAGE=$(echo "$1" | tr -d '\r') logger "SCP alert: $MESSAGE" echo "$MESSAGE" >&2 } @@ -51,18 +51,18 @@ then fi # Escape destination because it is also expanded on the remote end. -DEST_ESC=`shell_esc "$DEST"` +DEST_ESC=$(shell_esc "$DEST") if [ -z "$PRIVATE_KEY_FILE" ] then timeout $TIMEOUT sshpass -f ${PASSWORD_FILE} scp -o HashKnownHosts=no -o UserKnownHostsFile="${KNOWN_HOSTS_FILE} ~/.ssh/known_hosts ~/.ssh/known_hosts2 /etc/ssh/ssh_known_hosts" "${REPORT_FILE}" "${USERNAME}@${HOST}:${DEST_ESC}" 2>$ERROR_FILE else - timeout $TIMEOUT sshpass -f ${PASSWORD_FILE} -P "passphrase" scp -i "$PRIVATE_KEY_FILE" -o PasswordAuthentication=no -o HashKnownHosts=no -o UserKnownHostsFile="${KNOWN_HOSTS_FILE} ~/.ssh/known_hosts ~/.ssh/known_hosts2 /etc/ssh/ssh_known_hosts" "${REPORT_FILE}" "${USERNAME}@${HOST}:${DEST_ESC}" 2>$ERROR_FILE + timeout $TIMEOUT sshpass -f ${PASSWORD_FILE} -P "passphrase" scp -i "$PRIVATE_KEY_FILE" -o PasswordAuthentication=no -o HashKnownHosts=no -o UserKnownHostsFile="${KNOWN_HOSTS_FILE} ~/.ssh/known_hosts ~/.ssh/known_hosts2 /etc/ssh/ssh_known_hosts" "${REPORT_FILE}" "${USERNAME}@${HOST}:${DEST_ESC}" 2>"$ERROR_FILE" fi EXIT_CODE=$? -ERROR_SHORT=`head -n 3 $ERROR_FILE` +ERROR_SHORT=$(head -n 3 "$ERROR_FILE") if [ $EXIT_CODE -eq 1 ] then diff --git a/src/alert_methods/TippingPoint/alert b/src/alert_methods/TippingPoint/alert index fcef4d5d7e..f2ffdc9659 100644 --- a/src/alert_methods/TippingPoint/alert +++ b/src/alert_methods/TippingPoint/alert @@ -32,7 +32,7 @@ urlencode () { } # Create temp file for converted report -REPORT_DATE=$(xmlstarlet sel -t -v "report/timestamp" < $REPORT_PATH) +REPORT_DATE=$(xmlstarlet sel -t -v "report/timestamp" < "$REPORT_PATH") EXIT_CODE=$? if [ 0 -ne $EXIT_CODE ] then @@ -41,7 +41,7 @@ fi REPORT_DATE=$(date -d "$REPORT_DATE" +%Y%m%d%H%M%S) -CONVERTED_PATH=$(mktemp "$(dirname ${REPORT_PATH})/report-${REPORT_DATE}-XXXXXX.csv") +CONVERTED_PATH=$(mktemp "$(dirname "${REPORT_PATH}")/report-${REPORT_DATE}-XXXXXX.csv") EXIT_CODE=$? if [ 0 -ne $EXIT_CODE ] then @@ -58,7 +58,7 @@ then fi # Get and reformat scan run times -START_TIME=$(xmlstarlet sel -t -v "report/scan_start" < $REPORT_PATH) +START_TIME=$(xmlstarlet sel -t -v "report/scan_start" < "$REPORT_PATH") EXIT_CODE=$? if [ 0 -ne $EXIT_CODE ] then @@ -66,7 +66,7 @@ then fi START_TIME=$(TZ=UTC date -d "$START_TIME" +%Y-%m-%dT%H:%M:%S.000Z) -END_TIME=$(xmlstarlet sel -t -v "report/scan_end" < $REPORT_PATH) +END_TIME=$(xmlstarlet sel -t -v "report/scan_end" < "$REPORT_PATH") EXIT_CODE=$? if [ 0 -ne $EXIT_CODE ] then @@ -81,7 +81,7 @@ PRODUCT=$(urlencode "Greenbone Vulnerability Manager") FORMAT_VERSION=$(urlencode "1.0.0") CN_REPLACEMENT="Tippingpoint" -if [ "1" = $CERT_WORKAROUND ] +if [ "1" = "$CERT_WORKAROUND" ] then HTTP_CODE=$(curl -s -w ' - Status code %{http_code}' -F "file=@$CONVERTED_PATH" --netrc-file "$AUTH_PATH" "https://$CN_REPLACEMENT/vulnscanner/import?vendor=$VENDOR&product=$PRODUCT&version=$FORMAT_VERSION&runtime=$RUNTIME" --cacert "$CERT_PATH" --resolve "$CN_REPLACEMENT:443:$SMS_ADDRESS") CURL_EXIT="$?" diff --git a/src/alert_methods/vFire/alert b/src/alert_methods/vFire/alert index 44e26a5d17..e98508b3c1 100644 --- a/src/alert_methods/vFire/alert +++ b/src/alert_methods/vFire/alert @@ -17,7 +17,7 @@ # along with this program. If not, see . ALERT_CONFIG="$1" -CONNECTOR=`which greenbone_vfire_connector` +CONNECTOR=$(which greenbone_vfire_connector) if [ -z "$ALERT_CONFIG" ] then diff --git a/tools/create-gvm-migrate-config b/tools/create-gvm-migrate-config index acc88b746a..a184ecac29 100755 --- a/tools/create-gvm-migrate-config +++ b/tools/create-gvm-migrate-config @@ -67,7 +67,7 @@ cat > gvm-migrate-config << 'OUTER' # Make a temp dir. -TMP=`mktemp -d` || exit 1 +TMP=$(mktemp -d) || exit 1 # Output a temporary XSL file to do the config conversion. diff --git a/tools/greenbone-feed-sync.in b/tools/greenbone-feed-sync.in index 0eaf3d42b2..fd0e450685 100644 --- a/tools/greenbone-feed-sync.in +++ b/tools/greenbone-feed-sync.in @@ -126,7 +126,7 @@ else fi -RSYNC=`command -v rsync` +RSYNC=$(command -v rsync) # Current supported feed types (for --type parameter) FEED_TYPES_SUPPORTED="CERT, SCAP or GVMD_DATA" @@ -250,7 +250,7 @@ init_feed_type () { write_feed_xml () { if [ -r $TIMESTAMP ] then - FEED_VERSION=`cat $TIMESTAMP` + FEED_VERSION=$(cat $TIMESTAMP) else FEED_VERSION=0 fi @@ -271,7 +271,7 @@ write_feed_xml () { } create_tmp_key () { - KEYTEMPDIR=`mktemp -d` + KEYTEMPDIR=$(mktemp -d) cp "$ACCESSKEY" "$KEYTEMPDIR" TMPACCESSKEY="$KEYTEMPDIR/gsf-access-key" chmod 400 "$TMPACCESSKEY" @@ -325,7 +325,7 @@ get_value () is_feed_current () { if [ -r $TIMESTAMP ] then - FEED_VERSION=`cat $TIMESTAMP` + FEED_VERSION=$(cat $TIMESTAMP) fi if [ -z "$FEED_VERSION" ] @@ -335,12 +335,12 @@ is_feed_current () { return $FEED_CURRENT fi - FEED_INFO_TEMP_DIR=`mktemp -d` + FEED_INFO_TEMP_DIR=$(mktemp -d) if [ -e $ACCESSKEY ] then read feeduser < $ACCESSKEY - custid_at_host=`head -1 $ACCESSKEY | cut -d : -f 1` + custid_at_host=$(head -1 $ACCESSKEY | cut -d : -f 1) if [ -z "$feeduser" ] || [ -z "$custid_at_host" ] then @@ -390,7 +390,7 @@ is_feed_current () { fi fi - FEED_VERSION_SERVER=`cat "$FEED_INFO_TEMP_DIR/timestamp"` + FEED_VERSION_SERVER=$(cat "$FEED_INFO_TEMP_DIR/timestamp") if [ -z "$FEED_VERSION_SERVER" ] then @@ -470,7 +470,7 @@ sync_feed_data(){ mkdir -p "$FEED_DIR" read feeduser < $ACCESSKEY - custid_at_host=`head -1 $ACCESSKEY | cut -d : -f 1` + custid_at_host=$(head -1 $ACCESSKEY | cut -d : -f 1) if [ -z "$feeduser" ] || [ -z "$custid_at_host" ] then diff --git a/tools/gvm-export-config b/tools/gvm-export-config index 8abe343963..60f269dd52 100755 --- a/tools/gvm-export-config +++ b/tools/gvm-export-config @@ -45,15 +45,15 @@ sql () { echo "" echo -n " " -echo -n `sql "SELECT name FROM configs WHERE uuid = '$UUID'"` +echo -n $(sql "SELECT name FROM configs WHERE uuid = '$UUID'") echo "" echo -n " " -echo -n `sql "SELECT comment FROM configs WHERE uuid = '$UUID'"` +echo -n $(sql "SELECT comment FROM configs WHERE uuid = '$UUID'") echo "" echo -n " " -echo -n `sql "SELECT type FROM configs WHERE uuid = '$UUID'"` +echo -n $(sql "SELECT type FROM configs WHERE uuid = '$UUID'") echo "" echo " scan" @@ -68,7 +68,7 @@ echo " " echo " " -SELECTOR=`sql "SELECT nvt_selector FROM configs WHERE uuid='${UUID}';"` +SELECTOR=$(sql "SELECT nvt_selector FROM configs WHERE uuid='${UUID}';") if [ "$SELECTOR" = "54b45713-d4f4-4435-b20d-304c175ed8c5" ]; then echo " " else diff --git a/tools/gvm-manage-certs.in b/tools/gvm-manage-certs.in index dd986c028d..4eee940b72 100644 --- a/tools/gvm-manage-certs.in +++ b/tools/gvm-manage-certs.in @@ -196,7 +196,7 @@ set_up () if [ -z "$GVM_CERT_DIR" ] then USE_TEMP_DIR=1 - GVM_CERT_DIR=`mktemp -d` + GVM_CERT_DIR=$(mktemp -d) log_verbose "Using $GVM_CERT_DIR to temporarily store files." else USE_TEMP_DIR=0 diff --git a/tools/gvm-migrate-config b/tools/gvm-migrate-config index a05879a37e..0e26d87efe 100755 --- a/tools/gvm-migrate-config +++ b/tools/gvm-migrate-config @@ -24,7 +24,7 @@ # Make a temp dir. -TMP=`mktemp -d` || exit 1 +TMP=$(mktemp -d) || exit 1 # Output a temporary XSL file to do the config conversion.