Finding all Magento secure URIs
We recently needed to try and identify all HTTPS URI's in a customer's store and had to quickly write a script to scan the core
, local
and community
directories to find any pages that used HTTPS.
This is by no means 100% accurate, but will be a good starter indication of finding URL's that are defined as being secure.
cd app/code/core/Mage
( ack-grep "getUrl(['"]([^("|')]+)['"],([s]+)?array(['"]_secure['"]([s]+)?=>([s]+)?true))" * --output='$1' | while read LINE; do
FILE=$(echo "$LINE" | cut -f1 -d":")
URI=$(echo "$LINE" | cut -f3 -d":")
echo "$URI" | grep -qF '*' 2>/dev/null
if [[ $? -eq 0 ]]; then
MODULE=$(echo $FILE | ack-grep "^([^/]+)/" --output='$1')
CONTROLLER=$(echo $FILE | ack-grep "([^/]+)" --output='$1' | tail -n2 | head -n1 | sed 's/Controller.php//g' | tr '[A-Z]' '[a-z]')
CONFIG_FILE="$MODULE/etc/config.xml"
if [ -f "$CONFIG_FILE" ]; then
NAMESPACES=( $(cat $CONFIG_FILE | ack-grep "<frontName>(.+)?</frontName>" --output='$1') )
if [ ${#NAMESPACES[@]} -gt 0 ]; then
for NAMESPACE in ${NAMESPACES[@]}; do
echo "$NAMESPACE/$CONTROLLER"
done
fi
fi
else
echo $URI
fi
done ) | sed 's#/$##g' | sort -u