-
-
Notifications
You must be signed in to change notification settings - Fork 96
98 lines (86 loc) · 2.72 KB
/
test-unicode-scanner.yml
File metadata and controls
98 lines (86 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: Test Unicode Security Scanner
on:
push:
paths:
- 'check-for-unicode/**'
pull_request:
paths:
- 'check-for-unicode/**'
workflow_dispatch:
jobs:
test-scanner:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Make scripts executable
run: |
chmod +x check-for-unicode/run.sh
chmod +x check-for-unicode/test-suite/run-tests.sh
- name: Display scanner version
working-directory: check-for-unicode
run: ./run.sh --version
- name: Run test suite
working-directory: check-for-unicode/test-suite
run: bash run-tests.sh
- name: Test scanner help
working-directory: check-for-unicode
run: |
output=$(./run.sh --help)
if echo "$output" | grep -q "ALLOWLIST FORMAT"; then
echo "✓ Help includes allowlist documentation"
else
echo "✗ Help missing allowlist documentation"
exit 1
fi
if echo "$output" | grep -q "exclude-emojis"; then
echo "✓ Help includes emoji exclusion flag"
else
echo "✗ Help missing emoji exclusion flag"
exit 1
fi
- name: Test scanning a clean file
working-directory: check-for-unicode
run: |
if ./run.sh test-suite/clean-test.js; then
echo "✓ Clean file test passed"
else
echo "✗ Clean file test failed"
exit 1
fi
- name: Test detection of malicious file
working-directory: check-for-unicode
run: |
if ./run.sh test-suite/trojan-source-test.js; then
echo "✗ Malicious file was not detected"
exit 1
else
echo "✓ Malicious file correctly detected"
fi
- name: Test JSON output
working-directory: check-for-unicode
run: |
output=$(./run.sh --json test-suite/clean-test.js)
echo "$output" | jq .
if echo "$output" | jq -e '.scanner' > /dev/null; then
echo "✓ JSON output test passed"
else
echo "✗ JSON output test failed"
exit 1
fi
- name: Test quiet mode
working-directory: check-for-unicode
run: |
output=$(./run.sh --quiet test-suite/clean-test.js 2>&1)
if [ -z "$output" ]; then
echo "✓ Quiet mode test passed (no output)"
else
echo "✗ Quiet mode test failed (unexpected output: $output)"
exit 1
fi