Skip to content

Potential fix for code scanning alert no. 1: Prototype-polluting assignment#228

Draft
joshbwlng wants to merge 1 commit into
masterfrom
alert-autofix-1
Draft

Potential fix for code scanning alert no. 1: Prototype-polluting assignment#228
joshbwlng wants to merge 1 commit into
masterfrom
alert-autofix-1

Conversation

@joshbwlng

Copy link
Copy Markdown
Contributor

Potential fix for https://github.com/balena-io-modules/pinejs-client-js/security/code-scanning/1

General fix: validate computed property keys at runtime before indexing/writing, or use a structure immune to prototype keys (e.g., Map).
Best minimal fix here: add a strict runtime allowlist check in on(...) so only 'data' and 'error' are accepted, then proceed with existing logic unchanged.

In src/index.ts, inside on(...) (around lines 304–318), insert a guard before this.subscribers[name] access:

  • If name !== 'data' && name !== 'error', throw a TypeError.
  • Keep existing subscription/unsubscribe behavior unchanged.

No new imports/dependencies are required.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

See: https://github.com/balena-io-modules/pinejs-client-js/security/code-scanning/1

Change-type: patch
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
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.

1 participant