summaryrefslogtreecommitdiffhomepage
path: root/ci
diff options
context:
space:
mode:
authorLinus Färnstrand <faern@faern.net>2021-11-16 13:22:07 +0100
committerLinus Färnstrand <faern@faern.net>2021-11-16 13:22:07 +0100
commit86a1d7220e2a16ecdfc214cd5fc9594d55b9d048 (patch)
tree6926334479fbd8c82b60ad62754d813c2b5fafa9 /ci
parenta33760813316b88d2d309e449c6e88d8ef0e06dc (diff)
downloadmullvadvpn-86a1d7220e2a16ecdfc214cd5fc9594d55b9d048.tar.xz
mullvadvpn-86a1d7220e2a16ecdfc214cd5fc9594d55b9d048.zip
Make trojan source check script more universally usable
Make the script take the path to the dir to check as argument instead of being self aware.
Diffstat (limited to 'ci')
-rwxr-xr-xci/check-trojan-source.sh17
1 files changed, 12 insertions, 5 deletions
diff --git a/ci/check-trojan-source.sh b/ci/check-trojan-source.sh
index 7b18ad4952..1e35a05338 100755
--- a/ci/check-trojan-source.sh
+++ b/ci/check-trojan-source.sh
@@ -4,11 +4,17 @@
# See CVE-2021-42574. https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-42574
# UTF-8 encoding is assumed.
+# Pass the path to the directory to check as the first argument
+
set -eu
export LC_ALL=en_US.UTF-8
-cd "$( dirname "${BASH_SOURCE[0]}" )/.."
+if [ $# -ne 1 ]; then
+ echo "Usage: $0 <path>"
+ exit 1
+fi
+cd "$1"
FILES=()
while IFS='' read -r line; do FILES+=("$line"); done < <( find . -type f -exec grep -Il . {} + )
@@ -16,14 +22,15 @@ while IFS='' read -r line; do FILES+=("$line"); done < <( find . -type f -exec g
CODEPOINT_REGEX=$( printf "\u202a\|\u202b\|\u202c\|\u202d\|\u202e\|\u2066\|\u2067\|\u2068\|\u2069" )
matched=0
-
-echo "Scanning files: ${FILES[*]}"
-
for file in "${FILES[@]}"; do
if grep -q "${CODEPOINT_REGEX}" "$file"; then
- echo "Found code points in $file"
+ echo "Found potentially malicious unicode code points in $file"
matched=1
fi
done
+if [[ "$matched" == 0 ]]; then
+ echo "No potentially malicious unicode found"
+fi
+
exit $matched