diff --git a/scripts/run-evals.js b/scripts/run-evals.js index 063c5064..e37573d5 100644 --- a/scripts/run-evals.js +++ b/scripts/run-evals.js @@ -443,7 +443,16 @@ function parseGrading(raw) { return ok ? g : null; } +// Skill name must be a valid kebab-case identifier — no path separators, +// no "..", no absolute paths. Without this, --behavioral "../../x" would +// resolve to files outside the project tree for both reads and writes. +const VALID_SKILL_NAME = /^[a-z0-9]+(-[a-z0-9]+)*$/; + function runBehavioral(skillName, dryRun) { + if (!skillName || !VALID_SKILL_NAME.test(skillName)) { + console.error(`Invalid skill name: "${skillName}" — must be kebab-case (e.g. "my-skill")`); + process.exit(1); + } const caseFile = path.join(CASES_DIR, `${skillName}.json`); if (!fs.existsSync(caseFile)) { console.error(`No eval case file for "${skillName}"`);