Files
big-bear-scripts/.github/workflows/test-unicode-scanner.yml
Christopher a70b1293d0 Add allowlist support with ranges and comments (#70)
* Add allowlist support with ranges and comments

Introduces enhanced allowlist parsing in the Unicode Security Scanner, supporting single codes, code ranges, and inline comments. Updates documentation and test suite to verify allowlist functionality, including range and inline comment handling. Also adds a GitHub Actions workflow for automated scanner testing on Ubuntu and macOS.

* Simplify test command in CI workflow

Refactored the test step to use 'if ./run.sh ...' directly, removing the explicit check of the exit code for improved readability.

* Unify test workflow for multiple OS platforms

Replaces separate macOS and Ubuntu jobs with a matrix strategy to run tests on both platforms. Adds shell defaults and improves test steps with more robust output validation.
2025-11-28 10:11:37 -08:00

99 lines
2.7 KiB
YAML

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