#!/bin/bash # Quit script if something goes wrong set -o errexit -o nounset -o pipefail; SCRIPTDIR="$( dirname "$(readlink -f "$0")" )"; OUTFILE="${SCRIPTDIR}/../whitelists/magento2.yar"; TMPFILE="${OUTFILE}.new"; # First empty the target whitelist so we can completely generate a new one cat <"${OUTFILE}"; private rule Magento2 : ECommerce { condition: false } EOF # Create a temporary directory and make sure it is empty GENTEMPDIR="$( mktemp -d --suffix="_gen_whitelist_m2" )"; # Composer access tokens if [ ! -f "${HOME}/.composer/auth.json" ]; then echo -e "\nYou have no '.composer/auth.json' in your home dir. We will create it from a template and open an editor."; echo -e "Press [Enter] to continue. Press Ctrl-C if you wish to leave."; read; mkdir -p "${HOME}/.composer"; cat <"${HOME}/.composer/auth.json" { "INFO_GITHUB": "==== GET TOKEN: https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ ====", "github-oauth": { "github.com": "---github-token-goes-here---" }, "INFO_MAGENTO": "==== GET TOKEN: https://devdocs.magento.com/guides/v2.0/install-gde/prereq/connect-auth.html ====", "http-basic": { "repo.magento.com": { "username": "---public-key-goes-here---", "password": "---private-key-goes-here---" } } } EOF editor "${HOME}/.composer/auth.json"; fi # Add header to whitelist tempfile cat < "${OUTFILE}"; # Clean up rm "${TMPFILE}"; rm -rf "${GENTEMPDIR}";