Skip to content

feat(otdfctl): support decrypt --offset/--length and HTTP(S) URLs - #4229

Open
sujankota wants to merge 2 commits into
feat/sdk-load-tdf-from-urlfrom
feat/otdfctl-partial-decrypt
Open

sujankota wants to merge 2 commits into
feat/sdk-load-tdf-from-urlfrom
feat/otdfctl-partial-decrypt

Conversation

@sujankota

@sujankota sujankota commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #4221 (LoadTDFFromURL). Will retarget to main once that merges.

Proposed Changes

Part of DSPX-4886 (DSPX-5114): lets otdfctl decrypt a plaintext byte range, locally or from a TDF served over HTTP(S), which the xtest partial-decrypt tests at 100 GiB–50 TiB depend on.

  • decrypt --offset/--length (EXPERIMENTAL): decrypts only the requested plaintext range. --length defaults to -1 (to end) and is clamped at the end of the payload; an offset past the end fails, and -o leaves no file behind.
  • Only the segments covering the range are read and decrypted: Reader.Seek + WriteTo through a rangeWriter that stops the reader once the range is written, so boundary segments aren't fetched or decrypted twice.
  • HTTP(S) input: an http:// / https:// argument is loaded with LoadTDFFromURL (range requests, SDK's unauthenticated HTTP client), so only the zip directory, manifest and needed segments are downloaded.
  • Builds on the existing streaming decrypt (fix(cli): stream decrypt and inspect instead of buffering #3939, fix(cli): honor output modes and restrict decrypted files #4046); Decrypt handler gains URL, Offset, Length options.
  • Man page: new flags and examples.

Checklist

  • I have added or updated unit tests
  • I have added or updated integration tests (if appropriate)
  • I have added or updated documentation

Testing Instructions

  • Unit: cd otdfctl && go test ./pkg/handlers/ ./cmd/... (TestRangeWriter).
  • e2e: 5 new cases in otdfctl/e2e/encrypt-decrypt.bats (range across a segment boundary, offset to end via -o, length past end, piped stdin, offset past end). Ran locally against a CI-equivalent platform config: bats e2e/encrypt-decrypt.bats --filter "partial decrypt", all 5 pass.
  • Manual URL check: encrypted a 4.8 MB file, served it from a Range-capable server, ran otdfctl decrypt --offset 2097000 --length 400 http://127.0.0.1:8099/p.txt.tdf; output matched the plaintext and the server saw 11 range requests (tail + manifest, then exactly the two 2 MiB segments the range crosses).

Add EXPERIMENTAL --offset/--length to decrypt a plaintext byte range;
only the segments covering the range are read and decrypted. An
http(s):// argument is loaded with HTTP range requests via
LoadTDFFromURL.

Part of DSPX-4886 (DSPX-5114).

Signed-off-by: sujan kota <sujankota@gmail.com>
@sujankota
sujankota requested a review from a team as a code owner October 15, 2026 00:47
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 8b1310bc-616c-4c18-bdd0-f0eff7d0a972

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 341.653561ms
Throughput 292.69 requests/second

TDF3 Benchmark Results

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 33.891491417s
Average Latency 338.172256ms
Throughput 147.53 requests/second

Comment thread otdfctl/pkg/handlers/tdf.go Outdated
…imit

Signed-off-by: sujan kota <sujankota@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 408.97672ms
Throughput 244.51 requests/second

TDF3 Benchmark Results

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 45.228405599s
Average Latency 451.318879ms
Throughput 110.55 requests/second

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Govulncheck found vulnerabilities ⚠️

The following modules have known vulnerabilities:

  • otdfctl
  • sdk
  • service
  • lib/fixtures
  • tests-bdd

See the workflow run for details.

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants