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

Import/export max file size & rate limiting. Import only allowed with author present on pad #3833

Merged
merged 21 commits into from
Apr 14, 2020

Conversation

JohnMcLear
Copy link
Member

@JohnMcLear JohnMcLear commented Apr 4, 2020

  • Rate limits
    • Settings
    • Tests <-- can't test without an authorID.
  • Restricts import only if user is on pad
    • Settings
    • Tests <-- can't test without an authorID.
  • Max file size on import
    • Settings
    • Tests <-- can't test without an authorID

Also

  • loadSettings was not getting the correct settings, it was only parsing settings.json and ignoring defaults not present in the settings.json file.
    Tests without creating an authorID is not really feasible, I tried but I can't find a decent way.

This is good to merge as is, knowing that a future job is to write test coverage which includes a method to create an authorID that is present on a specific padID.

@JohnMcLear JohnMcLear self-assigned this Apr 4, 2020
@JohnMcLear JohnMcLear changed the title Max file size, Rate limiting & can only import with author present on pad - DO NOT MERGE Max file size, Rate limiting & can only import with author present on pad - Ready for review. Apr 5, 2020
@JohnMcLear JohnMcLear added this to the 1.8.2 milestone Apr 6, 2020
@JohnMcLear JohnMcLear modified the milestones: 1.8.2, 1.8.3 Apr 6, 2020
@JohnMcLear JohnMcLear changed the title Max file size, Rate limiting & can only import with author present on pad - Ready for review. URGENT! Max file size, Rate limiting & can only import with author present on pad - Ready for review. Apr 9, 2020
@muxator muxator self-requested a review April 11, 2020 09:09
@JohnMcLear
Copy link
Member Author

Am I blocking further review of this?

@muxator muxator force-pushed the rate-limiting branch 4 times, most recently from f72906d to eb38423 Compare April 12, 2020 19:57
@JohnMcLear
Copy link
Member Author

Quick questions: in this series, two final changes "bubbled up": they introduce and subsequently remove tests for the functionality (tests/backend/specs/api/rateLimitFileSizeAndAuthorSessionExists.js), leaving no trace of them.

I understand you said they cannot be implemented right now. Can I drop those two commits altogether?

I can't remember but if they are commented out they can be left in. The idea is that we have a reference for tests for when I can figure out how to create a session and put that session present in a pad. That or provide a method to bypass that with loadtest: true;

Either way it would be nice to have a reference / reminder knowing how infrequent I contribute :D

@muxator
Copy link
Contributor

muxator commented Apr 12, 2020

I can't remember but if they are commented out they can be left in.

No they are not commented out. The test file is introduced in a commit and wiped altogether in the next one. This is why I asked.

@JohnMcLear
Copy link
Member Author

In heinsight, I should have split rate limiting and author requirements up into two PRs. My apologies @muxator.

@muxator
Copy link
Contributor

muxator commented Apr 12, 2020

In heinsight, I should have split rate limiting and author requirements up into two PRs. My apologies @muxator.

I was thinking about that just now. I'm going to split them.

  1. max file size
  2. author requirements
  3. rate limiting

Edit: done. The next comments apply on this split version. In particular, please have a look at commit 9847bf6 because I need help there.

muxator and others added 3 commits April 13, 2020 01:04
… is not on that pad

Importing to a pad is allowed only if an author has a session estabilished and
has already contributed to that specific pad. This means that as long as the
user is on the pad (via the browser) then import is possible.

Note that an author session is NOT the same as a group session, which is not
required.

This setting does not apply to API requests, only to /p/$PAD$/import

This change of behaviour is introduced in Etherpad 1.8.3, and cannot be
disabled.
From Etherpad 1.8.3 onwards, the maximum allowed size for a single imported
file will always be bounded.

The maximum allowed size can be configured via importMaxFileSize.
@muxator muxator force-pushed the rate-limiting branch 2 times, most recently from a194093 to d75c1fc Compare April 12, 2020 23:58
The newly introduces environment variables are IMPORT_EXPORT_RATE_LIMIT_WINDOW
and IMPORT_EXPORT_MAX_REQ_PER_IP.
src/node/utils/Settings.js Outdated Show resolved Hide resolved
settings.json.template Outdated Show resolved Hide resolved
Copy link
Contributor

@muxator muxator left a comment

Choose a reason for hiding this comment

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

I need help to describe the effect of requireAuthorSessionToImport

@muxator muxator force-pushed the rate-limiting branch 2 times, most recently from 0d4b9b1 to 124b396 Compare April 13, 2020 22:46
The old loadSettings.js was a way of customizing settings upon load, because
the Settings module did not offer this functionality. But it did not work well,
since all the default settings were not loaded.

Let's get rid of loadSettings.js for the bulk of the tests (the "backend"
specs). For the "container" specs, we'll keep it in place until/if we rewrite
Settings.js making it less brittle.
This is in preparation to the next activities about import/export securization.
@muxator muxator force-pushed the rate-limiting branch 2 times, most recently from 11ebeae to 313229c Compare April 14, 2020 00:49
Copy link
Contributor

@muxator muxator left a comment

Choose a reason for hiding this comment

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

All done. I have one remaining point (important), and a UI note (not important)

  1. Is there a use case for which a user should want to set requireAuthorSessionToImport to false?

    If this is a needed security change, these checks should always be done, without the possibility of disabling them.

  2. when an import fails (for example because it is rate limited), the UI freezes and then times out. I am ok with keeping as-is, for now, but let's remember to fix it.

Edit: I decided to remove the configuration setting requireAuthorSessionToImport and always enable those checks. It will not possible to disable the new behaviour.

@muxator muxator merged commit 5acbdb8 into ether:develop Apr 14, 2020
@muxator muxator changed the title URGENT! Max file size, Rate limiting & can only import with author present on pad - Ready for review. Import/export max file size & rate limiting. Import only allowed with author present on pad Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants