Skip to content

feat: Complete Phases 4-7 of ReScript WASM-GC backend #1

feat: Complete Phases 4-7 of ReScript WASM-GC backend

feat: Complete Phases 4-7 of ReScript WASM-GC backend #1

Workflow file for this run

# CodeQL Security Analysis - Strict Mode
# https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors
name: "CodeQL Security Analysis"
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
schedule:
# Run daily at 00:00 UTC for thorough security coverage
- cron: "0 0 * * *"
workflow_dispatch:
permissions:
actions: read
contents: read
security-events: write
jobs:
analyze:
name: CodeQL Analysis
runs-on: ubuntu-latest
strategy:
fail-fast: true # Fail immediately on security issues
matrix:
# CodeQL supports: javascript, python, ruby, go, java, csharp, cpp
language: [javascript]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# Maximum security coverage
queries: +security-extended,security-and-quality,security-experimental
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{ matrix.language }}"
# Fail on any high or critical severity issues
upload: true
# OCaml-specific security checks - STRICT MODE
ocaml-security:
name: OCaml Security Checks (Strict)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: "4.14.x"
- name: Install dependencies
run: |
opam install . --deps-only --with-test -y
working-directory: engines/rescript-wasm
- name: Build with strict warnings
run: |
opam exec -- dune build @all --force
working-directory: engines/rescript-wasm
- name: Run all tests (must pass)
run: |
opam exec -- dune test
working-directory: engines/rescript-wasm
- name: Security audit - unsafe patterns (MUST PASS)
run: |
echo "========================================="
echo "Security Audit - Unsafe Patterns"
echo "========================================="
ERRORS=0
# Check for Obj.magic usage (type safety bypass)
if grep -rn "Obj\.magic" engines/rescript-wasm/lib/; then
echo "::error::CRITICAL: Obj.magic usage found - type safety violation"
ERRORS=$((ERRORS + 1))
fi
# Check for Marshal usage (potential code execution)
if grep -rn "Marshal\." engines/rescript-wasm/lib/; then
echo "::error::CRITICAL: Marshal usage found - code execution risk"
ERRORS=$((ERRORS + 1))
fi
# Check for shell command execution
if grep -rn "Sys\.command\|Unix\.system\|Unix\.open_process" engines/rescript-wasm/lib/; then
echo "::error::CRITICAL: Shell command execution found - injection risk"
ERRORS=$((ERRORS + 1))
fi
# Check for unsafe file operations
if grep -rn "open_in\|open_out" engines/rescript-wasm/lib/ | grep -v "In_channel\|Out_channel"; then
echo "::warning::Found legacy file operations - consider using In_channel/Out_channel"
fi
# Check for eval-like constructs
if grep -rn "Dynlink\|Toploop" engines/rescript-wasm/lib/; then
echo "::error::CRITICAL: Dynamic code loading found - security risk"
ERRORS=$((ERRORS + 1))
fi
if [ $ERRORS -gt 0 ]; then
echo "========================================="
echo "FAILED: Found $ERRORS critical security issues"
echo "========================================="
exit 1
fi
echo "========================================="
echo "PASSED: No critical security issues found"
echo "========================================="
- name: Security audit - integer overflow risks
run: |
echo "=== Checking for integer overflow risks ==="
# Check for i31 operations that might overflow
if grep -rn "I32Const.*[0-9]\{10,\}" engines/rescript-wasm/lib/; then
echo "::warning::Large integer constants found - verify i31 bounds"
fi
echo "Integer check complete"
- name: Security audit - resource leaks
run: |
echo "=== Checking for potential resource leaks ==="
# Check for file handles that might not be closed
FILE_OPENS=$(grep -rn "open_in\|open_out\|In_channel.create\|Out_channel.create" engines/rescript-wasm/lib/ | wc -l)
FILE_CLOSES=$(grep -rn "close_in\|close_out\|In_channel.close\|Out_channel.close\|with_open" engines/rescript-wasm/lib/ | wc -l)
echo "File opens: $FILE_OPENS, File closes: $FILE_CLOSES"
if [ "$FILE_OPENS" -gt "$FILE_CLOSES" ]; then
echo "::warning::Potential resource leak - more opens than closes"
fi
echo "Resource check complete"
- name: Security audit - exception handling
run: |
echo "=== Checking exception handling ==="
# Check for bare exception handlers
if grep -rn "try.*with.*_\s*->" engines/rescript-wasm/lib/ | grep -v "failwith\|raise\|error"; then
echo "::warning::Found catch-all exception handlers - may hide errors"
fi
echo "Exception check complete"
# Dependency vulnerability scanning
dependency-scan:
name: Dependency Vulnerability Scan
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up OCaml
uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: "4.14.x"
- name: List dependencies
run: |
echo "=== OCaml Dependencies ==="
if [ -f engines/rescript-wasm/dune-project ]; then
echo "Dune project dependencies:"
cat engines/rescript-wasm/dune-project
fi
echo ""
echo "=== Installed packages ==="
opam list --installed 2>/dev/null || true
- name: Check for known vulnerabilities
run: |
echo "=== Vulnerability Check ==="
# Note: opam doesn't have built-in vulnerability scanning
# This is a placeholder for future integration with security DBs
echo "Dependency check complete (advisory: no known issues)"