feat: Add support for sameSite field - #628
Conversation
moonD4rk
left a comment
There was a problem hiding this comment.
Thanks for this! I tested the branch on Windows against 12 Chromium forks and 3 Firefox profiles — the enum mappings are right (Firefox 0 = explicit SameSite=None, 256 = unset), and cookie output is identical to main apart from the new field.
Two things before merge.
1. CSV assertions are stale
CookieEntry.SameSite adds a CSV column, and 3 tests still expect the old header:
go test ./output/...output/output_test.go:109— add"same_site"to the expected headeroutput/output_test.go:116— add""to the expected rowoutput/reflect_test.go:57— add"same_site"to theCookieEntrycaseoutput/reflect_test.go:90— add""to theCookieEntrycase
2. Emit "unspecified" instead of an empty string
For cookies with no SameSite attribute (-1 on Chromium, 256 on Firefox) the field is currently "", which omitempty then drops entirely — so an importer can't tell "no SameSite attribute" from "unknown". It's not a rare case: 101 of 277 Chrome cookies on my test box.
"unspecified" is the value the WebExtensions SameSiteStatus enum uses for exactly this. It also gives the case -1: / case 256: branches something to do — right now they're empty and behave the same as having no case at all.
|
Updated. I hope to have addressed everything correctly. |
Recent browsers (and HTTP) added "sameSite" setting to limit cross site attacks. Add support for exporting this property from Firefox and Chrome and to export to csv and cookie-editor format. Also extract new "session" and "hostOnly" properties for cookie-editor format. Tested on Firefox, Chrome and Chromium. Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Summary
Recent browsers (and HTTP) added
sameSitesetting to limit cross site attacks.Add support for exporting this property from Firefox and Chrome and to export to csv and cookie-editor format.
Also extract new
sessionandhostOnlyproperties for cookie-editor format.Tested on Firefox, Chrome and Chromium.
Fixes #
Checklist
mainbranchgo 1.20(do not bump)