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

Adapt the test for recent core #857

Merged
merged 4 commits into from
Mar 29, 2020

Conversation

Wadeck
Copy link
Contributor

@Wadeck Wadeck commented Mar 26, 2020

With the security release of yesterday, some tests are no longer passing for the git plugin. As it uses a mock for the crumb filter and we added some logic there, it results in NPE.

By disabling the new security correction for tests only, we prevent the test to fail on recent core version. It does not modify the behavior of the plugin that is safe, it's just the way the test is written that make it fail.

The new system property support was added in 2.204.6 but due to its nature, we can inject it in previous version without issue.

@@ -32,6 +34,16 @@
private HttpServletResponse resp;
private FilterChain chain;

@BeforeClass
public static void setProps() {
System.setProperty("hudson.security.csrf.CrumbFilter.UNPROCESSED_PATHINFO", "true");
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't it safer to get the old value and restore it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated the code. Feel free to commit directly to the PR.

Copy link
Contributor

@MarkEWaite MarkEWaite Mar 26, 2020

Choose a reason for hiding this comment

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

When I checked out this pull request and modified pom.xml to allow it to compile with Jenkins 2.204.6, I get a null pointer exception in the unsetProps call.

java.lang.NullPointerException
        at java.util.Hashtable.put(Hashtable.java:460)
        at java.util.Properties.setProperty(Properties.java:166)
        at java.lang.System.setProperty(System.java:798)
        at hudson.plugins.git.GitStatusCrumbExclusionTest.unsetProps(GitStatusCrumbExclusionTest.java:47)

If I discard the most recent commit, then the test passes with a new spotbugs warning about a possible null pointer dereference in GitRevisionBuildParameters. That warning is a nice reminder that newer Jenkins versions include annotations which can help spotbugs find more problems for us.

I think this PR and jenkins-infra/jenkins.io#3002 highlight that it is time for the git plugin and the git client plugin to require a Jenkins version that is newer than 2.138.4.

I think that we should consider incrementing the major version of the git plugin and the git client plugin and have them depend on Jenkins 2.190.3. I think that would allow us to avoid several dependency related issues that are caused by the overly broad range of Jenkins versions supported by the git plugin and the git client plugin.

@fcojfernandez and @rsandell do you have concerns if we make git plugin require Jenkins 2.190.3 instead of 2.138.4? I'll also start a discussion in the git-plugin gitter channel

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MarkEWaite Good catch ;) corrected

Copy link
Member

@daniel-beck daniel-beck left a comment

Choose a reason for hiding this comment

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

Untested. Will need testing in PCT based on 2.222.1 or 2.204.6.

@fcojfernandez
Copy link
Member

the code looks good and the pass in local. I haven't executed the PCT, though.

I'm closing and re-opening to relaunch the CI, which seems to be a bit flaky today

@fcojfernandez
Copy link
Member

EC2 (aws) - Ubuntu 18.04 LTS (i-0ae7f33793f8450e4) was marked offline

Let's give another chance before opening a INFRA ticket

@fcojfernandez fcojfernandez reopened this Mar 27, 2020
@MarkEWaite MarkEWaite merged commit 5b3300d into jenkinsci:master Mar 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants