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

Hash order was changed in the last release #200

Merged
merged 4 commits into from May 31, 2018
Merged

Conversation

JJ
Copy link
Contributor

@JJ JJ commented May 31, 2018

Now it's guaranteed to always be different. You have to return always sorted keys. Hope this fixes the problem with 2018.05

@AlexDaniel
Copy link
Collaborator

Is it really a good idea to spend extra cycles for sorting stuff that is valid in any order? @samcv what do you think? Or is it good because it does not leak out the seed this way?

Maybe it would be better if the test understood that the result is correct even if the order is different?

@JJ
Copy link
Contributor Author

JJ commented May 31, 2018 via email

@samcv
Copy link
Contributor

samcv commented May 31, 2018

I think we should sort it before stringifying.

@ugexe
Copy link
Collaborator

ugexe commented May 31, 2018

Header order should be preserved. For instance: bot detection heuristics often use header order to check if header FOO is used before or after header BAR.

@AlexDaniel
Copy link
Collaborator

OK.

@AlexDaniel AlexDaniel merged commit bade43d into sergot:master May 31, 2018
@ugexe
Copy link
Collaborator

ugexe commented May 31, 2018

to clarify: I am against this PR. only the tests themselves should be modified.

@@ -50,7 +50,7 @@ lives-ok { $r1.set-method: 'PUT' }, "set method";
is $r1.method, 'PUT', 'set-method 1/1';

# parse
my $req = "GET /index HTTP/1.1\r\nHost: somesite\r\nAccept: test\r\n\r\nname=value&a=b\r\n";
my $req = "GET /index HTTP/1.1\r\nAccept: test\r\nHost: somesite\r\n\r\nname=value&a=b\r\n"; # Remember to use alphabetical order
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should require the CREATION order, not alphabetical order.

AlexDaniel added a commit that referenced this pull request May 31, 2018
This reverts commit bade43d, reversing
changes made to 355bf49.
@AlexDaniel
Copy link
Collaborator

OK, reverted the merge for now.

@AlexDaniel
Copy link
Collaborator

Uh, anyone looking at this?

zoffixznet added a commit to zoffixznet/http-useragent that referenced this pull request Jun 18, 2018
Fixes sergot#197 Fixes sergot#199 Kludges sergot#201
Fixes newly failing tests due to hash ordering now being
randomized in Perl 6, to prevent potential DoS attacks.

The module's design uses hashes to pass data for which ordering
is desired, but not required. So the proper fix would be a
larg-ish redesign that preserves the ordering of this data.

The fix simply sorts the data by keys, destroying original order,
but preserving *an* order, so that, for example, tests receive
predictable output.

Two pieces are affected:
1) Order of HTTP headers[^1]: The RFC says[^2] order doesn't
    matter, but there's some user demand[^3] for preserving the
    ordering for third party systems.
2) Order of Multi-Part form data: the HTML spec says[^4] the order
    of the parts represents the order the elements appear in the
    HTML. Looking at the .add-form-data method, I see they're passed
    via a hash, so order information is not available to the module
    from the very start and a differnt interface would be needed to
    make it available.

[1] sergot#201
[2] https://tools.ietf.org/html/rfc2616#section-4.2
[3] sergot#200 (comment)
[4] https://www.w3.org/TR/html4/interact/forms.html#h-17.13.4
ugexe pushed a commit that referenced this pull request Jun 18, 2018
Fixes #197 Fixes #199 Kludges #201
Fixes newly failing tests due to hash ordering now being
randomized in Perl 6, to prevent potential DoS attacks.

The module's design uses hashes to pass data for which ordering
is desired, but not required. So the proper fix would be a
larg-ish redesign that preserves the ordering of this data.

The fix simply sorts the data by keys, destroying original order,
but preserving *an* order, so that, for example, tests receive
predictable output.

Two pieces are affected:
1) Order of HTTP headers[^1]: The RFC says[^2] order doesn't
    matter, but there's some user demand[^3] for preserving the
    ordering for third party systems.
2) Order of Multi-Part form data: the HTML spec says[^4] the order
    of the parts represents the order the elements appear in the
    HTML. Looking at the .add-form-data method, I see they're passed
    via a hash, so order information is not available to the module
    from the very start and a differnt interface would be needed to
    make it available.

[1] #201
[2] https://tools.ietf.org/html/rfc2616#section-4.2
[3] #200 (comment)
[4] https://www.w3.org/TR/html4/interact/forms.html#h-17.13.4
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

4 participants