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

feat(filters): filter set-cookie headers #485

Merged
merged 1 commit into from
Aug 9, 2018
Merged

Conversation

Qard
Copy link
Contributor

@Qard Qard commented Aug 1, 2018

Fixes #468

Depends on elastic/set-cookie-serde/pull/1

Checklist

  • Implement code
  • Add tests

@watson
Copy link
Contributor

watson commented Aug 2, 2018

Note: The Node 8+9 tav tests are currently failing because of a bug in npm triggered by the use of a github dependency link.

@@ -51,6 +58,17 @@ function httpHeaders (payload) {
.map(function (k) { return k + '=' + cookies[k] })
.join('; ')
}

if (typeof headers['set-cookie'] !== 'undefined') {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we need to protect our selfs from people overwriting the undefined property right? If so you can just do a simple comparison instead. Unless there's an edge case I'm not considering?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean do if (headers['set-cookie'] !== undefined) instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

yep

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

headers['set-cookie'] = stringify(setCookies)
} catch (err) {
// Ignore error
headers['set-cookie'] = '[malformed set-cookie header]'
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure we want to overwrite it in this case? I guess it's to prevent leaking secrets, but it does make it hard to fix it if the user never sees how it looked 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not really sure. I think it makes sense, from a security perspective, to redact the entire header if the parser doesn't understand it. But I don't feel strongly about it. This just seemed like the most obvious approach at the time.

Maybe others have some opinions on this?

Copy link
Contributor

Choose a reason for hiding this comment

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

@elastic/apm-agent-devs @roncohen: Should we redact the entire Set-Cookie header if we can't parse it or just report it as is?

Copy link
Member

Choose a reason for hiding this comment

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

In the Java agent, we always redact the whole value. I’m not sure if the overhead of parsing the value is worth it.

package.json Outdated
@@ -84,6 +84,7 @@
"require-ancestors": "^1.0.0",
"require-in-the-middle": "^3.1.0",
"semver": "^5.5.0",
"set-cookie-serde": "github:qard/set-cookie-serde#implementation",
Copy link
Contributor

Choose a reason for hiding this comment

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

This PR is marked as "In Review", but I guess it should still be "In Progress" until this dependency have been published right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just marked as "In Review" to indicate it's as done as it will get until the PR for set-cookie-serde is merged and released. This is blocked until that gets released.

watson
watson previously approved these changes Aug 9, 2018
@Qard Qard merged commit f341bd3 into elastic:master Aug 9, 2018
@Qard Qard deleted the set-cookie branch August 9, 2018 19:33
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.

3 participants