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
30 changes: 27 additions & 3 deletions test/automation/pull-requests/pr-review-advisor-openshell.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -571,14 +571,20 @@ describe("PR review advisor OpenShell wrapper", () => {
expect(child.stderr).toBe("");
});

it("permits only the pinned image login files required by stable OpenShell exec", () => {
const policy = YAML.parse(
it("permits only the pinned image login files in managed review policies (#10947)", () => {
const advisorPolicy = YAML.parse(
fs.readFileSync("tools/pr-review-advisor/openshell-policy.yaml", "utf8"),
) as {
filesystem_policy: { read_only: string[]; read_write: string[] };
};
const postMergePolicy = YAML.parse(
fs.readFileSync("tools/post-merge-docs/review-policy.yaml", "utf8"),
) as {
filesystem_policy: { read_only: string[]; read_write: string[] };
};
const loginFiles = ["/sandbox/.bashrc", "/sandbox/.profile"];

expect(policy.filesystem_policy).toEqual({
expect(advisorPolicy.filesystem_policy).toEqual({
include_workdir: false,
read_only: [
"/usr/bin",
Expand All @@ -594,6 +600,12 @@ describe("PR review advisor OpenShell wrapper", () => {
],
read_write: ["/dev", "/sandbox/pr-review-advisor-runtime"],
});
expect(
advisorPolicy.filesystem_policy.read_only.filter((entry) => entry.startsWith("/sandbox/.")),
).toEqual(loginFiles);
expect(
postMergePolicy.filesystem_policy.read_only.filter((entry) => entry.startsWith("/sandbox/.")),
).toEqual(loginFiles);
});

it.each([
Expand Down Expand Up @@ -1227,6 +1239,18 @@ describe("PR review advisor OpenShell wrapper", () => {
"HEAD",
]),
);
expect(runArgs).not.toContain("--no-login-shell");
const commandBoundaryIndex = runArgs.indexOf("--");
expect(runArgs.slice(commandBoundaryIndex)).toEqual([
"--",
"/usr/bin/node",
"--no-warnings",
"/advisor/tools/pr-review-advisor/run-specialist.mts",
"--base",
"target/base",
"--head",
"HEAD",
]);
expect(runArgs.join("\n")).not.toContain("github-host-secret");
expect(runArgs.join("\n")).not.toContain("model-host-secret");
expect(runArgs.join("\n")).not.toContain("advisor-host-secret");
Expand Down
4 changes: 4 additions & 0 deletions test/generation/post-merge-docs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,10 @@ describe("post-merge documentation runner", () => {
},
});
expect(state.createArgs).not.toContain("--upload");
const policyIndex = state.createArgs.indexOf("--policy");
expect(state.createArgs[policyIndex + 1]).toBe(
path.join(input.env.TRUSTED_CHECKOUT, "tools/post-merge-docs/review-policy.yaml"),
);
expect(state.createArgs.slice(-6)).toEqual([
"--",
"/usr/bin/git",
Expand Down
3 changes: 3 additions & 0 deletions tools/post-merge-docs/review-policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ filesystem_policy:
- /usr/lib
- /usr/share/git-core
- /etc
# OpenShell 0.0.116 runs sandbox exec through bash -lc. The pinned image owns these files.
- /sandbox/.bashrc
- /sandbox/.profile
- /sandbox/repo
- /sandbox/config
read_write:
Expand Down
1 change: 1 addition & 0 deletions tools/pr-review-advisor/openshell-policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ filesystem_policy:
- /usr/lib
- /usr/share/git-core
- /etc
# OpenShell 0.0.116 runs sandbox exec through bash -lc. The pinned image owns these files.
- /sandbox/.bashrc
- /sandbox/.profile
- /advisor
Expand Down
Loading