-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixes to CI workflow to detect malicious unicode
- Loading branch information
Showing
1 changed file
with
12 additions
and
2 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
################################################################################ | ||
# File: .github/workflows/unicode_warn.yml | ||
# Version: 0.3 | ||
# Version: 0.4 | ||
# Purpose: Detects Unicode in PRs and comments the results of findings in PR | ||
# Authors: Michael Altfield <[email protected]> | ||
# Created: 2021-11-20 | ||
|
@@ -26,6 +26,11 @@ jobs: | |
pull-requests: write | ||
|
||
steps: | ||
|
||
- name: Dump GitHub context | ||
env: | ||
GITHUB_CONTEXT: ${{ toJSON(github) }} | ||
run: echo "$GITHUB_CONTEXT" | ||
|
||
- name: Prereqs | ||
env: | ||
|
@@ -45,11 +50,15 @@ jobs: | |
git config --global --add safe.directory "$(pwd)" | ||
git branch -a | ||
git log | ||
git checkout ${{ github.event.pull_request.head.ref }} | ||
git branch -a | ||
git log | ||
diff=`git diff --unified=0 ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep -E "^[+]" | grep -Ev '^(--- a/|\+\+\+ b/)'` | ||
if [ $? -ne 0 ]; then | ||
# there was an error in the diff | ||
human_result="WARNING: git diff failed!" | ||
echo "UNICODE_HUMAN_RESULT=${human_result}" >> $GITHUB_ENV | ||
echo "${human_result}" | ||
exit 1 | ||
fi | ||
|
@@ -62,6 +71,7 @@ jobs: | |
if [ $? -ne 0 ]; then | ||
# there was an error in the hexdump | ||
human_result="WARNING: hexdump failed!" | ||
echo "UNICODE_HUMAN_RESULT=${human_result}" >> $GITHUB_ENV | ||
echo "${human_result}" | ||
exit 1 | ||
fi | ||
|
@@ -106,7 +116,7 @@ jobs: | |
- name: Exit with or without error | ||
run: | | ||
if [[ "${{ env.UNICODE_HUMAN_RESULT }}" | grep -i "WARNING" ]]; then | ||
if [[ "${{ env.UNICODE_HUMAN_RESULT }}" | grep -Ei "ERROR|WARNING" ]]; then | ||
exit 1 | ||
else | ||
exit 0 | ||
|