Merge #456: validate --behavioral skill name

security: validate --behavioral skillName to prevent path traversal
This commit is contained in:
Addy Osmani
2026-08-06 15:44:11 -07:00
committed by GitHub
+9
View File
@@ -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}"`);