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
2 changes: 2 additions & 0 deletions src/engine/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ function createRuleContext(
const patterns = expandBracePattern(pattern);
const seen = new Set<string>();
for (const p of patterns) {
safeGlob(p);
const g = new Bun.Glob(p);
// dot: true so rules can target dot-prefixed paths like `.github/`,
// `.husky/`, `.vscode/` — first-class source dirs in code repos.
Expand Down Expand Up @@ -205,6 +206,7 @@ function createRuleContext(
// See https://github.com/archgate/cli/issues/222.
const seen = new Set<string>();
for (const p of globs) {
safeGlob(p);
const g = new Bun.Glob(p);
// oxlint-disable-next-line no-await-in-loop -- sequential scan per expanded brace alternative
for await (const file of g.scan({ cwd: projectRoot, dot: true })) {
Expand Down
39 changes: 39 additions & 0 deletions tests/engine/runner-security.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,43 @@ describe("runChecks path sandboxing", () => {
const result = await runChecks(tempDir, [loaded]);
expect(result.results[0].error).toContain("escapes project root");
});

test("blocks absolute paths produced by brace expansion", async () => {
const loaded = makeLoadedAdr(
{},
{
rules: {
"brace-abs-glob": {
description: "Attempt absolute path via brace expansion",
async check(ctx) {
await ctx.glob("{/etc/passwd,src/a.ts}");
},
},
},
}
);

const result = await runChecks(tempDir, [loaded]);
expect(result.results[0].error).toContain("access denied");
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.

test("blocks absolute paths produced by brace expansion in grepFiles", async () => {
const loaded = makeLoadedAdr(
{},
{
rules: {
"brace-abs-grepfiles": {
description:
"Attempt absolute path via brace expansion in grepFiles",
async check(ctx) {
await ctx.grepFiles(/./u, "{/etc/passwd,src/a.ts}");
},
},
},
}
);

const result = await runChecks(tempDir, [loaded]);
expect(result.results[0].error).toContain("access denied");
});
});