-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request from GHSA-p3q9-qff5-97p7
* Implement checksums for POST requests Previously, the checksum logic always looked at the query string, even on POST requests where the parameters are in the body. Add checksum support for POST parameters (this is somewhat complicated by the fact that scalelite's internal API uses Rails nested parameters), and match BigBlueButton's behaviour of rejecting a request if parameters are present in both the query string and POST request body. * Validate BigBlueButton API request content-type * Check 'GET' checksum on 'POST' request with json content type The checksum helper is also used on the Scalelite administration API, which is designed to be used with POST requests with json request body. The checker designed for the BigBlueButton APIs rejected this as an unsupported content type. The expected behaviour of these requests is to have the checksum in the query string, and the body isn't covered by the checksum. Adapt the code to support this behaviour. * Use right content type in Admin API tests, reject form data * Remove checksum validation workaround for admin api * Update supported request methods to match BigBlueButton * Remove incorrect POST req checksumming * Update tests for supported methods and content types * Remove unused GET_CHECKSUM_MIME_TYPES * Ensure create call does not pass parameters in POST body as-is to BBB * Fix formatting issues reported by rubocop * Correct list of endpoints supporting GET for content type check
- Loading branch information
Showing
12 changed files
with
286 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module Api | ||
class ScaleliteApiController < ApplicationController | ||
include ApiHelper | ||
|
||
skip_before_action :verify_authenticity_token | ||
|
||
before_action :verify_content_type | ||
before_action -> { verify_checksum(true) } | ||
|
||
def verify_content_type | ||
return unless request.post? && request.content_length.positive? | ||
|
||
raise UnsupportedContentType unless request.content_mime_type == Mime[:json] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.