Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-72412

Masking of one character secrets mangle output

XMLWordPrintable

      The masking of secrets of one char length mangles the output.

      With this credential (Secret = 'a'):

      the following job produces magled output

      #!/usr/bin/env groovy
      pipeline {
          agent any
          stages {
              stage('Check run') {
                  steps {
                      withCredentials([string(credentialsId: 'test-credentials-binding-plugin-masking-secret-text',
                              variable: 'VAR')]) {
                          sh '''
                              echo "VAR.length = ${#VAR}" 
                              echo "This should be masked: VAR = $VAR"
                          '''
                      }
                  }
              }
          }
      } 

      we obtain the following output in the console:

      [Pipeline] withEnv
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (Check run)
      [Pipeline] withCredentials
      Masking supported pattern matches of $VAR
      [Pipeline] {
      [Pipeline] sh
      ****+**** ****e****c****h****o**** ****'****V****A****R****.****l****e****n****g****t****h**** ****=**** ****1****'****
      ********V****A****R****.****l****e****n****g****t****h**** ****=**** ****1****
      ********+**** ****e****c****h****o**** ****'****T****h****i****s**** ****s****h****o****u****l****d**** ****b****e**** ****m********s****k****e****d****:**** ****V****A****R**** ****=**** ********'****
      ********T****h****i****s**** ****s****h****o****u****l****d**** ****b****e**** ****m********s****k****e****d****:**** ****V****A****R**** ****=**** ********
      ****[Pipeline] }
      [Pipeline] // withCredentials 

            Unassigned Unassigned
            agallardo Alberto Gallardo
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: