Skip to content
Open
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: 1 addition & 1 deletion lib/entry-points.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions src/config/file.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,67 @@ test("getConfigFileInput ignores repository property value when FF is off", asyn
.passes(t.is, undefined);
});

for (const { name, contents } of [
...["Security", "Sécurité", "日本語", "🛡️"].map((configName) => ({
name: configName,
contents: `name: ${configName}
paths:
- "src/${configName}"
paths-ignore:
- "generated/${configName}"
`,
})),
{
name: "Café",
contents: `name: "Caf\\u00e9"
paths:
- "src/Caf\\u00e9"
paths-ignore:
- "generated/Caf\\u00e9"
`,
},
]) {
test.serial(
`getRemoteConfig preserves UTF-8 configuration: ${name}`,
async (t) => {
const configFile = "octo-org/codeql-config/config.yml@main";
const config = {
name,
paths: [`src/${name}`],
"paths-ignore": [`generated/${name}`],
};
const client = github.getOctokit("123");
const response = {
data: {
content: Buffer.from(contents, "utf8").toString("base64"),
encoding: "base64",
},
};
const getContent = sinon
.stub(client.rest.repos, "getContent")
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
.resolves(response as any);
sinon.stub(api, "getApiClientWithExternalAuth").returns(client);

for (const features of [[], [Feature.ValidateDbConfig]]) {
await callee(getRemoteConfig)
.withFeatures(features)
.withArgs(configFile, SAMPLE_DOTCOM_API_DETAILS)
.passes(t.deepEqual, config);
}

t.assert(
getContent.alwaysCalledWithExactly({
owner: "octo-org",
repo: "codeql-config",
path: "config.yml",
ref: "main",
}),
);
},
);
}

test.serial("getRemoteConfig uses proxy when it is supposed to", async (t) => {
const client = github.getOctokit("123");
const response = {
Expand Down
2 changes: 1 addition & 1 deletion src/config/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export async function getRemoteConfig(
return parseUserConfig(
actionState.logger,
configFile,
Buffer.from(fileContents, "base64").toString("binary"),
Buffer.from(fileContents, "base64").toString("utf8"),
validateConfig,
);
}
1 change: 1 addition & 0 deletions unreleased-change-notes/fix-remote-config-utf8.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fixed remote configuration files corrupting Unicode names and paths or failing to parse when they contain non-ASCII characters.