Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d43f46c

Browse files
committed
Set Authorization header for downloading update-job-proxy
1 parent efcf614 commit d43f46c

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed

lib/start-proxy-action.js

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

src/start-proxy-action.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as toolcache from "@actions/tool-cache";
66
import { pki } from "node-forge";
77

88
import * as actionsUtil from "./actions-util";
9+
import { getApiDetails, getAuthorizationHeaderFor } from "./api-client";
910
import { getActionsLogger, Logger } from "./logging";
1011
import {
1112
Credential,
@@ -192,10 +193,20 @@ async function getProxyBinaryPath(logger: Logger): Promise<string> {
192193

193194
let proxyBin = toolcache.find(proxyFileName, proxyInfo.version);
194195
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.
199+
const apiDetails = getApiDetails();
200+
const authorization = getAuthorizationHeaderFor(
201+
logger,
202+
apiDetails,
203+
proxyInfo.url,
204+
"`update-job-proxy`",
205+
);
195206
const temp = await toolcache.downloadTool(
196207
proxyInfo.url,
197208
undefined,
198-
undefined,
209+
authorization,
199210
{
200211
accept: "application/octet-stream",
201212
},

0 commit comments

Comments
 (0)