Skip to content

fix(event-import): cap decoded record size before readline buffers (#1255) - #1276

Merged
tirthraj01 merged 3 commits into
rewrite/mainfrom
fix/1255-cap-event-import-record-size
Nov 29, 2026
Merged

tirthraj01 merged 3 commits into
rewrite/mainfrom
fix/1255-cap-event-import-record-size

Conversation

@tirthraj01

Copy link
Copy Markdown
Collaborator

Summary

Fixes #1255.

Addresses CWE-409 / Denial of Service by enforcing a streaming record size limit before readline buffers an entire record into memory.

Changes

  • Added RecordSizeLimitExceededError typed error naming the limit and record number.
  • Added createRecordSizeLimiter streaming Transform that tracks byte counts between newline (\n) boundaries.
  • On overflow past maxRecordBytes, destroys the source stream and fails early with RecordSizeLimitExceededError.
  • Exposed configurable maxRecordBytes in EventImportOptions (defaults to 1MB).
  • Added unit tests verifying early stream destruction on overflow and uninterrupted normal imports.

@changeset-bot

changeset-bot Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b308bf9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
nostream Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 29, 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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 45388a0d-8553-464e-a1b2-2de3f38bd6bd

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 thread Cargo.lock Resolved
@greptile-apps

greptile-apps Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The PR appears safe to merge with no outstanding findings.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge with no outstanding findings.

Summary

Adds a streaming size limit before readline buffers JSONL records.

  • JSONL imports stop oversized records before they reach readline.

Both earlier findings are addressed: source errors reach the reader, and CRLF endings no longer count toward the limit. Since the previous review, only an excluded changeset file changed. No new findings were identified.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Input stream] --> B[Record size limiter]
  B --> C[readline]
  C --> D[Parse and check events]
  D --> E[Save batches]
  B -- Record too large --> F[Destroy source and reject import]
Loading

Reviews (3) · Last reviewed commit: "chore(changeset): add changeset for #125..." · Reviewed by Greptile

Comment thread src/services/event-import-service.ts Resolved
Comment thread src/services/event-import-service.ts Resolved
@tirthraj01
tirthraj01 changed the base branch from main to rewrite/main November 29, 2026 08:16
greptile-apps[bot]
greptile-apps Bot previously approved these changes Nov 29, 2026
@coveralls

coveralls commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 46260903702

Coverage increased (+0.04%) to 77.622%

Details

  • Coverage increased (+0.04%) from the base build.
  • Patch coverage: 1 uncovered change across 1 file (33 of 34 lines covered, 97.06%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
src/services/event-import-service.ts 34 33 97.06%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 12114
Covered Lines: 9824
Line Coverage: 81.1%
Relevant Branches: 6355
Covered Branches: 4512
Branch Coverage: 71.0%
Branches in Coverage %: Yes
Coverage Strength: 767.01 hits per line

💛 - Coveralls

@greptile-apps
greptile-apps Bot dismissed their stale review November 29, 2026 12:10

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@tirthraj01
tirthraj01 merged commit a70871f into rewrite/main Nov 29, 2026
22 checks passed
@tirthraj01
tirthraj01 deleted the fix/1255-cap-event-import-record-size branch November 29, 2026 12:33
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.

event-import: cap the decoded record size before readline buffers it

2 participants