Skip to content

Commit 65e88e2

Browse files
authored
Encode when decode is on. Release M188 (#14953)
1 parent 30577e1 commit 65e88e2

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

Tasks/AzureKeyVaultV2/Tests/L0.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ describe('Azure Key Vault', function () {
6767
assert(tr.stdout.indexOf("##vso[task.setvariable variable=secret2;issecret=true;]secret2-value") > 0, "##vso[task.setvariable variable=secret2;issecret=true;]secret2-value");
6868
assert(tr.stdout.indexOf("##vso[task.setvariable variable=secret3;issecret=true;]secret3/versionIdentifierGuid-value") > 0, "##vso[task.setvariable variable=secret3;issecret=true;]secret3/versionIdentifierGuid-value");
6969
assert(tr.stdout.indexOf("##vso[task.setvariable variable=secret3/versionIdentifierGuid;issecret=true;]secret3/versionIdentifierGuid-value") > 0, "##vso[task.setvariable variable=secret3/versionIdentifierGuid;issecret=true;]secret3/versionIdentifierGuid-value");
70-
assert(tr.stdout.indexOf("##vso[task.setvariable variable=secret5_%AZP253B;issecret=true;]secret5_%AZP253B-value") > 0, "##vso[task.setvariable variable=secret5_%AZP253B;issecret=true;]secret5_%AZP253B-value");
70+
assert(tr.stdout.indexOf("##vso[task.setvariable variable=secret5_%3B;issecret=true;]secret5_%3B-value") > 0, "##vso[task.setvariable variable=secret5_%3B;issecret=true;]secret5_%3B-value");
7171

7272
assert(tr.stdout.indexOf("##vso[task.setvariable variable=secret4;issecret=true;]secret4-value") < 0, "secret4 value should not be set");
7373

Tasks/AzureKeyVaultV2/Tests/downloadSelectedSecrets.ts

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ process.env["ENDPOINT_DATA_AzureRMSpn_AzureKeyVaultServiceEndpointResourceId"] =
2424
process.env["ENDPOINT_URL_AzureRMSpn"] = "https://management.azure.com/";
2525
process.env["SYSTEM_DEFAULTWORKINGDIRECTORY"] = "C:\\a\\w\\";
2626
process.env["AGENT_TEMPDIRECTORY"] = process.cwd();
27+
process.env["DECODE_PERCENTS"] = "false";
2728

2829
tr.registerMock('azure-pipelines-task-lib/toolrunner', require('azure-pipelines-task-lib/mock-toolrunner'));
2930
tr.registerMock('./azure-arm-keyvault', require('./mock_node_modules/azure-arm-keyvault'));

Tasks/AzureKeyVaultV2/operations/KeyVault.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import tl = require("azure-pipelines-task-lib/task");
66
import * as path from 'path';
77
import * as fs from 'fs';
88

9+
const DECODE_PERCENTS = "DECODE_PERCENTS";
10+
911
export class SecretsToErrorsMapping {
1012
public errorsMap: { [key: string]: string; };
1113

@@ -193,8 +195,11 @@ export class KeyVault {
193195
}
194196

195197
// Encode percent explicitely as the task lib does not encode % to %AZP25 as of now.
196-
secretName = secretName.replace(/%/g, '%AZP25');
197-
secretValue = secretValue.replace(/%/g, '%AZP25');
198+
let decodePercents = tl.getVariable(DECODE_PERCENTS);
199+
if (decodePercents && decodePercents.toUpperCase() === "TRUE") {
200+
secretName = secretName.replace(/%/g, '%AZP25');
201+
secretValue = secretValue.replace(/%/g, '%AZP25');
202+
}
198203

199204
// Support multiple stages using different key vaults with the same secret name but with different version identifiers
200205
let secretNameWithoutVersion = secretName.split("/")[0];

Tasks/AzureKeyVaultV2/task.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"author": "Microsoft Corporation",
1515
"version": {
1616
"Major": 2,
17-
"Minor": 186,
17+
"Minor": 188,
1818
"Patch": 0
1919
},
2020
"demands": [],

Tasks/AzureKeyVaultV2/task.loc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"author": "Microsoft Corporation",
1515
"version": {
1616
"Major": 2,
17-
"Minor": 186,
17+
"Minor": 188,
1818
"Patch": 0
1919
},
2020
"demands": [],

0 commit comments

Comments
 (0)