[pull] main from hoppscotch:main#65
Merged
Merged
Conversation
Co-authored-by: jamesgeorge007 <25279263+jamesgeorge007@users.noreply.github.com>
Co-authored-by: mirarifhasan <arif.ishan05@gmail.com> Co-authored-by: Anwarul Islam <anwaarulislaam@gmail.com>
…factoring (#5061) * chore: prettier formatting applied * chore: added some lint fixed * fix: few lint errors * chore: prisma and pubsub are now global module * chore: add encapsulation consistency in service files * chore: made a cast function private * chore: cast function made private * refactor: module imports * refactor: posthog spelling
…ments (#4430) Co-authored-by: mirarifhasan <arif.ishan05@gmail.com>
Co-authored-by: mirarifhasan <arif.ishan05@gmail.com>
chore: removed unused CollType GQL enum
…le messages (#5072) Co-authored-by: jamesgeorge007 <25279263+jamesgeorge007@users.noreply.github.com>
…on (#5067) Co-authored-by: jamesgeorge007 <25279263+jamesgeorge007@users.noreply.github.com>
…5090) Co-authored-by: curiouscorrelation <curiouscorrelation@gmail.com>
Co-authored-by: jamesgeorge007 <25279263+jamesgeorge007@users.noreply.github.com>
…#5081) Co-authored-by: jamesgeorge007 <25279263+jamesgeorge007@users.noreply.github.com>
To be revisited after addressing security implications.
Co-authored-by: jamesgeorge007 <25279263+jamesgeorge007@users.noreply.github.com>
- Flexible assertions avoiding flakiness. - Update test fixtures conforming to the schema.
|
|
||
| self.addEventListener( | ||
| "message", | ||
| async (event: MessageEvent<IncomingSandboxWorkerMessage>) => { |
Check warning
Code scanning / CodeQL
Missing origin verification in `postMessage` handler Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the issue, we need to verify the origin of the incoming message in the postMessage handler. This involves checking the event.origin property against a list of trusted origins before processing the message. If the origin is not trusted, the handler should ignore the message.
The fix involves:
- Defining a list of trusted origins (e.g.,
const TRUSTED_ORIGINS = ['https://www.example.com'];). - Adding a conditional check at the start of the
messageevent listener to ensure theevent.originmatches one of the trusted origins. - Ignoring messages from untrusted origins by returning early from the handler.
Suggested changeset
1
packages/hoppscotch-common/src/helpers/workers/sandbox.worker.ts
| @@ -59,2 +59,4 @@ | ||
|
|
||
| const TRUSTED_ORIGINS = ['https://www.example.com']; | ||
|
|
||
| self.addEventListener( | ||
| @@ -62,2 +64,6 @@ | ||
| async (event: MessageEvent<IncomingSandboxWorkerMessage>) => { | ||
| if (!TRUSTED_ORIGINS.includes(event.origin)) { | ||
| return; // Ignore messages from untrusted origins | ||
| } | ||
|
|
||
| const { type, script, envs } = event.data |
Copilot is powered by AI and may make mistakes. Always verify output.
Unable to commit as this autofix suggestion is now outdated
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.1)
Can you help keep this open source service alive? 💖 Please sponsor : )