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

Move filename validation out of the Router and into the FilesAdaptor #6157

Merged
merged 4 commits into from
Oct 27, 2019

Conversation

mpatnode
Copy link

Didn't seem to make sense to me that the router would be deciding the syntax of my filenames. Specifically, I wanted to be able to create "directories" in AWS, and the router was rejecting the '/' character. Note, there is no behavior change in this code WRT how / is treated in a filename, because there is no AWS code here. That's a decision for the FilesAdaptor

src/Routers/FilesRouter.js Outdated Show resolved Hide resolved
@dplewis
Copy link
Member

dplewis commented Oct 25, 2019

@mpatnode Thanks for the PR!

Can you check travis and the failing tests?

@codecov
Copy link

codecov bot commented Oct 25, 2019

Codecov Report

Merging #6157 into master will decrease coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6157      +/-   ##
==========================================
- Coverage   93.78%   93.75%   -0.03%     
==========================================
  Files         166      166              
  Lines       11271    11285      +14     
==========================================
+ Hits        10570    10580      +10     
- Misses        701      705       +4
Impacted Files Coverage Δ
src/Adapters/Files/FilesAdapter.js 100% <100%> (ø) ⬆️
src/Adapters/Files/GridStoreAdapter.js 46.37% <100%> (+0.78%) ⬆️
src/Controllers/FilesController.js 93.02% <100%> (+0.52%) ⬆️
src/Adapters/Files/GridFSBucketAdapter.js 68.85% <100%> (+0.51%) ⬆️
src/Routers/FilesRouter.js 92.72% <100%> (-0.26%) ⬇️
src/Adapters/Storage/Mongo/MongoStorageAdapter.js 92.27% <0%> (-0.71%) ⬇️
src/RestWrite.js 93.56% <0%> (-0.17%) ⬇️
src/ParseServer.js 97.59% <0%> (+0.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f50f8be...3687a0e. Read the comment docs.

@mpatnode mpatnode marked this pull request as ready for review October 25, 2019 19:06
@mpatnode
Copy link
Author

That looks like some sort of race condition with the Redis config. No?
https://travis-ci.org/parse-community/parse-server/builds/602954308?utm_medium=notification&utm_source=github_status

@mpatnode
Copy link
Author

Hall happy now.

Copy link
Member

@dplewis dplewis left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I added a few comments and nits. We'll review the s3 adapter PR shortly after.

src/Adapters/Files/FilesAdapter.js Outdated Show resolved Hide resolved
@@ -56,6 +59,37 @@ export class FilesAdapter {
* @return {string} Absolute URL
*/
getFileLocation(config: Config, filename: string): string {}

/** Validate a filename for this adaptor type (optional)1G
Copy link
Member

Choose a reason for hiding this comment

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

1G? I also see you are using adaptor instead of adapter. Not to nitpick but can you change it for consistency.

Copy link
Author

Choose a reason for hiding this comment

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

How embarrassing

src/Adapters/Files/FilesAdapter.js Outdated Show resolved Hide resolved
*
* @param {string} filename
*
* @returns {null|*|Parse.Error} null if there are no errors
Copy link
Member

@dplewis dplewis Oct 26, 2019

Choose a reason for hiding this comment

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

@returns {null|Parse.Error} What does asterisk mean?

Copy link
Author

Choose a reason for hiding this comment

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

Intellij being over-zealous

src/Adapters/Files/FilesAdapter.js Outdated Show resolved Hide resolved
'Filename contains invalid characters.'
);
}
return null; // No errors
Copy link
Member

Choose a reason for hiding this comment

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

Remove the comment.

Copy link
Author

Choose a reason for hiding this comment

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

👍

src/Adapters/Files/GridStoreAdapter.js Show resolved Hide resolved
src/Adapters/Files/FilesAdapter.js Outdated Show resolved Hide resolved
@mpatnode
Copy link
Author

@dplewis Process question: Do you prefer we squash when addressing PR issues, or wait till all review is complete?

@dplewis
Copy link
Member

dplewis commented Oct 26, 2019

Good Job! There are 2 failing tests on travis, after that we will squash and merge this PR.

@mpatnode
Copy link
Author

Yeah, remembered that was going to fail after I walked away.

@mpatnode
Copy link
Author

postgres 😿

@dplewis
Copy link
Member

dplewis commented Oct 26, 2019

@mpatnode I can pull this down and look into it

@mpatnode
Copy link
Author

I think it's just a race condition in the test suite. Is it being ran randomized?

@dplewis
Copy link
Member

dplewis commented Oct 27, 2019

@mpatnode The problem with the test lies here Postgres uses FS adapter for testing. Although the adapters don't extend FileAdapter.js. FileAdapter is still used for validation

@dplewis dplewis merged commit 1c8d4a6 into parse-community:master Oct 27, 2019
UnderratedDev pushed a commit to UnderratedDev/parse-server that referenced this pull request Mar 21, 2020
…arse-community#6157)

* Move filename validation out of the Router and into the FilesAdaptor

* Address PR comments

* Update unittests to handle FilesAdapter interface change

* Make validateFilename optional
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.

2 participants