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

Bugfix: Removed @RequirePost and changed ssh key migration behavior #498

Merged
merged 3 commits into from
Sep 18, 2020

Conversation

djesionek
Copy link
Contributor

I changed the behavior from my feature added in #445 as suggested by @daniel-beck by moving the migration code to EC2Cloud.readResolve(). I also tested again the migration from 1.51 to 1.52. I could confirm that it wasn't working before and that it works now for me with that change.
Not sure why the @RequirePost lead to issues as it was requested as an addition but maybe someone can clarify if there is a better way than just removing it for now.

Thanks to @varyvol for the bugnotice and @daniel-beck for the hint how to fix it quickly.

@@ -1066,7 +1065,6 @@ public ListBoxModel doFillSshKeysCredentialsIdItems(@QueryParameter String sshKe
.includeCurrentValue(sshKeysCredentialsId);
}

@RequirePOST
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like fine to remove this annotation here, the method is just returning whether the credential-id showed is an actual rsa private key. But better to confirm with some security person: @daniel-beck, @Wadeck, ...

Copy link
Member

Choose a reason for hiding this comment

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

There's still a permission check.

The docs for this are at https://www.jenkins.io/doc/developer/security/form-validation/ -- please read and if anything specific is unclear, ask.

Copy link

Choose a reason for hiding this comment

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

getSshCredential retrieves credentials, but as the RequirePOST protects against CSRF, there is no issue. The method is already checking for ADMINISTER.

Side note, such methods should not have troubles to use POST for the check. You can change the

<f:entry field="sshKeysCredentialsId" title="${%EC2 Key Pair's Private Key}">
(and similar for Eucalyptus) by adding checkMethod="post"

@Wadeck
Copy link

Wadeck commented Sep 16, 2020

@markyjackson-taulia Please read the comment above about the RequirePOST ;)

A @RequirePOST is required when doing doCheckX
(from #445 (review))


Not sure why the @RequirePost lead to issues as it was requested as an addition

Be sure to test your code before commiting, there is no "manual test" performed everytime on PR and this could lead to broken release sometimes ;)

@djesionek
Copy link
Contributor Author

Now I tested the migration manually after all changes maybe we should release that as a hotfix or something before more updates fail.

@varyvol
Copy link

varyvol commented Sep 17, 2020

@MRamonLeon @res0nance @daniel-beck Tests are passing and even if no test was created to verify the issue, @djesionek has tested it manually. Should we maybe release this and work in the test later?

@res0nance
Copy link
Contributor

I think releasing as a bugfix release is reasonable. waiting to see if there are any other comments

@batmat
Copy link
Member

batmat commented Sep 17, 2020

I think that if really we've had people manually verifying the fix, we may want to merge, then do a followup PR for an automated test.

However, given the relative ease of use of @LocalData, I would recommend we also have a test accompanying this fix so it's caught next time.

@varyvol
Copy link

varyvol commented Sep 17, 2020

I've been trying to create an automated test with @LocalData but I've not been able so far: the clouds are not loaded by Jenkins.

But I've manually verified this is working properly: the credential is created and assigned to the existing cloud and the verification for the SSH key works now.

@varyvol
Copy link

varyvol commented Sep 18, 2020

See #500 for an automated test.

@MRamonLeon MRamonLeon merged commit dfa60b7 into jenkinsci:master Sep 18, 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
7 participants