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

Add a maximum feed size #906

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Add a maximum feed size #906

wants to merge 10 commits into from

Conversation

Half-Shot
Copy link
Contributor

This prevents massive feeds from potentially clogging up Hookshot. Some RSS/ATOM feeds are horribly maintained and just list every entry ever, so we've set a "sensible limit" of 25MB.

@Half-Shot Half-Shot requested a review from a team as a code owner February 29, 2024 18:36
const items = await storage.hasSeenFeedGuids(feedUrl, ...expectedHash);
expect(items).to.deep.equal(expectedHash);
});
it.only("should fail to handle a feed which exceed the maximum size.", async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Focused test!

We could probably use the "no focused tests" eslint rule.

it.only("should fail to handle a feed which exceed the maximum size.", async () => {
const { feedReader, feedUrl } = await constructFeedReader(() => ({
headers: {
'Content-Length': Math.pow(1024, 2).toString(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, isn't this exactly 1 megabyte? This should not be failing.

@Half-Shot Half-Shot requested a review from tadzik April 16, 2024 21:35
Copy link
Contributor

@tadzik tadzik left a comment

Choose a reason for hiding this comment

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

Minor nitpicks, but good to go.

},
Ok(body) => {
// Check if we only got the length after loading the response.
match body.len() as u64 <= max_content_size {
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: I'd just write it as if body.len() as u64 <= max_content_size {..., since if is also an expression in Rust. match kinda makes it seems like there's more to it than that.

<guid isPermaLink="true">http://www.example.com/blog/post/${i}</guid>
</item>`).join('')}
</channel>
</rss>`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: this is fine, measuring at 1.2 MB. If we wanted to be extra careful, we could do an assert checking if it's longer than 1024*1024.

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.

None yet

2 participants