Skip to content

Commit f594e7a

Browse files
authored
fix(selfhost): reject compose interpolation in image (#1890)
1 parent 34ffe28 commit f594e7a

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

scripts/deploy-selfhost-image.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ validate_inputs() {
129129
exit 1
130130
fi
131131
case "$image" in
132-
*[[:space:]\"\'\\]*)
133-
echo "error: image contains unsupported whitespace, quote, or backslash characters" >&2
132+
*[[:space:]\"\'\\\$\{\}]*)
133+
echo "error: image contains unsupported whitespace, quote, backslash, or compose interpolation characters" >&2
134134
exit 1
135135
;;
136136
esac

test/unit/selfhost-image-deploy.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,23 @@ describe("self-host image deploy script", () => {
192192
harness.cleanup();
193193
}
194194
});
195+
196+
it.each([
197+
"registry.example/gittensory:${GITHUB_OAUTH_CLIENT_SECRET}",
198+
"registry.example/gittensory:$GITHUB_OAUTH_CLIENT_SECRET",
199+
"registry.example/gittensory:{GITHUB_OAUTH_CLIENT_SECRET}",
200+
])("rejects compose interpolation characters in image %s", (image) => {
201+
const { harness, result } = runHarness({ args: [image], envFile: "EXISTING=1\n" });
202+
try {
203+
expect(result.status).not.toBe(0);
204+
expect(result.stderr).toContain(
205+
"image contains unsupported whitespace, quote, backslash, or compose interpolation characters",
206+
);
207+
expect(readFileSync(harness.envPath, "utf8")).toBe("EXISTING=1\n");
208+
expect(harness.readImages()).toBe("");
209+
expect(harness.readCalls()).not.toContain(" pull ");
210+
} finally {
211+
harness.cleanup();
212+
}
213+
});
195214
});

0 commit comments

Comments
 (0)