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

Avoid non-blob webresources fields on multipart requests #746

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

otaviojacobi
Copy link
Contributor

Change-type: patch

@otaviojacobi otaviojacobi requested review from Page- and a team March 12, 2024 15:06
@flowzone-app flowzone-app bot enabled auto-merge March 12, 2024 15:16
@@ -151,7 +157,9 @@ export const getUploaderMiddlware = (
completeUploads.push(
(async () => {
try {
if (!(await isFileInValidPath(fieldname, req))) {
if (
!(await isFileInValidPath(fieldname, req, parsedOdataRequest))
Copy link
Collaborator

Choose a reason for hiding this comment

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

As a later improvement there's a lot of work done in isFileInValidPath that would be nice to avoid duplicating if there are multiple uploads in a single request. I don't know if the duplication is avoidable but I suspect so

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in my todo list for webresources

src/webresource-handler/index.ts Outdated Show resolved Hide resolved
@@ -67,6 +67,7 @@ export const getWebresourceHandler = (): WebResourceHandler | undefined => {
const isFileInValidPath = async (
fieldname: string,
req: Express.Request,
odataRequest: uriParser.ParsedODataRequest,
): Promise<boolean> => {
if (req.method !== 'POST' && req.method !== 'PATCH') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we allow multipart requests on requests that aren't POST/PATCH?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Page- We don't do anything, basically. Whatever is the content of multpart/body in those requests is just dropped. IMHO it is the expected behaviour as it is the same thing of a GET request with a body (it works, but the body is just ignored as it should not be there).

@otaviojacobi otaviojacobi force-pushed the avoids-string-multipart-webresources-fields branch from 08b91f1 to be666fc Compare March 12, 2024 16:15
@otaviojacobi otaviojacobi requested review from Page- and fisehara March 12, 2024 16:17
@otaviojacobi otaviojacobi force-pushed the avoids-string-multipart-webresources-fields branch 3 times, most recently from a5f6022 to abb6980 Compare April 12, 2024 12:55
@otaviojacobi otaviojacobi force-pushed the avoids-string-multipart-webresources-fields branch from abb6980 to a7dfa37 Compare May 3, 2024 10:44
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.

3 participants