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

Allow masking custom headers #23

Merged
merged 1 commit into from
Mar 17, 2017
Merged

Allow masking custom headers #23

merged 1 commit into from
Mar 17, 2017

Conversation

amarruedo
Copy link
Contributor

Would you take this in consideration?

Sometimes custom headers are filled with authentication tokens, and it would be nice if those tokens do not appear in the logs.

This pipeline script:

#!groovy

httpRequest httpMode: 'GET', 
       customHeaders: [[name: 'X-Vault-Token', value: vault_token, maskValue: true],[name: 'X-Test', value: 'test']], 
       url: http://vault.default.svc.cluster.local:8200/v1/secret/mySecret

would output the folowing in the logs:

[Pipeline] httpRequest
HttpMode: GET
URL: http://vault.default.svc.cluster.local:8200/v1/secret/android_debug
Content-type: application/json
X-Vault-Token: *****
X-Test: test
Sending request to url: http://vault.default.svc.cluster.local:8200/v1/secret/mySecret
Response Code: HTTP/1.1 200 OK
Success code from [100‥399]

The default behaviour is to not mask the value, so the extra maskValue parameter is only required when you need to mask the value.

I've tested this on my local Jenkins (v 2.32.1) succesfully. I'm not java nor Jenkins plugin developer so it's possible that there is a better way to achieve this, but anyway, here are my two cents.

@janario janario merged commit 98aa748 into jenkinsci:master Mar 17, 2017
@janario
Copy link
Member

janario commented Mar 17, 2017

Thanks for the pull request.

I'm going to do some more tests local and release it soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants