Skip to content

net/http: say who owns the errors CrossOriginProtection returns - #719

Merged
tamnd merged 1 commit into
mainfrom
csrf-annot
Oct 27, 2026
Merged

tamnd merged 1 commit into
mainfrom
csrf-annot

Conversation

@tamnd

@tamnd tamnd commented Oct 27, 2026

Copy link
Copy Markdown
Owner

The problem

The lint job fails on #716 and #717, and on main since #711. Its log shows:

include/burrow/net/http.h:1073: http_cross_origin_protection_add_trusted_origin returns Error and says nothing about who owns it
include/burrow/net/http.h:1107: http_cross_origin_protection_check returns Error and says nothing about who owns it

The fix

Function Annotation Why
http_cross_origin_protection_add_trusted_origin BURROW_BORROWS(ret) Its errors come from fmt_errorf, which keeps them in the goroutine's error arena and is annotated the same way.
http_cross_origin_protection_check BURROW_STATIC(ret) It only returns the two static sentinel errors in http_csrf.c.

Checks

Locally, tools/check-annotations.sh prints ok annotations 229 headers. The rest of the lint job's source checks pass too: check-banned, check-alloc, check-globals, check-statics and check-errout. http_csrf.c passes the syntax check.

check-annotations wants an OWNS, BORROWS or STATIC on every function
that returns an Error. AddTrustedOrigin's comes from fmt_errorf, in the
goroutine's error arena, and Check's are static sentinels.
@tamnd tamnd added the area: pure Packages with no OS and no concurrency: strings through regexp label Oct 27, 2026
@tamnd
tamnd merged commit 12e207b into main Oct 27, 2026
0 of 44 checks passed
@tamnd
tamnd deleted the csrf-annot branch October 27, 2026 13:44
@tamnd tamnd mentioned this pull request Oct 27, 2026
23 of 27 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: pure Packages with no OS and no concurrency: strings through regexp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant