jenkins-infra / repository-permissions-updater

Artifactory permissions synchronization tool and data set
79 stars 1.06k forks source link

Plugin hosting request for buildpulse-flaky-tests-plugin #3979

Open siddhantdange opened 5 months ago

siddhantdange commented 5 months ago

Repository URL

https://github.com/buildpulse/buildpulse-flaky-tests-plugin

New Repository Name

buildpulse-flaky-tests-plugin

Description

Our Jenkins plugin allows one to easily send test results to BuildPulse for CI analytics and flaky test detection.

GitHub users to have commit permission

@siddhantdange

Jenkins project users to have release permission

sidbuildpulse

Issue tracker

GitHub issues

github-actions[bot] commented 5 months 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

siddhantdange commented 5 months ago

/hosting re-check

github-actions[bot] commented 5 months ago

Hello from your friendly Jenkins Hosting Checker

It looks like you have everything in order for your hosting request. A member of the Jenkins hosting team will check over things that I am not able to check(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

jenkins-cert-app commented 5 months 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 Jenkins 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-findings => the audit reveals some issues that require corrections :pencil2:.
Anyone:
  • /request-security-scan => the findings from the Jenkins Security Scan were corrected, this command will re-scan your repository :mag:.
  • /audit-review => the findings from the audit 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, version: 1.28.6)

jenkins-cert-app commented 5 months ago

:x: Jenkins Security Scan failed. The Security team was notified about this.

Wadeck commented 5 months ago

Hey @siddhantdange I think the Security scan is failing because you do not include in the pom.xml the pluginRepository, leading to the failure to find maven-hpi-plugin:3.13 (available in the Jenkins repo)

    <pluginRepositories>
        <pluginRepository>
            <id>repo.jenkins-ci.org</id>
            <url>https://repo.jenkins-ci.org/public/</url>
        </pluginRepository>
    </pluginRepositories>
siddhantdange commented 5 months ago

/request-security-scan

jenkins-cert-app commented 5 months ago

The Jenkins Security Scan discovered 4 finding(s) :mag:.

Please follow the instructions below for every identified issues:

After addressing the findings through one of the above methods:


Stapler: Missing POST/RequirePOST annotation

You can find detailed information about this finding here.

BuildPulseCommand.java#60 ``` Potential CSRF vulnerability: If BuildPulseCommand#downloadAndGetCommand 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.

BuildPulseCommand.java#60 ``` Potential missing permission check in BuildPulseCommand#downloadAndGetCommand ```

Jenkins: Plaintext password storage

You can find detailed information about this finding here.

BuildPulseStep.java#28 ``` Field should be reviewed whether it stores a password and is serialized to disk: key ```
BuildPulseCommand.java#20 ``` Field should be reviewed whether it stores a password and is serialized to disk: key ```
siddhantdange commented 5 months ago

/request-security-scan

jenkins-cert-app commented 5 months ago

The Jenkins Security Scan discovered 3 finding(s) :mag:.

Please follow the instructions below for every identified issues:

After addressing the findings through one of the above methods:


Stapler: Missing POST/RequirePOST annotation

You can find detailed information about this finding here.

BuildPulseCommand.java#63 ``` Potential CSRF vulnerability: If BuildPulseCommand#downloadAndGetCommand 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.

BuildPulseCommand.java#63 ``` Potential missing permission check in BuildPulseCommand#downloadAndGetCommand ```

Jenkins: Plaintext password storage

You can find detailed information about this finding here.

BuildPulseStep.java#28 ``` Field should be reviewed whether it stores a password and is serialized to disk: keyId ```
siddhantdange commented 5 months ago

/request-security-scan

jenkins-cert-app commented 5 months ago

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


:bulb: The Security team recommends that you are setting up the scan in your repository by following our guide.

siddhantdange commented 5 months ago

@NotMyFault is there any further action needed?

NotMyFault commented 5 months ago

I'll take a look later the week

siddhantdange commented 5 months ago

Hi @NotMyFault - just wanted to check back in here!

NotMyFault commented 5 months ago

I'll take a look when I get a shot to, currently I don't

NotMyFault commented 4 months ago

I took a brief look over your hosting request and have some feedback for you:

mawinter69 commented 4 months ago
siddhantdange commented 3 months ago

Hi @NotMyFault, we've pushed an update that addresses many of these points, do you mind checking the pom.xml again? Also, many of these dependencies we have are for our tests (updated pom.xml to reflect that).

@mawinter69

Test Jenkinsfile:

pipeline {
    agent {
        docker {
            image 'ruby:3.0.5' // Specify the Ruby container image you want to use
            args '-u root' // Optionally, specify additional Docker container run arguments
        }
    }

    environment {
        GIT_REPO_URL = 'my-repo-url' // Replace with your repository URL
        GIT_BRANCH = 'main' // Replace with your branch name if needed
    }

    stages {
        stage('Clone Repository') {
            steps {
                script {
                    echo 'Cloning the repository...'
                    scmVars = git branch: "${env.GIT_BRANCH}", url: "${env.GIT_REPO_URL}", credentialsId: 'github'
                    env.GIT_COMMIT = scmVars.GIT_COMMIT
                }
            }
        }

        stage('Setup') {
            steps {
                script {
                    sh "gem install bundler -v '2.3.26'"
                    sh 'bundle install --jobs=4 --retry=3 --path vendor/bundle'
                    sh 'bin/rspec'
                }
            }
        }
    }

    post {
        always {
            buildpulseStep accountId: '', repositoryId: '', junitXMLPaths: '', key: '', secret: '', commitSHA: env.GIT_COMMIT, branch: env.GIT_BRANCH, tags: '', quota: '', coveragePaths: ''
        }
    }
}
mawinter69 commented 3 months ago

To test with a real agent install the Mock agent plugin, create an agent and run the pipeline on that agent. I'm not familiar with docker agents in Jenkins but afaik such docker containers run on the controller host and the docker plugin creates a local workspace on the controller and maps this at the same place in the docker container. So the path on the agent and the controller are identical and your plugin finds the file.

You might not persist the key yourself, but Jenkins is writing xml files with step parameters to the file system

siddhantdange commented 3 months ago

@mawinter69 I tested this pipeline with the Jenkinsfile above + my plugin, running on Mock Agent, and it seems to work fine.

From the logs:

Running on [agent](http://localhost:8080/computer/agent/) in /var/jenkins_home/mock-agents/agent/workspace/test-pipeline

Happy to paste full logs if you want to see that.

mawinter69 commented 3 months ago

I think it only works because the mock-agent runs on the same physical machine with the same user. So you should setup a real agent that is running on a different machine (or on the same machine as a different user that has no access to /var/jenkins_home)

siddhantdange commented 3 months ago

@mawinter69 Made the necessary changes, tested it on another agent on another node. Mind taking another look?

mawinter69 commented 3 months ago

It looks good now from the point that execution on agents works without problems I think. This leaves 2 open points:

mawinter69 commented 3 months ago

There might be one issue with downloading the binary file: https://github.com/buildpulse/buildpulse-jenkins-plugin/blob/d2e6c4cdf257ffdac2b6efe888c15c1e4bac347b/src/main/java/io/jenkins/plugins/BuildPulseCommand.java#L172 is executed on the controller so when the controller is Linux you will always get the unix binary even when the agent is on windows. With FilePath.toComputer() -> Computer.getSystemProperties() you can determine the remote OS.

https://github.com/buildpulse/buildpulse-jenkins-plugin/blob/d2e6c4cdf257ffdac2b6efe888c15c1e4bac347b/src/main/java/io/jenkins/plugins/BuildPulseStep.java#L132 Looks suspicious, why hard coded git url pointing to something not existing?

siddhantdange commented 3 months ago

@mawinter69 Addressed these comments and updated repository. The hardcoded url is for a required argument to the binary - the binary infers repository url from env vars for other CI providers, however, this does not apply here so we've filled in a dummy value (added comment for clarity).

mawinter69 commented 3 months ago

Some more things

siddhantdange commented 3 months ago

@mawinter69 Updated once more - will add the config.jelly as a part of a future update. By the way, I appreciate all the time you're spending here!

Also looks like when clicking on a plugin 'Available Plugins', it redirects me to the plugin documentation (plugin README)

mawinter69 commented 3 months ago

A few more things:

siddhantdange commented 3 months ago

@mawinter69 updated CODEOWNERS, pom.xml, and renamed the repository to buildpulse-flaky-tests-plugin

mawinter69 commented 3 months ago

The urls in line 33-35 are missing a / after the org

siddhantdange commented 3 months ago

@NotMyFault @mawinter69 updated

github-actions[bot] commented 3 months ago

Hello from your friendly Jenkins Hosting Checker

It looks like you have everything in order for your hosting request. A member of the Jenkins hosting team will check over things that I am not able to check(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

siddhantdange commented 3 months ago

@mawinter69 is this approved?

NotMyFault commented 3 months ago

/request-security-scan

jenkins-cert-app commented 3 months ago

The Jenkins Security Scan discovered 2 finding(s) :mag:.

Please follow the instructions below for every identified issues:

After addressing the findings through one of the above methods:


Jenkins: Plaintext password storage

You can find detailed information about this finding here.

BuildPulseStep.java#42 ``` Field should be reviewed whether it stores a password and is serialized to disk: key ```
BuildPulseCommand.java#24 ``` Field should be reviewed whether it stores a password and is serialized to disk: keyId ```
siddhantdange commented 3 months ago

/request-security-scan

jenkins-cert-app commented 3 months ago

The Jenkins Security Scan discovered 1 finding(s) :mag:.

Please follow the instructions below for every identified issues:

After addressing the findings through one of the above methods:


Jenkins: Plaintext password storage

You can find detailed information about this finding here.

BuildPulseCommand.java#24 ``` Field should be reviewed whether it stores a password and is serialized to disk: keyId ```
siddhantdange commented 3 months ago

/request-security-scan

jenkins-cert-app commented 3 months ago

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


:bulb: The Security team recommends that you are setting up the scan in your repository by following our guide.

siddhantdange commented 3 months ago

@NotMyFault keyId is never serialized to disk

siddhantdange commented 2 months ago

@NotMyFault @mawinter69 Just wanted to bump this

timja commented 1 month ago

Hi apologies for the delay.


  1. function name should not include step: https://github.com/buildpulse/buildpulse-flaky-tests-plugin/blob/main/src/main/java/io/jenkins/plugins/buildpulse/BuildPulseStep.java#L195
  2. its not recommended to include developers in your pom.xml as from experience this is never maintained, information from the plugin site will come from this repository in respect to maintainers, https://github.com/buildpulse/buildpulse-flaky-tests-plugin/blob/main/pom.xml#L18-L24
  3. your plugin doesn't look to be properly setup in respect to version, you should have revision and changelist properties defined, see https://github.com/jenkinsci/archetypes/blob/master/empty-plugin/src/main/resources/archetype-resources/pom.xml#L35-L36
mawinter69 commented 1 month ago