Created
April 22, 2022 04:34
-
-
Save quynhethereal/d322774c2fd9a9ca6b8e637ee52f4736 to your computer and use it in GitHub Desktop.
Shell script to be used with circleCI to detect unsafe HTTP usage in PR
This file contains 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 | |
echo '------Scanning for unsafe HTTP usage in Doc ------' | |
#Need to set this flag to return exit code 1 to CI, hence fail the step | |
set -e | |
git diff $CIRCLE_BRANCH master --name-only | while read FILE; do | |
#Skip check for this file, duh | |
if [[ "$FILE" == *"check_http_string.sh"* ]]; then | |
continue | |
fi | |
if [[ $(echo "$FILE") ]]; then | |
content=$(<"$FILE") | |
if [[ $(echo "$content" | grep -e "http://" -e "HTTP://") ]]; then | |
echo -e "You have used unsafe HTTP connection in the file: "$FILE". Change it to HTTPS!" >&2 | |
exit 1 | |
fi | |
fi | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment