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

Loosen header checks for case-insensitivity #10

Merged
merged 5 commits into from
Dec 3, 2014
Merged

Conversation

konklone
Copy link
Collaborator

@konklone konklone commented Dec 3, 2014

I don't have any empirical evidence that sites may use different cases for their headers. I just figure, better safe than sorry.

This also provide a way to easily get at the contents of the specified header with non-? versions of methods. So this adds tests for the new methods as well.

This also fixes an existing bug with secure cookie detection, which probably merits a gem update.

Also provide a way to easily get at the contents of the specified
header. This adds tests for the new methods.
@konklone konklone changed the title Loosen header checks for case-insensitivit Loosen header checks for case-insensitivity Dec 3, 2014
@benbalter
Copy link
Owner

This also provide a way to easily get at the contents of the specified header with non-? versions of methods.

What's the rationale for that?

Edit See what you did there.

end

def secure_cookies?
return nil if !response || !has_cookies?
cookie = response.headers["Set-Cookie"]
cookie = header_from(response, "Set-Cookie")
Copy link
Owner

Choose a reason for hiding this comment

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

should you be passing response here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Er, no. I should not. The tests didn't catch this. I'll fix and update the tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I fixed this in a new commit. It adds a test for secure cookies (using github.com) and also flushed out an existing bug with secure cookie detection.

@konklone
Copy link
Collaborator Author

konklone commented Dec 3, 2014

The alternative is to make header_from a publicly documented method, and have developers specify the header string themselves, and I understood the point of the ? methods to abstract that.

I specifically need to capture the value of the HSTS header, to analyze the max-age and includeSubdomains flags contained therein. I could do this with site.response && site.response.headers['Strict-Transport-Security'], but I figured the library was already pretty well poised to do that for me.

!!header_from("Content-Security-Policy")
end

def click_jacking_protection?
Copy link
Owner

Choose a reason for hiding this comment

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

To be DRY perhaps these should be !!click_jacking_protection?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good call - updated in a new commit. I also merged in the latest changes from master.

@konklone
Copy link
Collaborator Author

konklone commented Dec 3, 2014

I think I've addressed everything - if the build passes, I'm ready to merge it if you are.

@benbalter
Copy link
Owner

🤘 Thanks. Nice work.

benbalter added a commit that referenced this pull request Dec 3, 2014
Loosen header checks for case-insensitivity
@benbalter benbalter merged commit 89bdce2 into master Dec 3, 2014
@benbalter benbalter deleted the loosen-headers branch December 3, 2014 19:18
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