Skip to content

Instantly share code, notes, and snippets.

@ams0
Last active January 7, 2021 01:03
Show Gist options
  • Save ams0/84767f247558a9190e9890b072629c05 to your computer and use it in GitHub Desktop.
Save ams0/84767f247558a9190e9890b072629c05 to your computer and use it in GitHub Desktop.
Checks the current subscription for public access containers in all storage accounts
#!/bin/bash
red=`tput setaf 1`
reset=`tput sgr0`
subscription=$(az account show -o tsv --query id)
echo "Checking subscription $subscription"
for account in `az storage account list -o tsv --query [].name`
do
for container in `az storage container list --auth-mode login --account-name $account -o tsv --query [].name 2>/dev/null`
do
#echo " ...checking container $container in storage account $account"
public=$(az storage container show --auth-mode login --account-name $account --name $container -o json --query properties.publicAccess)
if [[ $public == *"container"* ]]
then
echo "container $container in storage account $account is ${red}insecure!${reset}"
fi
done
#echo "Done with analysis of account $account"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment