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

Add datastore option for Jenkins home directory #17681

Merged
merged 4 commits into from Jul 18, 2023
Merged

Add datastore option for Jenkins home directory #17681

merged 4 commits into from Jul 18, 2023

Conversation

MegaManSec
Copy link
Contributor

@MegaManSec MegaManSec commented Feb 21, 2023

This patch adds a new option to the jenkins_gather.rb script, allowing a
user to specify the "jenkins home" directory, instead of running a potentially
time-and-resource-consuming "find /" command. Default directories are
now also included.

This patch is inspired by an environment where the "find /" command was
taking too long, and there was no way to set a configuration, despite
the correct directory being known. This patch also now allows for
alternative Jenkins directories to be gathered, not just the first one
found by `find'.

@MegaManSec
Copy link
Contributor Author

Also: performing find / continues even after the first directory is found. It could be improved by adding the -print -quit flags tot he search I suppose, which would make it stop after the first result (although this is not compatible with netbsd apparently)

@bcoles
Copy link
Contributor

bcoles commented Feb 22, 2023

There seems to be a lot of unrelated style changes introduced in this PR. Please run rubocop.

@bcoles bcoles added the needs-linting The module needs additional work to pass our automated linting rules label Feb 22, 2023
@github-actions
Copy link

Thanks for your pull request! Before this pull request can be merged, it must pass the checks of our automated linting tools.

We use Rubocop and msftidy to ensure the quality of our code. This can be ran from the root directory of Metasploit:

rubocop <directory or file>
tools/dev/msftidy.rb <directory or file>

You can automate most of these changes with the -a flag:

rubocop -a <directory or file>

Please update your branch after these have been made, and reach out if you have any problems.

…ional value that a user can suggest the home directory.
@MegaManSec
Copy link
Contributor Author

I am unsure why the commit contains styling changes at all, and I did not change anything other than the find_home function and the top of the file.. I think that rubocop may have run but without parsing .rubocop.yaml.

@bcoles
Copy link
Contributor

bcoles commented Feb 22, 2023

I am unsure why the commit contains styling changes at all, and I did not change anything other than the find_home function and the top of the file.. I think that rubocop may have run but without parsing .rubocop.yaml.

rubocop was run over the modules a couple of weeks ago:

You've likely forked and performed modifications before these changes were applied, which resulted in the rubocop changes being reverted.

@gwillcox-r7 gwillcox-r7 added module docs enhancement and removed needs-linting The module needs additional work to pass our automated linting rules labels Feb 23, 2023
@gwillcox-r7 gwillcox-r7 self-assigned this May 31, 2023
Copy link
Contributor

@gwillcox-r7 gwillcox-r7 left a comment

Choose a reason for hiding this comment

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

Overall looks good but had one concern that might not be related to this PR per say.

modules/post/multi/gather/jenkins_gather.rb Show resolved Hide resolved
@gwillcox-r7 gwillcox-r7 removed their assignment Jun 5, 2023
Change the default Windows location to C:\ProgramData\Jenkins\.jenkins\.
Change Windows default to C:\ProgramData\Jenkins\.jenkins.
@cgranleese-r7
Copy link
Contributor

Tested against Windows 10 and Jenkins Docker image version 2.414.

Windows

msf6 post(multi/gather/jenkins_gather) > set jenkins_home C:\\ProgramData\\Jenkins\\.jenkins
jenkins_home => C:\ProgramData\Jenkins\.jenkins
msf6 post(multi/gather/jenkins_gather) > time run

[-] Cannot read master.key or hudson.util.Secret...
[-] Encrypted strings will not be able to be decrypted...
[-] Could not read credentials.xml...
[*] Post module execution completed
[+] Command "run" completed in 0.8574719999996887 seconds
msf6 post(multi/gather/jenkins_gather) > unset JENKINS_HOME
Unsetting JENKINS_HOME...
msf6 post(multi/gather/jenkins_gather) > time run

[*] Searching for Jenkins directory... This could take some time...
[*] Found Jenkins installation at C:\ProgramData\Jenkins\.jenkins\
[-] Cannot read master.key or hudson.util.Secret...
[-] Encrypted strings will not be able to be decrypted...
[-] Could not read credentials.xml...
[*] Post module execution completed
[+] Command "run" completed in 0.7100030000001425 seconds

Docker

msf6 post(multi/gather/jenkins_gather) > set jenkins_home C:\\ProgramData\\Jenkins\\.jenkins
jenkins_home => C:\ProgramData\Jenkins\.jenkins
msf6 post(multi/gather/jenkins_gather) > time run

[-] Cannot read master.key or hudson.util.Secret...
[-] Encrypted strings will not be able to be decrypted...
[-] Could not read credentials.xml...
[*] Post module execution completed
[+] Command "run" completed in 0.712282999999843 seconds
msf6 post(multi/gather/jenkins_gather) > unset JENKINS_HOME
Unsetting JENKINS_HOME...
msf6 post(multi/gather/jenkins_gather) > time run

[*] Searching for Jenkins directory... This could take some time...
[*] Found Jenkins installation at C:\ProgramData\Jenkins\.jenkins\
[-] Cannot read master.key or hudson.util.Secret...
[-] Encrypted strings will not be able to be decrypted...
[-] Could not read credentials.xml...
[*] Post module execution completed
[+] Command "run" completed in 0.7935689999994793 seconds

Co-authored-by: cgranleese-r7 <69522014+cgranleese-r7@users.noreply.github.com>
@cgranleese-r7 cgranleese-r7 changed the title Add default locations for the Jenkins home directory, and add an optional value that a user can suggest the home directory. Add datastore options for Jenkins home directory Jul 18, 2023
@cgranleese-r7 cgranleese-r7 changed the title Add datastore options for Jenkins home directory Add datastore option for Jenkins home directory Jul 18, 2023
@cgranleese-r7 cgranleese-r7 merged commit a0f04a7 into rapid7:master Jul 18, 2023
34 checks passed
@cgranleese-r7
Copy link
Contributor

Release Notes

This PR adds a new datastore option for Jenkins home directory to the jenkins_gather module.

@jheysel-r7 jheysel-r7 added the rn-enhancement release notes enhancement label Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants