Skip to content

Commit

Permalink
Replaced legacy .. with equivalent $(..).
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos A. Parra F committed Mar 29, 2021
1 parent a82d1d4 commit 040d7ba
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
12 changes: 6 additions & 6 deletions src/alert_methods/SCP/alert
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/alert_methods/TippingPoint/alert
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -58,15 +58,15 @@ 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
exit $EXIT_CODE
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
Expand All @@ -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="$?"
Expand Down
2 changes: 1 addition & 1 deletion src/alert_methods/vFire/alert
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

ALERT_CONFIG="$1"
CONNECTOR=`which greenbone_vfire_connector`
CONNECTOR=$(which greenbone_vfire_connector)

if [ -z "$ALERT_CONFIG" ]
then
Expand Down
2 changes: 1 addition & 1 deletion tools/create-gvm-migrate-config
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
16 changes: 8 additions & 8 deletions tools/greenbone-feed-sync.in
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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" ]
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tools/gvm-export-config
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ sql () {
echo "<config id=\"${UUID}\">"

echo -n " <name>"
echo -n `sql "SELECT name FROM configs WHERE uuid = '$UUID'"`
echo -n $(sql "SELECT name FROM configs WHERE uuid = '$UUID'")
echo "</name>"

echo -n " <comment>"
echo -n `sql "SELECT comment FROM configs WHERE uuid = '$UUID'"`
echo -n $(sql "SELECT comment FROM configs WHERE uuid = '$UUID'")
echo "</comment>"

echo -n " <type>"
echo -n `sql "SELECT type FROM configs WHERE uuid = '$UUID'"`
echo -n $(sql "SELECT type FROM configs WHERE uuid = '$UUID'")
echo "</type>"

echo " <usage_type>scan</usage_type>"
Expand All @@ -68,7 +68,7 @@ echo " </preferences>"

echo " <nvt_selectors>"

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 " <all_selector/>"
else
Expand Down
2 changes: 1 addition & 1 deletion tools/gvm-manage-certs.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tools/gvm-migrate-config
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit 040d7ba

Please sign in to comment.