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

[JENKINS-64338] - mask credentials also outside of log #174

Merged
merged 2 commits into from Apr 7, 2021
Merged

[JENKINS-64338] - mask credentials also outside of log #174

merged 2 commits into from Apr 7, 2021

Conversation

scddev
Copy link

@scddev scddev commented Apr 6, 2021

https://issues.jenkins.io/browse/JENKINS-64338

To have proper masking like in credential-plugin, a similar approach is chosen by using also a Step instead of the BuildWrapper.

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your master branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

Copy link
Member

@jetersen jetersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution.

@jetersen
Copy link
Member

jetersen commented Apr 6, 2021

Seems like the test are broken on Jenkins 2.277.1, JDK 8 and ubuntu-20.04

@jetersen
Copy link
Member

jetersen commented Apr 7, 2021

Neat, I forgot that we actually do have non mock test for withVault

@Test
@ConfiguredWithCode("vault.yml")
@EnvsFromFile(value = {VAULT_AGENT_FILE, VAULT_APPROLE_FILE})
public void vaultReturns404() throws Exception {
WorkflowJob pipeline = j.createProject(WorkflowJob.class, "Pipeline");
String pipelineText = IOUtils.toString(TestConstants.class.getResourceAsStream("pipeline.groovy"));
pipeline.setDefinition(new CpsFlowDefinition(pipelineText, true));
WorkflowRun build = pipeline.scheduleBuild2(0).get();
j.assertBuildStatus(Result.FAILURE, build);
j.assertLogContains("Vault credentials not found for '" + VAULT_PATH_KV1_1 + "'", build);
}

withVault([configuration: configuration, vaultSecrets: secrets]) {

String pipelineText = IOUtils.toString(TestConstants.class.getResourceAsStream("custom_credential.groovy"));
pipelineText = pipelineText.replaceAll("#VAULT_TOKEN#", container.getRootToken());
pipeline.setDefinition(new CpsFlowDefinition(pipelineText, false));
}
@Test
public void CustomCredentialTestOK() throws Exception {
GlobalVaultConfiguration globalVaultConfiguration = GlobalVaultConfiguration.get();
VaultConfiguration vaultConfiguration = new VaultConfiguration();
vaultConfiguration.setVaultUrl(container.getAddress());
vaultConfiguration.setTimeout(1);
vaultConfiguration.setEngineVersion(1);
vaultConfiguration.setSkipSslVerification(true);
globalVaultConfiguration.setConfiguration(vaultConfiguration);
WorkflowRun build = pipeline.scheduleBuild2(0).get();
j.assertBuildStatus(Result.SUCCESS, build);
j.assertLogContains("****", build);

@scddev scddev requested a review from jetersen April 7, 2021 06:46
Copy link
Member

@jetersen jetersen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, is there anything missing on your end @scddev ?

@scddev
Copy link
Author

scddev commented Apr 7, 2021

Looks fine for me also.

@jetersen jetersen changed the title JENKINS-64338 mask credentials also outside of log [JENKINS-64338] - mask credentials also outside of log Apr 7, 2021
@jetersen jetersen merged commit c7ad977 into jenkinsci:master Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants