segmentio / segmentio/analytics.js-integrations
Heap integration defaults to http in moz-extension contexts.
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 125
- Forks
- 136
- Avg merge
- 2h 45m
- Merged PRs (30d)
- 1
Description
I'm using segment within a web-extension codebase that supports both Chrome and Firefox.
The heap integration for segment does not specify a scheme for the injected script:
https://github.com/segmentio/analytics.js-integrations/blob/master/integrations/heap/lib/index.js#L24
When this script is injected into the background script of a Chrome extension, the protocol is correctly resolved as https.
When this script is injected into the background script of a Firefox extension, the scheme reverts to http.
see: https://imgur.com/a/wumClPn
I'd really prefer not to load mixed content in our extension. I'd also like my analytics code to not be vulnerable to MITM attacks.
Right now the workaround is ugly - Stick a mutationObserver on the page, wait for analytics.js to inject the heap script, then fix the scheme myself and re-inject.
I'd like to propose a check in the heap integration for the following two protocols:
"moz-extension:"
"chrome-extension:"
If window.location.protocol is either of those values, I believe the integration should specify the scheme as 'https://' instead of leaving it empty and getting mixed behavior across browsers.
I'm happy to put the PR together myself if needed.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in integrations/heap/lib/index.js at the injected-script URL referenced by the issue. Check how window.location.protocol is handled in Chrome and Firefox extension background contexts, then verify that moz-extension: and chrome-extension: contexts use HTTPS and do not load mixed content.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100