#!/usr/bin/env python3 """Best-effort compile/syntax checks per language for SecureCodePairs. Toolchains available on the build host are used for real checks: Python (ast), C/C++ (gcc/g++ -fsyntax-only), Rust (rustc), Ruby (ruby -c), JavaScript (node --check), Go (go vet) for standalone code, Java (javac) for standalone code. Framework-dependent snippets (Flask/Spring/Gin/Rails/Express/Next/ASP.NET/TS modules) are detected via markers and fall back to a brace/paren heuristic so the build stays reproducible without those packages installed. Missing toolchains degrade gracefully (reported as warnings). """ import os import shutil import subprocess import tempfile # Markers that indicate a framework-dependent snippet unsuitable for standalone compile. FRAMEWORK_MARKERS = { "Java": ("org.springframework", "@RestController", "@Controller", "@Service", "@SpringBootApplication", "@GetMapping", "@PostMapping", "@RequestMapping", "@Repository", "import org."), "Go": ("gin.", "github.com/gin-gonic", "google.golang.org/grpc", "func "), "TypeScript": ("import ", "export ", "@"), "C#": ("using Microsoft", "[ApiController]", "ControllerBase", "using "), "PHP": ("Laravel", "Illuminate", "Artisan", "