-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
DeeDeeG's February 2024 refactor of the Download microservice (complementary to PR 132) #133
Conversation
Also fix un-authed API requests for dev mode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall I love these changes!
The safety added by them is fantastic, and especially invaluable.
The one thing I will comment on, is I'm going back and forth on the max length check of the queryParams
. While this is 100% valid, it does feel brittle since it'd possibly break with new parameters being supported. Although at the same time, these parameters haven't changed at all since the implementation of this microservice so it may be a total moot point.
If you think we can rely on the stability of the existing parameters not being changed to much, then lets go right on ahead and merge this one into my branch, since besides that I don't have a single concern about the contents of the PR
tl;dr: we can maybe raise the limit to 100 or 250 characters? Or drop the limit altogether? Whichever you prefer. My feeling on the length is, we own the length check and the set of valid parameters in a couple of files contained in this microservice, so we can update the max length allowed at the same time we add any longer valid combo of parameters... if we remember to update it. That said, maybe we'd forget to update it. (I know I might easily forget to, now that you mention it.) My motivation was to stop us spending a tiny amount of extra resources trying to parse some ridiculous megabytes-long set of query parameters -- I'm unsure how the app would respond do that, I guess I can test it relatively easily... (Also as a fairly weak guard against unexpected behavior when duplicate or bogus arguments are provided, but it doesn't really do much for that, TBH.) On the other hand, we could pretty easily raise this to, say, 100 characters and have it do mostly the same job. It just means we'd be sorting through up to ~25 bogus params max per request, instead of ~9. I imagine this is blazingly fast ™️ regardless. (Heck, I bet parsing through 10,000 bogus params is pretty darn fast.) Anyway, how's raising it to 100 or 250 characters, as a compromise? Gives us nearly 3x (100) or nearly 7x (250) the wiggle room for future params to be added? Or just drop the length limit? Whatever you prefer I can easily go with. |
Research:
^ Repeating a parameter
^ Node or its HTTP module apparently has its own limits here, at least by default. I get an error message. Repeating the parameter
Upon further testing, I can repeat the
EDIT: Yeah, this is a NodeJS thing specifically to combat DDoSes, which is what I was going for here. Context (see answers here): https://stackoverflow.com/questions/24167656/nodejs-max-header-size-in-http-request
|
@DeeDeeG This is some amazing research here. I'm seriously impressed. Also love seeing how there is absolutely a standard shown for just denying requests with too large headers. So with that said, I'd be totally up for just giving us some wiggle room. Just enough that forgetting to adjust this once or twice doesn't give us any issues, which I think a 100 character limit would be perfect for. Honestly, I bet we could give our selves appropriate wiggle room with a limit of 50 even. I just would hate for it to break immediately on a single parameter change. |
Neither risks much DDoS exposure, and this lets us update parameters in the future without having to remember this limit is here and update the limit as well. Prevents us from accidentally breaking the microservice, although the error messages if this got in our way would be extremely specific! But not much downside to increasing this a bit, either.
Increased it to 100 for now. 👍 Slightly unrelated, but there's an error code or two that bug me. package-frontend/microservices/download/index.js Lines 16 to 23 in 637e081
It's sending See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses for standard meanings of these codes. If people use certain software like
EDIT to add: Also, in package-frontend/microservices/download/utils.js Lines 329 to 336 in 637e081
|
@DeeDeeG That's a valid point. Feel free to make that change as well then we can go ahead and merge this one! Thanks for catching the weird return HTTP status, and for going with the suggestion of enlarging the accepted URI length |
Also, give an error that's now a plain '500' a more specific message.
I updated the codes, and I felt a bit bad about making a 505 (easy to search for in the code) into a plain 500 with the standard message "Server Error", so I made the message more specific "Server Error While Finding Link", as it's serving as the catch-all (in the As a bonus, seeing capital "L" "Link" reminds me of Legend of Zelda, so that's kinda neat, arguably. But anyway, this should be good to go now, probably! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is beautiful @DeeDeeG!
Thanks a ton for contributing and helping improve this microservice!
Which is still one of my favourites due to our work to make it have zero dependencies. Idk why that fact just tickles my brain in this world of NodeJS and a million deps.
But I think everything looks good now, just one final look and lets get it merged into my branch.
Which btw do love the Zelda tidbit in here, and the fact we can now test this microservice without any auth, which is a really good thing
DeeDeeG's February 2024 refactor of the Download microservice (complementary to PR 132)
This one is my changes, which were originally independently implemented on another branch (main...DeeDeeG:package-frontend:download-refactor-plus-more-error-handling) (Current tip of branch: DeeDeeG@007e7a2), but now re-done over PR 132, since those changes are cool too!!
All stemmed from some comments in (late, sorry!) review of #130 and #131.
Two people independently thought of ways to address that. This PR now targets my work onto confused's work (PR 132) to super-saiyan-fuse them together, or something.
See also: #132 which this is targeting to be merged into directly.