Skip to content

Commit 5164346

Browse files
Mask auth token in locationUltilities.ts (#325)
* masking secrets in npm get accesstoken * Update package json * fix azure-pipelines-tasks-packaging-common repo url. mask auth token in locationUltilities.ts fixed some vulnerability by running npm audit fix * add loc resource string * fix test cases
1 parent 4b12763 commit 5164346

File tree

5 files changed

+33
-29
lines changed

5 files changed

+33
-29
lines changed

common-npm-packages/packaging-common/Tests/npm/npmL0.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,8 @@ export function npmcommon() {
248248
},
249249
getEndpointAuthorization: (id, optional) => {
250250
return { scheme: 'OAuth', parameters: { 'AccessToken': authToken } };
251-
}
251+
},
252+
setSecret : msg => null
252253
};
253254
const mockParser = {
254255
GetRegistries: (npmrc: string) => [registry]

common-npm-packages/packaging-common/locationUtilities.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ export function getSystemAccessToken(): string {
116116
tl.debug('Getting credentials for local feeds');
117117
const auth = tl.getEndpointAuthorization('SYSTEMVSSCONNECTION', false);
118118
if (auth.scheme === 'OAuth') {
119-
tl.debug('Got auth token');
119+
tl.debug(tl.loc("Info_GotAndMaskAuth"));
120+
tl.setSecret(auth.parameters['AccessToken']);
120121
return auth.parameters['AccessToken'];
121122
} else {
122123
tl.warning('Could not determine credentials to use');

common-npm-packages/packaging-common/module.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"Info_UsingToolPath": "Using tool path: %s",
1515
"Info_UsingVersion": "Using version: %s",
1616
"Info_BasicCredRestriction": "This task now configures NuGet to send these credentials using the Basic scheme\nonly. Most users will be unaffected by this change. If these are Windows domain\ncredentials and they have recently stopped working, try setting the build\nvariable %s to the value '%s' (without quotes).",
17+
"Info_GotAndMaskAuth":"Got auth token, setting it as secret so it does not print in console log",
1718
"NGCommon_AddingSources": "Setting credentials in NuGet.config",
1819
"NGCommon_AreaNotFoundInSps": "Unable to locate the '%s' [%s] area. The service containing that area may not be available in your region.",
1920
"NGCommon_DetectedNuGetExtensionsPath": "Detected NuGet extensions loader path (NUGET_EXTENSIONS_PATH environment variable): %s",
@@ -27,6 +28,5 @@
2728
"NGCommon_UnabletoDetectNuGetVersion": "Unknown NuGet version selected.",
2829
"NGCommon_UnableToFindTool": "Unable to find tool %s",
2930
"Warning_SessionCreationFailed": "Could not create provenance session.",
30-
"Warning_UpdatingNuGetVersion": "Updating version of NuGet.exe to %s from %s. Behavior changes or breaking changes might occur as NuGet updates to a new version. If this is not desired, uncheck the 'Check for Latest Version' option in the task."
31-
}
31+
"Warning_UpdatingNuGetVersion": "Updating version of NuGet.exe to %s from %s. Behavior changes or breaking changes might occur as NuGet updates to a new version. If this is not desired, uncheck the 'Check for Latest Version' option in the task." }
3232
}

common-npm-packages/packaging-common/package-lock.json

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

common-npm-packages/packaging-common/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "azure-pipelines-tasks-packaging-common",
3-
"version": "3.239.0",
3+
"version": "3.241.0",
44
"description": "Azure Pipelines Packaging Tasks Common",
55
"scripts": {
66
"test": "mocha _build/Tests/L0.js",
@@ -9,7 +9,7 @@
99
"author": "Microsoft Corporation",
1010
"repository": {
1111
"type": "git",
12-
"url": "https://github.com/Microsoft/azure-pipelines-tasks"
12+
"url": "https://github.com/microsoft/azure-pipelines-tasks-common-packages/tree/main/common-npm-packages/packaging-common"
1313
},
1414
"license": "MIT",
1515
"dependencies": {
@@ -27,7 +27,7 @@
2727
"ltx": "^2.6.2",
2828
"mocha": "^8.4.0",
2929
"q": "^1.5.0",
30-
"semver": "^5.5.0",
30+
"semver": "^5.7.2",
3131
"typed-rest-client": "1.8.4"
3232
},
3333
"devDependencies": {

0 commit comments

Comments
 (0)