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

Resolve credential leak via ps while jenkins-cli is used during puppe… #946

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

avbm
Copy link

@avbm avbm commented Feb 21, 2020

…t runs

Pull Request (PR) description

Passes credentials to jenkins-cli as environement variables by default so passwords aren't visible in the output of ps during puppet agent runs.

This Pull Request (PR) fixes the following issues

Not sure if this has an associated issue

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

Looking at this, there should be a wrapper define for the CLI to keep the logic central. Not strictly needed for this PR, but it'd be a nice improvement.

I've updated #937 to update this module to our current standard. I'm hoping to get it merged so we at least have working unit tests again. Ideally this should be rebased when that's merged.

manifests/cli.pp Outdated
@@ -64,6 +64,15 @@
' '
)

if $::jenkins::cli_env_var {
$cmd_environment = [
"JENKINS_USER_ID=${::jenkins::cli_username}",
Copy link
Member

Choose a reason for hiding this comment

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

Please use consistent indenting and remove the leading colons from variables. This is a repeated thing in the PR so I'll only comment it once :)

Suggested change
"JENKINS_USER_ID=${::jenkins::cli_username}",
"JENKINS_USER_ID=${jenkins::cli_username}",

Copy link
Author

Choose a reason for hiding this comment

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

fixed the indents using puppet-lint

@@ -336,6 +336,48 @@
Boolean $purge_plugins = $jenkins::params::purge_plugins,
) inherits jenkins::params {

validate_string($version)
Copy link
Member

Choose a reason for hiding this comment

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

We use data types and since you're not changing anything, I think it should already be covered. Please have a look at the parameters to verify.

Copy link
Author

Choose a reason for hiding this comment

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

You are correct. I removed all the validate statements since using types makes them moot

$_cli_auth_arg = "-auth '${cli_username}:${cli_password}'"
# username and password passed as environment variables to prevent showing in ps output
# so setting cli_auth_arg to empty string
$_cli_auth_arg = ""
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$_cli_auth_arg = ""
$_cli_auth_arg = ''

@avbm avbm force-pushed the upstream_master_cli branch 2 times, most recently from 83a8f76 to f38eb0b Compare February 24, 2020 15:19
@avbm
Copy link
Author

avbm commented Feb 24, 2020

I made updates based on your feedback @ekohl. Let me know if it looks good now. Also I have a question about commit/merge practices. I usually like to rebase and squash updates on feature/bugfix branches. ex. my current fixes were squashed into my previous commit and pushed to my fork. I was wondering if there was a best pracitces/recommend process around this for this repo/org. (ie should we squash in fixes or keep them as separate commits)

@avbm avbm force-pushed the upstream_master_cli branch 3 times, most recently from 1557d86 to a51b5fa Compare February 24, 2020 22:01
@avbm
Copy link
Author

avbm commented Feb 24, 2020

Rebased on current master HEAD

@avbm
Copy link
Author

avbm commented Feb 25, 2020

@ekohl or @bastelfreak : are any other chages/updates required in this PR?
I agree with @ekohl that we need to centralize logic in a wrapper but i would prefer to do that in a separate PR to keep the changes easy to comprehend.

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

It would be nice to have some tests around this. Looks like right now there's not a single test around passing in a password. Other than that it looks correct.

@avbm avbm force-pushed the upstream_master_cli branch 7 times, most recently from 88f5c74 to 26897d9 Compare February 27, 2020 01:22
@avbm
Copy link
Author

avbm commented Feb 27, 2020

@ekohl , I added a couple of unit tests to ensure the auth args are added to enviornment when defined and they are absent when not defined.
Let me know if any other tests are required else please merge.

@avbm
Copy link
Author

avbm commented Feb 28, 2020

Hey @ekohl , just wanted to check if there were any updates required for this PR could be merged?

@vox-pupuli-tasks
Copy link

Dear @avbm, thanks for the PR!

This is Vox Pupuli Tasks, your friendly Vox Pupuli Github Bot. I noticed that your pull request has CI failures. Can you please have a look at the failing CI jobs?
If you need any help, you can reach out to us on our IRC channel voxpupuli on Freenode or our Slack channel voxpupuli at slack.puppet.com.
You can find my sourcecode at voxpupuli/vox-pupuli-tasks

@vox-pupuli-tasks
Copy link

Dear @avbm, thanks for the PR!

This is Vox Pupuli Tasks, your friendly Vox Pupuli GitHub Bot. I noticed that your pull request contains merge conflict. Can you please rebase?

You can find my sourcecode at voxpupuli/vox-pupuli-tasks

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