Skip to content

feat(bson-parsing): restrict web worker scope COMPASS-11128 - #892

Draft
mabaasit wants to merge 5 commits into
web-worker-parsingfrom
restrict-worker-scope
Draft

mabaasit wants to merge 5 commits into
web-worker-parsingfrom
restrict-worker-scope

Conversation

@mabaasit

@mabaasit mabaasit commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

Description

COMPASS-11128

Open Questions

Checklist


Stack created with GitHub Stacks CLI • Give Feedback 💬

@mabaasit
mabaasit requested review from a team as code owners September 21, 2026 08:51
@mabaasit
mabaasit requested review from LuciaHarcekova and removed request for a team September 21, 2026 08:51
@mabaasit
mabaasit added this pull request to stack #894 September 21, 2026 08:51
@mabaasit mabaasit changed the title feat(bson-parsin): restrict web worker scope feat(bson-parsing): restrict web worker scope Sep 21, 2026
// Used by this file.
'self',
'onmessage',
'postMessage',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Adding const { self, onmessage, postMessage } = globalThis; above this statement should remove this requirement, and we do want to avoid a situation where the "sandbox" could call postMessage()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, that's much better and will clean this up

'parseInt',
'encodeURIComponent',
'decodeURIComponent',
'Buffer',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Buffer is a Node.js concept, do we need that?

'__defineSetter__',
'__lookupGetter__',
'__lookupSetter__',
'constructor',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Object.prototype.constructor is part of standard JS, why are we excluding that?

@mabaasit mabaasit changed the title feat(bson-parsing): restrict web worker scope feat(bson-parsing): restrict web worker scope COMPASS-11128 Sep 22, 2026
@mabaasit
mabaasit marked this pull request as draft September 22, 2026 08:58
Copilot AI lite review requested due to automatic review settings September 23, 2026 11:19
@mabaasit
mabaasit force-pushed the restrict-worker-scope branch from b1f6d4c to 2460ab7 Compare September 23, 2026 11:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The worker response callback can break, and test environment cleanup is incorrect.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

This pull request hardens the BSON parser web worker by restricting its scope and expanding worker tests.

Changes:

  • Restricts worker globals and prototypes.
  • Supports direct worker URLs in tests.
  • Adds worker lifecycle and security coverage.
File Summary
packages/​shell-bson-parser/​src/​worker.ts Restricts worker capabilities. Critical (3 votes): postMessage must remain available.
packages/​shell-bson-parser/​src/​worker-client.ts Adds test worker URL handling.
packages/​shell-bson-parser/​src/​index.spec.ts Expands worker behavior tests. Moderate (1 vote): delete the environment variable instead of assigning undefined.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +61 to +62
'Buffer',
]);
@mabaasit
mabaasit force-pushed the restrict-worker-scope branch from 2460ab7 to b4a5690 Compare September 23, 2026 14:48
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.

3 participants