Skip to content

Commit

Permalink
Forward proxy ENV variables to proxy container
Browse files Browse the repository at this point in the history
Multiple users have reported `dependabot-action` not respecting their
proxy settings. We had not been passing those along to our proxy.
  • Loading branch information
Landon Grindheim authored and GitHub committed May 3, 2022
1 parent 148f5e0 commit 895a5b2
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
26 changes: 26 additions & 0 deletions __tests__/proxy-integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,30 @@ integration('ProxyBuilder', () => {
const stdout = proc.stdout.toString()
expect(stdout).toEqual('ca-pem-contents')
})

jest.setTimeout(20000)
it('forwards custom proxy urls if configured', async () => {
process.env.HTTP_PROXY = 'HTTP_PROXY'

const proxy = await builder.run(jobId, credentials)
await proxy.container.start()

const id = proxy.container.id
const proc = spawnSync('docker', ['exec', id, 'printenv', 'HTTP_PROXY'])
const output = proc.stdout.toString()
expect(output).toEqual('HTTP_PROXY')
})

jest.setTimeout(20000)
it('forwards downcased proxy urls if configured', async () => {
process.env.https_proxy = 'https_proxy'

const proxy = await builder.run(jobId, credentials)
await proxy.container.start()

const id = proxy.container.id
const proc = spawnSync('docker', ['exec', id, 'printenv', 'https_proxy'])
const output = proc.stdout.toString()
expect(output).toEqual('https_proxy')
})
})
10 changes: 9 additions & 1 deletion dist/main/index.js

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

2 changes: 1 addition & 1 deletion dist/main/index.js.map

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,15 @@ export class ProxyBuilder {
name: containerName,
AttachStdout: true,
AttachStderr: true,
Env: [`JOB_ID=${jobId}`],
Env: [
`http_proxy=${process.env.http_proxy}`,
`HTTP_PROXY=${process.env.HTTP_PROXY}`,
`https_proxy=${process.env.https_proxy}`,
`HTTPS_PROXY=${process.env.HTTPS_PROXY}`,
`no_proxy=${process.env.no_proxy}`,
`NO_PROXY=${process.env.NO_PROXY}`,
`JOB_ID=${jobId}`
],
Entrypoint: [
'sh',
'-c',
Expand Down

0 comments on commit 895a5b2

Please sign in to comment.