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

support jcasc and renovate plugin #125

Merged
merged 39 commits into from Apr 18, 2024
Merged

support jcasc and renovate plugin #125

merged 39 commits into from Apr 18, 2024

Conversation

StefanSpieker
Copy link
Contributor

@StefanSpieker StefanSpieker commented Feb 7, 2024

Started at Contributor summit. Thanks a lot @basil and @nre-ableton. It was quite some fun doing this with you together. I think I finally managed to get it compatible with JCasC, still some fine-tuning and testing to do ...

So after some iterations it was a quite big renovation, including:

  • JENKINS-53442 JCasC support
  • renovating the Plugin internally to fix some remaining deprecation warnings
  • moving the configuration into global config /manage
  • adjust the restore styling to the latest design
  • adding TOC to the README
  • replaced org.apache.commons.lang.StringUtils usage with native Java calls
  • improved the test coverage
  • added PermissionChecks and CSRF protection

This also comes with BREAKING CHANGES:

  • The config filename changed (from thinBackup.xml to org.jvnet.hudson.plugins.thinbackup.ThinBackupPluginImpl.xml) and will be automatically converted after the first start with the new version. The new name complies with the newer naming convention, which was automatically adjusted because of the internal renovation.

Testing done

Submitter checklist

Edit tasklist title
Beta Give feedback Tasklist Submitter checklist, more options

Delete tasklist

Delete tasklist block?
Are you sure? All relationships in this tasklist will be removed.
  1. Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
    Options
  2. Ensure that the pull request title represents the desired changelog entry
    Options
  3. Please describe what you did
    Options
  4. Link to relevant issues in GitHub or Jira
    Options
  5. Link to relevant pull requests, esp. upstream and downstream changes
    Options
  6. Ensure you have provided tests - that demonstrates feature works or fixes the issue
    Options

@sbandaru08
Copy link

Hi Stefan Spieker,

I hope this message finds you well. I wanted to touch base regarding the upcoming deployment of the change you have in this PR. Could you provide an estimated timeline for when we can expect this to be fully deployed?

I'm quite excited about the new features. Is there a possibility for me to install a beta version in the meantime? This would allow me to start exploring the new capabilities and provide any early feedback that might be useful.

Looking forward to your response and eager to get started with the new enhancements.

Best regards,
Satish

@StefanSpieker
Copy link
Contributor Author

Hi.
I still have some minor things to sort out. In general JCasC already works. The screen for restoring a backup does not work yet and I need a solution for converting the settings.
So I will not promise anything, but I guess I will continue on the weekend. If you are interested, I might be able to provide a version to test early next week.

Copy link
Member

@basil basil left a comment

Choose a reason for hiding this comment

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

Finally getting to this PR after coming back from the Contributor Summit. Sorry it took so long. I hope you don't mind that I took the liberty of formatting the codebase to make this change easier to review.

Great job cleaning up this very old code! think adding an HtmlUnit test for the GlobalConfiguration as in the archetype will help flush out and fix the remaining issues and give us confidence in this refactoring.

@StefanSpieker StefanSpieker marked this pull request as ready for review March 24, 2024 09:41
@StefanSpieker
Copy link
Contributor Author

Thanks a lot @basil for all the suggestions! That really helped bring up some confidence that the introduced changes really work. It also helped increase my understanding of how to test within the Jenkins ecosystem. If you have the time, it would be great if you could check if I managed to implement your suggestions correctly.

@sbandaru08 You could give it a try, if you like. My tests were quite successful, I will test it on another system before releasing it. So if you want to give it a try, you can grab it from ci.jenkins.io and upload it manually to your instance.

@mawinter69
Copy link

mawinter69 commented Mar 26, 2024

The configuration of the plugin is still on it's own page backupsettings.jelly with the Management link method doSaveSettings acting as proxy to save the configuration by calling each setter.
I think it would be better to migrate that jelly to config.jelly under ThinBackupPluginImpl so that it appears under the system configuration. Saving would then make use of the configure method and use the stapler binding.
There is also one issue with saving configuration. You should implement your own configure method and make sure that the configuration is saved afterwards. Ideally each setter method calls save() at the end and you use BulkChange in the configure method to avoid that each setter calls save

@StefanSpieker
Copy link
Contributor Author

In many places Jenkins.getInstanceOrNull() is used with a following check for null This should be replaced with Jenkins.get() and remove the null check.

Thanks a lot, this is a technical debt because of intensive mocking usage. I need to move to Jenkinsrule and stop mocking everything. I guess this will also improve the test coverage and improve the tests.

@StefanSpieker
Copy link
Contributor Author

@mawinter69 Thanks a lot again. I think I have integrated all your suggestions and have learned quite a few things on the way. I will test this a little more and bring a fresh new version 2 out. @sbandaru08: I think it is now really ready to test, if you like and have the time.

Copy link
Member

@basil basil left a comment

Choose a reason for hiding this comment

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

Looks good overall, and interactive testing works fine. Very nice job on renovating this plugin!

The one thing I would suggest before releasing this (I know, there seems to be an endless list of tasks with this plugin) is to get Jenkins Security Scan enabled on trunk and then confirm this PR is not creating any new security warnings. Old plugins like this often have existing security scan warnings, many of them false positives, but with a substantial rewrite like this, it's always worth checking that new problems aren't being introduced, and the security scan is a great way to do that automatically. If we aren't sure about something, we can always ask for a review from the security team before releasing it, which is always better than a security vulnerability being detected after a release!

pom.xml Outdated Show resolved Hide resolved
try {
Files.move(oldConfig.toPath(), newConfig.toPath(), StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
LOGGER.severe(
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps throw new UncheckedIOException(e); would be more desirable than logging and driving on, following the general principle of failing fast, but no strong preference here.

Co-authored-by: Basil Crow <me@basilcrow.com>
@StefanSpieker
Copy link
Contributor Author

Looks good overall, and interactive testing works fine. Very nice job on renovating this plugin!

The one thing I would suggest before releasing this (I know, there seems to be an endless list of tasks with this plugin) is to get Jenkins Security Scan enabled on trunk and then confirm this PR is not creating any new security warnings. Old plugins like this often have existing security scan warnings, many of them false positives, but with a substantial rewrite like this, it's always worth checking that new problems aren't being introduced, and the security scan is a great way to do that automatically. If we aren't sure about something, we can always ask for a review from the security team before releasing it, which is always better than a security vulnerability being detected after a release!

Thanks a lot for your constant improvement suggestions. I already learned a lot about how things work and also understand the plugin a lot better! 😉 I really enjoyed polishing this plugin and will try to contribute some learnings to the documentation. I hope that it might be easier for the next one to work on these things.
I'm seeing a couple of Missing POST/RequirePOST annotation and Stapler: Missing permission check. Furthermore, I guess it is fine to fix these warnings. How can I trigger a PR scan?

@basil
Copy link
Member

basil commented Apr 3, 2024

I'm seeing a couple of Missing POST/RequirePOST annotation and Stapler: Missing permission check. Furthermore, I guess it is fine to fix these warnings. How can I trigger a PR scan?

Many (but not all) of those "missing POST annotation" or "missing permission check" warnings are false positive: the very detailed guidance from the security team in the security scan results should help you determine whether that is the case. It is possible but rare for the security scan to turn up legitimate existing issues; an example of this was in Email Extension. The main thing to check is that you aren't introducing any new issues in this PR. You should be able to merge the main branch in, and then GitHub Actions should run the security scan against this PR and flag any new issues, if found.

@StefanSpieker
Copy link
Contributor Author

Thanks again @basil! The documentation is great. Since I'm only using the methods for validation of an admin form, I decided that it will not harm to restrict that also to ADMINISTER. Adding @POST should also not harm, because the documentation states that the doCheck...() can safely be annotated with that, because the used Jenkins version is new enough and anyhow uses POST.
I do not want to be cheeky, but if you have the time, could you take another look? Or should I ask someone from security to verify that I do not introduce new problems?

@basil
Copy link
Member

basil commented Apr 4, 2024

It looks like you applied the maximum strength fix (requiring POST and adding missing permission checks everywhere) to all security scan warnings, in which case I don't see a need to ask for security team review. Most such checks are probably overkill, but it doesn't hurt. I could see a need for security team review if you were on the fence about whether or not a warning was a false positive, but that doesn't seem to be the case if you've applied the maximum strength fix to all warnings.

@MutenR0sh1
Copy link
Contributor

Thanks for the renovation. Works fine in our setup.

@StefanSpieker StefanSpieker merged commit 3e9363d into master Apr 18, 2024
16 checks passed
@StefanSpieker StefanSpieker deleted the jcasc branch April 18, 2024 18:38
@nre-ableton
Copy link

nre-ableton commented Apr 18, 2024

Very nice! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants