Skip to content

Add proxy support via http-proxy-agent library #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: release/vNext
Choose a base branch
from
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
125 changes: 122 additions & 3 deletions package-lock.json

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

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@microsoft/security-devops-azdevops-task-lib",
"version": "1.12.0",
"version": "1.13.0",
"description": "Microsoft Security DevOps for Azure DevOps task library.",
"author": "Microsoft Corporation",
"license": "MIT",
Expand All @@ -13,7 +13,8 @@
"adm-zip": "0.5.10",
"azure-pipelines-task-lib": "4.3.1",
"azure-pipelines-tool-lib": "2.0.4",
"decompress-response": "^8.1.0"
"decompress-response": "^8.1.0",
"https-proxy-agent": "^7.0.5"
},
"devDependencies": {
"@types/node": "^20.3.1",
Expand Down
8 changes: 7 additions & 1 deletion src/msdo-nuget-client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as https from 'https';
import { HttpsProxyAgent } from 'https-proxy-agent';
import * as fs from 'fs';
import * as path from 'path';
import * as process from 'process';
Expand Down Expand Up @@ -592,12 +593,17 @@ async function callService(
* @returns Https request options.
*/
function resolveRequestOptions(accessToken: string): Object {
// Get proxy settings
const proxyConfig = tl.getHttpProxyConfiguration();
const proxyAgent = proxyConfig ? new HttpsProxyAgent(proxyConfig.proxyFormattedUrl) : null;

let options = {
method: 'GET',
timeout: 2500,
headers: {
'Content-Type': 'application/json'
}
},
agent: proxyAgent
};

if (!common.isNullOrWhiteSpace(accessToken)) {
Expand Down