Skip to content
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

Encode when decode is on. Release M188 #14953

Merged
merged 1 commit into from
Jun 9, 2021
Merged
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
2 changes: 1 addition & 1 deletion Tasks/AzureKeyVaultV2/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('Azure Key Vault', function () {
assert(tr.stdout.indexOf("##vso[task.setvariable variable=secret2;issecret=true;]secret2-value") > 0, "##vso[task.setvariable variable=secret2;issecret=true;]secret2-value");
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");
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");
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");
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");

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

Expand Down
1 change: 1 addition & 0 deletions Tasks/AzureKeyVaultV2/Tests/downloadSelectedSecrets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ process.env["ENDPOINT_DATA_AzureRMSpn_AzureKeyVaultServiceEndpointResourceId"] =
process.env["ENDPOINT_URL_AzureRMSpn"] = "https://management.azure.com/";
process.env["SYSTEM_DEFAULTWORKINGDIRECTORY"] = "C:\\a\\w\\";
process.env["AGENT_TEMPDIRECTORY"] = process.cwd();
process.env["DECODE_PERCENTS"] = "false";

tr.registerMock('azure-pipelines-task-lib/toolrunner', require('azure-pipelines-task-lib/mock-toolrunner'));
tr.registerMock('./azure-arm-keyvault', require('./mock_node_modules/azure-arm-keyvault'));
Expand Down
9 changes: 7 additions & 2 deletions Tasks/AzureKeyVaultV2/operations/KeyVault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import tl = require("azure-pipelines-task-lib/task");
import * as path from 'path';
import * as fs from 'fs';

const DECODE_PERCENTS = "DECODE_PERCENTS";

export class SecretsToErrorsMapping {
public errorsMap: { [key: string]: string; };

Expand Down Expand Up @@ -193,8 +195,11 @@ export class KeyVault {
}

// Encode percent explicitely as the task lib does not encode % to %AZP25 as of now.
secretName = secretName.replace(/%/g, '%AZP25');
secretValue = secretValue.replace(/%/g, '%AZP25');
let decodePercents = tl.getVariable(DECODE_PERCENTS);
if (decodePercents && decodePercents.toUpperCase() === "TRUE") {
secretName = secretName.replace(/%/g, '%AZP25');
secretValue = secretValue.replace(/%/g, '%AZP25');
}

// Support multiple stages using different key vaults with the same secret name but with different version identifiers
let secretNameWithoutVersion = secretName.split("/")[0];
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureKeyVaultV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 186,
"Minor": 188,
"Patch": 0
},
"demands": [],
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureKeyVaultV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 186,
"Minor": 188,
"Patch": 0
},
"demands": [],
Expand Down