Skip to content

Commit

Permalink
Merge pull request #202 from CleverTap/task/WEB-2516/XSS_bugfix
Browse files Browse the repository at this point in the history
XSS bug fix
  • Loading branch information
PraveenCTzen authored May 3, 2024
2 parents 00f17e5 + 4a36b20 commit c7ac1c9
Show file tree
Hide file tree
Showing 10 changed files with 433 additions and 150 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ on:
types: [opened, synchronize, reopened]
jobs:
build:
runs-on: macos-latest
runs-on: macos-12
steps:
- uses: actions/checkout@v2
- name: Use node.js version 10.x
- name: Use node.js version 10.24.1
uses: actions/[email protected]
with:
node-version: '10.x'
node-version: '10.24.1'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ on:
types: [published]
jobs:
build:
runs-on: macos-latest
runs-on: macos-12
steps:
- uses: actions/checkout@v2
- name: Use node.js version 10.x
- name: Use node.js version 10.24.1
uses: actions/[email protected]
with:
node-version: '10.x'
node-version: '10.24.1'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
Expand All @@ -27,10 +27,10 @@ jobs:
run: yarn run test:coverage
- name: Build package
run: yarn run build
- name: Use node.js version 10.x
- name: Use node.js version 10.24.1
uses: actions/[email protected]
with:
node-version: '10.x'
node-version: '10.24.1'
registry-url: 'https://registry.npmjs.org'
- name: Publish package to npm
run: npm publish
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/sw_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ on:
types: [opened, synchronize, reopened]
jobs:
build:
runs-on: macos-latest
runs-on: macos-12
steps:
- uses: actions/checkout@v2
- name: Use node.js version 10.x
- name: Use node.js version 10.24.1
uses: actions/[email protected]
with:
node-version: '10.x'
node-version: '10.24.1'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/sw_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ on:
types: [published]
jobs:
build:
runs-on: macos-latest
runs-on: macos-12
steps:
- uses: actions/checkout@v2
- name: Use node.js version 10.x
- name: Use node.js version 10.24.1
uses: actions/[email protected]
with:
node-version: '10.x'
node-version: '10.24.1'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
Expand Down
241 changes: 174 additions & 67 deletions clevertap.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion clevertap.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion clevertap.min.js

Large diffs are not rendered by default.

55 changes: 55 additions & 0 deletions src/util/clevertap-handler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// clevertap-handler.js

const ctEventhandler = (html) => {
const ctScript = `
var clevertap = {
event: {
push: (eventName) => {
window.parent.postMessage({
action: 'Event',
value: eventName
},'*');
}
},
profile: {
push: (eventName) => {
window.parent.postMessage({
action: 'Profile',
value: eventName
},'*');
}
},
onUserLogin: {
push: (eventName) => {
window.parent.postMessage({
action: 'OUL',
value: eventName
},'*');
}
},
closeBoxPopUp: () => {
window.parent.postMessage({
action: 'closeBoxPopUp',
value: 'closeBoxPopUp'
},'*');
},
closeBannerPopUp: () => {
window.parent.postMessage({
action: 'closeBannerPopUp',
value: 'closeBannerPopUp'
},'*');
},
closeInterstitialPopUp: () => {
window.parent.postMessage({
action: 'closeInterstitialPopUp',
value: 'closeInterstitialPopUp'
},'*');
}
}
`
const insertPosition = html.indexOf('<script>')
html = [html.slice(0, insertPosition + '<script>'.length), ctScript, html.slice(insertPosition + '<script>'.length)].join('')
return html
}

export default ctEventhandler
12 changes: 12 additions & 0 deletions src/util/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@ export const VARIABLES = 'WZRK_PE'
export const PUSH_DELAY_MS = 1000
export const MAX_DELAY_FREQUENCY = 1000 * 60 * 10
export const WZRK_FETCH = 'wzrk_fetch'
export const WIZ_IFRAME = 'wiz-iframe'
export const WIZ_IFRAME_INTENT = 'wiz-iframe-intent'
export const ADJUST_IFRAME_HEIGHT = 'adjustIFrameHeight'
export const UPDATE_HEIGHT = 'update height'
export const GET_NOTIFICATION = 'getnotif'
export const EVENT = 'Event'
export const PROFILE = 'Profile'
export const OUL = 'OUL'
export const CLOSE_BOX_POPUP = 'closeBoxPopUp'
export const CLOSE_BANNER_POPUP = 'closeBannerPopUp'
export const GET_NOTIFICATION_DATA = 'getnotifData'
export const CLOSE_INTERSTITIAL_POPUP = 'closeInterstitialPopUp'

export const SYSTEM_EVENTS = [
'Stayed',
Expand Down
Loading

0 comments on commit c7ac1c9

Please sign in to comment.