Skip to content

feat: Add support for sameSite field - #628

Open
freddy77 wants to merge 1 commit into
moonD4rk:mainfrom
freddy77:samesite
Open

feat: Add support for sameSite field#628
freddy77 wants to merge 1 commit into
moonD4rk:mainfrom
freddy77:samesite

Conversation

@freddy77

@freddy77 freddy77 commented Aug 4, 2026

Copy link
Copy Markdown

Summary

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.

Fixes #

Checklist

  • Pull request targets the main branch
  • All CI checks pass (lint, test, build)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • go.mod directive remains go 1.20 (do not bump)

@moonD4rk moonD4rk changed the title Add support for sameSite field feat: Add support for sameSite field Aug 5, 2026

@moonD4rk moonD4rk left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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 header
  • output/output_test.go:116 — add "" to the expected row
  • output/reflect_test.go:57 — add "same_site" to the CookieEntry case
  • output/reflect_test.go:90 — add "" to the CookieEntry case

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.

@freddy77

freddy77 commented Aug 5, 2026

Copy link
Copy Markdown
Author

Updated. I hope to have addressed everything correctly.

@freddy77
freddy77 requested a review from moonD4rk August 5, 2026 07:18
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>
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