Merge pull request #1210 from mabashian/1029-passwords-preview

Scrub passwords from extra vars preview on launch
This commit is contained in:
Jake McDermott
2018-04-03 01:36:17 -04:00
committed by GitHub

View File

@@ -37,6 +37,8 @@ export default
scope.promptData.extraVars = ToJSON(scope.parseType, scope.promptData.prompts.variables.value, false); scope.promptData.extraVars = ToJSON(scope.parseType, scope.promptData.prompts.variables.value, false);
const surveyPasswords = {};
if (scope.promptData.launchConf.ask_tags_on_launch) { if (scope.promptData.launchConf.ask_tags_on_launch) {
scope.promptData.prompts.tags.value = consolidateTags(scope.promptData.prompts.tags.value, "#job_launch_job_tags"); scope.promptData.prompts.tags.value = consolidateTags(scope.promptData.prompts.tags.value, "#job_launch_job_tags");
} }
@@ -69,10 +71,20 @@ export default
break; break;
} }
} }
if (surveyQuestion.type === 'password' && surveyQuestion.model.toString()!=="") {
surveyPasswords[surveyQuestion.variable] = '$encrypted$';
}
}); });
} }
scope.promptExtraVars = $.isEmptyObject(scope.promptData.extraVars) ? '---' : '---\n' + jsyaml.safeDump(scope.promptData.extraVars); // We don't want to modify the extra vars when we merge them with the survey
// password $encrypted$ strings so we clone it
const extraVarsClone = _.cloneDeep(scope.promptData.extraVars);
// Replace the survey passwords with $encrypted$ to display to the user
const cleansedExtraVars = Object.assign(extraVarsClone, surveyPasswords);
scope.promptExtraVars = $.isEmptyObject(scope.promptData.extraVars) ? '---' : '---\n' + jsyaml.safeDump(cleansedExtraVars);
ParseTypeChange({ ParseTypeChange({
scope: scope, scope: scope,