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

Default to POST form validation #4623

Merged
merged 3 commits into from Mar 21, 2021

Conversation

daniel-beck
Copy link
Member

@daniel-beck daniel-beck commented Apr 4, 2020

I wonder whether this is worth an escape hatch? I don't think so given how frequent POST requests for these already are. Thoughts?

Proposed changelog entries

  • Switch to sending POST requests by default for form validation URLs

Proposed upgrade guidelines

N/A

Submitter checklist

  • (If applicable) Jira issue is well described
  • Changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developer, depending on the change). Examples
    • Fill-in the Proposed changelog entries section only if there are breaking changes or other changes which may require extra steps from users during the upgrade
  • Appropriate autotests or explanation to why this change has no tests
  • For dependency updates: links to external changelogs and, if possible, full diffs

Desired reviewers

@mention

Maintainer checklist

Before the changes are marked as ready-for-merge:

  • There are at least 2 approvals for the pull request and no outstanding requests for change
  • Conversations in the pull request are over OR it is explicit that a reviewer does not block the change
  • Changelog entries in the PR title and/or Proposed changelog entries are correct
  • Proper changelog labels are set so that the changelog can be generated automatically
  • If the change needs additional upgrade steps from users, upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the PR title. (example)
  • If it would make sense to backport the change to LTS, a Jira issue must exist, be a Bug or Improvement, and be labeled as lts-candidate to be considered (see query).

@daniel-beck daniel-beck added work-in-progress The PR is under active development, not ready to the final review on-hold This pull request depends on another event/release, and it cannot be merged right now rfe For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted labels Apr 4, 2020
@fqueiruga
Copy link
Contributor

One question, is there any risk to break plugins with this one? For example, if plugins perform a request to their own defined endpoints and depend on the default HTTP method.

@jglick
Copy link
Member

jglick commented Apr 6, 2020

In principle some plugin could have added a @GET annotation to a doCheckXXX method and thus be broken by this. I am not sure why anyone would have bothered, though, as this would not have been solving any bug; normally people add @POST to defend against CSRF attacks, but there is little reason to add @GET except as a matter of documentation.

Copy link
Contributor

@sladyn98 sladyn98 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@varyvol
Copy link

varyvol commented Sep 3, 2020

@daniel-beck this has several approvals but it's marked as WiP and on hold? Does it need further work?

@varyvol varyvol removed work-in-progress The PR is under active development, not ready to the final review on-hold This pull request depends on another event/release, and it cannot be merged right now labels Oct 1, 2020
@varyvol varyvol requested a review from a team October 1, 2020 13:56
Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

Pull request template should be followed. This security hardening (IIUC) should definitely be present in the changelog and, if there is a risk of regressions, in the upgrade guidelines

@daniel-beck
Copy link
Member Author

security hardening

Nope, as the endpoints would still handle GET requests.

@daniel-beck daniel-beck added on-hold This pull request depends on another event/release, and it cannot be merged right now work-in-progress The PR is under active development, not ready to the final review labels Nov 5, 2020
Copy link
Member

@uhafner uhafner left a comment

Choose a reason for hiding this comment

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

combobox.jelly is missing a checkMethod attribute, is this intended?

Otherwise the PR looks good!

@daniel-beck
Copy link
Member Author

@uhafner If it's supported internally, it's just a case of missing Jelly doc. Wouldn't be the first time. Will check when I have some time to work on this.

@daniel-beck
Copy link
Member Author

@uhafner Thanks for the suggestion. It was in fact just missing Jelly doc, which I added. (Tested via UI Samples Plugin)

@daniel-beck
Copy link
Member Author

@oleg-nenashev

Pull request template should be followed.

Done, thanks for the explicit reminder. I removed it as this was really just for a PR build, as the comment stated. Now I think I'm feeling better about merging this even without all the pieces in place.

@timja
Copy link
Member

timja commented Mar 1, 2021

@daniel-beck if you want this in then can you remove on-hold please?

@daniel-beck daniel-beck removed the work-in-progress The PR is under active development, not ready to the final review label Mar 1, 2021
@daniel-beck
Copy link
Member Author

@timja Thanks for the reminder. I don't want this in 2.282, perhaps 2.283 just in case I forgot something.

@timja
Copy link
Member

timja commented Mar 18, 2021

@daniel-beck do you want this in soon?

@daniel-beck daniel-beck removed the on-hold This pull request depends on another event/release, and it cannot be merged right now label Mar 18, 2021
@daniel-beck
Copy link
Member Author

@timja Thanks for the reminder. I removed the label.

Thanks for the reviews everyone!

@timja timja added the ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback label Mar 18, 2021
@timja
Copy link
Member

timja commented Mar 18, 2021

This PR is now ready for merge, after ~24 hours, we will merge it if there's no negative feedback.

Thanks!

@timja timja merged commit 43dbc8f into jenkinsci:master Mar 21, 2021
@miglen
Copy link

miglen commented Jun 17, 2021

In principle some plugin could have added a @GET annotation to a doCheckXXX method and thus be broken by this. I am not sure why anyone would have bothered, though, as this would not have been solving any bug; normally people add @POST to defend against CSRF attacks, but there is little reason to add @GET except as a matter of documentation.

You had actually predicted the future. I personally don't see much value here as those checks should not contain any sensitive information or configurable settings and only be used to validate things.

There is the related issue: https://issues.jenkins.io/browse/JENKINS-65790

@sabberworm
Copy link

You had actually predicted the future. I personally don't see much value here as those checks should not contain any sensitive information or configurable settings and only be used to validate things.

There is the related issue: https://issues.jenkins.io/browse/JENKINS-65790

Maybe the solution isn’t to roll back this change but to look at the status code of the response and handle non-200 responses differently (e.g. by not blindly inserting the response into the DOM as HTML)?

@daniel-beck
Copy link
Member Author

look at the status code of the response and handle non-200 responses differently (e.g. by not blindly inserting the response into the DOM as HTML

I attempted to do that in #5333 but based on the bug it isn't effective here.

@sabberworm
Copy link

sabberworm commented Jun 30, 2021

Debugging a bit, it seems here’s the part where the HTML is inserted:

+ id + '" style="display:none">' + rsp.responseText + '</div>';

Interestingly, the code already checks the response status but then decides to parse and add the HTML anyway, just hidden (with a toggle to let the user see it). Which won’t prevent the style tags from being evaluated…

@daniel-beck
Copy link
Member Author

@sabberworm Nice find, could you submit a PR to fix this?

@sabberworm
Copy link

@sabberworm Nice find, could you submit a PR to fix this?

Done, see #5601

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-for-merge The PR is ready to go, and it will be merged soon if there is no negative feedback rfe For changelog: Minor enhancement. use `major-rfe` for changes to be highlighted
Projects
None yet