Skip to content

Commit

Permalink
Error on multiline secret
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsciple committed Feb 22, 2018
1 parent b7b47e4 commit 1db7834
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions node/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ export function setVariable(name: string, val: string, secret: boolean = false):
let varValue = val || '';
debug('set ' + name + '=' + (secret && varValue ? '********' : varValue));
if (secret) {
if (varValue && varValue.match(/\r|\n/) && `${process.env['SYSTEM_UNSAFEALLOWMULTILINESECRET']}`.toUpperCase() != 'TRUE') {
throw new Error(loc('lib_MultilineSecret'));
}

im._vault.storeSecret('SECRET_' + key, varValue);
delete process.env[key];
} else {
Expand All @@ -141,6 +145,20 @@ export function setVariable(name: string, val: string, secret: boolean = false):
command('task.setvariable', { 'variable': name || '', 'issecret': (secret || false).toString() }, varValue);
}

/**
* Registers a value with the logger, so the value will be masked from the logs.
*
* @param val value to register
*/
export function setSecret(val: string): void {
if (val) {
if (val.match(/\r|\n/) && `${process.env['SYSTEM_UNSAFEALLOWMULTILINESECRET']}`.toUpperCase() !== 'TRUE') {
throw new Error(loc('lib_MultilineSecret'));
}
command('task.setsecret', {}, val);
}
}

/** Snapshot of a variable at the time when getVariables was called. */
export interface VariableInfo {
name: string;
Expand Down

0 comments on commit 1db7834

Please sign in to comment.