Skip to content

Commit d6897f7

Browse files
authored
Merge pull request #7075 from topcoder-platform/develop
Prod release - Security issues - Community App PHASE 2
2 parents 0601651 + 69fa10d commit d6897f7

File tree

69 files changed

+39
-4072
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+39
-4072
lines changed

__tests__/shared/components/TopcoderHeader/desktop/SubMenu/Item.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import Renderer from 'react-test-renderer/shallow';
3-
import Item from 'components/TopcoderHeader/desktop/SubMenu/Item';
3+
import Item from 'components/SubMenu/Item';
44

55
test('Matches shallow shapshot', () => {
66
const renderer = new Renderer();

__tests__/shared/components/TopcoderHeader/desktop/SubMenu/__snapshots__/Item.jsx.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
exports[`Matches shallow shapshot 1`] = `
44
<li
5-
className="src-shared-components-TopcoderHeader-desktop-SubMenu-Item-___style__item___2Q-ud src-shared-components-TopcoderHeader-desktop-SubMenu-Item-___style__current___38PHh"
5+
className="src-shared-components-SubMenu-Item-___style__item___2U0li src-shared-components-SubMenu-Item-___style__current___3WfNb"
66
role="button"
77
tabIndex={0}
88
>
@@ -21,7 +21,7 @@ exports[`Matches shallow shapshot 1`] = `
2121

2222
exports[`Matches shallow shapshot 2`] = `
2323
<li
24-
className="src-shared-components-TopcoderHeader-desktop-SubMenu-Item-___style__item___2Q-ud"
24+
className="src-shared-components-SubMenu-Item-___style__item___2U0li"
2525
role="button"
2626
tabIndex={0}
2727
>

src/server/services/communities.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export async function getMetadata(communityId) {
132132
communityId, 'metadata.json',
133133
);
134134
try {
135-
metadata = JSON.parse(fs.readFileSync(uri, 'utf8'));
135+
metadata = JSON.parse(await promisify(fs.readFile)(uri, 'utf8'));
136136
} catch (error) {
137137
const msg = `Failed to get metadata for ${communityId} community`;
138138
logger.error(msg, error);

src/shared/components/Contentful/Article/Article.jsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import IconFacebook from 'assets/images/icon-facebook.svg';
3434
import IconTwitter from 'assets/images/icon-twitter.svg';
3535
import IconLinkedIn from 'assets/images/icon-linkedIn.svg';
3636
import DiscordIconWhite from 'assets/images/tc-edu/discord-icon-white.svg';
37+
import getSecureRandomIndex from 'utils/secureRandom';
3738

3839
const htmlToText = require('html-to-text');
3940

@@ -45,7 +46,7 @@ const LOCAL_STORAGE_KEY = 'VENBcnRpY2xlVm90ZXM=';
4546
const DEFAULT_BANNER_IMAGE = 'https://images.ctfassets.net/piwi0eufbb2g/7v2hlDsVep7FWufHw0lXpQ/2505e61a880e68fab4e80cd0e8ec1814/0C37CB5E-B253-4804-8935-78E64E67589E.png?w=1200&h=630';
4647
// random ads banner - left sidebar
4748
const RANDOM_BANNERS = ['6G8mjiTC1mzeSQ2YoUG1gB', '1DnDD02xX1liHfSTf5Vsn8', 'HQZ3mN0rR92CbNTkKTHJ5', '1OLoX8ZsvjAnn4TdGbZESD', '77jn01UGoQe2gqA7x0coQD'];
48-
const RANDOM_BANNER = RANDOM_BANNERS[_.random(0, 4)];
49+
const RANDOM_BANNER = RANDOM_BANNERS[getSecureRandomIndex(RANDOM_BANNERS.length)];
4950

5051
class Article extends React.Component {
5152
componentDidMount() {

src/shared/components/Contentful/MemberTalkCloud/MemberTalkCloud.jsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import PT from 'prop-types';
99
import React from 'react';
1010
import { themr } from 'react-css-super-themr';
1111
import { fixStyle } from 'utils/contentful';
12+
import getSecureRandomIndex from 'utils/secureRandom';
1213
import defaultTheme from './themes/default.scss';
1314

1415
const MAX_MARGIN_TOP = 0;
@@ -17,7 +18,7 @@ const MAX_MARGIN_LEFT = 30;
1718

1819
const getRandomTranslate = () => ({
1920
y: MAX_MARGIN_TOP,
20-
x: _.random(MIN_MARGIN_LEFT, MAX_MARGIN_LEFT, false),
21+
x: getSecureRandomIndex(MIN_MARGIN_LEFT, MAX_MARGIN_LEFT),
2122
});
2223

2324
export class MemberTalkCloud extends React.Component {
@@ -92,7 +93,7 @@ export class MemberTalkCloud extends React.Component {
9293
<img
9394
alt={activeBlob.handle}
9495
src={activeBlob.imageURL}
95-
key={Math.random()}
96+
key={getSecureRandomIndex(0, 1000)}
9697
/>
9798
<span className={theme.activeHandle}>{activeBlob.handle}</span>
9899
<div className={blob}>

src/shared/components/MemberSearch/ListContainer/index.jsx

-52
This file was deleted.

src/shared/components/MemberSearch/ListContainer/style.scss

-47
This file was deleted.

src/shared/components/MemberSearch/LoadMoreButton/index.jsx

-22
This file was deleted.

src/shared/components/MemberSearch/LoadMoreButton/style.scss

-15
This file was deleted.

src/shared/components/MemberSearch/LoadingListItem/index.jsx

-50
This file was deleted.

0 commit comments

Comments
 (0)