Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/lib/skill-install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,22 @@ describe("collectFiles", () => {
}
});

it("reports hidden directories in skippedDotfiles", () => {
setup({
"SKILL.md": "---\nname: safe\n---\n",
".secret/token.txt": "secret-value",
"scripts/visible.sh": "#!/bin/sh",
"scripts/.hidden.sh": "#!/bin/sh",
});
try {
const { files, skippedDotfiles } = collectFiles(tmpDir);
expect(files.sort()).toEqual(["SKILL.md", "scripts/visible.sh"]);
expect(skippedDotfiles.sort()).toEqual([".secret/", "scripts/.hidden.sh"]);
} finally {
cleanup();
}
});

it("flags files with unsafe characters", () => {
setup({
"SKILL.md": "---\nname: bad\n---\n",
Expand Down
6 changes: 3 additions & 3 deletions src/lib/skill-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export function collectFiles(dir: string): CollectedFiles {
for (const entry of fs.readdirSync(current, { withFileTypes: true })) {
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
if (entry.name.startsWith(".")) {
if (entry.isFile()) skippedDotfiles.push(rel);
skippedDotfiles.push(entry.isDirectory() ? `${rel}/` : rel);
continue;
}
if (entry.isDirectory()) {
Expand Down Expand Up @@ -293,8 +293,8 @@ export function postInstall(
: paths.mirrorDir;
const mirrorFile = `${paths.mirrorDir}/${rel}`;
// mirrorDir contains $HOME which must expand, so we use double
// quotes for the mkdir target but shellQuote the relative part
// to prevent injection from file names.
// quotes (not shellQuote). Safe because validateRelativePath
// restricts filenames to [A-Za-z0-9._-/] before we reach here.
const result = sshExec(
ctx,
`mkdir -p "${mirrorSubdir}" && cat > "${mirrorFile}"`,
Expand Down
2 changes: 1 addition & 1 deletion src/nemoclaw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,7 @@ async function sandboxSkillInstall(sandboxName, args = []) {
process.exit(1);
}
if (collected.skippedDotfiles.length > 0) {
console.log(` ${D}Skipping ${collected.skippedDotfiles.length} dotfile(s): ${collected.skippedDotfiles.join(", ")}${R}`);
console.log(` ${D}Skipping ${collected.skippedDotfiles.length} hidden path(s): ${collected.skippedDotfiles.join(", ")}${R}`);
}
const fileLabel = collected.files.length === 1 ? "1 file" : `${collected.files.length} files`;
console.log(` ${G}✓${R} Validated SKILL.md (name: ${frontmatter.name}, ${fileLabel})`);
Expand Down
Loading