Skip to content

Commit 4e820a4

Browse files
committed
Apply review feedback
1 parent d43f46c commit 4e820a4

File tree

9 files changed

+28
-33
lines changed

9 files changed

+28
-33
lines changed

lib/analyze-action.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action-post.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/start-proxy-action.js

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-lib.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/upload-sarif-action.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api-client.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,30 +74,32 @@ export function getApiClientWithExternalAuth(
7474
}
7575

7676
/**
77-
* Gets a value for the `Authorization` header to download `url` or `undefined` if the
77+
* Gets a value for the `Authorization` header for a request to `url`; or `undefined` if the
7878
* `Authorization` header should not be set for `url`.
7979
*
8080
* @param logger The logger to use for debugging messages.
8181
* @param apiDetails Details of the GitHub API we are using.
8282
* @param url The URL for which we want to add an `Authorization` header.
83-
* @param purpose A description of what we want to download, for debug messages.
83+
*
8484
* @returns The value for the `Authorization` header or `undefined` if it shouldn't be populated.
8585
*/
8686
export function getAuthorizationHeaderFor(
8787
logger: Logger,
8888
apiDetails: GitHubApiDetails,
8989
url: string,
90-
purpose: string = "CodeQL tools",
9190
): string | undefined {
91+
// We only want to provide an authorization header if we are downloading
92+
// from the same GitHub instance the Action is running on.
93+
// This avoids leaking Enterprise tokens to dotcom.
9294
if (
9395
url.startsWith(`${apiDetails.url}/`) ||
9496
(apiDetails.apiURL && url.startsWith(`${apiDetails.apiURL}/`))
9597
) {
96-
logger.debug(`Providing an authorization token to download ${purpose}.`);
98+
logger.debug(`Providing an authorization token for '${url}'.`);
9799
return `token ${apiDetails.auth}`;
98100
}
99101

100-
logger.debug(`Downloading ${purpose} without an authorization token.`);
102+
logger.debug(`Requesting '${url}' without an authorization token.`);
101103
return undefined;
102104
}
103105

src/setup-codeql.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,11 +567,9 @@ export const downloadCodeQL = async function (
567567
const headers: OutgoingHttpHeaders = {
568568
accept: "application/octet-stream",
569569
};
570-
// We only want to provide an authorization header if we are downloading
571-
// from the same GitHub instance the Action is running on.
572-
// This avoids leaking Enterprise tokens to dotcom.
573-
// We also don't want to send an authorization header if there's already a token provided in the URL.
574570
let authorization: string | undefined = undefined;
571+
572+
// We don't want to send an authorization header if there's already a token provided in the URL.
575573
if (searchParams.has("token")) {
576574
logger.debug("CodeQL tools URL contains an authorization token.");
577575
} else {

src/start-proxy-action.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,11 @@ async function getProxyBinaryPath(logger: Logger): Promise<string> {
193193

194194
let proxyBin = toolcache.find(proxyFileName, proxyInfo.version);
195195
if (!proxyBin) {
196-
// We only want to provide an authorization header if we are downloading
197-
// from the same GitHub instance the Action is running on.
198-
// This avoids leaking Enterprise tokens to dotcom.
199196
const apiDetails = getApiDetails();
200197
const authorization = getAuthorizationHeaderFor(
201198
logger,
202199
apiDetails,
203200
proxyInfo.url,
204-
"`update-job-proxy`",
205201
);
206202
const temp = await toolcache.downloadTool(
207203
proxyInfo.url,

0 commit comments

Comments
 (0)