jenkins-infra / repository-permissions-updater

Artifactory permissions synchronization tool and data set
77 stars 1.03k forks source link

Remote Build Result Trigger Plugin #3147

Closed itfsw closed 1 year ago

itfsw commented 1 year ago

Repository URL

https://github.com/itfsw/remote-result-trigger-plugin

New Repository Name

remote-result-trigger-plugin

Description

Remote-Build-Result-Trigger-Plugin

A plugin for Jenkins CI that gives you the ability to monitor successful build on a remote Jenkins server.

Instructions

Enable the trigger within the "Remote Build Result Trigger" section of the build's configuration page.
When remote server build successful, plugin will trigger a local build and inject remote envs to job.

EVN_NAME description
REMOTE_BUILD_NUMBER The remote build number, such as "153".
REMOTE_BUILD_TIMESTAMP The remote build timestamp, such as "1676017363424".
REMOTE_BUILD_URL Full URL of this build, like https://server:port/jenkins/job/foo/15/ (Jenkins URL must be set).
REMOTE_${PARAMETER_NAME} If remote job use buildWithParameters, use remote parameters replace ${PARAMETER_NAME}.

configuration screen

Screenshot

configuration screen

GitHub users to have commit permission

@itfsw

Jenkins project users to have release permission

itfsw

Issue tracker

GitHub issues

jenkins-cert-app commented 1 year ago

Security audit, information and commands

The security team is auditing all the hosting requests, to ensure a better security by default.

This message informs you that a security scan was triggered on your repository. It takes ~10 minutes to complete.

Commands The bot will parse all comments, and it will check if any line start with a command. Security team only:
  • /audit-ok => the audit is complete, the hosting can continue :tada:.
  • /audit-skip => the audit is not necessary, the hosting can continue :tada:.
  • /audit-required => the superficial audit was not sufficient, a deeper look is necessary :mag:.
  • /audit-findings => the audit reveals some issues that require corrections :pencil2:.
Anyone:
  • /request-security-scan => the findings from the security scan were corrected, this command will re-scan your repository :mag:.
  • /audit-review => the findings from the audits were corrected, this command will ping the security team to review the findings :eyes:. It's only applicable when the previous audit required changes.
Only one command can be requested per comment.

(automatically generated message)

github-actions[bot] commented 1 year ago

Hello from your friendly Jenkins Hosting Checker

It appears you have some issues with your hosting request. Please see the list below and correct all issues marked Required. Your hosting request will not be approved until these issues are corrected. Issues marked with Warning or Info are just recommendations and will not stall the hosting process.

You can re-trigger a check by editing your hosting request or by commenting /hosting re-check

daniel-beck commented 1 year ago

For a brand new plugin, https://github.com/itfsw/remote-result-trigger-plugin/blob/4d2abe990706536ca6deec12eed627858439ac00/pom.xml#L12-L14 is an indicator of a bad copy & paste from elsewhere. I suggest you go with a more recent core, and remove the compatibleSince.

https://github.com/itfsw/remote-result-trigger-plugin/blob/4d2abe990706536ca6deec12eed627858439ac00/pom.xml#L58-L78 I recommend you look into using https://github.com/jenkinsci/bom.

jenkins-cert-app commented 1 year ago

The CodeQL Scan discovered 5 finding(s) :mag:. For each of them, either apply the recommended correction, suppress the warning or provide a justification.

Once you're done, either re-run the scan with /request-security-scan or request the Security team to review your justifications with /audit-review.


Jenkins: Missing permission check on a form fill web method with credentials lookup

You can find detailed information about this finding here.

CredentialsAuth.java#140 ``` doFillCredentialsItems should perform a permission check before calling #lookupCredentials ```

Stapler: Missing POST/RequirePOST annotation

You can find detailed information about this finding here.

CredentialsAuth.java#140 ``` Potential CSRF vulnerability: If CredentialsAuthDescriptor#doFillCredentialsItems connects to user-specified URLs, modifies state, or is expensive to run, it should be annotated with @POST or @RequirePOST ```

Stapler: Missing permission check

You can find detailed information about this finding here.

CredentialsAuth.java#140 ``` Potential missing permission check in CredentialsAuthDescriptor#doFillCredentialsItems ```

Jenkins: Plaintext password storage

You can find detailed information about this finding here.

CredentialsAuth.java#30 ``` Field should be reviewed whether it stores a password and is serialized to disk: credentials ```

Jenkins: Generally unsafe method calls

You can find detailed information about this finding here.

SSLSocketManager.java#20 ``` Potentially unsafe invocation of SSLContext#init ```
itfsw commented 1 year ago

/hosting re-check

github-actions[bot] commented 1 year ago

Hello from your friendly Jenkins Hosting Checker

It looks like you have everything in order for your hosting request. A human volunteer will check over things that I am not able to check for (code review, README content, etc) and process the request as quickly as possible. Thank you for your patience.

Hosting team members can host this request with /hosting host

NotMyFault commented 1 year ago

/request-security-scan

NotMyFault commented 1 year ago

/audit-review

jenkins-cert-app commented 1 year ago

The CodeQL Scan discovered 5 finding(s) :mag:. For each of them, either apply the recommended correction, suppress the warning or provide a justification.

Once you're done, either re-run the scan with /request-security-scan or request the Security team to review your justifications with /audit-review.


Jenkins: Missing permission check on a form fill web method with credentials lookup

You can find detailed information about this finding here.

CredentialsAuth.java#140 ``` doFillCredentialsItems should perform a permission check before calling #lookupCredentials ```

Stapler: Missing POST/RequirePOST annotation

You can find detailed information about this finding here.

CredentialsAuth.java#140 ``` Potential CSRF vulnerability: If CredentialsAuthDescriptor#doFillCredentialsItems connects to user-specified URLs, modifies state, or is expensive to run, it should be annotated with @POST or @RequirePOST ```

Stapler: Missing permission check

You can find detailed information about this finding here.

CredentialsAuth.java#140 ``` Potential missing permission check in CredentialsAuthDescriptor#doFillCredentialsItems ```

Jenkins: Plaintext password storage

You can find detailed information about this finding here.

CredentialsAuth.java#30 ``` Field should be reviewed whether it stores a password and is serialized to disk: credentials ```

Jenkins: Generally unsafe method calls

You can find detailed information about this finding here.

SSLSocketManager.java#20 ``` Potentially unsafe invocation of SSLContext#init ```
itfsw commented 1 year ago

/request-security-scan

NotMyFault commented 1 year ago

@Wadeck Your bot -1's me :(

Is there a chance to react with "+1" when requesting a re-run?

jenkins-cert-app commented 1 year ago

The CodeQL Scan did not find anything dangerous with your plugin, congratulations! :tada:

Wadeck commented 1 year ago

@NotMyFault the -1 is because the "status" was not expected. I need to check what happened, there were lot of commands there :) (the -1 was on the audit-review not the re-run of the scan)

NotMyFault commented 1 year ago

Hey @itfsw,

I took a general look over your hosting request and have a few recommendations:

itfsw commented 1 year ago

@NotMyFault all fixed

itfsw commented 1 year ago

/request-security-scan

jenkins-cert-app commented 1 year ago

The CodeQL Scan did not find anything dangerous with your plugin, congratulations! :tada:

daniel-beck commented 1 year ago

https://github.com/itfsw/remote-result-trigger-plugin/blob/42a8c0f65973579a4ec06afd5c0deee2d67e26b0/src/main/java/io/jenkins/plugins/remote/result/trigger/auth2/CredentialsAuth.java#L151-L152 Only one of these is needed, they both independently accomplish that. Note that doFillCredentialsIdItems are not considered to have side effects, so a suppression here would also be fine.

https://github.com/itfsw/remote-result-trigger-plugin/blob/42a8c0f65973579a4ec06afd5c0deee2d67e26b0/src/main/java/io/jenkins/plugins/remote/result/trigger/RemoteBuildResultTrigger.java#L194 looks like an unsafe default. Unsure what use case this being Boolean covers, that looks like something added for backwards compatibility with an older release (bad copy & paste again?). Should be easier with a boolean and defaulting to not trust.

itfsw commented 1 year ago

@daniel-beck

  1. doFillCredentialsIdItems has removed RequirePOST.
  2. "Unsure what use case this being Boolean covers, that looks like something added for backwards compatibility with an older release (bad copy & paste again?)", ....I found the problem,it's used to my local test,I will remove it.
itfsw commented 1 year ago

/request-security-scan

jenkins-cert-app commented 1 year ago

The CodeQL Scan discovered 2 finding(s) :mag:. For each of them, either apply the recommended correction, suppress the warning or provide a justification.

Once you're done, either re-run the scan with /request-security-scan or request the Security team to review your justifications with /audit-review.


Stapler: Missing POST/RequirePOST annotation

You can find detailed information about this finding here.

RemoteBuildResultTrigger.java#235 ``` Potential CSRF vulnerability: If RemoteBuildResultTriggerDescriptor#doCheckRemoteJenkinsUrl connects to user-specified URLs, modifies state, or is expensive to run, it should be annotated with @POST or @RequirePOST ```

Stapler: Missing permission check

You can find detailed information about this finding here.

RemoteBuildResultTrigger.java#235 ``` Potential missing permission check in RemoteBuildResultTriggerDescriptor#doCheckRemoteJenkinsUrl ```

Jenkins: Generally unsafe method calls

You can find detailed information about this finding here.

itfsw commented 1 year ago

/request-security-scan

jenkins-cert-app commented 1 year ago

The CodeQL Scan discovered 1 finding(s) :mag:. For each of them, either apply the recommended correction, suppress the warning or provide a justification.

Once you're done, either re-run the scan with /request-security-scan or request the Security team to review your justifications with /audit-review.


Stapler: Missing permission check

You can find detailed information about this finding here.

RemoteBuildResultTrigger.java#237 ``` Potential missing permission check in RemoteBuildResultTriggerDescriptor#doCheckRemoteJenkinsUrl ```

Jenkins: Generally unsafe method calls

You can find detailed information about this finding here.

itfsw commented 1 year ago

/request-security-scan

jenkins-cert-app commented 1 year ago

The CodeQL Scan did not find anything dangerous with your plugin, congratulations! :tada:

NotMyFault commented 1 year ago

/hosting re-check

github-actions[bot] commented 1 year ago

Hello from your friendly Jenkins Hosting Checker

It looks like you have everything in order for your hosting request. A human volunteer will check over things that I am not able to check for (code review, README content, etc) and process the request as quickly as possible. Thank you for your patience.

Hosting team members can host this request with /hosting host

itfsw commented 1 year ago

/request-security-scan

jenkins-cert-app commented 1 year ago

The CodeQL Scan did not find anything dangerous with your plugin, congratulations! :tada:

NotMyFault commented 1 year ago

Hey @itfsw,

itfsw commented 1 year ago

@NotMyFault Thanks for review,all need fixed has done. But i have pull new version to support monitor more than one remote jobs. So we need a new review.

New Readme

itfsw commented 1 year ago

/request-security-scan

jenkins-cert-app commented 1 year ago

The CodeQL Scan discovered 3 finding(s) :mag:. For each of them, either apply the recommended correction, suppress the warning or provide a justification.

Once you're done, either re-run the scan with /request-security-scan or request the Security team to review your justifications with /audit-review.


Stapler: Missing permission check

You can find detailed information about this finding here.

RemoteJenkinsServer.java#110 ``` Potential missing permission check in DescriptorImpl#doCheckUrl ```
RemoteJobInfo.java#102 ``` Potential missing permission check in DescriptorImpl#doFillRemoteJenkinsServerItems ```

Jenkins: Plaintext password storage

You can find detailed information about this finding here.

RemoteJobResultUtils.java#283 ``` Field should be reviewed whether it stores a password and is serialized to disk: serverJobKey ```
itfsw commented 1 year ago

/request-security-scan

jenkins-cert-app commented 1 year ago

The CodeQL Scan did not find anything dangerous with your plugin, congratulations! :tada:

NotMyFault commented 1 year ago

/request-security-scan

jenkins-cert-app commented 1 year ago

The CodeQL Scan did not find anything dangerous with your plugin, congratulations! :tada:

github-actions[bot] commented 1 year ago

Hello from your friendly Jenkins Hosting Checker

It looks like you have everything in order for your hosting request. A human volunteer will check over things that I am not able to check for (code review, README content, etc) and process the request as quickly as possible. Thank you for your patience.

Hosting team members can host this request with /hosting host

NotMyFault commented 1 year ago

/hosting host

jenkins-infra-bot commented 1 year ago

Hosting request complete, the code has been forked into the jenkinsci project on GitHub as https://github.com/jenkinsci/remote-result-trigger-plugin

GitHub issues has been selected for issue tracking and was enabled for the forked repo.

A pull request has been created against the repository permissions updater to setup release permissions. Additional users can be added by modifying the created file.

Please delete your original repository (if there are no other forks), under 'Danger Zone', so that the jenkinsci organization repository is the definitive source for the code. If there are other forks, please contact GitHub support to make the jenkinsci repo the root of the fork network (mention that Jenkins approval was given in support request 569994). Also, please make sure you properly follow the documentation on documenting your plugin so that your plugin is correctly documented.

You will also need to do the following in order to push changes and release your plugin:

In order for your plugin to be built by the Jenkins CI Infrastructure and check pull requests, please add a Jenkinsfile to the root of your repository with the following content: buildPlugin(useContainerAgent: true, jdkVersions: [8, 11])

Welcome aboard!