Skip to content

fix(sdk): DSPX-4607 canonicalize DPoP headers and extract zipstream constants - #3973

Open
dmihalcik-virtru wants to merge 1 commit into
mainfrom
fix/lint-sdk-headers
Open

fix(sdk): DSPX-4607 canonicalize DPoP headers and extract zipstream constants#3973
dmihalcik-virtru wants to merge 1 commit into
mainfrom
fix/lint-sdk-headers

Conversation

@dmihalcik-virtru

@dmihalcik-virtru dmihalcik-virtru commented Sep 3, 2026

Copy link
Copy Markdown
Member

Part of the DSPX-4607 lint burndown, following the golangci-lint v2.13.2 bump (#3965). Branched from main, independent of the other burndown PRs.

What

12 findings in sdk:

7 × canonicalheader — cosmetic only

sdk/auth/oauth/oauth.go:74:17:  use "DPoP" instead of "dpop"
sdk/auth/oauth/oauth.go:166:36: use "DPoP-Nonce" instead of "dpop-nonce"
sdk/auth/token_adding_interceptor_test.go:204:44: use "Authorization" instead of "authorization"

No wire behaviour changes. http.Header's Set/Get/Values run every key through textproto.CanonicalMIMEHeaderKey, so "dpop", "DPoP" and "Dpop" all resolve to the same canonical Dpop entry and serialize identically. This is a readability fix, not a protocol fix.

Deliberately not touched: headers.Set("typ", "dpop+jwt") at oauth.go:241 — that's a JWT header, not an HTTP one.

2 → 3 × goconst in the zip segment writer

Reported: "segment" ×20 and "finalize" ×13. Extracted as errTypeSegment and opFinalize.

Also extracted opWriteSegment ("write-segment" ×7), which the linter didn't report: it first occurs on line 57 alongside "segment", and uniq-by-line: true collapses the two. Fixing only the reported pair would have surfaced it as a fresh finding on the next run.

2 × QF1012

builder.WriteString(fmt.Sprintf(...))fmt.Fprintf(&builder, ...) in the connect-wrapper generator. Verified byte-identical output: re-ran go run ./sdk/codegen, which rewrites all of sdk/sdkconnect/*.go, and jj status shows no change to any generated file.

1 × SA1019

kas_client_test.go sets the deprecated RewrapResponse.EntityWrappedKey. That's the entire point of the test — upgradeRewrapRequestV1 exists to translate that legacy field — so it's annotated rather than migrated.

Testing

$ cd sdk && golangci-lint run -c ../.golangci.yaml
0 issues.
$ go test ./...            # all pass
$ go test -run TestREADMECodeBlocks ./...
ok  	github.com/opentdf/platform/sdk	1.367s

Clean under both the current main config and the tuned config in #3968.

Given the DPoP surface, this is worth an xtest run before merge even though the header changes are provably cosmetic.

DSPX-4607 burndown index

@dmihalcik-virtru
dmihalcik-virtru requested review from a team as code owners September 3, 2026 21:41
@github-actions github-actions Bot added the comp:sdk A software development kit, including library, for client applications and inter-service communicati label Sep 3, 2026
@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 42 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Team

Run ID: 72f791d8-e6bb-4282-a541-f8985548cca3

📥 Commits

Reviewing files that changed from the base of the PR and between d5933ed and cedc25e.

📒 Files selected for processing (5)
  • sdk/auth/oauth/oauth.go
  • sdk/auth/token_adding_interceptor_test.go
  • sdk/codegen/runner/generate.go
  • sdk/internal/zipstream/segment_writer.go
  • sdk/kas_client_test.go

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 255.925935ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 138.683579ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 430.22284ms
Throughput 232.44 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 1m0.356693736s
Average Latency 602.51314ms
Throughput 82.84 requests/second

…onstants

golangci-lint v2.13.2 reports 12 findings in sdk:

  - 7 canonicalheader: Header.Set/Get/Values called with non-canonical names.
    Cosmetic only, since net/http canonicalizes via
    textproto.CanonicalMIMEHeaderKey before the value reaches the wire.
  - 2 goconst in the zip segment writer ("segment" x20, "finalize" x13).
  - 2 QF1012 in the codegen runner.
  - 1 SA1019 for a test that deliberately covers the deprecated
    RewrapResponse.EntityWrappedKey field.

Signed-off-by: Dave Mihalcik <dmihalcik@virtru.com>
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 170.589471ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 96.543068ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 346.536819ms
Throughput 288.57 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 45.924617698s
Average Latency 458.099975ms
Throughput 108.87 requests/second

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

⚠️ Govulncheck found vulnerabilities ⚠️

The following modules have known vulnerabilities:

  • otdfctl
  • service
  • tests-bdd

See the workflow run for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:sdk A software development kit, including library, for client applications and inter-service communicati size/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant