FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Decode remote config files as UTF-8 by theinfosecguy · Pull Request #4323 · github/codeql-action · GitHub

Repository navigation

Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .js  (1) .md  (1) .ts  (2) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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,
);
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Back | FazBrowse Home | New Git URL