Skip to content

Commit b568aaa

Browse files
author
himaniraghav3
committed
Merge branch 'develop' into PM-228
2 parents 58e7b40 + addbf7e commit b568aaa

File tree

20 files changed

+112
-159
lines changed

20 files changed

+112
-159
lines changed

config/constants/development.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ module.exports = {
5151
// duration to show the prompt saying user will be logged out, before actually logging out the user
5252
IDLE_TIMEOUT_GRACE_MINUTES: 5,
5353
MULTI_ROUND_CHALLENGE_TEMPLATE_ID: 'd4201ca4-8437-4d63-9957-3f7708184b07',
54-
UNIVERSAL_NAV_URL: '//uni-nav.topcoder-dev.com/v1/tc-universal-nav.js',
54+
UNIVERSAL_NAV_URL: 'https://uni-nav.topcoder-dev.com/v1/tc-universal-nav.js',
5555
HEADER_AUTH_URLS_HREF: `https://accounts-auth0.${DOMAIN}?utm_source=community-app-main`,
5656
HEADER_AUTH_URLS_LOCATION: `https://accounts-auth0.${DOMAIN}?retUrl=%S&utm_source=community-app-main`,
5757
SKILLS_V5_API_URL: `${API_V5}/standardized-skills/skills/autocomplete`,

config/constants/production.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module.exports = {
4848
IDLE_TIMEOUT_MINUTES: 10,
4949
IDLE_TIMEOUT_GRACE_MINUTES: 5,
5050
MULTI_ROUND_CHALLENGE_TEMPLATE_ID: 'd4201ca4-8437-4d63-9957-3f7708184b07',
51-
UNIVERSAL_NAV_URL: '//uni-nav.topcoder.com/v1/tc-universal-nav.js',
51+
UNIVERSAL_NAV_URL: 'https://uni-nav.topcoder.com/v1/tc-universal-nav.js',
5252
HEADER_AUTH_URLS_HREF: `https://accounts-auth0.${DOMAIN}?utm_source=community-app-main`,
5353
HEADER_AUTH_URLS_LOCATION: `https://accounts-auth0.${DOMAIN}?retUrl=%S&utm_source=community-app-main`,
5454
SKILLS_V5_API_URL: `${API_V5}/standardized-skills/skills/autocomplete`,

config/env.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ dotenvFiles.forEach(dotenvFile => {
4949
// Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims.
5050
// https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421
5151
// We also resolve them to make sure all tools using them work consistently.
52-
const appDirectory = fs.realpathSync(process.cwd())
52+
const appDirectory = process.cwd()
5353
process.env.NODE_PATH = (process.env.NODE_PATH || '')
5454
.split(path.delimiter)
5555
.filter(folder => folder && !path.isAbsolute(folder))

config/paths.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const url = require('url')
66

77
// Make sure any symlinks in the project folder are resolved:
88
// https://github.com/facebook/create-react-app/issues/637
9-
const appDirectory = fs.realpathSync(process.cwd())
9+
const appDirectory = process.cwd()
1010
const resolveApp = relativePath => path.resolve(appDirectory, relativePath)
1111

1212
const envPublicUrl = process.env.PUBLIC_URL

config/webpack.config.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false'
2727
// makes for a smoother build process.
2828
const shouldInlineRuntimeChunk = process.env.INLINE_RUNTIME_CHUNK !== 'false'
2929

30-
// Check if TypeScript is setup
31-
const useTypeScript = fs.existsSync(paths.appTsConfig)
32-
3330
// style files regexes
3431
const cssRegex = /\.css$/
3532
const cssModuleRegex = /\.module\.css$/
@@ -257,7 +254,7 @@ module.exports = function (webpackEnv) {
257254
// for React Native Web.
258255
extensions: paths.moduleFileExtensions
259256
.map(ext => `.${ext}`)
260-
.filter(ext => useTypeScript || !ext.includes('ts')),
257+
.filter(ext => !ext.includes('ts')),
261258
alias: {
262259
// Support React Native Web
263260
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/

docker/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Use the base image with Node.js
22
FROM node:12
3+
RUN useradd -m -s /bin/bash appuser
34
ARG NODE_ENV
45
ARG BABEL_ENV
56

@@ -18,6 +19,9 @@ COPY . /challenge-engine-ui
1819
# Set working directory for future use
1920
WORKDIR /challenge-engine-ui
2021

22+
RUN chown -R appuser:appuser /challenge-engine-ui
23+
USER appuser
24+
2125
# Install the dependencies from package.json
2226
RUN echo "NODE ENV in Docker: $NODE_ENV"
2327
RUN echo "BABEL ENV in Docker: $BABEL_ENV"

scripts/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const printBuildError = require('react-dev-utils/printBuildError')
2828
const measureFileSizesBeforeBuild =
2929
FileSizeReporter.measureFileSizesBeforeBuild
3030
const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild
31-
const useYarn = fs.existsSync(paths.yarnLockFile)
31+
const useYarn = false
3232

3333
// These sizes are pretty large. We'll warn for bundles exceeding them.
3434
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024

scripts/start.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const paths = require('../config/paths')
3232
const configFactory = require('../config/webpack.config')
3333
const createDevServerConfig = require('../config/webpackDevServer.config')
3434

35-
const useYarn = fs.existsSync(paths.yarnLockFile)
35+
const useYarn = false
3636
const isInteractive = process.stdout.isTTY
3737

3838
// Warn and crash if required files are missing

scripts/test.js

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,16 @@ process.on('unhandledRejection', err => {
1616
require('../config/env')
1717

1818
const jest = require('jest')
19-
const execSync = require('child_process').execSync
2019
let argv = process.argv.slice(2)
2120

22-
function isInGitRepository () {
23-
try {
24-
execSync('git rev-parse --is-inside-work-tree', { stdio: 'ignore' })
25-
return true
26-
} catch (e) {
27-
return false
28-
}
29-
}
30-
31-
function isInMercurialRepository () {
32-
try {
33-
execSync('hg --cwd . root', { stdio: 'ignore' })
34-
return true
35-
} catch (e) {
36-
return false
37-
}
38-
}
39-
4021
// Watch unless on CI, in coverage mode, or explicitly running all tests
4122
if (
4223
!process.env.CI &&
4324
argv.indexOf('--coverage') === -1 &&
4425
argv.indexOf('--watchAll') === -1
4526
) {
4627
// https://github.com/facebook/create-react-app/issues/5210
47-
const hasSourceControl = isInGitRepository() || isInMercurialRepository()
48-
argv.push(hasSourceControl ? '--watch' : '--watchAll')
28+
argv.push('--watchAll')
4929
}
5030

5131
jest.run(argv)

src/components/ChallengeEditor/ChallengeView/index.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import PropTypes from 'prop-types'
44
import cn from 'classnames'
55
import { withRouter } from 'react-router-dom'
66
import styles from './ChallengeView.module.scss'
7-
import xss from 'xss'
87
import Track from '../../Track'
98
import NDAField from '../NDAField'
109
import UseSchedulingAPIField from '../UseSchedulingAPIField'
@@ -18,7 +17,6 @@ import ChallengeTotalField from '../ChallengeTotal-Field'
1817
import Loader from '../../Loader'
1918
import AssignedMemberField from '../AssignedMember-Field'
2019
import { getResourceRoleByName } from '../../../util/tc'
21-
import { isBetaMode } from '../../../util/cookie'
2220
import { loadGroupDetails } from '../../../actions/challenges'
2321
import {
2422
REVIEW_TYPES,
@@ -29,6 +27,7 @@ import {
2927
} from '../../../config/constants'
3028
import PhaseInput from '../../PhaseInput'
3129
import CheckpointPrizesField from '../CheckpointPrizes-Field'
30+
import { isBetaMode } from '../../../util/localstorage'
3231

3332
const ChallengeView = ({
3433
projectDetail,
@@ -114,10 +113,7 @@ const ChallengeView = ({
114113
<div className={cn(styles.row, styles.topRow)}>
115114
<div className={styles.col}>
116115
<span>
117-
<span className={styles.fieldTitle}>Project:</span>
118-
<span dangerouslySetInnerHTML={{
119-
__html: xss(projectDetail ? projectDetail.name : '')
120-
}} />
116+
<span className={styles.fieldTitle}>Project: {projectDetail ? projectDetail.name : ''}</span>
121117
</span>
122118
</div>
123119
{selectedMilestone &&

src/components/ChallengeEditor/index.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ import moment from 'moment-timezone'
88
import { pick } from 'lodash/fp'
99
import { withRouter } from 'react-router-dom'
1010
import { toastr } from 'react-redux-toastr'
11-
import xss from 'xss'
12-
1311
import {
1412
VALIDATION_VALUE_TYPE,
1513
PRIZE_SETS_TYPE,
@@ -69,11 +67,11 @@ import Tooltip from '../Tooltip'
6967
import CancelDropDown from './Cancel-Dropdown'
7068
import UseSchedulingAPIField from './UseSchedulingAPIField'
7169

72-
import { isBetaMode } from '../../util/cookie'
7370
import MilestoneField from './Milestone-Field'
7471
import DiscussionField from './Discussion-Field'
7572
import CheckpointPrizesField from './CheckpointPrizes-Field'
7673
import { canChangeDuration } from '../../util/phase'
74+
import { isBetaMode } from '../../util/localstorage'
7775

7876
const theme = {
7977
container: styles.modalContainer
@@ -1704,10 +1702,7 @@ class ChallengeEditor extends Component {
17041702
<div className={cn(styles.row, styles.topRow)}>
17051703
<div className={styles.col}>
17061704
<span>
1707-
<span className={styles.fieldTitle}>Project:</span>
1708-
<span dangerouslySetInnerHTML={{
1709-
__html: xss(projectDetail ? projectDetail.name : '')
1710-
}} />
1705+
<span className={styles.fieldTitle}>Project: {projectDetail ? projectDetail.name : ''}</span>
17111706
</span>
17121707
</div>
17131708
<div className={styles.col}>

src/components/ChallengesComponent/index.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { CONNECT_APP_URL, PROJECT_ROLES } from '../../config/constants'
1010
import { PrimaryButton } from '../Buttons'
1111
import ChallengeList from './ChallengeList'
1212
import styles from './ChallengesComponent.module.scss'
13-
import xss from 'xss'
1413
import { checkReadOnlyRoles } from '../../util/tc'
1514

1615
const ChallengesComponent = ({
@@ -61,12 +60,9 @@ const ChallengesComponent = ({
6160
<Helmet title={activeProject ? activeProject.name : ''} />
6261
{!dashboard && <div className={styles.titleContainer}>
6362
<div className={styles.titleLinks}>
64-
<div
65-
className={styles.title}
66-
dangerouslySetInnerHTML={{
67-
__html: xss(activeProject ? activeProject.name : '')
68-
}}
69-
/>
63+
<div className={styles.title}>
64+
{activeProject ? activeProject.name : ''}
65+
</div>
7066
{activeProject && activeProject.id && (
7167
<span>
7268
(

src/components/ProjectCard/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React from 'react'
22
import PT from 'prop-types'
33
import { Link } from 'react-router-dom'
44
import cn from 'classnames'
5-
import xss from 'xss'
65

76
import styles from './ProjectCard.module.scss'
87

@@ -14,7 +13,7 @@ const ProjectCard = ({ projectName, projectId, selected, setActiveProject }) =>
1413
className={cn(styles.projectName, { [styles.selected]: selected })}
1514
onClick={() => setActiveProject(parseInt(projectId))}
1615
>
17-
<div className={styles.name} dangerouslySetInnerHTML={{ __html: xss(projectName) }} />
16+
<div className={styles.name}>{projectName}</div>
1817
</Link>
1918
</div>
2019
)

src/config/constants.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export const {
1919
CP_TRACK_ID,
2020
CHALLENGE_TYPE_ID,
2121
MARATHON_TYPE_ID,
22-
SEGMENT_API_KEY,
2322
MULTI_ROUND_CHALLENGE_TEMPLATE_ID,
2423
UNIVERSAL_NAV_URL,
2524
HEADER_AUTH_URLS_HREF,

src/index.js

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,35 @@ import ReactDOM from 'react-dom'
66
import './styles/main.scss'
77
import 'react-redux-toastr/lib/css/react-redux-toastr.min.css'
88
import App from './App'
9-
import { SEGMENT_API_KEY, UNIVERSAL_NAV_URL } from './config/constants'
9+
import { UNIVERSAL_NAV_URL } from './config/constants'
1010

1111
ReactDOM.render(<App />, document.getElementById('root'))
1212

13-
/* eslint-disable */
14-
if (!_.isEmpty(SEGMENT_API_KEY)) {
15-
!function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware"];analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};for(var e=0;e<analytics.methods.length;e++){var t=analytics.methods[e];analytics[t]=analytics.factory(t)}analytics.load=function(e,t){var n=document.createElement("script");n.type="text/javascript";n.async=!0;n.src="https://cdn.segment.com/analytics.js/v1/"+e+"/analytics.min.js";var a=document.getElementsByTagName("script")[0];a.parentNode.insertBefore(n,a);analytics._loadOptions=t};analytics.SNIPPET_VERSION="4.1.0";
16-
analytics.load(SEGMENT_API_KEY);
17-
analytics.page();
18-
}}();
19-
}
20-
/* eslint-enable */
21-
2213
// <!-- Start of topcoder Topcoder Universal Navigation script -->
23-
// eslint-disable-next-line no-unused-expressions
24-
!(function (n, t, e, a, c, i, o) {
25-
// eslint-disable-next-line no-unused-expressions, no-sequences
26-
;(n['TcUnivNavConfig'] = c),
27-
(n[c] =
28-
n[c] ||
29-
function () {
30-
;(n[c].q = n[c].q || []).push(arguments)
31-
}),
32-
(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) {
3318
// eslint-disable-next-line no-unused-expressions, no-sequences
34-
;(i = t.createElement(e)), (o = t.getElementsByTagName(e)[0])
35-
i.async = 1
36-
i.type = 'module'
37-
i.src = a
38-
o.parentNode.insertBefore(i, o)
39-
})(
40-
window,
41-
document,
42-
'script',
43-
UNIVERSAL_NAV_URL,
44-
'tcUniNav'
45-
)
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+
}
4640
// <!-- End of topcoder Topcoder Universal Navigation script -->

src/routes.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ import { saveToken } from './actions/auth'
1717
import { loadChallengeDetails } from './actions/challenges'
1818
import { connect } from 'react-redux'
1919
import { checkAllowedRoles, checkOnlyReadOnlyRoles, checkReadOnlyRoles } from './util/tc'
20-
import { setCookie, removeCookie, isBetaMode } from './util/cookie'
2120
import IdleTimer from 'react-idle-timer'
2221
import modalStyles from './styles/modal.module.scss'
2322
import ConfirmationModal from './components/Modal/ConfirmationModal'
2423
import Users from './containers/Users'
24+
import { isBetaMode, removeFromLocalStorage, saveToLocalStorage } from './util/localstorage'
2525

2626
const { ACCOUNTS_APP_LOGIN_URL, IDLE_TIMEOUT_MINUTES, IDLE_TIMEOUT_GRACE_MINUTES, COMMUNITY_APP_URL } = process.env
2727

@@ -99,8 +99,8 @@ class Routes extends React.Component {
9999
} else {
100100
console.error('An unexpected error occurred while getting auth token')
101101
}
102-
const redirectBackToUrl = window.location.origin + this.props.location.pathname
103-
window.location = ACCOUNTS_APP_LOGIN_URL + '?retUrl=' + redirectBackToUrl
102+
const redirectBackToUrl = encodeURIComponent(window.location.origin + this.props.location.pathname)
103+
window.location = `${ACCOUNTS_APP_LOGIN_URL}?retUrl=${redirectBackToUrl}`
104104
})
105105
}
106106

@@ -109,9 +109,9 @@ class Routes extends React.Component {
109109
const params = new URLSearchParams(search)
110110
if (!_.isEmpty(params.get('beta'))) {
111111
if (params.get('beta') === 'true' && !isBetaMode()) {
112-
setCookie(BETA_MODE_COOKIE_TAG, 'true')
112+
saveToLocalStorage(BETA_MODE_COOKIE_TAG, 'true')
113113
} else if (params.get('beta') === 'false' && isBetaMode()) {
114-
removeCookie(BETA_MODE_COOKIE_TAG)
114+
removeFromLocalStorage(BETA_MODE_COOKIE_TAG)
115115
}
116116
this.props.history.push(this.props.location.pathname)
117117
}

src/util/cookie.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)