Skip to content

Commit cd22f67

Browse files
committed
fixes to CI workflow to detect malicious unicode
* #90 * maltfield/detect-malicious-unicode#4
1 parent eeb21ad commit cd22f67

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

.github/workflows/unicode_warn.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
################################################################################
22
# File: .github/workflows/unicode_warn.yml
3-
# Version: 0.3
3+
# Version: 0.4
44
# Purpose: Detects Unicode in PRs and comments the results of findings in PR
55
# Authors: Michael Altfield <michael@michaelaltfield.net>
66
# Created: 2021-11-20
@@ -26,6 +26,11 @@ jobs:
2626
pull-requests: write
2727

2828
steps:
29+
30+
- name: Dump GitHub context
31+
env:
32+
GITHUB_CONTEXT: ${{ toJSON(github) }}
33+
run: echo "$GITHUB_CONTEXT"
2934

3035
- name: Prereqs
3136
env:
@@ -45,11 +50,15 @@ jobs:
4550
git config --global --add safe.directory "$(pwd)"
4651
git branch -a
4752
git log
53+
git checkout ${{ github.event.pull_request.head.ref }}
54+
git branch -a
55+
git log
4856
4957
diff=`git diff --unified=0 ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep -E "^[+]" | grep -Ev '^(--- a/|\+\+\+ b/)'`
5058
if [ $? -ne 0 ]; then
5159
# there was an error in the diff
5260
human_result="WARNING: git diff failed!"
61+
echo "UNICODE_HUMAN_RESULT=${human_result}" >> $GITHUB_ENV
5362
echo "${human_result}"
5463
exit 1
5564
fi
@@ -62,6 +71,7 @@ jobs:
6271
if [ $? -ne 0 ]; then
6372
# there was an error in the hexdump
6473
human_result="WARNING: hexdump failed!"
74+
echo "UNICODE_HUMAN_RESULT=${human_result}" >> $GITHUB_ENV
6575
echo "${human_result}"
6676
exit 1
6777
fi
@@ -106,7 +116,7 @@ jobs:
106116
- name: Exit with or without error
107117
run: |
108118
109-
if [[ "${{ env.UNICODE_HUMAN_RESULT }}" | grep -i "WARNING" ]]; then
119+
if [[ "${{ env.UNICODE_HUMAN_RESULT }}" | grep -Ei "ERROR|WARNING" ]]; then
110120
exit 1
111121
else
112122
exit 0

0 commit comments

Comments
 (0)