CodeQL for game code
Security scanning for Unity and Unreal projects that live in Perforce, at Magnopus.
The problem
Most of a game studio’s code never lives on GitHub. It sits in Perforce and only compiles inside Unity or Unreal, so GitHub’s built-in CodeQL setup can’t see it.
What I built
- A Python toolkit that runs CodeQL inside real engine builds: Unity C#, Unreal Engine C++, native C# and C++ and Swift, plus a no-build mode for Python, JavaScript and TypeScript.
- Unreal scans trace the actual UnrealBuildTool build, and Unity scans regenerate the Visual Studio solution first, so CodeQL analyzes the code the game really ships.
- Perforce projects report to GitHub: a TeamCity job scans the normal checkout and uploads SARIF to a code-free GitHub repo, so findings show up as code scanning alerts.
- One setup script installs the CodeQL CLI and query packs on any build agent, and CodeQL scans run for a .NET services codebase in GitHub Actions.
Stack
- Python
- CodeQL CLI
- SARIF and GitHub code scanning
- TeamCity
- GitHub Actions
- Perforce
- Unity (C#)
- Unreal Engine (C++)
- Swift