@@ -174,6 +174,7 @@ export interface IConfiguration {
174
174
poolId : number ;
175
175
createDiagnosticWriter ?: ( ) => IDiagnosticWriter ;
176
176
agent : agentifm . TaskAgent ;
177
+ creds ?: any ;
177
178
}
178
179
179
180
export interface IServiceChannel extends NodeJS . EventEmitter {
@@ -426,13 +427,31 @@ interface IndexFunction {
426
427
( input : string ) : ReplacementPosition [ ] ;
427
428
}
428
429
429
- function createMaskFunction ( jobEnvironment : agentifm . JobEnvironment ) : ReplacementFunction {
430
+ function createMaskFunction ( jobEnvironment : agentifm . JobEnvironment , config : IConfiguration ) : ReplacementFunction {
430
431
var noReplacement = ( input : string ) => {
431
432
return input ;
432
433
} ;
433
434
434
435
var envMasks = jobEnvironment . mask || [ ] ;
435
436
var maskHints = [ ] ;
437
+
438
+ // add masks for basic creds, in case force-basic was specified
439
+ if ( config && config . creds ) {
440
+ if ( config . creds . username ) {
441
+ var maskHint = {
442
+ value : config . creds . username
443
+ } ;
444
+ maskHints . push ( maskHint ) ;
445
+ }
446
+ if ( config . creds . password ) {
447
+ var maskHint = {
448
+ value : config . creds . password
449
+ } ;
450
+ maskHints . push ( maskHint ) ;
451
+ }
452
+ }
453
+
454
+ // add masks sent by the server
436
455
envMasks . forEach ( ( maskHint : agentifm . MaskHint ) => {
437
456
if ( maskHint . type === agentifm . MaskType . Variable && maskHint . value ) {
438
457
if ( jobEnvironment . variables [ maskHint . value ] ) {
@@ -447,19 +466,7 @@ function createMaskFunction(jobEnvironment: agentifm.JobEnvironment): Replacemen
447
466
if ( maskHints . length > 0 ) {
448
467
var indexFunctions : IndexFunction [ ] = [ ] ;
449
468
maskHints . forEach ( ( maskHint : agentifm . MaskHint , index : number ) => {
450
- if ( maskHint . type === agentifm . MaskType . Variable ) {
451
- var toReplace = jobEnvironment . variables [ maskHint . value ] ;
452
- indexFunctions . push ( ( input : string ) => {
453
- var results : ReplacementPosition [ ] = [ ] ;
454
- var index : number = input . indexOf ( toReplace ) ;
455
- while ( index > - 1 ) {
456
- results . push ( { start : index , length : toReplace . length } ) ;
457
- index = input . indexOf ( toReplace , index + 1 ) ;
458
- }
459
- return results ;
460
- } ) ;
461
- }
462
- else if ( maskHint . type === agentifm . MaskType . Regex ) {
469
+ if ( maskHint . type === agentifm . MaskType . Regex ) {
463
470
indexFunctions . push ( ( input : string ) => {
464
471
var stubInput : string = input ;
465
472
var results : ReplacementPosition [ ] = [ ] ;
@@ -479,6 +486,21 @@ function createMaskFunction(jobEnvironment: agentifm.JobEnvironment): Replacemen
479
486
return results ;
480
487
} ) ;
481
488
}
489
+ else {
490
+ var toReplace = maskHint . value ;
491
+ if ( maskHint . type === agentifm . MaskType . Variable ) {
492
+ toReplace = jobEnvironment . variables [ maskHint . value ] ;
493
+ }
494
+ indexFunctions . push ( ( input : string ) => {
495
+ var results : ReplacementPosition [ ] = [ ] ;
496
+ var index : number = input . indexOf ( toReplace ) ;
497
+ while ( index > - 1 ) {
498
+ results . push ( { start : index , length : toReplace . length } ) ;
499
+ index = input . indexOf ( toReplace , index + 1 ) ;
500
+ }
501
+ return results ;
502
+ } ) ;
503
+ }
482
504
} ) ;
483
505
484
506
return ( input : string ) => {
@@ -537,7 +559,7 @@ function createMaskFunction(jobEnvironment: agentifm.JobEnvironment): Replacemen
537
559
// TODO: JobInfo is going away soon. We should just offer the task context the full job message.
538
560
// Until then, we're making the full job message available
539
561
//
540
- export function jobInfoFromJob ( job : agentifm . JobRequestMessage , systemAuthHandler : baseifm . IRequestHandler ) : IJobInfo {
562
+ export function jobInfoFromJob ( job : agentifm . JobRequestMessage , systemAuthHandler : baseifm . IRequestHandler , config : IConfiguration ) : IJobInfo {
541
563
var info : IJobInfo = {
542
564
description : job . jobName ,
543
565
jobId : job . jobId ,
@@ -548,7 +570,7 @@ export function jobInfoFromJob(job: agentifm.JobRequestMessage, systemAuthHandle
548
570
lockToken : job . lockToken ,
549
571
systemAuthHandler : systemAuthHandler ,
550
572
variables : job . environment . variables ,
551
- mask : createMaskFunction ( job . environment )
573
+ mask : createMaskFunction ( job . environment , config )
552
574
} ;
553
575
554
576
return info ;
0 commit comments