cbe6c4ccb2a229070c54d068798b567d3801b604
hiram
  Thu Jul 31 11:08:32 2025 -0700
safety check on validity of directory path refs #34917

diff --git src/hg/utils/otto/genArk/pushNewOnes.sh src/hg/utils/otto/genArk/pushNewOnes.sh
index 7e33b65b999..c9aec4bb79d 100755
--- src/hg/utils/otto/genArk/pushNewOnes.sh
+++ src/hg/utils/otto/genArk/pushNewOnes.sh
@@ -1,17 +1,24 @@
 #!/bin/bash
 
+#############################################################################
+###  This source is from the source tree:
+###     ~/kent/src/hg/utils/otto/genArk/pushNewOnes.sh
+###  do *not* edit this in the otto directory /hive/data/inside/GenArk/pushRR/
+###  where this is used.
+#############################################################################
+
 # exit on any error
 set -beEu -o pipefail
 
 export expectHost="hgwdev"
 
 export hostName=$(hostname -s)
 if [[ "${hostName}" != "${expectHost}" ]]; then
   printf "ERROR: must run this on %s !  This is: %s\n" "${expectHost}" "${hostName}" 1>&2
   exit 255
 fi
 
 #############################################################################
 ### rsync out one given directory.  The excludes avoid:
 ###  1. the various alpha.hub.txt, beta.hub.txt, public.hub.txt and user.hub.txt
 ###  2. any contrib/ directories.
@@ -42,22 +49,35 @@
 
 export inCommon=`comm -12 <(zgrep "/hub.txt" dev.todayList.gz | cut -f2 | sort)  <(zgrep "/hub.txt" hgw1.todayList.gz | cut -f2 | sort) | wc -l`
 printf "# in common hgwdev to hgw1: %d\n" "${inCommon}" 1>&2
 
 export onHgw1NotDev=`comm -13 <(zgrep "/hub.txt" dev.todayList.gz | cut -f2 | sort) <(zgrep "/hub.txt" hgw1.todayList.gz | cut -f2 | sort) | wc -l`
 printf "# on hgw1 not in hgwdev: %d\n" "${onHgw1NotDev}" 1>&2
 
 export onDevNotHgw1=`comm -23 <(zgrep "/hub.txt" dev.todayList.gz | cut -f2 | sort) <(zgrep "/hub.txt" hgw1.todayList.gz | cut -f2 | sort) | wc -l`
 printf "# on hgwdev not in hgw1: %d\n" "${onDevNotHgw1}" 1>&2
 
 if [ "${onDevNotHgw1}" -gt 0 ]; then
 
 comm -23 <(zgrep "/hub.txt" dev.todayList.gz | cut -f2 | sort) \
    <(zgrep "/hub.txt" hgw1.todayList.gz | cut -f2 | sort) \
      | sed -e 's#/hub.txt##;' | while read P
-do
+do	# make sure it really is a valid directory path
+   validCount=`echo "${P}" | awk -F'/' '{print NF}'`
+   if [ "${validCount}" -gt 4 ]; then
+      if [ -d "/gbdb/genark/${P}" ]; then	# and it really is a directory
         sendTo "${P}"
+      else
+        printf "ERROR: invalid directory path '/gbdb/genark/${P}'\n" 1>&2
+        exit 255
+      fi
+   else
+      printf "ERROR: invalid directory path '${P}'\n" 1>&2
+      exit 255
+   fi
 done
 
 else
   printf "# nothing to push, all up to date.\n" 1>&2
 fi
+
+printf "### finished pushNewOnes.sh %s\n" "`date '+%F %T'`" 1>&2