Skip to content

Commit bbe2de2

Browse files
committed
PM-222 - tackle SAST/open-redirect: ensure uninav domain is as expected
1 parent 0276a77 commit bbe2de2

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

src/index.js

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,30 @@ import { UNIVERSAL_NAV_URL } from './config/constants'
1111
ReactDOM.render(<App />, document.getElementById('root'))
1212

1313
// <!-- Start of topcoder Topcoder Universal Navigation script -->
14-
// eslint-disable-next-line no-unused-expressions
15-
!(function (n, t, e, a, c, i, o) {
16-
// eslint-disable-next-line no-unused-expressions, no-sequences
17-
;(n['TcUnivNavConfig'] = c),
18-
(n[c] =
19-
n[c] ||
20-
function () {
21-
;(n[c].q = n[c].q || []).push(arguments)
22-
}),
23-
(n[c].l = 1 * new Date())
14+
// SAST/open-redirect handling: make sure script hostname matches what we expect
15+
if ((new URL(UNIVERSAL_NAV_URL)).hostname.match(/uni-nav.topcoder(-dev)?.com$/i)) {
16+
// eslint-disable-next-line no-unused-expressions
17+
!(function (n, t, e, a, c, i, o) {
2418
// eslint-disable-next-line no-unused-expressions, no-sequences
25-
;(i = t.createElement(e)), (o = t.getElementsByTagName(e)[0])
26-
i.async = 1
27-
i.type = 'module'
28-
i.src = a
29-
o.parentNode.insertBefore(i, o)
30-
})(
31-
window,
32-
document,
33-
'script',
34-
UNIVERSAL_NAV_URL,
35-
'tcUniNav'
36-
)
19+
;(n['TcUnivNavConfig'] = c),
20+
(n[c] =
21+
n[c] ||
22+
function () {
23+
;(n[c].q = n[c].q || []).push(arguments)
24+
}),
25+
(n[c].l = 1 * new Date())
26+
// eslint-disable-next-line no-unused-expressions, no-sequences
27+
;(i = t.createElement(e)), (o = t.getElementsByTagName(e)[0])
28+
i.async = 1
29+
i.type = 'module'
30+
i.src = a
31+
o.parentNode.insertBefore(i, o)
32+
})(
33+
window,
34+
document,
35+
'script',
36+
UNIVERSAL_NAV_URL,
37+
'tcUniNav'
38+
)
39+
}
3740
// <!-- End of topcoder Topcoder Universal Navigation script -->

0 commit comments

Comments
 (0)