mirror of
https://github.com/addyosmani/agent-skills.git
synced 2026-08-12 18:07:26 +02:00
Merge #456: validate --behavioral skill name
security: validate --behavioral skillName to prevent path traversal
This commit is contained in:
@@ -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}"`);
|
||||
|
||||
Reference in New Issue
Block a user