# CodeQL Analysis — OWASP Top 10 SAST (T-08/T-10, issue #195)
#
# Runs GitHub CodeQL security scanning for Python and JavaScript/TypeScript.
# Triggers on push to main, PRs to main, and weekly schedule.

name: CodeQL

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  schedule:
    # Run every Monday at 06:00 UTC
    - cron: '0 6 * * 1'

permissions:
  actions: read
  contents: read
  security-events: write

jobs:
  analyze:
    name: CodeQL (${{ matrix.language }})
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        language: ['python', 'javascript-typescript']

    steps:
      - name: Checkout repository
        uses: actions/checkout@v6

      - name: Initialize CodeQL
        uses: github/codeql-action/init@v4
        with:
          languages: ${{ matrix.language }}
          queries: security-extended

      - name: Autobuild
        uses: github/codeql-action/autobuild@v4

      - name: Perform CodeQL Analysis
        # Analysis runs fine; upload fails on private repos without GitHub
        # Advanced Security (requires Enterprise Cloud). Remove continue-on-error
        # once code scanning is enabled or the repo goes public.
        continue-on-error: true
        uses: github/codeql-action/analyze@v4
        with:
          category: "/language:${{ matrix.language }}"
