Last active
January 7, 2021 01:03
-
-
Save ams0/84767f247558a9190e9890b072629c05 to your computer and use it in GitHub Desktop.
Checks the current subscription for public access containers in all storage accounts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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